cubefarm 0.3.5 → 0.3.7
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/cubefarm.js +9 -1
- package/dist/assets/ToyWorld-DQTMvcEl.js +2 -0
- package/dist/assets/{index-CeoPkKws.js → index-D3lYbosx.js} +30 -30
- package/dist/assets/{index-BU33ZUhQ.css → index-hi9vqi9h.css} +1 -1
- package/dist/assets/{rapier-JdQfFHwQ.js → rapier-DfUh5clU.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/index.js +281 -158
- package/dist-server/index.js.map +4 -4
- package/package.json +3 -1
- package/dist/assets/ToyWorld-KCq1UWWM.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToyWorld-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToyWorld-DQTMvcEl.js","assets/rapier-DfUh5clU.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ee(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,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=ee(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ne=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function re(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,ne)}catch(e){ne(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ie(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else re(ie.bind(null,e))}var ae={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ae,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ie,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=re,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.0`})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=p();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),h=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=d(),n=p(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}function m(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&m(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),ae=Symbol.for(`react.lazy`),oe=Symbol.for(`react.activity`),se=Symbol.for(`react.legacy_hidden`),ce=Symbol.for(`react.memo_cache_sentinel`),le=Symbol.for(`react.view_transition`),ue=Symbol.for(`react.recoverable`),de=Symbol.iterator;function fe(e){return typeof e!=`object`||!e?null:(e=de&&e[de]||e[`@@iterator`],typeof e==`function`?e:null)}var pe=Symbol.for(`react.client.reference`);function me(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case ne:return`Suspense`;case re:return`SuspenseList`;case oe:return`Activity`;case le:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case P:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?me(e.type)||`Memo`:t;case ae:t=e._payload,e=e._init;try{return me(e(t))}catch{}}return null}var he=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e={pending:!1,data:null,method:null,action:null},ve=[],ye=-1;function be(e){return{current:e}}function xe(e){0>ye||(e.current=ve[ye],ve[ye]=null,ye--)}function Se(e,t){ye++,ve[ye]=e.current,e.current=t}var Ce=be(null),we=be(null),Te=be(null),Ee=be(null);function De(e,t){switch(Se(Te,t),Se(we,e),Se(Ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?vp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=vp(t),e=yp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}xe(Ce),Se(Ce,e)}function Oe(){xe(Ce),xe(we),xe(Te)}function ke(e){var t=e.memoizedState;t!==null&&(hh._currentValue=t.memoizedState,Se(Ee,e)),t=Ce.current;var n=yp(t,e.type);t!==n&&(Se(we,e),Se(Ce,n))}function Ae(e){we.current===e&&(xe(Ce),xe(we)),Ee.current===e&&(xe(Ee),hh._currentValue=_e)}var je,Me;function I(e){if(je===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);je=t&&t[1]||``,Me=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+je+e+Me}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -4281,51 +4281,51 @@ No matching component was found for:
|
|
|
4281
4281
|
gl_FragColor = vec4(color, opacity);
|
|
4282
4282
|
#include <tonemapping_fragment>
|
|
4283
4283
|
#include <${parseInt(`186`.replace(/\D+/g,``))>=154?`colorspace_fragment`:`encodings_fragment`}>
|
|
4284
|
-
}`);function jy({color:e=`black`,opacity:t=1,transparent:n=!1,screenspace:r=!1,toneMapped:i=!0,polygonOffset:a=!1,polygonOffsetFactor:o=0,renderOrder:s=0,thickness:c=.05,angle:l=Math.PI,clippingPlanes:u,...d}){let f=v.useRef(null),[p]=v.useState(()=>new Ay({side:1})),{gl:m}=W_(),h=m.getDrawingBufferSize(new B);v.useMemo(()=>xv({OutlinesMaterial:Ay}),[]);let g=v.useRef(0),_=v.useRef(null);return v.useLayoutEffect(()=>{let e=f.current;if(!e)return;let t=e.parent;if(t&&t.geometry&&(g.current!==l||_.current!==t.geometry)){g.current=l,_.current=t.geometry;let n=e.children?.[0];n&&(l&&n.geometry.dispose(),e.remove(n)),t.skeleton?(n=new ro,n.material=p,n.bind(t.skeleton,t.bindMatrix),e.add(n)):t.isInstancedMesh?(n=new vo(t.geometry,p,t.count),n.instanceMatrix=t.instanceMatrix,e.add(n)):(n=new Ga,n.material=p,e.add(n)),n.geometry=l?Dy(t.geometry,l):t.geometry,n.morphTargetInfluences=t.morphTargetInfluences,n.morphTargetDictionary=t.morphTargetDictionary}}),v.useLayoutEffect(()=>{let l=f.current;if(!l)return;let d=l.children[0];if(d){d.renderOrder=s;let f=l.parent;j_(d,{morphTargetInfluences:f.morphTargetInfluences,morphTargetDictionary:f.morphTargetDictionary}),j_(d.material,{transparent:n,thickness:c,color:e,opacity:t,size:h,screenspace:r,toneMapped:i,polygonOffset:a,polygonOffsetFactor:o,clippingPlanes:u,clipping:u&&u.length>0})}}),v.useEffect(()=>()=>{let e=f.current;if(!e)return;let t=e.children[0];t&&(l&&t.geometry.dispose(),e.remove(t))},[]),v.createElement(`group`,xy({ref:f},d))}var My=`modulepreload`,Ny=function(e){return`/`+e},Py={},Fy=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ny(t,n),t=s(t),t in Py)return;Py[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:My,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Iy=(0,v.createContext)(null);function Ly({iterations:e=10,ms:t=250,threshold:n=.75,step:r=.1,factor:i=.5,flipflops:a=1/0,bounds:o=e=>e>100?[60,100]:[40,60],onIncline:s,onDecline:c,onChange:l,onFallback:u,children:d}){let[f,p]=(0,v.useState)(()=>({fps:0,index:0,factor:i,flipped:0,refreshrate:0,fallback:!1,frames:[],averages:[],subscriptions:new Map,subscribe:e=>{let t=Symbol();return f.subscriptions.set(t,e.current),()=>void f.subscriptions.delete(t)}})),m=0;return G_(()=>{let{frames:i,averages:d}=f;if(!f.fallback&&d.length<e){i.push(performance.now());let p=i[i.length-1]-i[0];if(p>=t){if(f.fps=Math.round(i.length/p*1e3*1)/1,f.refreshrate=Math.max(f.refreshrate,f.fps),d[f.index++%e]=f.fps,d.length===e){let[t,i]=o(f.refreshrate),p=d.filter(e=>e>=i),h=d.filter(e=>e<t);p.length>e*n&&(f.factor=Math.min(1,f.factor+r),f.flipped++,s&&s(f),f.subscriptions.forEach(e=>e.onIncline&&e.onIncline(f))),h.length>e*n&&(f.factor=Math.max(0,f.factor-r),f.flipped++,c&&c(f),f.subscriptions.forEach(e=>e.onDecline&&e.onDecline(f))),m!==f.factor&&(m=f.factor,l&&l(f),f.subscriptions.forEach(e=>e.onChange&&e.onChange(f))),f.flipped>a&&!f.fallback&&(f.fallback=!0,u&&u(f),f.subscriptions.forEach(e=>e.onFallback&&e.onFallback(f))),f.averages=[]}f.frames=[]}}}),v.createElement(Iy.Provider,{value:f},d)}function Ry(e,t){let n=new Set;for(let r of(e??``).matchAll(/\b(?:depends\s+on|blocked\s+by)\s*:?\s*((?:#\d+(?:\s*(?:,|and|&)\s*)?)+)/gi))for(let e of r[1].matchAll(/#(\d+)/g))t.has(Number(e[1]))&&n.add(Number(e[1]));return[...n]}var zy=`cubefarm:audio`;function By(){try{let e=JSON.parse(localStorage.getItem(zy)??`null`),t=Number(e?.volume);return{volume:Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t))):70,muted:e?.muted===!0}}catch{return{volume:70,muted:!1}}}var Vy=By(),Hy=new Set,Uy=null,Wy=null,Gy=!1,Ky=()=>Vy.muted?0:(Vy.volume/100)**2;function qy(){if(!Gy)return null;try{if(!Uy){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Uy=new e,Wy=Uy.createGain(),Wy.gain.value=Ky(),Wy.connect(Uy.destination)}return Uy.state===`suspended`&&Uy.resume().catch(()=>void 0),Uy.state===`running`&&Wy?{ctx:Uy,out:Wy}:null}catch{return null}}function Jy(){Gy=!0,qy()}for(let e of[`pointerdown`,`keydown`])window.addEventListener(e,Jy,{once:!0,capture:!0});var Yy=()=>Vy;function Xy(e){return Hy.add(e),()=>void Hy.delete(e)}function Zy(e){Vy={...Vy,...e,volume:Math.max(0,Math.min(100,Math.round(e.volume??Vy.volume)))};try{localStorage.setItem(zy,JSON.stringify(Vy))}catch{}if(Uy&&Wy)try{Wy.gain.cancelScheduledValues(Uy.currentTime),Wy.gain.setTargetAtTime(Ky(),Uy.currentTime,.015)}catch{}for(let e of Hy)e()}var Qy=()=>Zy({muted:!Vy.muted});function $y({freq:e,to:t,type:n=`sine`,at:r=0,dur:i,peak:a,attack:o=.015}){let s=qy();if(s)try{let c=s.ctx.currentTime+r,l=s.ctx.createOscillator(),u=s.ctx.createGain();l.type=n,l.frequency.setValueAtTime(e,c),t&&l.frequency.exponentialRampToValueAtTime(t,c+i),u.gain.setValueAtTime(1e-4,c),u.gain.exponentialRampToValueAtTime(a,c+o),u.gain.exponentialRampToValueAtTime(1e-4,c+i),l.connect(u).connect(s.out),l.start(c),l.stop(c+i+.05)}catch{}}var eb=null;function tb({at:e=0,dur:t,peak:n,filter:r=`lowpass`,freq:i,to:a,q:o=1,attack:s=.005}){let c=qy();if(c)try{if(!eb||eb.sampleRate!==c.ctx.sampleRate){eb=c.ctx.createBuffer(1,c.ctx.sampleRate*2,c.ctx.sampleRate);let e=eb.getChannelData(0);for(let t=0;t<e.length;t++)e[t]=Math.random()*2-1}let l=c.ctx.currentTime+e,u=c.ctx.createBufferSource();u.buffer=eb;let d=c.ctx.createBiquadFilter();d.type=r,d.Q.value=o,d.frequency.setValueAtTime(i,l),a&&d.frequency.exponentialRampToValueAtTime(a,l+t);let f=c.ctx.createGain();f.gain.setValueAtTime(1e-4,l),f.gain.exponentialRampToValueAtTime(n,l+s),f.gain.exponentialRampToValueAtTime(1e-4,l+t),u.connect(d).connect(f).connect(c.out),u.start(l,Math.random()),u.stop(l+t+.05)}catch{}}var nb=-1/0;function rb(){performance.now()-nb<800||(nb=performance.now(),[1046.5,1568].forEach((e,t)=>$y({freq:e,type:`triangle`,at:t*.11,dur:.18,peak:.12})))}function ib(){$y({freq:660,to:1320,type:`square`,dur:.12,peak:.035}),$y({freq:1320,to:990,type:`triangle`,at:.12,dur:.1,peak:.08}),$y({freq:1760,type:`triangle`,at:.24,dur:.18,peak:.07})}function ab(){[880,1318.5].forEach((e,t)=>$y({freq:e,at:t*.16,dur:1.1,peak:.18,attack:.02}))}function ob(e=.75){tb({dur:e,peak:.1,filter:`bandpass`,freq:220,to:900,q:.8,attack:e*.45}),$y({freq:70,to:55,dur:e,peak:.05,attack:e*.4})}function sb(){tb({dur:.09,peak:.1,filter:`bandpass`,freq:2600,to:900,q:1.4,attack:.003}),$y({freq:520,to:190,type:`triangle`,dur:.08,peak:.07,attack:.004})}function cb(){$y({freq:520,to:330,dur:.16,peak:.13,attack:.008}),$y({freq:1040,to:660,type:`triangle`,dur:.07,peak:.025,attack:.004})}function lb(){tb({dur:.28,peak:.07,filter:`bandpass`,freq:350,to:2400,q:2.2,attack:.05}),$y({freq:220,to:660,type:`triangle`,dur:.24,peak:.035,attack:.03}),tb({at:.24,dur:.05,peak:.05,filter:`bandpass`,freq:1800,q:1.5,attack:.002})}function ub(e=!1){tb({dur:e?.09:.12,peak:e?.07:.045,freq:(e?700:480)*(.9+Math.random()*.2),q:.7})}var db=0;function fb(e,t,n){let r=Math.floor(e/Math.PI);t&&r!==db&&ub(n),db=r}function pb(){tb({dur:.3,peak:.14,filter:`bandpass`,freq:5200,to:2600,q:.8,attack:.03}),tb({at:.18,dur:.9,peak:.05,filter:`bandpass`,freq:900,to:1500,q:.5,attack:.2}),[784,988,1318.5].forEach((e,t)=>$y({freq:e,type:`triangle`,at:.2+t*.08,dur:.3,peak:.06}))}var mb={error:{rank:5,play:()=>[0,.2].forEach(e=>$y({freq:110,type:`sawtooth`,at:e,dur:.16,peak:.035,attack:.02}))},qaFailed:{rank:4,play:()=>{$y({freq:392,to:370,type:`triangle`,dur:.26,peak:.12}),$y({freq:311,to:196,type:`triangle`,at:.26,dur:.55,peak:.12})}},ready:{rank:3,play:()=>[784,988,1175,1568].forEach((e,t)=>$y({freq:e,type:`triangle`,at:t*.07,dur:.28,peak:.09}))},merged:{rank:2,play:()=>{tb({dur:.07,peak:.16,filter:`bandpass`,freq:1400,q:1.2,attack:.002}),$y({freq:523,to:1046,type:`square`,at:.04,dur:.12,peak:.04}),[1046.5,1318.5,1568].forEach(e=>$y({freq:e,type:`triangle`,at:.14,dur:.5,peak:.05})),tb({at:.12,dur:.6,peak:.03,filter:`bandpass`,freq:2500,q:.6,attack:.08})}},welcome:{rank:1,play:()=>[659,784,1046.5].forEach((e,t)=>$y({freq:e,type:`sine`,at:t*.12,dur:t===2?.5:.2,peak:.12}))}},hb=150,gb=1e3,_b=null,vb=null,yb=0,bb=-1/0,xb=(e,t)=>e&&mb[e].rank>=mb[t].rank?e:t;function Sb(e){let t=performance.now();t-bb<gb&&mb[e].rank<=yb&&!_b||(_b=xb(_b,e),!vb&&(vb=setTimeout(Cb,Math.max(hb,bb+gb-t))))}function Cb(){vb=null;let e=_b;_b=null,e&&(bb=performance.now(),yb=mb[e].rank,mb[e].play())}var wb=1,Tb=`cubefarm:view`;function Eb(){try{let e=JSON.parse(localStorage.getItem(Tb)??`null`);return e&&[e.floor,e.x,e.z,e.yaw,e.pitch].every(Number.isFinite)?e:null}catch{return null}}function Db(e){try{localStorage.setItem(Tb,JSON.stringify(e))}catch{}}var Ob=600,q=Ty((e,t)=>({connected:!1,loaded:!1,user:null,ghReady:!0,demo:!1,workspaceRoot:``,settings:{sessionLimit:0,defaultModel:`claude-opus-5-5`,defaultEffort:`medium`,runtime:`terminal`,defaultCli:`claude`,hiring:`approve`,teamCap:6,ceoHeartbeatMin:60,managerName:``,companyName:``,projectsDir:``,setupDone:!0,tutorialStep:-1,pacingSessions:3},clis:[],repos:[],agents:{},logs:{},screens:{},qa:{},requests:[],ceo:{queue:[],job:null,lastReviewAt:null,nextReviewAt:null},messages:[],phoneReadAt:0,usage:{state:`normal`,until:null},restarting:!1,floor:Eb()?.floor??0,travel:null,overlay:null,focus:null,locked:!1,started:!1,toasts:[],held:null,chargeAt:null,apply(n){let r=t().loaded;switch(n.type){case`snapshot`:{let r=n.data,i={},a={},o={};for(let{log:e,...t}of r.agents)i[t.id]=t,a[t.id]=e,t.screenshotAt&&(o[t.id]=t.screenshotAt);let s={};for(let e of r.qa)s[kb(e.repoId,e.prNumber)]=e;let c=r.repos.some(e=>e.floor===t().floor);e({loaded:!0,user:r.user,ghReady:r.ghReady,ghError:r.ghError,demo:r.demo,workspaceRoot:r.workspaceRoot,settings:r.settings,repos:r.repos.sort((e,t)=>e.floor-t.floor),agents:i,logs:a,screens:o,qa:s,requests:r.requests,ceo:r.ceo,messages:r.messages,phoneReadAt:r.phoneReadAt,officeCommit:r.officeCommit,officeUpdate:r.officeUpdate,usage:r.usage,clis:r.clis??[],restarting:!1,floor:c?t().floor:0});break}case`repo`:{let i=t().repos.find(e=>e.id===n.repo.id),a=new Set(i?.pulls.filter(e=>e.state===`OPEN`).map(e=>e.number));r&&n.repo.pulls.some(e=>e.state===`MERGED`&&a.has(e.number))&&Sb(`merged`);let o=t().repos.filter(e=>e.id!==n.repo.id);o.push(n.repo),e({repos:o.sort((e,t)=>e.floor-t.floor)});break}case`repoRemoved`:{let r=t().repos.filter(e=>e.id!==n.repoId);e({repos:r,floor:t().floor>r.length?0:t().floor});break}case`agent`:{let i=t().agents[n.agent.id];r&&!i&&n.agent.role!==`ceo`&&Sb(`welcome`),r&&i&&i.status!==`error`&&n.agent.status===`error`&&Sb(`error`),e({agents:{...t().agents,[n.agent.id]:n.agent}});break}case`agentRemoved`:{let{[n.agentId]:r,...i}=t().agents;e({agents:i});break}case`log`:{let r=(t().logs[n.agentId]??[]).concat(n.lines);e({logs:{...t().logs,[n.agentId]:r.length>Ob?r.slice(-600):r}});break}case`screen`:{let r=t().agents[n.agentId];e({screens:{...t().screens,[n.agentId]:n.at},agents:r?{...t().agents,[n.agentId]:{...r,hasScreenshot:!0,screenshotAt:n.at,browserUrl:n.url??r.browserUrl}}:t().agents});break}case`qa`:{let i=t().qa[kb(n.qa.repoId,n.qa.prNumber)]?.status,a=e=>e===`failed`||e===`needs-human`;r&&n.qa.status===`passed`&&i!==`passed`&&Sb(`ready`),r&&a(n.qa.status)&&!a(i)&&Sb(`qaFailed`),e({qa:{...t().qa,[kb(n.qa.repoId,n.qa.prNumber)]:n.qa}});break}case`qaRemoved`:{let{[kb(n.repoId,n.prNumber)]:r,...i}=t().qa;e({qa:i});break}case`settings`:e({settings:n.settings});break;case`clis`:e({clis:n.clis});break;case`request`:{let i=t().requests.find(e=>e.id===n.request.id);r&&n.request.kind===`hire`&&n.request.status===`approved`&&i?.status===`pending`&&Sb(`welcome`);let a=t().requests.filter(e=>e.id!==n.request.id);a.push(n.request),e({requests:a.sort((e,t)=>e.createdAt-t.createdAt)});break}case`ceo`:e({ceo:n.ceo});break;case`message`:{e({messages:[...t().messages.slice(-199),n.message]});let r=t().overlay,i=r?.kind===`phone`&&(r.tab??`chat`)===`chat`;if(n.message.from===`ceo`&&!i){rb();let e=t().agents.ceo?.name??`CEO`,r=n.message.text.replace(/\s+/g,` `);t().pushToast(`info`,`📱 ${e}: ${r.length>110?`${r.slice(0,109)}…`:r}`)}break}case`phoneRead`:e({phoneReadAt:Math.max(t().phoneReadAt,n.at)});break;case`toast`:t().pushToast(n.level,n.text);break;case`officeUpdate`:e({officeUpdate:n.officeUpdate});break;case`usage`:e({usage:n.usage})}},setConnected:t=>e({connected:t}),setRestarting:t=>e({restarting:t}),setOfficeUpdate:t=>e({officeUpdate:t}),openOverlay(t){e(t?{overlay:t,focus:null,held:null,chargeAt:null}:{overlay:t}),t&&document.pointerLockElement&&document.exitPointerLock()},setFocus:n=>{let r=t().focus;(r?.id!==n?.id||r?.label!==n?.label)&&e({focus:n})},setHeld:t=>e({held:t,chargeAt:null}),setCharge:t=>e({chargeAt:t}),setLocked:t=>e({locked:t}),start:()=>e({started:!0}),goToFloor(n){if(n===t().floor||t().travel){e({overlay:null});return}e({overlay:null,held:null,chargeAt:null,travel:{to:n,phase:`closing`}})},finishTravel(n){let r=t().travel;r&&e(n===`arrived`?{floor:r.to,travel:{...r,phase:`opening`}}:{travel:null})},pushToast(n,r){let i=wb++;e({toasts:[...t().toasts.slice(-4),{id:i,level:n,text:r}]}),setTimeout(()=>t().dismissToast(i),n===`error`?9e3:5e3)},dismissToast:n=>e({toasts:t().toasts.filter(e=>e.id!==n)})})),kb=(e,t)=>`${e}#${t}`,Ab=(e,t)=>e.find(e=>e.floor===t)??null,jb=(e,t)=>Object.values(e).filter(e=>e.repoId===t).sort((e,t)=>e.role===t.role?e.desk-t.desk:e.role===`dev`?-1:1),Mb=e=>e?.kind===`kanban`||e?.kind===`terminal`||e?.kind===`manager`,Nb=e=>e.status===`preparing`||e.status===`working`,Pb=(e,t)=>e.filter(e=>e.from===`ceo`&&!e.requestId&&e.at>t).length,Fb=e=>e.filter(e=>e.status===`pending`);function Ib(){let e=q(e=>e.requests),t=q(e=>e.messages),n=q(e=>e.phoneReadAt);return Fb(e).length+Pb(t,n)}function Lb(e,t,n){let r=e.pulls.filter(e=>e.state===`OPEN`),i=new Map(t.map(e=>[e.id,e])),a=t.filter(e=>e.role===`dev`),o=(e,t)=>a.find(t=>t.prNumber===e)??a.find(e=>e.branch&&e.branch===t),s=[];for(let e of a){if(e.issueNumber==null||e.task!==`issue`||e.status===`idle`||e.prNumber!=null&&r.some(t=>t.number===e.prNumber))continue;let t=e.status===`preparing`?`setting up`:e.status===`working`?`working`:e.status===`error`?`needs help`:e.status===`stopped`?`stopped`:`finished · no PR`;s.push({key:`a-${e.id}`,number:e.issueNumber,title:e.issueTitle??``,agent:e,note:t,tone:e.status===`error`?`bad`:e.status===`stopped`||e.status===`done`?`warn`:void 0})}let c=[],l=[];for(let t of r){let r=n[kb(e.id,t.number)],a=(r?.devAgentId?i.get(r.devAgentId):void 0)??o(t.number,t.headRefName),s=r?.qaAgentId?i.get(r.qaAgentId):void 0,u={key:`pr-${t.number}`,number:t.number,prNumber:t.number,title:t.title,url:t.url,qa:r};if(r?.status===`passed`){l.push({...u,agent:a,note:r.mergeNote?`QA ✓ · ${r.mergeNote}`:t.mergeable===`CONFLICTING`?`QA ✓ · conflicts`:t.checks===`failing`?`QA ✓ · CI failing`:e.autoMerge&&t.checks===`pending`?`QA ✓ · waiting for checks`:`✅ QA passed`,tone:t.mergeable===`CONFLICTING`||t.checks===`failing`?`warn`:`good`});continue}let d=r?.status;c.push({...u,agent:d===`testing`?s:a,note:d===`queued`?`waiting for QA${r&&r.round>1?` · round ${r.round}`:``}`:d===`testing`?`🔍 testing · round ${r.round}`:d===`failed`?`❌ failed · back to dev`:d===`fixing`?`🔧 fixing · round ${r.round}`:d===`needs-human`?`⚠️ needs you`:t.isDraft?`draft`:`not tested yet`,tone:d===`failed`||d===`needs-human`?`bad`:d===`fixing`||!d?`warn`:void 0})}let u=new Set([...s.map(e=>e.number),...r.flatMap(e=>e.closesIssues)]),d=new Set(e.issues.map(e=>e.number));return{backlog:e.issues.filter(e=>!u.has(e.number)).map(e=>{let t=Ry(e.body,d),n=e.labels.map(e=>e.replace(/^swarm:/i,`🎯 `)).slice(0,2).join(`, `);return{key:`i-${e.number}`,number:e.number,title:e.title,url:e.url,note:t.length?`⏳ after #${t.join(`, #`)}`:n||void 0}}),progress:s,qa:c,ready:l,merged:e.pulls.filter(e=>e.state===`MERGED`).sort((e,t)=>(t.mergedAt??``).localeCompare(e.mergedAt??``)).map(e=>({key:`m-${e.number}`,number:e.number,prNumber:e.number,title:e.title,url:e.url,agent:o(e.number,e.headRefName)}))}}var Rb=1.75,zb=new URLSearchParams(window.location.search).has(`stats`);function Bb(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function Vb(){return(0,v.useSyncExternalStore)(Bb,()=>document.hidden)}function Hb(){let e=q(e=>Mb(e.overlay)),t=Vb();return e||t}function Ub({paused:e}){let t=W_(e=>e.size),n=W_(e=>e.viewport.dpr),r=W_(e=>e.advance),i=W_(e=>e.clock),a=(0,v.useRef)({size:t,dpr:n});return(0,v.useEffect)(()=>{let o=a.current.size!==t||a.current.dpr!==n;a.current={size:t,dpr:n},e&&o&&r(i.elapsedTime)},[e,t,n,r,i]),null}function Wb(e){let t=e>130?144:e>100?120:60;return[Math.round(t*.6),Math.round(t*.9)]}function Gb({onChange:e}){let t=({factor:t})=>e(Math.round((1+.75*t)*100)/100);return(0,K.jsx)(Ly,{factor:1,step:.25,bounds:Wb,onIncline:t,onDecline:t})}var Kb=null,qb=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e);function Jb({paused:e}){let t=W_(e=>e.gl),n=(0,v.useRef)({start:0,prev:0,frames:0});return(0,v.useEffect)(()=>{n.current.start=0},[e]),G_(()=>{let e=performance.now(),r=n.current;(!r.start||e-r.prev>1e3)&&(r.start=e,r.frames=0),r.prev=e,r.frames++;let i=e-r.start;if(i<500||!Kb)return;let{calls:a,triangles:o}=t.info.render,s=r.frames*1e3/i;Kb.textContent=`${Math.round(s)} fps · ${(i/r.frames).toFixed(1)} ms · ${a} calls · ${qb(o)} tris · dpr ${t.getPixelRatio().toFixed(2)}`,r.start=e,r.frames=0}),null}function Yb(){let e=Hb();return(0,K.jsxs)(`div`,{className:`stats`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{ref:e=>{Kb=e},hidden:e,children:`measuring…`}),e&&(0,K.jsx)(`span`,{children:`⏸ 3D view paused`})]})}var Xb=3.6,Zb=1.65,Qb=.3,$b={doorHalf:1.2,cabinHalf:1.5,depth:2.6,doorHeight:2.5},ex={x:0,z:10.4,yaw:0},tx=(e,t,n,r,i)=>({minX:e-n/2,maxX:e+n/2,minZ:t-r/2,maxZ:t+r/2,h:i}),nx={desk:.78,seated:1.3,board:3.45,couch:.95,coffeeTable:.5,kitchen:2,cooler:1.5,bookshelf:2.2,cabinet:2.1,reception:1.13,glass:2.8};function rx(){let e=.4,{doorHalf:t,cabinHalf:n,depth:r}=$b;return[{minX:-16.4,maxX:16.4,minZ:-12.4,maxZ:-12},{minX:-16.4,maxX:-16,minZ:-12,maxZ:12},{minX:16,maxX:16.4,minZ:-12,maxZ:12},{minX:-16,maxX:-t,minZ:12,maxZ:12.4},{minX:t,maxX:16,minZ:12,maxZ:12.4},{minX:-n-e,maxX:-n,minZ:12,maxZ:12+r},{minX:n,maxX:n+e,minZ:12,maxZ:12+r},{minX:-n,maxX:n,minZ:12+r,maxZ:12+r+e}]}var ix=()=>({minX:-$b.doorHalf,maxX:$b.doorHalf,minZ:12,maxZ:12.4}),ax=[-10.5,-3.5,3.5,10.5],ox=[-6.2,-1.6,3],sx=ax.length*ox.length,cx={w:1.9,d:.95,h:.74};function lx(e){let t=ox.length-1-Math.floor(e/ax.length)%ox.length;return{x:ax[e%ax.length],z:ox[t]}}var ux={w:12,h:3,y:.45,z:-11.94},dx={x:-13.7,y:2.25,w:3.2,h:1.8,bezel:.09,depth:.12},fx={officeX:-10,lobbyX:-12.9,w:1.3,d:.3,h:1.85},px=e=>tx(e,12-fx.d/2,fx.w,fx.d,fx.h),mx={x:14,stations:[-5.2,-2,1.2]},hx=-Math.PI/2,gx=e=>({x:mx.x,z:mx.stations[e%mx.stations.length]});function _x(){let e=rx();for(let t=0;t<sx;t++){let{x:n,z:r}=lx(t);e.push(tx(n,r,cx.w+.1,cx.d+.1,nx.desk)),e.push(tx(n,r+.8,.7,.6,nx.seated))}for(let t of mx.stations)e.push(tx(mx.x,t,cx.d+.1,cx.w+.1,nx.desk)),e.push(tx(mx.x-.8,t,.6,.7,nx.seated));e.push(tx(0,-11.75,ux.w+.4,.5,nx.board));let t=dx;return e.push(tx(t.x,-12+t.depth/2,t.w+t.bezel*2,t.depth,t.y+t.h/2+t.bezel)),e.push(tx(-15.1,6.5,1.1,3.2,nx.couch)),e.push(tx(-13.4,6.5,.9,1.4,nx.coffeeTable)),e.push(px(fx.officeX)),e.push(tx(15.55,7.4,.9,5,nx.kitchen)),e.push(tx(15.5,-9.5,.7,.7,nx.cooler)),e}var vx={minX:-16,maxX:-6.5,minZ:-12,maxZ:-3.5,doorMinX:-11,doorMaxX:-9.2},yx={x:-11.2,z:-8.6,w:2.6,d:1.1},bx={x:3,z:-3.5,w:5,d:1.2},xx={minX:6.5,maxX:16,minZ:-12,maxZ:-3.5,doorMinX:8.2,doorMaxX:10},Sx={x:12,z:-7.4},Cx={x:14.6,seats:[6.6,7.9,9.2,10.4]},wx=Math.PI/2;function Tx(){let e=rx(),t=vx,n=.12;e.push({minX:t.maxX-n,maxX:t.maxX+n,minZ:t.minZ,maxZ:t.maxZ,h:nx.glass}),e.push({minX:t.minX,maxX:t.doorMinX,minZ:t.maxZ-n,maxZ:t.maxZ+n,h:nx.glass}),e.push({minX:t.doorMaxX,maxX:t.maxX,minZ:t.maxZ-n,maxZ:t.maxZ+n,h:nx.glass});let r=xx;e.push({minX:r.minX-n,maxX:r.minX+n,minZ:r.minZ,maxZ:r.maxZ,h:nx.glass}),e.push({minX:r.minX,maxX:r.doorMinX,minZ:r.maxZ-n,maxZ:r.maxZ+n,h:nx.glass}),e.push({minX:r.doorMaxX,maxX:r.maxX,minZ:r.maxZ-n,maxZ:r.maxZ+n,h:nx.glass}),e.push(tx(Sx.x,Sx.z,cx.w+.1,cx.d+.1,nx.desk)),e.push(tx(Sx.x,Sx.z+.8,.7,.6,nx.seated));for(let t of Cx.seats)e.push(tx(Cx.x,t,.7,.7,nx.seated));return e.push(tx(yx.x,yx.z,yx.w,yx.d,nx.desk)),e.push(tx(yx.x,yx.z-1.1,.8,.8,nx.seated)),e.push(tx(-15.6,-8,.8,5,nx.bookshelf)),e.push(px(fx.lobbyX)),e.push(tx(bx.x,bx.z,bx.w,bx.d,nx.reception)),e.push(tx(11.5,4,3.2,1,nx.couch)),e.push(tx(11.5,6.2,1.6,.9,nx.coffeeTable)),e.push(tx(12,-11.45,4.4,1.1,nx.cabinet)),e}function Ex(e,t,n,r=Qb){for(let i=0;i<2;i++)for(let i of n){let n=i.minX-r,a=i.maxX+r,o=i.minZ-r,s=i.maxZ+r;if(e<=n||e>=a||t<=o||t>=s)continue;let c=[n-e,a-e,o-t,s-t],l=c.map(Math.abs),u=l.indexOf(Math.min(...l));u<2?e+=c[u]:t+=c[u]}return{x:e,z:t}}var Dx=[`#ffffff`,`#ffd166`,`#ef476f`,`#06d6a0`,`#118ab2`,`#2b2d42`],Ox=[`quiff`,`afro`,`bun`,`curls`],kx={feminine:[[`long`,4],[`ponytail`,3],[`bun`,3],[`curls`,2],[`afro`,2],[`sidePart`,2],[`buzz`,1]],masculine:[[`crop`,2],[`quiff`,3],[`sidePart`,3],[`buzz`,2],[`bald`,2],[`curls`,2],[`afro`,2],[`long`,1],[`ponytail`,1],[`bun`,1]]};function Ax(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function jx(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Mx(e,t){let n=e*t.reduce((e,[,t])=>e+t,0);for(let[e,r]of t)if((n-=r)<0)return e;return t[t.length-1][0]}function Nx(e){let t=jx(Ax(e.id)),[n,r,i,a,o,s,c,l,u]=Array.from({length:9},t),d=e.role===`dev`,f=e.look===`masculine`,p=Mx(n,kx[e.look]),m=f?Mx(r,[[`none`,5],[`stubble`,2],[`beard`,2],[`moustache`,1]]):`none`,h=e.role===`qa`?`none`:Mx(i,[[`none`,6],[`round`,2],[`square`,2]]),g=d&&p!==`afro`&&a<.3;return{hair:p,facialHair:m,glasses:h,headphones:g,headwear:d&&!g&&!Ox.includes(p)?Mx(o,[[`none`,7],[`beanie`,1],[`cap`,1]]):`none`,outfit:d?Mx(s,[[`tee`,1],[`hoodie`,1],[`stripe`,1],[`sweater`,1]]):`tee`,height:+(.94+c*.12).toFixed(3),shoulders:+(.92+l*.16).toFixed(3),accent:Math.floor(u*Dx.length)}}function Px(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new W,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=Fx(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t!==0){c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=Fx(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}}return c}function Fx(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new Pi(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var Ix=new fr,Lx=new zn,Rx=new Sr;function zx(e,{at:t=[0,0,0],rot:n=[0,0,0],scale:r=[1,1,1]}={}){return Lx.setFromEuler(Rx.set(...n)),e.applyMatrix4(Ix.compose(new V(...t),Lx,new V(...r))),e}function Bx(...e){e.some(e=>!e.index)&&(e=e.map(e=>e.index?e.toNonIndexed():e));let t=Px(e);if(!t)throw Error(`could not merge character geometry`);return e.forEach(e=>e.dispose()),t}var Vx=(e,t=14,n=10)=>new al(e,t,n),Hx=(e,t,n=6,r=12)=>new ws(e,t,n,r),Ux=(e,t,n)=>new Cs(e,t,n),Wx=()=>zx(new al(.215,24,16,0,Math.PI*2,0,1.75),{at:[0,.02,.01],rot:[.55,0,0]});function Gx(e,t,n){let r=[];for(let i=0;i<e;i++){let a=1-2*(i+.5)/e,o=Math.sqrt(1-a*a),s=i*2.39996,c=new V(Math.cos(s)*o,a,Math.sin(s)*o).multiplyScalar(t);n(c)&&r.push(c)}return r}function Kx(e){switch(e){case`crop`:return Wx();case`long`:return Bx(Wx(),zx(Vx(.215,20,14),{at:[0,-.1,.07],scale:[1.05,1.25,.8]}));case`ponytail`:{let e={at:[0,.08,.2],rot:[.45,0,0]},t=zx(Hx(.075,.24,6,10),{at:[0,-.17,.04]});return Bx(Wx(),zx(Vx(.085,12,10),e),zx(t,e))}case`bun`:return Bx(Wx(),zx(Vx(.1,14,10),{at:[0,.18,.12]}));case`quiff`:{let e=[-.09,-.045,0,.045,.09].map((e,t)=>zx(new Ds(.058,.19+t%2*.04,8),{at:[e,.2-Math.abs(e)*.45,-.09+Math.abs(e)*.35],rot:[-.75,0,-e*3]}));return e.push(zx(Vx(.1,14,10),{at:[0,.17,-.1],scale:[1.4,.7,1]})),Bx(Wx(),...e)}case`afro`:{let e=new V(0,.1,.06),t=Gx(26,.235,e=>e.z>-.08&&e.y>-.15).map(t=>zx(Vx(.075,10,8),{at:[e.x+t.x,e.y+t.y,e.z+t.z]}));return Bx(zx(Vx(.245,22,16),{at:[e.x,e.y,e.z]}),...t)}case`sidePart`:return Bx(Wx(),zx(Vx(.12,16,10),{at:[.05,.16,-.1],rot:[.3,0,-.35],scale:[1.35,.5,.9]}),zx(Vx(.07,12,8),{at:[-.08,.2,-.04],scale:[1,.6,1.2]}));case`buzz`:return zx(new al(.205,24,14,0,Math.PI*2,0,1.6),{at:[0,.015,.012],rot:[.5,0,0]});case`bald`:return new al(.208,24,6,-.3,Math.PI+.6,1.2,.58);case`curls`:{let e=Gx(60,.2,e=>e.y>.02&&e.y+e.z*.9>-.02).map(e=>zx(Vx(.055,8,6),{at:[e.x*1.02,e.y+.03,e.z*1.02+.01]}));return Bx(Wx(),...e)}}}function qx(e,t,n,r,i){let a=e.toNonIndexed(),o=a.attributes,s=[],c=o.position;for(let e=0;e<c.count;e+=3){let a=(c.getX(e)+c.getX(e+1)+c.getX(e+2))/3,o=(c.getY(e)+c.getY(e+1)+c.getY(e+2))/3;(c.getZ(e)+c.getZ(e+1)+c.getZ(e+2))/3<0&&((a-t)/r)**2+((o-n)/i)**2<1||s.push(e,e+1,e+2)}let l=new W;for(let e of[`position`,`normal`,`uv`]){let t=o[e],n=new Float32Array(s.length*t.itemSize);s.forEach((e,r)=>{for(let i=0;i<t.itemSize;i++)n[r*t.itemSize+i]=t.array[e*t.itemSize+i]}),l.setAttribute(e,new Pi(n,t.itemSize))}return e.dispose(),a.dispose(),l}var Jx=(e,t)=>qx(new al(e,28,12,Math.PI-.15,Math.PI+.3,t,Math.PI-t),0,-.088,.07,.048),Yx=()=>Bx(...[-1,1].map(e=>zx(Hx(.022,.05,4,8),{at:[e*.036,-.052,-.197],rot:[.25,0,e*1.2],scale:[1,1,.7]})));function Xx(e){switch(e){case`none`:return null;case`stubble`:return Jx(.203,2);case`moustache`:return Yx();case`beard`:return Bx(zx(Jx(.212,1.95),{at:[0,.012,-.004],scale:[1.03,1.12,1.04]}),...[-1,1].map(e=>zx(Hx(.028,.09,4,8),{at:[e*.188,-.07,-.035],rot:[0,0,e*.25]})),Yx())}}function Zx(e,t=-.215){if(e===`none`)return null;let n=e===`round`?[-.075,.075].map(e=>zx(new sl(.047,.01,6,20),{at:[e,.02,t]})):[-.078,.078].flatMap(e=>[zx(Ux(.1,.018,.016),{at:[e,.058,t]}),zx(Ux(.1,.014,.016),{at:[e,-.02,t]}),zx(Ux(.014,.09,.016),{at:[e-.045,.02,t]}),zx(Ux(.014,.09,.016),{at:[e+.045,.02,t]})]),r=[-1,1].map(e=>zx(Ux(.012,.012,.19),{at:[e*.172,.035,-.11],rot:[0,e*.4,0]}));return Bx(...n,zx(Ux(.05,.012,.012),{at:[0,.03,t]}),...r)}function Qx(){let e=zx(new sl(.245,.018,6,28,Math.PI),{at:[0,0,.01]}),t=[-1,1].map(e=>zx(new Es(.072,.072,.055,18),{at:[e*.235,-.01,.01],rot:[0,0,Math.PI/2]})),n=[-1,1].map(e=>zx(new Es(.052,.052,.012,18),{at:[e*.266,-.01,.01],rot:[0,0,Math.PI/2]}));return{shell:Bx(e,...t),covers:Bx(...n)}}function $x(e){switch(e){case`none`:return null;case`beanie`:{let e=.228,t=1.42,n={at:[0,.035,.02],rot:[.35,0,0]};return Bx(zx(new al(e,24,12,0,Math.PI*2,0,t),n),zx(zx(new sl(e*Math.sin(t),.03,8,28),{at:[0,e*Math.cos(t),0],rot:[Math.PI/2,0,0]}),n),zx(Vx(.06,12,8),{at:[0,.035+.258*Math.cos(.35),.02+.258*Math.sin(.35)]}))}case`cap`:{let e=.224,t=1.35,n={at:[0,.02,.015],rot:[.18,0,0]};return Bx(zx(new al(e,24,12,0,Math.PI*2,0,t),n),zx(zx(new Es(.14,.14,.014,24,1,!1,Math.PI/2,Math.PI),{at:[0,e*Math.cos(t),-.13],rot:[-.08,0,0],scale:[1,1,.9]}),n),zx(Vx(.022,8,6),{at:[0,.02+e*Math.cos(.18),.015+e*Math.sin(.18)]}))}}}function eS(e){switch(e){case`tee`:return{main:null,trim:null};case`stripe`:return{main:null,trim:new Es(.204,.204,.075,28,1,!0).translate(0,.32,0)};case`hoodie`:return{main:Bx(zx(new sl(.12,.055,10,24),{at:[0,.5,.03],rot:[Math.PI/2-.35,0,0],scale:[1.05,1.15,1]}),zx(Vx(.11,16,10),{at:[0,.5,.12],scale:[1.05,.9,.55]}),zx(Ux(.22,.1,.02),{at:[0,.14,-.196]})),trim:Bx(...[-1,1].flatMap(e=>[zx(Hx(.01,.11,3,6),{at:[e*.045,.39,-.196],rot:[-.25,0,e*.08]}),zx(Vx(.016,8,6),{at:[e*.05,.32,-.208]})]))};case`sweater`:{let e=[-.12,-.06,0,.06,.12].map(e=>{let t=-Math.sqrt(.2*.2-e*e)-.004;return zx(Ux(.04,.04,.012),{at:[e,.33,t],rot:[0,-Math.asin(e/.2),Math.PI/4]})});return{main:null,trim:Bx(zx(new sl(.105,.045,10,24),{at:[0,.505,-.01],rot:[Math.PI/2,0,0]}),new Es(.206,.206,.05,28,1,!0).translate(0,.2,0),...e)}}}}function tS(e,t){return Object.fromEntries(e.map(e=>[e,t(e)]))}var nS={legs:Bx(...[-.11,.11].flatMap(e=>[zx(Hx(.08,.26),{at:[e,.5,-.17],rot:[Math.PI/2,0,0]}),zx(Hx(.07,.3),{at:[e,.27,-.36]})])),shoes:Bx(...[-.11,.11].map(e=>zx(Ux(.13,.09,.22),{at:[e,.05,-.42]}))),torso:Hx(.2,.24,8,16),collar:new sl(.1,.03,8,20),sleeve:Hx(.065,.36,6,12),hand:Vx(.07,14,10),head:Vx(.2,24,18),ears:Bx(...[-.2,.2].map(e=>zx(Vx(.05,10,8),{at:[e,-.01,0]}))),eyes:Bx(...[-.07,.07].map(e=>zx(Vx(.03,10,8),{at:[e,.02,-.18]}))),nose:Vx(.028,10,8),mouth:new sl(.045,.011,6,16,Math.PI),lashes:Bx(...[-1,1].map(e=>zx(Ux(.035,.008,.008),{at:[e*.1,.045,-.172],rot:[0,0,e*-.6]}))),cheeks:Bx(...[-1,1].map(e=>zx(Vx(.03,10,8),{at:[e*.115,-.045,-.165],scale:[1,.6,.3]}))),hairClip:Ux(.07,.035,.035),shirtFront:Ux(.11,.22,.02),tie:Ux(.045,.2,.012),tieKnot:Ux(.06,.04,.02),coatOpening:Ux(.06,.3,.02),badge:Ux(.07,.05,.015),inspectorGlasses:Zx(`round`,-.2),hair:tS([`crop`,`long`,`ponytail`,`bun`,`quiff`,`afro`,`sidePart`,`buzz`,`bald`,`curls`],Kx),facialHair:tS([`none`,`stubble`,`beard`,`moustache`],Xx),glasses:tS([`none`,`round`,`square`],e=>Zx(e)),headphones:Qx(),headwear:tS([`none`,`beanie`,`cap`],$x),outfit:tS([`tee`,`hoodie`,`stripe`,`sweater`],eS)},rS=new ao(new Uint8Array([110,190,255]),3,1,ye);rS.minFilter=D,rS.magFilter=D,rS.generateMipmaps=!1,rS.needsUpdate=!0;var iS=new Map;function aS(e,t={}){let n=`${e}|${t.emissive??``}|${t.emissiveIntensity??``}|${t.opacity??``}`,r=iS.get(n);return r||(r=new Dl({color:e,gradientMap:rS,emissive:t.emissive??`#000000`,emissiveIntensity:t.emissiveIntensity??1,transparent:t.transparent??(t.opacity!==void 0&&t.opacity<1),opacity:t.opacity??1}),iS.set(n,r)),r}function oS(e,t){let n=`map|${e}`,r=iS.get(n);return r||(r=new Dl({map:t,gradientMap:rS}),iS.set(n,r)),r}function sS(e){let t=`glow|${e}`,n=iS.get(t);return n||(n=new Na({color:e,toneMapped:!1}),iS.set(t,n)),n}var cS=new Tl({color:`#bfe8ff`,transparent:!0,opacity:.22,roughness:.05,metalness:0,depthWrite:!1,side:2});function lS(e,t){let n=new H(e),r={h:0,s:0,l:0};return n.getHSL(r),n.setHSL(r.h,r.s,Math.max(0,Math.min(1,r.l+t))),`#${n.getHexString()}`}function uS(e,t,n){return`#${new H(e).lerp(new H(t),n).getHexString()}`}var dS=`"JetBrains Mono", Consolas, "Cascadia Mono", monospace`,fS=`Fredoka, "Segoe UI", system-ui, sans-serif`;function pS(e,t,n,r,i,a){e.beginPath(),e.roundRect(t,n,r,i,a)}function mS(e,t,n,r){let i=t.split(/\s+/),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n)o=i;else if(o&&a.push(o),o=t,a.length===r)break}if(a.length<r&&o&&a.push(o),a.length===r&&i.join(` `).length>a.join(` `).length){let t=a[r-1];for(;t.length>1&&e.measureText(`${t}…`).width>n;)t=t.slice(0,-1);a[r-1]=`${t}…`}return a}var hS={bg:`#1b1b29`,bar:`#2a2a3d`,text:`#e8e8f2`,tool:`#8be9fd`,result:`#8d8da8`,system:`#bd93f9`,error:`#ff6b6b`,manager:`#ffb86c`,done:`#50fa7b`,thinking:`#f1fa8c`},gS=[`·`,`✢`,`✳`,`✶`,`✻`,`✽`,`✻`,`✶`,`✳`,`✢`],_S=[`Crafting`,`Pondering`,`Tinkering`,`Brewing`,`Noodling`,`Scheming`,`Assembling`,`Percolating`];function vS(e){return e?e.startsWith(`mcp__playwright__`)?`Browsing`:e===`Bash`||e===`PowerShell`?`Running`:e===`Edit`||e===`Write`||e===`MultiEdit`?`Editing`:e===`Read`||e===`Grep`||e===`Glob`?`Reading`:e===`WebFetch`||e===`WebSearch`?`Researching`:e:``}function yS(e,t,n,r,i,a,o,s,c){e.fillStyle=hS.bg,e.fillRect(0,0,t,n),e.fillStyle=hS.bar,e.fillRect(0,0,t,30),[`#ff5f57`,`#febc2e`,`#28c840`].forEach((t,n)=>{e.fillStyle=t,e.beginPath(),e.arc(18+n*20,15,6,0,Math.PI*2),e.fill()}),e.fillStyle=`#b8b8cc`,e.font=`600 14px ${dS}`,e.textBaseline=`middle`;let l=r.status===`idle`?`idle`:r.role===`ceo`?(r.issueTitle??`running the company`).toLowerCase():r.task===`qa`?`QA of PR #${r.prNumber}`:r.task===`fix`?`fixing PR #${r.prNumber}`:r.issueNumber?`issue #${r.issueNumber}`:`idle`,u=r.role===`qa`?`qa-lab`:r.role===`ceo`?`hq`:`swarm`,d=`${r.name.toLowerCase()}@${u} — ${l} — ${c}`;e.fillText(d,84,16);let f=o?Math.round(t*.56):t;if(r.status===`idle`&&i.length<=1){bS(e,0,30,t,n-30,r,s);return}e.font=`14px ${dS}`;let p=e.measureText(`M`).width,m=Math.max(10,Math.floor((f-20)/p)),h=r.status===`working`||r.status===`preparing`?28:8,g=Math.floor((n-30-10-h)/17),_=[];for(let e=i.length-1;e>=0&&_.length<g;e--){let t=i[e],n=[],r=t.text||` `;for(let e=0;e<r.length;e+=m)n.push(r.slice(e,e+m));for(let e=n.length-1;e>=0&&_.length<g;e--)_.unshift({text:n[e],kind:t.kind})}let v=48.5;for(let t of _)t.kind===`tool`&&t.text.startsWith(`⏺`)?(e.fillStyle=hS.done,e.fillText(`⏺`,10,v),e.fillStyle=hS.tool,e.fillText(t.text.slice(1),10+p,v)):t.kind===`text`&&t.text.startsWith(`●`)?(e.fillStyle=`#ffffff`,e.fillText(`●`,10,v),e.fillStyle=hS.text,e.fillText(t.text.slice(1),10+p,v)):(e.fillStyle=hS[t.kind]??hS.text,e.fillText(t.text,10,v)),v+=17;if(r.status===`working`||r.status===`preparing`){let t=Math.floor(s/120)%gS.length,i=r.status===`preparing`?`Setting up worktree`:vS(r.currentTool)||_S[Math.floor(s/6e3)%_S.length],a=r.startedAt?Math.floor((Date.now()-r.startedAt)/1e3):0,o=Math.floor(a/60);e.fillStyle=`#ff9e64`,e.font=`600 14px ${dS}`,e.fillText(`${gS[t]} ${i}… (${o}m ${a%60}s)`,10,n-14)}o&&xS(e,f,30,t-f,n-30,r.browserUrl,a)}function bS(e,t,n,r,i,a,o){let s=o/1e3,c=e.createLinearGradient(t,n,t+r,n+i);c.addColorStop(0,`#26264a`),c.addColorStop(1,`#3b2a55`),e.fillStyle=c,e.fillRect(t,n,r,i);let l=t+r/2+Math.sin(s*.7)*r*.25,u=n+i/2+Math.cos(s*.9)*i*.18;e.textAlign=`center`,e.font=`64px ${fS}`,e.fillText(`✻`,l,u-20),e.fillStyle=`#ffd6a5`,e.font=`600 26px ${fS}`,e.fillText(`${a.name} is free`,l,u+34),e.fillStyle=`#b8b8dd`,e.font=`18px ${fS}`,e.fillText(a.role===`qa`?`waiting for a PR to test…`:a.role===`ceo`?`thinking about the company…`:`waiting for an issue…`,l,u+62),e.textAlign=`left`}function xS(e,t,n,r,i,a,o){e.fillStyle=`#e9ecf2`,e.fillRect(t,n,r,i),e.fillStyle=`#d5d9e2`,e.fillRect(t,n,r,34),pS(e,t+10,n+6,r-20,22,11),e.fillStyle=`#ffffff`,e.fill(),e.fillStyle=`#4a5160`,e.font=`13px ${fS}`,e.textBaseline=`middle`;let s=(a??`about:blank`).replace(/^https?:\/\//,``);e.fillText(`🔒 ${s.length>42?`${s.slice(0,41)}…`:s}`,t+20,n+18);let c={x:t+4,y:n+38,w:r-8,h:i-42};if(o&&o.complete&&o.naturalWidth>0){let t=Math.min(c.w/o.naturalWidth,c.h/o.naturalHeight),n=o.naturalWidth*t,r=o.naturalHeight*t;e.drawImage(o,c.x+(c.w-n)/2,c.y,n,r)}else e.fillStyle=`#9aa1b2`,e.textAlign=`center`,e.font=`16px ${fS}`,e.fillText(`🌐 loading page…`,c.x+c.w/2,c.y+c.h/2),e.textAlign=`left`}var SS=[{key:`backlog`,title:`📋 Backlog`,chip:`#ffd166`,note:`#fff3b0`},{key:`progress`,title:`🔨 In progress`,chip:`#4cc9f0`,note:`#cfeefd`},{key:`qa`,title:`🔍 In QA`,chip:`#ff9f68`,note:`#ffe3cf`},{key:`ready`,title:`✅ Ready to merge`,chip:`#80ed99`,note:`#d8f9df`},{key:`merged`,title:`🎉 Merged`,chip:`#c77dff`,note:`#eadcff`}],CS={warn:`#ffd8a8`,bad:`#ffc9c9`,good:`#d8f9df`};function wS(e,t,n,r,i){e.fillStyle=`#fbfbf8`,e.fillRect(0,0,t,n),e.fillStyle=`rgba(120,140,170,0.05)`;for(let r=0;r<6;r++)e.fillRect(r*431%t,r*97%n,260,40);e.textBaseline=`middle`,e.fillStyle=`#2d3142`,e.font=`700 46px ${fS}`,e.fillText(r.fullName,40,48),e.font=`500 26px ${fS}`,e.fillStyle=`#6c7086`;let a=r.lastSync?`synced ${new Date(r.lastSync).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:`syncing…`;e.textAlign=`right`,e.fillText(`${r.autoAssign?`⚡ auto-assign on · `:``}${a}`,t-40,50),e.textAlign=`left`;let o=(t-80)/SS.length;SS.forEach((t,r)=>{let a=40+r*o,s=i[t.key];pS(e,a+8,96,o-16,52,26),e.fillStyle=t.chip,e.fill(),e.fillStyle=`#1f2233`,e.font=`600 30px ${fS}`,e.fillText(`${t.title} ${s.length}`,a+30,123),r>0&&(e.strokeStyle=`#d9dbe3`,e.lineWidth=3,e.beginPath(),e.moveTo(a,96),e.lineTo(a,n-30),e.stroke());let c=(o-48)/2,l=Math.floor((n-96-70)/116)*2,u=s.length>l?s.slice(0,l-1):s;if(u.forEach((n,r)=>{TS(e,a+16+r%2*(c+16),164+Math.floor(r/2)*116,c,104,n,n.tone?CS[n.tone]:t.note)}),s.length>u.length){e.fillStyle=`#6c7086`,e.font=`600 26px ${fS}`;let t=u.length;e.fillText(`+${s.length-u.length} more`,a+30+t%2*(c+16),164+Math.floor(t/2)*116+52)}s.length===0&&(e.fillStyle=`#b4b7c5`,e.font=`italic 500 26px ${fS}`,e.fillText(t.key===`backlog`?`no open issues`:`nothing here yet`,a+30,206))})}function TS(e,t,n,r,i,a,o){let s=(a.number*37%7-3)*.006;e.save(),e.translate(t+r/2,n+i/2),e.rotate(s),e.translate(-r/2,-i/2),e.fillStyle=`rgba(0,0,0,0.12)`,e.fillRect(4,6,r,i),e.fillStyle=o,e.fillRect(0,0,r,i),e.fillStyle=`rgba(0,0,0,0.06)`,e.fillRect(0,0,r,10),e.fillStyle=`#2d3142`,e.font=`700 22px ${fS}`,e.textBaseline=`top`,e.fillText(`${a.prNumber?`PR `:``}#${a.number}`,14,12),e.font=`500 19px ${fS}`,mS(e,a.title,r-28,2).forEach((t,n)=>e.fillText(t,14,38+n*21)),e.textBaseline=`middle`,a.agent&&(e.fillStyle=a.agent.color,e.beginPath(),e.arc(22,i-15,8,0,Math.PI*2),e.fill(),e.fillStyle=`#2d3142`,e.font=`600 17px ${fS}`,e.fillText(a.agent.name,36,i-14)),a.note&&(e.font=`500 16px ${fS}`,e.fillStyle=`#5c6078`,e.textAlign=`right`,e.fillText(a.note,r-12,i-14),e.textAlign=`left`),e.restore(),e.textBaseline=`middle`}function ES(e,t,n,r){e.clearRect(0,0,t,n);let i=r.status===`working`?r.currentTool?.startsWith(`mcp__playwright`)?`🌐`:r.currentTool===`Bash`||r.currentTool===`PowerShell`?`▶️`:r.currentTool?`⌨️`:`💭`:r.status===`preparing`?`📦`:r.status===`done`?`✅`:r.status===`error`?`❗`:r.status===`stopped`?`⏸️`:r.role===`qa`?`🧪`:r.role===`ceo`?`🏛️`:`☕`;pS(e,4,4,t-8,n-8,(n-8)/2),e.fillStyle=`rgba(255,255,255,0.94)`,e.fill(),e.lineWidth=6,e.strokeStyle=r.color,e.stroke(),e.textBaseline=`middle`,e.font=`38px ${fS}`,e.fillText(i,22,n/2+2),e.fillStyle=`#23263a`,e.font=`700 40px ${fS}`;let a=r.status!==`idle`,o=r.role===`ceo`?`${r.name} · CEO`:r.role===`qa`?a&&r.prNumber?`${r.name} · QA PR #${r.prNumber}`:`${r.name} · ${r.title||`QA`}`:a&&r.task===`fix`&&r.prNumber?`${r.name} · 🔧 PR #${r.prNumber}`:a&&r.task===`qa`&&r.prNumber?`${r.name} · 🧪 PR #${r.prNumber}`:a&&r.issueNumber?`${r.name} · #${r.issueNumber}`:r.title?`${r.name} · ${r.title}`:r.name;for(;o.length>4&&e.measureText(o).width>t-96;)o=`${o.slice(0,-2)}…`;e.fillText(o,78,n/2+2)}function DS(e,t,n,r,i,a,o){e.clearRect(0,0,t,n),pS(e,4,4,t-8,n-8,28),e.fillStyle=`rgba(255,255,255,0.95)`,e.fill(),e.lineWidth=6,e.strokeStyle=o,e.setLineDash([14,8]),e.stroke(),e.setLineDash([]),e.textBaseline=`middle`,e.font=`44px ${fS}`,e.fillText(`📄`,20,n/2+2);let s=(t,n)=>{let r=t;for(;r.length>4&&e.measureText(r).width>n;)r=`${r.slice(0,-2)}…`;return r};e.fillStyle=`#23263a`,e.font=`700 40px ${fS}`,e.fillText(s(`${r} · candidate`,t-100),80,n*.36),e.fillStyle=`#5c6078`,e.font=`600 28px ${fS}`,e.fillText(s(`${i}${a?` · floor ${a}`:``}`,t-100),80,n*.72)}function OS(e,t,n,r,i,a=`#ffffff`){pS(e,0,0,t,n,28),e.fillStyle=i,e.fill(),e.textAlign=`center`,e.textBaseline=`middle`;let o=r.reduce((e,t)=>e+t.size*1.25,0),s=n/2-o/2;for(let n of r){s+=n.size*1.25/2,e.fillStyle=n.color??a,e.font=`${n.weight??700} ${n.size}px ${fS}`;let r=n.text;for(;r.length>3&&e.measureText(r).width>t-40;)r=`${r.slice(0,-2)}…`;e.fillText(r,t/2,s),s+=n.size*1.25/2}e.textAlign=`left`}function kS(e,t,n,r){let i=e.createLinearGradient(0,0,0,n);i.addColorStop(0,`#74c0fc`),i.addColorStop(.7,`#c5e8ff`),i.addColorStop(1,`#e6f6ff`),e.fillStyle=i,e.fillRect(0,0,t,n),e.fillStyle=`rgba(255,255,255,0.9)`;for(let i=0;i<6;i++){let a=(r*131+i*223)%t+20,o=40+(r*17+i*53)%(n*.35);for(let t=0;t<4;t++)e.beginPath(),e.arc(a+t*22,o+t%2*6,18+t%3*6,0,Math.PI*2),e.fill()}let a=[`#8aa4c8`,`#9fb6d6`,`#7d95bb`,`#a8bddb`],o=0,s=0;for(;o<t;){let t=40+(r+s*37)%70,i=n*(.18+(r*7+s*29)%30/100);e.fillStyle=a[s%a.length],e.fillRect(o,n-i,t-4,i),e.fillStyle=`rgba(255,255,230,0.55)`;for(let r=n-i+10;r<n-10;r+=16)for(let n=o+6;n<o+t-12;n+=12)(n+r+s)%3&&e.fillRect(n,r,5,7);o+=t,s++}}var AS=[{status:`preparing`,label:`Checking out the code`},{status:`installing`,label:`Installing dependencies`},{status:`starting`,label:`Starting the app`}],jS={unconfigured:{text:`NOT SET UP`,bg:`#5c6078`},stopped:{text:`STOPPED`,bg:`#5c6078`},preparing:{text:`STARTING`,bg:`#f4a261`},installing:{text:`STARTING`,bg:`#f4a261`},starting:{text:`STARTING`,bg:`#f4a261`},running:{text:`● LIVE`,bg:`#ef233c`},error:{text:`ERROR`,bg:`#e63946`}};function MS(e,t,n){let r=t;for(;r.length>2&&e.measureText(r).width>n;)r=`${r.slice(0,-2)}…`;return r}function NS(e,t,n,r){let i=r.preview;e.fillStyle=hS.bg,e.fillRect(0,0,t,n),e.textBaseline=`middle`,e.textAlign=`left`,e.fillStyle=hS.bar,e.fillRect(0,0,t,118),e.fillStyle=r.color,e.fillRect(0,112,t,6),e.font=`700 34px ${fS}`;let a=`FLOOR ${r.floor}`,o=e.measureText(a).width+44;pS(e,40,30,o,54,27),e.fillStyle=r.color,e.fill(),e.fillStyle=`#ffffff`,e.fillText(a,62,58);let s=jS[i.status];e.font=`700 38px ${fS}`;let c=e.measureText(s.text).width+52;pS(e,t-40-c,28,c,58,29),e.fillStyle=s.bg,e.fill(),e.fillStyle=`#ffffff`,e.textAlign=`center`,e.fillText(s.text,t-40-c/2,58),e.textAlign=`left`,e.font=`700 50px ${fS}`;let l=40+o+26;e.fillText(MS(e,r.name,t-40-c-26-l),l,58);let u=(n,r,i,a,o=700)=>{e.font=`${o} ${i}px ${fS}`,e.fillStyle=a,e.textAlign=`center`,e.fillText(MS(e,n,t-100),t/2,r),e.textAlign=`left`},d=(e,t=`#8d8da8`)=>u(e,n-50,32,t,600),f=118+(n-118-100)/2,p=i.ref??`the app`;if(i.status===`stopped`){let n=f-70;e.fillStyle=r.color,e.beginPath(),e.arc(t/2,n,84,0,Math.PI*2),e.fill(),e.fillStyle=`#ffffff`,e.beginPath(),e.moveTo(t/2-26,n-42),e.lineTo(t/2-26,n+42),e.lineTo(t/2+44,n),e.closePath(),e.fill(),u(`Press E to open the app`,f+80,70,`#ffffff`),d(`The app isn't running. Start it from the viewer.`)}else if(i.status===`unconfigured`)u(`⚙️`,f-90,110,`#ffffff`,400),u(`No run command yet.`,f+40,66,`#ffffff`),u(`Set one in the manager's console.`,f+120,44,`#b8b8cc`,600),d(`Press E to open the app`);else if(i.status===`error`){let n=(i.error??``).split(/\r?\n/).find(e=>e.trim())?.trim()||`The app stopped unexpectedly.`;e.fillStyle=`#e63946`,e.fillRect(0,f-120,t,130),e.font=`700 44px ${fS}`,e.fillStyle=`#ffffff`,e.fillText(MS(e,`⚠ ${n}`,t-100),50,f-55),u(`The app couldn't start.`,f+90,52,`#ffffff`),d(`Press E to see the log and try again`,`#ffb4ba`)}else if(i.status!==`running`){let n=Math.max(0,AS.findIndex(e=>e.status===i.status));u(`Getting ${p} ready…`,198,46,`#b8b8cc`,600),u(`${AS[n].label}…`,f-20,72,`#ffffff`);let r=(t-200-18*(AS.length-1))/AS.length;AS.forEach((t,i)=>{let a=100+i*(r+18),o=f+90;pS(e,a,o,r,34,17),e.fillStyle=i<n?hS.done:i===n?`#f4a261`:`#3a3a52`,e.fill(),e.font=`600 28px ${fS}`,e.fillStyle=i<=n?hS.text:`#6c6c88`,e.textAlign=`center`,e.fillText(`${i<n?`✓ `:``}${t.label}`,a+r/2,o+70),e.textAlign=`left`}),d(`Step ${n+1} of ${AS.length} · press E to watch`)}else{let n=r.shot?t*.5:t-112;e.font=`600 34px ${fS}`,e.fillStyle=`#b8b8cc`,e.fillText(`Serving at`,56,190),e.font=`700 50px ${dS}`,e.fillStyle=hS.tool,e.fillText(MS(e,(i.url??``).replace(/^https?:\/\//,``).replace(/\/$/,``),n),56,258),e.font=`700 42px ${fS}`;let a=e.measureText(p).width+48;if(pS(e,56,326,a,64,32),e.fillStyle=r.color,e.fill(),e.fillStyle=`#ffffff`,e.fillText(p,80,359),i.commit&&(e.font=`600 42px ${dS}`,e.fillStyle=hS.thinking,e.fillText(i.commit,56+a+24,359)),i.startedAt&&(e.font=`500 32px ${fS}`,e.fillStyle=`#8d8da8`,e.fillText(`up since ${new Date(i.startedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`,56,448)),r.shot){let i=t-n-56-70,a=Math.round(i*.5625),o=t-40-i;e.fillStyle=`#3a3a52`,e.fillRect(o-6,162,i+12,a+12);let s=r.shot,c=Math.max(i/s.width,a/s.height);e.drawImage(s,0,0,i/c,a/c,o,168,i,a),e.font=`500 26px ${fS}`,e.fillStyle=`#8d8da8`,e.fillText(MS(e,r.shotBy?`latest from ${r.shotBy}'s browser`:`latest agent screenshot`,i),o,168+a+36)}d(`Press E to open the app`,hS.done)}}var PS=new Map;function FS(e,t=3.2){let n=(0,v.useRef)(null),r=e?`${e.id}|${e.label}`:``;return(0,v.useEffect)(()=>{let r=n.current;if(r&&e)return PS.set(r,{...e,range:t}),()=>{PS.delete(r)}},[r,t]),n}function IS(e,t,n,r){let i=(0,v.useMemo)(()=>{let n=document.createElement(`canvas`);n.width=e,n.height=t;let r=new vs(n);return r.colorSpace=xt,r.anisotropy=8,r},[e,t]);return(0,v.useEffect)(()=>{let r=i.image.getContext(`2d`);r.clearRect(0,0,e,t),n(r),i.needsUpdate=!0;let a=!0;return document.fonts?.ready.then(()=>{a&&(r.clearRect(0,0,e,t),n(r),i.needsUpdate=!0)}),()=>{a=!1}},[i,...r]),(0,v.useEffect)(()=>()=>i.dispose(),[i]),i}var LS={gapMs:2e3,ms:1500},RS={ball:2.5,dart:3};function zS(e,t){let n=e&&typeof e==`object`?e.toy:void 0;return n===`dart`?`dart`:typeof n==`string`&&t.includes(n)?`ball`:null}function BS(e,t,n){return e!==null&&!n&&t>=RS[e]}var VS=(e,t,n=LS.gapMs)=>e===void 0||t-e>=n,HS=e=>e*e*(3-2*e);function US(e){return!(e>=0)||e>=LS.ms?0:e<120?HS(e/120):e<850?1:1-HS((e-850)/(LS.ms-850))}function WS(e){return!(e>=0)||e>=400?0:e<70?HS(e/70):1-HS((e-70)/330)}var GS=(e,t,n)=>Math.min(n,Math.max(t,e));function KS(e,t,n=1.1,r=.5){if(e===0&&t===0)return{head:0,twist:0};let i=Math.atan2(-e,-t),a=GS(i,-n,n);return{head:a,twist:GS(i-a,-r,r)}}var qS=[],JS=1,YS=new Set,XS=new Map,ZS=new Map,QS=0;function $S(e,t){let n={id:e,obj:t,key:JS++};qS=[...qS,n];for(let e of YS)e();return()=>{qS=qS.filter(e=>e!==n);for(let e of YS)e()}}var eC=()=>qS;function tC(e){return YS.add(e),()=>void YS.delete(e)}function nC(e,t){let n=XS.get(e);return n||XS.set(e,n=new Set),n.add(t),()=>{n.delete(t),n.size||XS.delete(e)}}function rC(e,t=performance.now()){if(!VS(ZS.get(e),t))return!1;ZS.set(e,t),QS++;for(let t of XS.get(e)??[])t();return!0}var iC=()=>QS,aC=1.16,oC=`#1f1d2b`;function sC(e,t,n,r){let i=n-8-34;e.lineWidth=8,e.lineJoin=`round`,e.strokeStyle=oC,e.fillStyle=`#ffffff`,e.beginPath(),e.roundRect(8,8,t-16,i-8,40),e.fill(),e.stroke(),e.beginPath(),e.moveTo(62,i-6),e.lineTo(28,n-8),e.lineTo(104,i-6),e.fill(),e.beginPath(),e.moveTo(62,i),e.lineTo(28,n-8),e.lineTo(104,i),e.stroke(),e.fillStyle=`#e63946`,e.font=`700 ${r.length>2?84:100}px ${fS}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(r,t/2,(8+i)/2+4)}function cC({text:e,since:t}){let n=(0,v.useRef)(null),r=IS(256,176,t=>sC(t,256,176,e),[e]);return G_(()=>{if(!n.current)return;let e=performance.now()-t,r=LS.ms-e,i=e<90?.3+e/90*.9:e<170?1.2-(e-90)/80*.2:r<150?Math.max(.01,r/150):1;n.current.scale.setScalar(i)}),(0,K.jsx)(Oy,{position:[.18,1.45,0],children:(0,K.jsx)(`group`,{ref:n,scale:.3,children:(0,K.jsxs)(`mesh`,{position:[.195,.156,0],renderOrder:2,children:[(0,K.jsx)(`planeGeometry`,{args:[.5,.344]}),(0,K.jsx)(`meshBasicMaterial`,{map:r,transparent:!0,toneMapped:!1,depthWrite:!1})]})})})}function lC(e,t){let n=W_(e=>e.camera),r=(0,v.useRef)(-1/0),[i,a]=(0,v.useState)(null),o=(0,v.useMemo)(()=>({w:0,flinch:0,headYaw:0,headPitch:0,twist:0}),[]),s=(0,v.useMemo)(()=>new V,[]);return(0,v.useEffect)(()=>{let n=t.current;return n?$S(e,n):void 0},[e,t]),(0,v.useEffect)(()=>nC(e,()=>{let e=performance.now();r.current=e,cb(),a({text:Math.random()<.65?`hey!`:`!`,since:e})}),[e]),(0,v.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>a(null),LS.ms);return()=>clearTimeout(e)},[i]),{pose:e=>{let i=e-r.current;o.w=US(i),o.flinch=WS(i);let a=t.current;if(o.w===0||!a)return o.w=o.flinch=o.headYaw=o.headPitch=o.twist=0,o;a.worldToLocal(s.copy(n.position));let c=KS(s.x,s.z);return o.headYaw=c.head,o.twist=c.twist,o.headPitch=Math.min(.45,Math.max(-.3,Math.atan2(s.y-aC,Math.hypot(s.x,s.z)))),o},bubble:i&&(0,K.jsx)(cC,{text:i.text,since:i.since},i.since)}}var uC={pitch:-.34,yaw:.26},dC={typing:{l:uC,r:uC,lean:.1,headPitch:-.02,headYaw:0,type:1,mouse:0},browsing:{l:uC,r:{pitch:-.4,yaw:-.22},lean:.06,headPitch:.05,headYaw:.04,type:.25,mouse:1},thinking:{l:uC,r:{pitch:.55,yaw:.95},lean:.02,headPitch:.1,headYaw:-.12,type:.3,mouse:0},relaxed:{l:{pitch:-.9,yaw:.35},r:{pitch:-.9,yaw:.35},lean:-.1,headPitch:.06,headYaw:0,type:0,mouse:0},cheer:{l:{pitch:1.45,yaw:-.35},r:{pitch:1.45,yaw:-.35},lean:-.05,headPitch:.2,headYaw:0,type:0,mouse:0},slump:{l:{pitch:-1.35,yaw:-.15},r:{pitch:-1.35,yaw:-.15},lean:.25,headPitch:-.45,headYaw:0,type:0,mouse:0}},fC=e=>({...e,l:{...e.l},r:{...e.r}}),pC=`#1f1d2b`,mC=[`#1f1d2b`,`#7f5539`,`#1f1d2b`,`#c1121f`,`#355070`,`#1f1d2b`];function hC({agent:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(null),r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(fC(dC.relaxed)),o=(0,v.useRef)(Math.random()*100),s=(0,v.useRef)({name:null,at:0}),c=(0,v.useMemo)(()=>Nx(e),[e.id,e.look,e.role]),l=(0,v.useRef)(null),u=lC(e.id,l);e.currentTool&&(s.current={name:e.currentTool,at:performance.now()}),G_((l,d)=>{let f=performance.now(),p=f/1e3+o.current,m=e.status===`working`||e.status===`preparing`,h=e.status===`done`&&e.endedAt!=null&&Date.now()-e.endedAt<7e3,g=f-s.current.at,_=s.current.name?.startsWith(`mcp__playwright`)&&g<4e3,v=m?e.status===`preparing`?`typing`:_?`browsing`:!e.currentTool&&g>2500?`thinking`:`typing`:e.status===`error`?`slump`:h?`cheer`:`relaxed`,y=dC[v],b=a.current,x=1-Math.exp(-d*5);for(let e of[`l`,`r`])b[e].pitch+=(y[e].pitch-b[e].pitch)*x,b[e].yaw+=(y[e].yaw-b[e].yaw)*x;for(let e of[`lean`,`headPitch`,`headYaw`,`type`,`mouse`])b[e]+=(y[e]-b[e])*x;let S=Math.sin(p*.8)+Math.sin(p*2.1)*.6>-.35?1:.15,C=b.type*S*.1,w=e.status===`preparing`?10:19,T=Math.max(0,Math.sin(p*w))*C,E=Math.max(0,Math.sin(p*w+2.4))*C*(1-b.mouse),D=Math.sin(p*3.1)*.05*b.type,O=Math.sin(p*2.7+1)*.05*b.type,k=Math.sin(p*1.9)*.06*b.mouse,A=(Math.sin(p*5.3)>.93?.04:0)*b.mouse,j=h?Math.sin(p*9)*.35:0,M=-(c.height-1)*.55,N=u.pose(f),ee=N.flinch*.55;if(r.current&&i.current&&(r.current.rotation.set(b.l.pitch+M+T+ee,-(b.l.yaw+D)+j,0),i.current.rotation.set(b.r.pitch+M+E-A+ee,b.r.yaw+O*(1-b.mouse)+k-j,0)),t.current&&(t.current.rotation.x=-b.lean+Math.sin(p*1.6)*.015+(m?Math.sin(p*9)*.006*S:0)+N.flinch*.2,t.current.rotation.y=N.twist*N.w),n.current){let t=m&&Math.sin(p*.55+2)>.92?-.22:0,r=e.status===`preparing`?Math.sin(p*1.3)*.5:Math.sin(p*.4)*.08,i=b.headPitch+t+(m?Math.sin(p*4.5)*.02*S:0),a=r+b.headYaw;n.current.rotation.set(i+(N.headPitch-i)*N.w,a+(N.headYaw-a)*N.w,(v===`thinking`?.12:0)*(1-N.w))}});let d=aS(e.skin),f=e.role===`qa`,p=e.role===`ceo`,m=e.look===`feminine`,h=e.status===`working`||e.status===`preparing`,g=aS(f?`#f8f9fa`:p?`#2b2d42`:e.color),_=aS(c.hair===`buzz`?uS(e.hair,e.skin,.35):e.hair),y=aS(pC),b=Dx[c.accent],x=e.status===`error`,S=nS.hair[c.hair],C=nS.facialHair[c.facialHair],w=nS.glasses[c.glasses],T=nS.headwear[c.headwear],E=nS.outfit[c.outfit],D=c.hair!==`buzz`&&c.hair!==`bald`,O=m&&c.headwear===`none`&&[`long`,`ponytail`,`bun`,`sidePart`,`curls`].includes(c.hair),k=c.headphones&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{geometry:nS.headphones.shell,material:aS(`#2b2d42`),castShadow:!0}),(0,K.jsx)(`mesh`,{geometry:nS.headphones.covers,material:aS(lS(e.color,.12))})]});return(0,K.jsxs)(`group`,{ref:l,children:[u.bubble,(0,K.jsx)(`mesh`,{geometry:nS.legs,material:aS(`#3d4a6b`),castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:pC,angle:0})}),(0,K.jsx)(`mesh`,{geometry:nS.shoes,material:y,castShadow:!0}),(0,K.jsxs)(`group`,{ref:t,position:[0,.5,-(c.height-1)*.25],scale:c.height,children:[(0,K.jsxs)(`group`,{scale:[c.shoulders,1,1],children:[(0,K.jsx)(`mesh`,{position:[0,.3,0],geometry:nS.torso,material:g,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.015,color:pC,angle:0})}),c.outfit!==`sweater`&&(0,K.jsx)(`mesh`,{position:[0,.5,-.02],rotation:[Math.PI/2,0,0],geometry:nS.collar,material:aS(p?`#f8f9fa`:lS(e.color,-.15))}),E.main&&(0,K.jsx)(`mesh`,{geometry:E.main,material:aS(lS(e.color,-.08)),castShadow:!0}),E.trim&&(0,K.jsx)(`mesh`,{geometry:E.trim,material:aS(c.outfit===`stripe`?b:c.outfit===`hoodie`?`#f8f9fa`:lS(e.color,-.14))}),p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{position:[0,.36,-.192],geometry:nS.shirtFront,material:aS(`#f8f9fa`)}),(0,K.jsx)(`mesh`,{position:[0,.33,-.206],geometry:nS.tie,material:aS(e.color)}),(0,K.jsx)(`mesh`,{position:[0,.445,-.206],geometry:nS.tieKnot,material:aS(lS(e.color,-.2))})]}),f&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{position:[0,.27,-.196],geometry:nS.coatOpening,material:aS(e.color)}),(0,K.jsx)(`mesh`,{position:[.1,.38,-.19],rotation:[.1,0,0],geometry:nS.badge,material:aS(`#ffd166`)})]}),!h&&k&&(0,K.jsx)(`group`,{position:[0,.49,-.09],rotation:[Math.PI/2-.5,0,0],scale:.74,children:k})]}),[{ref:r,x:-.25},{ref:i,x:.25}].map(({ref:e,x:t})=>(0,K.jsxs)(`group`,{ref:e,position:[t*c.shoulders,.44,0],children:[(0,K.jsx)(`mesh`,{position:[0,0,-.24],rotation:[Math.PI/2,0,0],geometry:nS.sleeve,material:g,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:pC,angle:0})}),(0,K.jsx)(`mesh`,{position:[0,0,-.5],geometry:nS.hand,material:d,castShadow:!0})]},t)),(0,K.jsxs)(`group`,{ref:n,position:[0,.66,0],children:[(0,K.jsx)(`mesh`,{geometry:nS.head,material:d,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.015,color:pC,angle:0})}),S&&(0,K.jsx)(`mesh`,{geometry:S,material:_,castShadow:D,children:D&&(0,K.jsx)(jy,{thickness:.012,color:pC,angle:0})}),(0,K.jsx)(`mesh`,{geometry:nS.ears,material:d}),(0,K.jsx)(`mesh`,{geometry:nS.eyes,material:y}),(0,K.jsx)(`mesh`,{position:[0,-.02,-.2],geometry:nS.nose,material:aS(lS(e.skin,-.08))}),(0,K.jsx)(`mesh`,{position:[0,x?-.1:-.075,-.175],rotation:[.25,0,x?0:Math.PI],geometry:nS.mouth,material:y}),C&&(0,K.jsx)(`mesh`,{geometry:C,material:aS(c.facialHair===`stubble`?uS(e.skin,e.hair,.3):e.hair)}),m&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{geometry:nS.lashes,material:y}),(0,K.jsx)(`mesh`,{geometry:nS.cheeks,material:aS(`#ff9aa2`)})]}),O&&(0,K.jsx)(`mesh`,{position:[.15,.13,-.08],rotation:[0,0,.5],geometry:nS.hairClip,material:aS(f?`#ff9f68`:lS(e.color,.15))}),f&&(0,K.jsx)(`mesh`,{geometry:nS.inspectorGlasses,material:y}),w&&(0,K.jsx)(`mesh`,{geometry:w,material:aS(mC[c.accent])}),T&&(0,K.jsx)(`mesh`,{geometry:T,material:aS(c.accent===0?lS(e.color,-.2):b),castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:pC,angle:0})}),h&&k]})]})]})}var gC=`#1f1d2b`;function J({size:e,position:t,rotation:n,color:r,outline:i=!1,shadow:a=!0,children:o}){return(0,K.jsxs)(`mesh`,{position:t,rotation:n,castShadow:a,receiveShadow:!0,material:aS(r),children:[(0,K.jsx)(`boxGeometry`,{args:e}),i&&(0,K.jsx)(jy,{thickness:.018,color:gC}),o]})}function _C({r:e,rTop:t,h:n,position:r,rotation:i,color:a,outline:o=!1,shadow:s=!0,seg:c=20}){return(0,K.jsxs)(`mesh`,{position:r,rotation:i,castShadow:s,receiveShadow:!0,material:aS(a),children:[(0,K.jsx)(`cylinderGeometry`,{args:[t??e,e,n,c]}),o&&(0,K.jsx)(jy,{thickness:.018,color:gC})]})}function vC({r:e,position:t,scale:n,color:r,outline:i=!1,shadow:a=!0}){return(0,K.jsxs)(`mesh`,{position:t,scale:n,castShadow:a,material:aS(r),children:[(0,K.jsx)(`sphereGeometry`,{args:[e,20,14]}),i&&(0,K.jsx)(jy,{thickness:.018,color:gC})]})}var yC={w:1,h:.6,px:896,py:538},bC=`#f1d19b`;function xC(e,t){let n=W_(e=>e.camera),{canvas:r,tex:i}=(0,v.useMemo)(()=>{let e=document.createElement(`canvas`);e.width=yC.px,e.height=yC.py;let t=new vs(e);return t.colorSpace=xt,t.anisotropy=8,{canvas:e,tex:t}},[]);(0,v.useEffect)(()=>()=>i.dispose(),[i]);let a=(0,v.useRef)(!0),o=(0,v.useRef)(0),s=(0,v.useRef)(null),c=(0,v.useRef)(e);c.current=e,(0,v.useEffect)(()=>{a.current=!0},[e]),(0,v.useEffect)(()=>q.subscribe((t,n)=>{if(t.logs[e.id]!==n.logs[e.id]&&(a.current=!0),t.screens[e.id]!==n.screens[e.id]){let n=new Image;n.onload=()=>{s.current=n,a.current=!0},n.src=`/api/agents/${e.id}/screen?t=${t.screens[e.id]}`}}),[e.id]),(0,v.useEffect)(()=>{let t=q.getState().screens[e.id];if(!t)return;let n=new Image;n.onload=()=>{s.current=n,a.current=!0},n.src=`/api/agents/${e.id}/screen?t=${t}`},[e.id]),(0,v.useEffect)(()=>{document.fonts?.ready.then(()=>a.current=!0)},[]);let l=(0,v.useMemo)(()=>new V,[]);return G_(()=>{let e=performance.now(),u=c.current,d=u.status===`working`||u.status===`preparing`||u.status===`idle`&&(q.getState().logs[u.id]?.length??0)<=1;if(!a.current&&!(d&&e-o.current>200))return;if(t.current){t.current.getWorldPosition(l);let r=l.distanceTo(n.position);if(r>16&&o.current!==0||r>8&&e-o.current<900)return}if(e-o.current<120)return;o.current=e,a.current=!1;let f=q.getState().logs[u.id]??[],p=u.screenshotAt!=null&&Date.now()-u.screenshotAt<12e4,m=u.hasScreenshot&&u.status!==`idle`&&(u.currentTool?.startsWith(`mcp__playwright`)||p||u.status===`done`),h=q.getState().settings,g=u.role!==`ceo`&&h.runtime===`terminal`?u.cli||h.defaultCli:`claude`;yS(r.getContext(`2d`),yC.px,yC.py,u,f,s.current,!!m,e,g),i.needsUpdate=!0}),i}function SC({agent:e}){let t=IS(512,96,t=>ES(t,512,96,e),[e.name,e.status,e.issueNumber,e.currentTool,e.color]);return(0,K.jsx)(Oy,{position:[0,1.98,-.32],children:(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`planeGeometry`,{args:[1.15,.216]}),(0,K.jsx)(`meshBasicMaterial`,{map:t,transparent:!0,toneMapped:!1,depthWrite:!1})]})})}var CC={y:1.31,z:-.3,tilt:-.06},wC=`#2b2d42`,TC=`#3d4152`;function EC({accent:e,children:t}){return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(_C,{r:.17,rTop:.15,h:.025,position:[0,.782,CC.z-.04],color:TC,outline:!0}),(0,K.jsx)(J,{size:[.07,.36,.05],position:[0,.95,CC.z-.07],color:TC,outline:!0}),(0,K.jsxs)(`group`,{position:[0,CC.y,CC.z],rotation:[CC.tilt,0,0],children:[(0,K.jsx)(J,{size:[yC.w+.07,yC.h+.07,.05],color:wC,outline:!0}),(0,K.jsx)(J,{size:[.6,.36,.07],position:[0,0,-.055],color:TC}),t,(0,K.jsx)(`mesh`,{position:[0,0,-.091],rotation:[0,Math.PI,0],material:sS(e),children:(0,K.jsx)(`circleGeometry`,{args:[.06,24]})}),(0,K.jsx)(`mesh`,{position:[yC.w/2-.02,-yC.h/2-.018,.026],material:sS(`#7CFFB2`),children:(0,K.jsx)(`circleGeometry`,{args:[.008,10]})})]})]})}function DC({agent:e,accent:t}){let n=(0,v.useRef)(null),r=xC(e,n);return(0,K.jsx)(EC,{accent:t,children:(0,K.jsxs)(`mesh`,{ref:n,position:[0,0,.026],children:[(0,K.jsx)(`planeGeometry`,{args:[yC.w,yC.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:r,toneMapped:!1})]})})}function OC({accent:e,qa:t}){let n=IS(640,384,e=>{e.fillStyle=`#151621`,e.fillRect(0,0,640,384),OS(e,640,384,[{text:t?`🔍`:`🪑`,size:70},{text:t?`QA STATION`:`VACANT`,size:70,color:`#ffd6a5`},{text:t?`press E or click to hire a tester`:`press E or click to hire an agent`,size:36,color:`#a9adc6`,weight:500}],`rgba(0,0,0,0)`)},[t]);return(0,K.jsx)(EC,{accent:e,children:(0,K.jsxs)(`mesh`,{position:[0,0,.026],children:[(0,K.jsx)(`planeGeometry`,{args:[yC.w,yC.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,toneMapped:!1})]})})}function kC(){let e=IS(512,176,e=>{e.fillStyle=`#d7dbe3`,e.fillRect(0,0,512,176),[14,13,12,11].forEach((t,n)=>{let r=(496-(t-1)*5)/t;for(let i=0;i<t;i++)e.fillStyle=n===0&&(i===0||i===t-1)?`#ffb4a2`:`#ffffff`,e.beginPath(),e.roundRect(8+i*(r+5),8+n*34,r,28,6),e.fill()}),e.fillStyle=`#ffffff`,e.beginPath(),e.roundRect(130,144,252,26,6),e.fill()},[]);return(0,K.jsxs)(`group`,{position:[0,.77,.27],children:[(0,K.jsx)(J,{size:[.52,.03,.18],position:[0,.015,0],color:`#c3c8d3`,outline:!0}),(0,K.jsxs)(`mesh`,{position:[0,.031,0],rotation:[-Math.PI/2,0,0],children:[(0,K.jsx)(`planeGeometry`,{args:[.5,.17]}),(0,K.jsx)(`meshToonMaterial`,{map:e})]}),(0,K.jsx)(`mesh`,{position:[.46,.002,.02],rotation:[-Math.PI/2,0,0],material:aS(`#3d4152`),children:(0,K.jsx)(`planeGeometry`,{args:[.24,.2]})}),(0,K.jsx)(`mesh`,{position:[.46,.022,.02],scale:[.75,.5,1],material:aS(`#f4f4f8`),castShadow:!0,children:(0,K.jsx)(`sphereGeometry`,{args:[.05,14,10]})})]})}var AC=`#dfe7ef`,jC=`#ff9f68`;function MC({agent:e,accent:t,repoId:n,position:r,role:i=`dev`,rotationY:a=0}){let o=i===`qa`,s=FS(e?{id:`agent-${e.id}`,label:e.role===`ceo`?`Open ${e.name}'s desk (CEO) · P texts them from anywhere`:`View ${e.name}'s ${o?`test run`:`terminal`}`,action:{kind:`terminal`,agentId:e.id}}:{id:`vacant-${i}-${n}-${r.join()}`,label:o?`Hire a QA tester for this station`:`Hire an agent for this desk`,action:{kind:`hire`,repoId:n,role:i}},3.6),c=e?lS(e.color,.1):`#ffffff`,l=o?AC:bC,u=o?jC:t;return(0,K.jsxs)(`group`,{ref:s,position:r,rotation:[0,a,0],children:[(0,K.jsx)(J,{size:[1.9,.06,.95],position:[0,.74,0],color:l,outline:!0}),[[-.88,-.42],[.88,-.42],[-.88,.42],[.88,.42]].map(([e,t])=>(0,K.jsx)(J,{size:[.06,.71,.06],position:[e,.355,t],color:`#5c677d`},`${e}${t}`)),(0,K.jsx)(J,{size:[1.76,.4,.03],position:[0,.5,-.44],color:lS(l,-.08)}),e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(DC,{agent:e,accent:t}),(0,K.jsx)(kC,{}),(0,K.jsx)(_C,{r:.045,h:.1,position:[.76,.82,.02],color:c,outline:!0}),(0,K.jsx)(SC,{agent:e})]}):(0,K.jsx)(OC,{accent:t,qa:o}),o?(0,K.jsxs)(`group`,{position:[-.72,.77,-.2],children:[(0,K.jsx)(J,{size:[.3,.05,.1],position:[0,.06,0],color:`#adb5bd`,outline:!0}),[`#ff6b6b`,`#4cc9f0`,`#80ed99`].map((e,t)=>(0,K.jsx)(_C,{r:.022,h:.16,position:[-.09+t*.09,.1,0],color:e,outline:!0},e))]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_C,{r:.06,rTop:.07,h:.09,position:[-.76,.815,-.22],color:`#e07a5f`,outline:!0}),(0,K.jsx)(vC,{r:.09,position:[-.76,.92,-.22],color:`#52b788`,outline:!0})]}),(0,K.jsxs)(`group`,{position:[0,0,e?.8:.6],children:[(0,K.jsx)(J,{size:[.52,.08,.5],position:[0,.44,0],color:u,outline:!0}),(0,K.jsx)(J,{size:[.48,.42,.07],position:[0,.72,.28],color:u,outline:!0}),(0,K.jsx)(_C,{r:.035,h:.36,position:[0,.22,0],color:`#444a5c`}),(0,K.jsx)(_C,{r:.26,h:.04,position:[0,.03,0],color:`#444a5c`}),e&&(0,K.jsx)(hC,{agent:e})]})]})}var NC=`#b9c2cf`;function PC({floorLabel:e,accent:t}){let n=W_(e=>e.camera),r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(0),{doorHalf:o,cabinHalf:s,depth:c,doorHeight:l}=$b,u=12.15,d=FS({id:`elevator`,label:`Use the elevator`,action:{kind:`elevator`}},3.5),f=FS({id:`elevator-panel`,label:`Choose a floor`,action:{kind:`elevator`}},2.5),p=IS(512,128,t=>OS(t,512,128,[{text:e,size:56,color:`#7CFFB2`}],`#15151f`),[e]);return G_((e,t)=>{let s=q.getState().travel,c=n.position.x,l=n.position.z-u,d=Math.hypot(c,l)<2.8,f=s?.phase===`closing`?0:d||s?.phase===`opening`?1:0;a.current+=(f-a.current)*(1-Math.exp(-t*5));let p=a.current*o*.98;r.current&&(r.current.position.x=-o/2-p),i.current&&(i.current.position.x=o/2+p)}),(0,K.jsxs)(`group`,{children:[(0,K.jsxs)(`group`,{ref:d,children:[(0,K.jsx)(J,{size:[.22,l+.1,.36],position:[-o-.05,(l+.1)/2,12],color:NC,outline:!0}),(0,K.jsx)(J,{size:[.22,l+.1,.36],position:[o+.05,(l+.1)/2,12],color:NC,outline:!0}),(0,K.jsx)(J,{size:[o*2+.32,.22,.36],position:[0,l+.08,12],color:NC,outline:!0}),(0,K.jsx)(`mesh`,{ref:r,position:[-o/2,l/2,u],material:aS(`#d9dee6`),castShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,l,.06]})}),(0,K.jsx)(`mesh`,{ref:i,position:[o/2,l/2,u],material:aS(`#d9dee6`),castShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,l,.06]})})]}),(0,K.jsxs)(`mesh`,{position:[0,l+.55,11.97],rotation:[0,Math.PI,0],children:[(0,K.jsx)(`planeGeometry`,{args:[1.6,.4]}),(0,K.jsx)(`meshBasicMaterial`,{map:p,toneMapped:!1})]}),(0,K.jsxs)(`group`,{position:[o+.55,1.2,11.97],rotation:[0,Math.PI,0],children:[(0,K.jsx)(J,{size:[.22,.4,.04],position:[0,0,0],color:NC,outline:!0}),(0,K.jsx)(`mesh`,{position:[0,.08,.025],material:sS(t),children:(0,K.jsx)(`circleGeometry`,{args:[.05,20]})}),(0,K.jsx)(`mesh`,{position:[0,-.08,.025],material:sS(`#ffffff`),children:(0,K.jsx)(`circleGeometry`,{args:[.05,20]})})]}),(0,K.jsxs)(`group`,{position:[0,0,12],children:[(0,K.jsx)(`mesh`,{position:[0,.01,c/2],rotation:[-Math.PI/2,0,0],receiveShadow:!0,material:aS(`#8d7b68`),children:(0,K.jsx)(`planeGeometry`,{args:[s*2,c]})}),(0,K.jsx)(`mesh`,{position:[0,l+.2,c/2],rotation:[Math.PI/2,0,0],material:aS(`#f1f3f5`),children:(0,K.jsx)(`planeGeometry`,{args:[s*2,c]})}),(0,K.jsx)(`mesh`,{position:[0,l+.18,c/2],rotation:[Math.PI/2,0,0],material:sS(`#fff6d6`),children:(0,K.jsx)(`circleGeometry`,{args:[.45,32]})}),[-1,1].map(e=>(0,K.jsx)(`mesh`,{position:[e*(s+.05),Xb/2,(c+.05)/2],material:aS(`#c8ced8`),children:(0,K.jsx)(`boxGeometry`,{args:[.1,Xb,c-.05]})},e)),(0,K.jsx)(`mesh`,{position:[0,Xb/2,c+.05],material:aS(`#c8ced8`),children:(0,K.jsx)(`boxGeometry`,{args:[s*2+.2,Xb,.1]})}),(0,K.jsx)(J,{size:[s*2-.2,.05,.08],position:[0,.95,c-.05],color:`#e9c46a`,outline:!0}),(0,K.jsxs)(`group`,{ref:f,position:[s-.02,1.25,.9],rotation:[0,-Math.PI/2,0],children:[(0,K.jsx)(J,{size:[.36,.7,.04],position:[0,0,0],color:NC,outline:!0}),[.22,.08,-.06,-.2].map((e,n)=>(0,K.jsx)(`mesh`,{position:[0,e,.025],material:sS(n===0?t:`#fdfdfd`),children:(0,K.jsx)(`circleGeometry`,{args:[.04,16]})},e))]})]})]})}var FC=[1280,720],IC=`#2b2d42`,LC=uS(`#7CFFB2`,`#fbf3e4`,.35),RC={running:`#7CFFB2`,error:`#ff6b6b`,preparing:`#ffd166`,installing:`#ffd166`,starting:`#ffd166`};function zC(e){return q(t=>{let n=null,r=0;for(let i of e){let e=t.screens[i.id];e&&e>r&&(r=e,n=i)}return n?`${n.id}|${r}|${n.name}`:null})}function BC({repo:e,agents:t}){let n=e.preview,r=n.status===`running`,i=e.fullName.split(`/`)[1]??e.fullName,a=zC(t),[o,s]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!r||!a)return s(null);let[e,t,n]=a.split(`|`),i=!0,o=new Image;return o.onload=()=>i&&s({img:o,by:n}),o.src=`/api/agents/${e}/screen?t=${t}`,()=>{i=!1,o.onload=null}},[r,a]);let c=IS(FC[0],FC[1],t=>NS(t,FC[0],FC[1],{floor:e.floor,name:i,color:e.color,preview:n,shot:o?.img??null,shotBy:o?.by??null}),[e.floor,i,e.color,n.status,n.url,n.ref,n.commit,n.startedAt,n.error,o]),l=FS({id:`app-${e.id}`,label:`Open the app`,action:{kind:`app`,repoId:e.id}},6),u=dx,d=u.w+u.bezel*2,f=u.h+u.bezel*2;return(0,K.jsxs)(`group`,{ref:l,position:[u.x,u.y,-12],children:[r&&(0,K.jsx)(`mesh`,{position:[0,0,.012],material:sS(LC),children:(0,K.jsx)(`planeGeometry`,{args:[d+.18,f+.18]})}),(0,K.jsx)(J,{size:[d,f,u.depth],position:[0,0,u.depth/2],color:IC,outline:!0,shadow:!1}),(0,K.jsxs)(`mesh`,{position:[0,0,u.depth+.002],children:[(0,K.jsx)(`planeGeometry`,{args:[u.w,u.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:c,toneMapped:!1})]}),(0,K.jsx)(`mesh`,{position:[u.w/2-.04,-u.h/2-u.bezel/2,u.depth+.002],material:sS(RC[n.status]??`#6c7086`),children:(0,K.jsx)(`circleGeometry`,{args:[.022,12]})})]})}function VC({repo:e,agents:t}){let n=q(e=>e.qa),r=(0,v.useMemo)(()=>Lb(e,t,n),[e,t,n]),i=(0,v.useMemo)(()=>JSON.stringify([e.fullName,e.autoAssign,e.lastSync?Math.floor(e.lastSync/6e4):0,...Object.values(r).map(e=>e.map(e=>[e.key,e.title,e.note,e.agent?.name,e.agent?.color,e.tone]))]),[r,e]),a=Math.round(2560*ux.h/ux.w),o=IS(2560,a,t=>wS(t,2560,a,e,r),[i]),s=FS({id:`board-${e.id}`,label:`Open the Kanban board`,action:{kind:`kanban`,repoId:e.id}},7),c=ux.y+ux.h/2;return(0,K.jsxs)(`group`,{ref:s,position:[0,0,ux.z],children:[(0,K.jsx)(J,{size:[ux.w+.24,ux.h+.24,.06],position:[0,c,.03],color:`#aab4c3`,outline:!0,shadow:!1}),(0,K.jsxs)(`mesh`,{position:[0,c,.065],children:[(0,K.jsx)(`planeGeometry`,{args:[ux.w,ux.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:o,toneMapped:!1})]}),(0,K.jsx)(J,{size:[3.2,.05,.16],position:[3.5,ux.y-.12,.1],color:`#aab4c3`,outline:!0}),[`#e63946`,`#1d3557`,`#2a9d8f`].map((e,t)=>(0,K.jsx)(_C,{r:.018,h:.16,position:[2.6+t*.22,ux.y-.075,.12],rotation:[0,0,Math.PI/2],color:e},e))]})}function HC({position:e,scale:t=1,pot:n=`#e07a5f`}){return(0,K.jsxs)(`group`,{position:e,scale:t,children:[(0,K.jsx)(_C,{r:.22,rTop:.28,h:.5,position:[0,.25,0],color:n,outline:!0}),(0,K.jsx)(vC,{r:.36,position:[0,.8,0],color:`#52b788`,outline:!0}),(0,K.jsx)(vC,{r:.28,position:[.2,1.05,.08],color:`#40916c`,outline:!0}),(0,K.jsx)(vC,{r:.25,position:[-.18,1.12,-.05],color:`#74c69d`,outline:!0}),(0,K.jsx)(vC,{r:.2,position:[.02,1.35,0],color:`#52b788`,outline:!0})]})}function UC({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(J,{size:[.45,1,.45],position:[0,.5,0],color:`#f1f3f5`,outline:!0}),(0,K.jsx)(_C,{r:.18,h:.5,position:[0,1.25,0],color:`#8ecae6`,outline:!0}),(0,K.jsx)(J,{size:[.08,.06,.06],position:[0,.8,-.24],color:`#457b9d`})]})}function WC({position:e,rotationY:t=0,color:n=`#6c63ff`}){let r=lS(n,-.12);return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(J,{size:[3,.42,1],position:[0,.25,0],color:n,outline:!0}),(0,K.jsx)(J,{size:[3,.6,.25],position:[0,.7,.38],color:r,outline:!0}),(0,K.jsx)(J,{size:[.25,.55,1],position:[-1.5,.45,0],color:r,outline:!0}),(0,K.jsx)(J,{size:[.25,.55,1],position:[1.5,.45,0],color:r,outline:!0}),(0,K.jsx)(J,{size:[.5,.4,.14],position:[-.9,.62,.22],color:`#ffd166`,outline:!0}),(0,K.jsx)(J,{size:[.5,.4,.14],position:[.9,.62,.22],color:`#ef476f`,outline:!0})]})}function GC({position:e,rotationY:t=0}){return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(J,{size:[1.3,.08,.8],position:[0,.42,0],color:`#f1d19b`,outline:!0}),(0,K.jsx)(J,{size:[1.1,.38,.6],position:[0,.2,0],color:`#c9a26b`}),(0,K.jsx)(_C,{r:.05,h:.1,position:[.3,.51,.1],color:`#ffffff`,outline:!0}),(0,K.jsx)(J,{size:[.3,.04,.22],position:[-.25,.48,-.05],color:`#4cc9f0`,outline:!0})]})}function KC({position:e}){let t=(0,v.useRef)(null);return G_(()=>{if(!t.current)return;let e=performance.now()/1e3;t.current.children.forEach((t,n)=>{let r=(e*.4+n/3)%1;t.position.y=r*.4,t.scale.setScalar(.5+r),t.material.opacity=.5*(1-r)})}),(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(J,{size:[.8,.9,4],position:[0,.45,0],color:`#8ecae6`,outline:!0}),(0,K.jsx)(J,{size:[.9,.06,4.1],position:[-.02,.93,0],color:`#f8f9fa`,outline:!0}),(0,K.jsx)(J,{size:[.45,.55,.4],position:[.05,1.24,-1.1],color:`#343a40`,outline:!0}),(0,K.jsx)(J,{size:[.3,.12,.3],position:[-.1,1.1,-1.1],color:`#495057`}),(0,K.jsx)(`mesh`,{position:[-.2,1.35,-1.1],rotation:[0,-Math.PI/2,0],material:sS(`#ff6b6b`),children:(0,K.jsx)(`circleGeometry`,{args:[.03,12]})}),(0,K.jsx)(_C,{r:.05,h:.1,position:[-.15,1.01,-1.1],color:`#ffffff`,outline:!0}),(0,K.jsx)(`group`,{ref:t,position:[-.15,1.1,-1.1],children:[0,1,2].map(e=>(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`sphereGeometry`,{args:[.03,8,6]}),(0,K.jsx)(`meshBasicMaterial`,{color:`#ffffff`,transparent:!0,opacity:.4,depthWrite:!1})]},e))}),(0,K.jsx)(_C,{r:.2,rTop:.24,h:.1,position:[0,1.01,.6],color:`#f4a261`,outline:!0}),(0,K.jsx)(vC,{r:.07,position:[.05,1.1,.55],color:`#e63946`}),(0,K.jsx)(vC,{r:.07,position:[-.06,1.1,.66],color:`#ffd166`}),(0,K.jsx)(vC,{r:.07,position:[.07,1.1,.7],color:`#80ed99`}),(0,K.jsx)(_C,{r:.1,rTop:.07,h:.25,position:[0,1.08,1.4],color:`#ced4da`,outline:!0}),(0,K.jsx)(J,{size:[.8,2,.8],position:[0,1,2.45],color:`#f1f3f5`,outline:!0}),(0,K.jsx)(J,{size:[.04,.5,.05],position:[-.42,1.3,2.2],color:`#adb5bd`})]})}function qC({position:e,size:t,color:n}){return(0,K.jsx)(`mesh`,{position:e,rotation:[-Math.PI/2,0,0],receiveShadow:!0,material:aS(n),children:(0,K.jsx)(`planeGeometry`,{args:t})})}function JC({position:e,rotationY:t=0}){let n=(0,v.useRef)(null),r=(0,v.useRef)(null);return G_(()=>{let e=new Date,t=e.getMinutes()+e.getSeconds()/60,i=e.getHours()%12+t/60;r.current&&(r.current.rotation.z=-(t/60)*Math.PI*2),n.current&&(n.current.rotation.z=-(i/12)*Math.PI*2)}),(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(_C,{r:.36,h:.06,rotation:[Math.PI/2,0,0],color:`#ffffff`,outline:!0,shadow:!1}),(0,K.jsx)(`group`,{ref:n,position:[0,0,.04],children:(0,K.jsx)(`mesh`,{position:[0,.1,0],material:aS(`#1f1d2b`),children:(0,K.jsx)(`boxGeometry`,{args:[.035,.2,.01]})})}),(0,K.jsx)(`group`,{ref:r,position:[0,0,.045],children:(0,K.jsx)(`mesh`,{position:[0,.14,0],material:aS(`#e63946`),children:(0,K.jsx)(`boxGeometry`,{args:[.025,.28,.01]})})})]})}function YC({position:e,rotationY:t=0}){let n=[`#e63946`,`#457b9d`,`#2a9d8f`,`#f4a261`,`#9b5de5`,`#ffbe0b`,`#06d6a0`];return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(J,{size:[4.8,2.2,.6],position:[0,1.1,0],color:`#b08968`,outline:!0}),[.35,.95,1.55].map((e,t)=>(0,K.jsxs)(`group`,{children:[(0,K.jsx)(J,{size:[4.6,.04,.55],position:[0,e-.25,.04],color:`#9c6644`,shadow:!1}),Array.from({length:14},(r,i)=>(0,K.jsx)(J,{size:[.14+i*t%3*.03,.34+(i+t)%4*.04,.4],position:[-2.1+i*.3,e-.05,.08],color:n[(i+t*3)%n.length],shadow:!1},i))]},e))]})}function XC({from:e,to:t,height:n=2.8}){let r=t[0]-e[0],i=t[1]-e[1],a=Math.hypot(r,i),o=(e[0]+t[0])/2,s=(e[1]+t[1])/2,c=-Math.atan2(i,r);return(0,K.jsxs)(`group`,{position:[o,0,s],rotation:[0,c,0],children:[(0,K.jsx)(`mesh`,{position:[0,n/2,0],material:cS,children:(0,K.jsx)(`boxGeometry`,{args:[a,n,.04]})}),(0,K.jsx)(J,{size:[a,.08,.1],position:[0,n,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(J,{size:[a,.08,.1],position:[0,.04,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(J,{size:[.08,n,.1],position:[-a/2,n/2,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(J,{size:[.08,n,.1],position:[a/2,n/2,0],color:`#8d99ae`,shadow:!1})]})}var ZC=`#fbf3e4`;function QC({position:e,rotationY:t,width:n,seed:r}){let i=IS(512,256,e=>kS(e,512,256,r),[r]),a=1.8;return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsxs)(`mesh`,{position:[0,0,.01],children:[(0,K.jsx)(`planeGeometry`,{args:[n,a]}),(0,K.jsx)(`meshBasicMaterial`,{map:i,toneMapped:!1})]}),(0,K.jsx)(J,{size:[n+.16,.1,.1],position:[0,a/2,.04],color:`#ffffff`,outline:!0,shadow:!1}),(0,K.jsx)(J,{size:[n+.16,.14,.18],position:[0,-1.8/2,.06],color:`#ffffff`,outline:!0,shadow:!1}),[-n/2,0,n/2].map(e=>(0,K.jsx)(J,{size:[.08,a,.1],position:[e,0,.04],color:`#ffffff`,shadow:!1},e))]})}function $C({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(J,{size:[1.4,.06,.5],position:[0,0,0],color:`#e9ecef`,shadow:!1}),(0,K.jsx)(`mesh`,{position:[0,-.035,0],rotation:[Math.PI/2,0,0],material:sS(`#fffbe8`),children:(0,K.jsx)(`planeGeometry`,{args:[1.25,.38]})})]})}function ew({accent:e,floorColor:t,westWindows:n=[-8,0,8],eastWindows:r=[-8,0],seed:i=1}){let a=aS(ZC),o=.3,{doorHalf:s,doorHeight:c}=$b,l=(0,v.useMemo)(()=>{let e=[];for(let t=-12;t<=12;t+=6)for(let n=-8;n<=8;n+=5.5)e.push([t,Xb-.04,n]);return e},[]),u=(0,v.useMemo)(()=>{let e=document.createElement(`canvas`);e.width=e.height=512;let n=e.getContext(`2d`);for(let e=0;e<8;e++){let r=e*173%512;for(let i=-r;i<512;i+=256){let a=(e*7+Math.floor((i+r)/256)*3)%5*.012-.024;n.fillStyle=lS(t,a),n.fillRect(i,e*64,256,64),n.fillStyle=lS(t,-.1),n.fillRect(i,e*64,3,64),n.fillStyle=lS(t,a-.035);for(let t=0;t<3;t++)n.fillRect(i+30+t*70,e*64+18+t*12,60,2)}n.fillStyle=lS(t,-.12),n.fillRect(0,e*64,512,3)}let r=new vs(e);return r.colorSpace=xt,r.wrapS=r.wrapT=w,r.repeat.set(8,6),r.anisotropy=8,r},[t]),d=16-s;return(0,K.jsxs)(`group`,{children:[(0,K.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],receiveShadow:!0,children:[(0,K.jsx)(`planeGeometry`,{args:[32,24]}),(0,K.jsx)(`meshToonMaterial`,{map:u})]}),(0,K.jsx)(`mesh`,{rotation:[Math.PI/2,0,0],position:[0,Xb,0],material:aS(`#f3efe6`),children:(0,K.jsx)(`planeGeometry`,{args:[32,24]})}),l.map(e=>(0,K.jsx)($C,{position:e},e.join())),(0,K.jsx)(`mesh`,{position:[0,Xb/2,-12-o/2],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[32.6,Xb,o]})}),(0,K.jsx)(`mesh`,{position:[-16-o/2,Xb/2,0],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,Xb,24]})}),(0,K.jsx)(`mesh`,{position:[16.15,Xb/2,0],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,Xb,24]})}),[-1,1].map(e=>(0,K.jsx)(`mesh`,{position:[e*(s+d/2),Xb/2,12.15],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[d,Xb,o]})},e)),(0,K.jsx)(`mesh`,{position:[0,(Xb+c)/2,12.15],material:a,children:(0,K.jsx)(`boxGeometry`,{args:[s*2,Xb-c,o]})}),[{p:[0,0,-11.98],r:0,w:32},{p:[-15.98,0,0],r:Math.PI/2,w:24},{p:[15.98,0,0],r:-Math.PI/2,w:24},{p:[-(s+d/2),0,11.98],r:Math.PI,w:d},{p:[s+d/2,0,11.98],r:Math.PI,w:d}].map(({p:t,r:n,w:r},i)=>(0,K.jsxs)(`group`,{position:[t[0],0,t[2]],rotation:[0,n,0],children:[(0,K.jsx)(`mesh`,{position:[0,.06,0],material:aS(lS(e,-.2)),children:(0,K.jsx)(`boxGeometry`,{args:[r,.12,.04]})}),(0,K.jsx)(`mesh`,{position:[0,.95,0],material:aS(e),children:(0,K.jsx)(`boxGeometry`,{args:[r,.12,.03]})})]},i)),n.map((e,t)=>(0,K.jsx)(QC,{position:[-15.98,1.95,e],rotationY:Math.PI/2,width:5.5,seed:i*3+t},`w${e}`)),r.map((e,t)=>(0,K.jsx)(QC,{position:[15.98,1.95,e],rotationY:-Math.PI/2,width:5.5,seed:i*5+t+7},`e${e}`))]})}function tw(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hemisphereLight`,{args:[`#fffaf0`,`#a48a6a`,.95]}),(0,K.jsx)(`ambientLight`,{intensity:.18}),(0,K.jsx)(`directionalLight`,{position:[9,14,7],intensity:1.55,castShadow:!0,"shadow-mapSize":[2048,2048],"shadow-camera-left":-18,"shadow-camera-right":18,"shadow-camera-top":14,"shadow-camera-bottom":-14,"shadow-camera-near":1,"shadow-camera-far":40,"shadow-bias":-6e-4,"shadow-normalBias":.03})]})}var nw=[{id:`blaster-orange`,body:`#ff8c1a`,trim:`#3a86ff`,foam:`#3a86ff`},{id:`blaster-blue`,body:`#3a86ff`,trim:`#ff8c1a`,foam:`#ff8c1a`}],rw=e=>nw.some(t=>t.id===e),iw={mag:12,gapMs:250,reloadMs:1e3};function aw(e,t){return e.reloadAt===null||t-e.reloadAt<iw.reloadMs?e:{ammo:iw.mag,reloadAt:null}}function ow(e,t){let n=aw(e,t);return n.reloadAt===null?null:Math.min(1,Math.max(0,(t-n.reloadAt)/iw.reloadMs))}function sw(e,t,n){let r=aw(e,n);return r.reloadAt!==null||r.ammo<=0||n-t<iw.gapMs?null:{ammo:r.ammo-1,reloadAt:null}}function cw(e,t){let n=aw(e,t);return n.reloadAt!==null||n.ammo>=iw.mag?null:{ammo:n.ammo,reloadAt:t}}function lw(e,t){return`Darts ${aw(e,t).ammo}/${iw.mag}`}var uw={maxAngle:28*Math.PI/180,minSpeed:6};function dw(e,t){let n=Math.hypot(e.x,e.y,e.z);return n<uw.minSpeed?!1:-(e.x*t.x+e.y*t.y+e.z*t.z)/n>=Math.cos(uw.maxAngle)}function fw(e,t=40,n=1){let r=e.length+n-t;return r<=0?[]:[...e].sort((e,t)=>e.born-t.born).slice(0,r)}var pw=.2,mw=null;function hw(e){mw=e}var gw=()=>mw?.count()??0,_w=()=>mw?.stuck()??0,vw=()=>(mw?.loose()??[]).filter(e=>e.y<pw),yw=e=>mw?.remove(e)??!1,bw={reach:.1,animMs:350},xw=e=>e!==`charging`,Sw=(e,t,n,r)=>Math.hypot(n.x-e,n.z-t)<=r;function Cw(e,t,n,r,i){return xw(e)?r.filter(e=>Sw(t,n,e,i+bw.reach)):[]}var ww=0,Tw=(e=1)=>void(ww+=e),Ew=()=>ww,Dw=null,Ow=null,kw=null;function Aw(e){Dw=e}function jw(e){Ow=e}function Mw(e){kw=e}function Nw(){let{held:e,chargeAt:t}=q.getState(),n=null;try{n=kw?kw():null}catch{}let r={held:e,charging:t!==null,hoop:Ow?Ow():null,roomba:n,darts:gw(),dartsStuck:_w(),reactions:iC(),vacuumed:Ew()};try{if(Dw)return{...Dw(),...r}}catch{}return{balls:[],bodies:0,...r}}typeof window<`u`&&!Object.getOwnPropertyDescriptor(window,`__swarmToys`)&&Object.defineProperty(window,"__swarmToys",{get:Nw,enumerable:!1,configurable:!1});var Pw=!1;function Fw(e){Pw||(Pw=!0,console.warn(`Office toys are switched off: the physics engine failed to load.`,e))}var Iw=()=>null,Lw=(0,v.lazy)(async()=>{try{let[e,t]=await Promise.all([Fy(()=>import(`./ToyWorld-KCq1UWWM.js`),__vite__mapDeps([0,1])),Fy(()=>import(`./rapier-JdQfFHwQ.js`).then(e=>e.o),[])]);return await t.init(),e}catch(e){return Fw(e),{default:Iw}}}),Rw=class extends v.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`Office toys stopped on this floor after an error (the next floor gets fresh ones):`,e)}render(){return this.state.failed?null:this.props.children}},zw=(0,v.memo)(function({floor:e}){return Pw?null:(0,K.jsx)(Rw,{children:(0,K.jsx)(v.Suspense,{fallback:null,children:(0,K.jsx)(Lw,{floor:e})})})});function Bw({position:e,size:t,px:n,draw:r,deps:i,rotationY:a=Math.PI}){let o=IS(n[0],n[1],r,i);return(0,K.jsxs)(`mesh`,{position:e,rotation:[0,a,0],children:[(0,K.jsx)(`planeGeometry`,{args:t}),(0,K.jsx)(`meshBasicMaterial`,{map:o,transparent:!0,toneMapped:!1})]})}function Vw({repo:e}){let t=q(e=>e.agents),n=(0,v.useMemo)(()=>jb(t,e.id),[t,e.id]),r=(0,v.useMemo)(()=>new Map(n.filter(e=>e.role===`dev`).map(e=>[e.desk,e])),[n]),i=(0,v.useMemo)(()=>new Map(n.filter(e=>e.role===`qa`).map(e=>[e.desk,e])),[n]),a=n.filter(e=>e.status===`working`||e.status===`preparing`).length,o=q(e=>e.qa),s=Object.values(o).filter(t=>t.repoId===e.id&&t.status!==`passed`).length,c=Object.values(o).filter(t=>t.repoId===e.id&&t.status===`passed`).length,l=e.fullName.split(`/`)[1]??e.fullName,u=lS(e.color,.24);return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(ew,{accent:e.color,floorColor:`#d9b48a`,seed:e.floor}),ox.map(e=>(0,K.jsx)(qC,{position:[0,.004,e+.35],size:[24.4,2.9],color:u},e)),Array.from({length:sx},(t,n)=>{let{x:i,z:a}=lx(n);return(0,K.jsx)(MC,{agent:r.get(n)??null,accent:e.color,repoId:e.id,position:[i,0,a]},n)}),(0,K.jsx)(qC,{position:[mx.x-.4,.005,-2],size:[3.4,10.4],color:`#ffd8bf`}),mx.stations.map((t,n)=>{let{x:r,z:a}=gx(n);return(0,K.jsx)(MC,{role:`qa`,rotationY:hx,agent:i.get(n)??null,accent:e.color,repoId:e.id,position:[r,0,a]},`qa${n}`)}),(0,K.jsx)(Bw,{position:[15.97,3.2,-2],rotationY:-Math.PI/2,size:[3.2,.55],px:[768,132],draw:e=>OS(e,768,132,[{text:`🔍 QA LAB · ${s} in testing`,size:56}],`#ff9f68`),deps:[s]}),(0,K.jsx)(VC,{repo:e,agents:n}),(0,K.jsx)(BC,{repo:e,agents:n}),(0,K.jsx)(PC,{floorLabel:`▲ ${e.floor} · ${l}`,accent:e.color}),(0,K.jsx)(zw,{floor:`office`}),(0,K.jsx)(Bw,{position:[-4.6,1.95,11.97],size:[4.2,1.3],px:[1024,317],draw:t=>OS(t,1024,317,[{text:`FLOOR ${e.floor}`,size:58,color:`rgba(255,255,255,0.85)`,weight:600},{text:e.fullName,size:74},{text:e.description||`no description`,size:36,weight:500,color:`rgba(255,255,255,0.85)`}],e.color),deps:[e.floor,e.fullName,e.description,e.color]}),(0,K.jsx)(Bw,{position:[4.6,1.95,11.97],size:[4.2,1.3],px:[1024,317],draw:t=>OS(t,1024,317,[{text:`👩💻 ${n.length} on the team`,size:54,color:`#2d3142`},{text:`⚙️ ${a} busy · 🔍 ${s} in QA · ✅ ${c} to merge`,size:46,color:`#2d3142`,weight:600},{text:`📋 ${e.issues.length} open issue${e.issues.length===1?``:`s`}${e.autoAssign?` · ⚡ auto`:``}`,size:44,color:`#5c6078`,weight:500}],`#fffdf5`),deps:[n.length,a,s,c,e.issues.length,e.autoAssign]}),(0,K.jsx)(HC,{position:[-7.1,0,-11.3]}),(0,K.jsx)(HC,{position:[7.1,0,-11.3]}),(0,K.jsx)(HC,{position:[-15.3,0,11.2],scale:1.2}),(0,K.jsx)(HC,{position:[-11,0,-11.3],scale:1.1}),(0,K.jsx)(HC,{position:[15.3,0,11.3],scale:.9,pot:`#8338ec`}),(0,K.jsx)(WC,{position:[-15.1,0,6.5],rotationY:-Math.PI/2,color:lS(e.color,-.05)}),(0,K.jsx)(GC,{position:[-13.4,0,6.5],rotationY:Math.PI/2}),(0,K.jsx)(KC,{position:[15.55,0,7]}),(0,K.jsx)(UC,{position:[15.5,0,-9.5]}),(0,K.jsx)(JC,{position:[-10,2.75,-11.95]}),(0,K.jsx)(Bw,{position:[10,2.2,-11.97],rotationY:0,size:[2.2,1.4],px:[512,326],draw:e=>OS(e,512,326,[{text:`🚀`,size:90},{text:`SHIP IT`,size:64},{text:`small PRs, happy reviewers`,size:26,weight:500}],`#3a86ff`),deps:[]})]})}var Hw=`#ff8a5b`,Uw=`#9b5de5`;function Ww(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.settings),r=q(e=>e.qa),i=q(e=>e.requests);return(0,v.useMemo)(()=>{let a=Object.values(t),o=a.filter(e=>e.status===`working`||e.status===`preparing`).length,s=e.reduce((e,t)=>e+t.pulls.filter(e=>e.state===`OPEN`).length,0),c=e.reduce((e,t)=>e+t.pulls.filter(e=>e.state===`MERGED`).length,0),l=e.reduce((e,t)=>e+t.issues.length,0),u=e.map(e=>({floor:e.floor,name:e.fullName,color:e.color,team:a.filter(t=>t.repoId===e.id).length,working:a.filter(t=>t.repoId===e.id&&(t.status===`working`||t.status===`preparing`)).length,prs:e.pulls.filter(e=>e.state===`OPEN`).length})),d=Object.values(r),f=d.filter(e=>e.status!==`passed`).length,p=d.filter(e=>e.status===`passed`).length,m=Fb(i).length;return{repos:e.length,agents:a.length,working:o,openPrs:s,inQa:f,readyToMerge:p,merged:c,issues:l,floors:u,max:n.sessionLimit,pending:m}},[e,t,n,r,i])}function Gw(){let e=Ww(),t=FS({id:`manager-console`,label:`Open the manager's console`,action:{kind:`manager`}},3.2),n=IS(1024,640,t=>{let n=t.createLinearGradient(0,0,1024,640);n.addColorStop(0,`#20224a`),n.addColorStop(1,`#3a1f4d`),t.fillStyle=n,t.fillRect(0,0,1024,640),t.fillStyle=`#ffd6a5`,t.font=`700 54px ${fS}`,t.textBaseline=`middle`,t.fillText(`✻ Manager Console`,50,70),[[`Floors (repos)`,`${e.repos}`],[`Agents on staff`,`${e.agents}`],[`Sessions running`,e.max?`${e.working} / ${e.max}`:`${e.working}`],[`Open issues`,`${e.issues}`],[`PRs in QA / ready to merge`,`${e.inQa} / ${e.readyToMerge}`],[`📄 Hiring decisions waiting`,`${e.pending}`]].forEach(([e,n],r)=>{let i=150+r*68;pS(t,50,i-30,924,60,16),t.fillStyle=`rgba(255,255,255,0.07)`,t.fill(),t.fillStyle=`#c9c9ee`,t.font=`500 34px ${fS}`,t.fillText(e,76,i),t.fillStyle=`#ffffff`,t.font=`700 38px ${fS}`,t.textAlign=`right`,t.fillText(n,948,i),t.textAlign=`left`}),t.fillStyle=`#7CFFB2`,t.font=`600 32px ${fS}`,t.fillText(`Press E or click to manage floors, team & issues`,50,592)},[e]);return(0,K.jsxs)(`group`,{ref:t,position:[yx.x,0,yx.z],children:[(0,K.jsx)(J,{size:[yx.w,.08,yx.d],position:[0,.76,0],color:`#8d5a3b`,outline:!0}),(0,K.jsx)(J,{size:[yx.w-.1,.72,.06],position:[0,.37,-yx.d/2+.05],color:`#6f4530`}),(0,K.jsx)(J,{size:[.08,.72,yx.d-.1],position:[-yx.w/2+.08,.37,0],color:`#6f4530`}),(0,K.jsx)(J,{size:[.08,.72,yx.d-.1],position:[yx.w/2-.08,.37,0],color:`#6f4530`}),(0,K.jsx)(J,{size:[.1,.34,.1],position:[0,.97,-.15],color:`#adb5bd`}),(0,K.jsx)(J,{size:[.4,.03,.26],position:[0,.815,-.15],color:`#adb5bd`,outline:!0}),(0,K.jsx)(J,{size:[1.42,.92,.06],position:[0,1.55,-.18],color:`#343a40`,outline:!0}),(0,K.jsxs)(`mesh`,{position:[0,1.55,-.145],children:[(0,K.jsx)(`planeGeometry`,{args:[1.34,.84]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,toneMapped:!1})]}),(0,K.jsx)(J,{size:[.5,.025,.16],position:[0,.815,.25],color:`#f4f4f8`,outline:!0}),(0,K.jsx)(_C,{r:.05,h:.11,position:[.9,.855,.1],color:`#ffd166`,outline:!0}),(0,K.jsx)(J,{size:[.3,.2,.03],position:[-.95,.9,-.1],rotation:[-.3,.3,0],color:`#e9c46a`,outline:!0}),(0,K.jsxs)(`group`,{position:[0,0,-1.1],children:[(0,K.jsx)(J,{size:[.64,.12,.6],position:[0,.48,0],color:`#2b2d42`,outline:!0}),(0,K.jsx)(J,{size:[.62,.8,.12],position:[0,.95,-.3],color:`#2b2d42`,outline:!0}),(0,K.jsx)(_C,{r:.04,h:.4,position:[0,.22,0],color:`#6c757d`}),(0,K.jsx)(_C,{r:.3,h:.04,position:[0,.03,0],color:`#6c757d`})]})]})}function Kw(){let e=Ww(),t=FS({id:`directory`,label:`Floor directory — take the elevator`,action:{kind:`elevator`}},4),n=IS(768,560,t=>{pS(t,0,0,768,560,30),t.fillStyle=`#23263a`,t.fill(),t.fillStyle=`#ffd6a5`,t.font=`700 46px ${fS}`,t.textBaseline=`middle`,t.fillText(`Directory`,36,52);let n=[...e.floors].sort((e,t)=>t.floor-e.floor).slice(0,7);n.forEach((e,n)=>{let r=118+n*58;t.fillStyle=e.color,pS(t,36,r-22,54,44,12),t.fill(),t.fillStyle=`#1f2233`,t.font=`700 30px ${fS}`,t.textAlign=`center`,t.fillText(String(e.floor),63,r+1),t.textAlign=`left`,t.fillStyle=`#ffffff`,t.font=`600 28px ${fS}`;let i=e.name.length>24?`${e.name.slice(0,23)}…`:e.name;t.fillText(i,108,r),t.fillStyle=`#a9adc6`,t.font=`500 24px ${fS}`,t.textAlign=`right`,t.fillText(`${e.working}/${e.team} busy · ${e.prs} PR`,740,r),t.textAlign=`left`});let r=118+n.length*58;t.fillStyle=Hw,pS(t,36,r-22,54,44,12),t.fill(),t.fillStyle=`#1f2233`,t.font=`700 30px ${fS}`,t.textAlign=`center`,t.fillText(`G`,63,r+1),t.textAlign=`left`,t.fillStyle=`#ffffff`,t.font=`600 28px ${fS}`,t.fillText(`Lobby & manager's office`,108,r),e.floors.length===0&&(t.fillStyle=`#a9adc6`,t.font=`500 26px ${fS}`,t.fillText(`No floors yet: connect a repo in the`,36,r+80),t.fillText(`manager's office (back left corner).`,36,r+116))},[e]);return(0,K.jsx)(`group`,{ref:t,position:[4.4,1.75,11.97],rotation:[0,Math.PI,0],children:(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`planeGeometry`,{args:[2.6,1.9]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,transparent:!0,toneMapped:!1})]})})}function qw(){let e=Ww(),t=IS(512,160,t=>OS(t,512,160,[{text:`🏆 ${e.merged} PRs merged`,size:50,color:`#2d3142`}],`#ffe8a3`),[e.merged]),n=Math.min(8,e.merged);return(0,K.jsxs)(`group`,{position:[12,0,-11.45],children:[(0,K.jsx)(J,{size:[4.4,2.1,1],position:[0,1.05,0],color:`#b08968`,outline:!0}),(0,K.jsx)(J,{size:[4.1,1.2,.8],position:[0,1.2,.12],color:`#fdf6e3`,shadow:!1}),(0,K.jsx)(J,{size:[4.1,.04,.8],position:[0,1.2,.12],color:`#b08968`,shadow:!1}),Array.from({length:n},(e,t)=>(0,K.jsxs)(`group`,{position:[-1.7+t%4*1.1,t<4?.62:1.22,.2],children:[(0,K.jsx)(_C,{r:.08,rTop:.16,h:.22,position:[0,.2,0],color:`#ffd43b`,outline:!0}),(0,K.jsx)(_C,{r:.03,h:.1,position:[0,.05,0],color:`#ffd43b`}),(0,K.jsx)(J,{size:[.2,.04,.2],position:[0,.01,0],color:`#495057`})]},t)),(0,K.jsxs)(`mesh`,{position:[0,2.45,.02],children:[(0,K.jsx)(`planeGeometry`,{args:[2.4,.75]}),(0,K.jsx)(`meshBasicMaterial`,{map:t,transparent:!0,toneMapped:!1})]})]})}function Jw(){let e=q(e=>e.agents.ceo),t=q(e=>e.ceo),n=Fb(q(e=>e.requests)).length,r=e?.status===`working`?t.job?.label??`Working`:`Free for a chat (press P)`,i=t.queue.length?`${t.queue[0].label}${t.queue.length>1?` (+${t.queue.length-1})`:``}`:`nothing queued`;return(0,K.jsx)(Bw,{position:[15.97,2.05,Sx.z],rotationY:-Math.PI/2,size:[3.4,1.9],px:[816,456],draw:t=>OS(t,816,456,[{text:`🧠 ${e?.name??`CEO`}'s board`,size:54},{text:`Now: ${r}`,size:36,weight:600},{text:`Next: ${i}`,size:32,weight:500,color:`rgba(255,255,255,0.8)`},{text:n?`📄 ${n} candidate${n===1?``:`s`} waiting for you`:`📄 no candidates waiting`,size:34,weight:600,color:n?`#ffe066`:`#ffffff`}],`#3c2a63`),deps:[e?.name,r,i,n]})}function Yw(){let e=xx,t=q(e=>e.agents.ceo);return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(qC,{position:[(e.minX+e.maxX)/2,.005,(e.minZ+e.maxZ)/2],size:[e.maxX-e.minX,e.maxZ-e.minZ],color:`#e6dcff`}),(0,K.jsx)(XC,{from:[e.minX,e.minZ],to:[e.minX,e.maxZ]}),(0,K.jsx)(XC,{from:[e.minX,e.maxZ],to:[e.doorMinX,e.maxZ]}),(0,K.jsx)(XC,{from:[e.doorMaxX,e.maxZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(J,{size:[e.doorMaxX-e.doorMinX,.5,.1],position:[(e.doorMinX+e.doorMaxX)/2,2.55,e.maxZ],color:`#8d99ae`}),(0,K.jsx)(Bw,{position:[(e.doorMinX+e.doorMaxX)/2,3.1,e.maxZ+.06],rotationY:0,size:[3.4,.5],px:[816,120],draw:e=>OS(e,816,120,[{text:`CEO${t?` · ${t.name}`:``}`,size:52}],Uw),deps:[t?.name]}),t&&(0,K.jsx)(MC,{agent:t,accent:Uw,repoId:``,position:[Sx.x,0,Sx.z]}),(0,K.jsx)(Jw,{}),(0,K.jsx)(HC,{position:[e.maxX-.7,0,e.maxZ-.7],scale:1.1,pot:Uw}),(0,K.jsx)(HC,{position:[e.minX+.6,0,e.maxZ-.6],scale:.9})]})}function Xw(e){return{id:e.id,name:e.name,repoId:e.repoId,role:e.role,title:e.title,specialty:e.specialty,brief:e.brief,hiredBy:`ceo`,look:e.look,task:null,desk:0,color:e.color,hair:e.hair,skin:e.skin,model:e.model,effort:e.effort,cli:``,terminal:!1,status:`idle`,issueNumber:null,issueTitle:null,branch:null,prNumber:null,prUrl:null,currentTool:null,startedAt:null,endedAt:null,costUsd:0,turns:0,browserUrl:null,hasScreenshot:!1,screenshotAt:null,lastError:null}}function Zw({req:e}){let t=q(t=>t.repos.find(t=>t.id===e.repoId)?.floor??null),n=IS(512,128,n=>DS(n,512,128,e.name,e.title,t,e.color),[e.name,e.title,t,e.color]);return(0,K.jsx)(Oy,{position:[0,1.95,-.1],children:(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`planeGeometry`,{args:[1.15,.29]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,transparent:!0,toneMapped:!1,depthWrite:!1})]})})}function Qw({z:e,req:t}){let n=FS(t?{id:`candidate-${t.id}`,label:`Read ${t.name}'s resume (${t.title})`,action:{kind:`phone`,tab:`hires`,requestId:t.id}}:null,3.2),r=(0,v.useMemo)(()=>t?Xw(t):null,[t]),i=`#06d6a0`;return(0,K.jsxs)(`group`,{ref:n,position:[Cx.x,0,e],rotation:[0,wx,0],children:[(0,K.jsx)(J,{size:[.52,.08,.5],position:[0,.44,0],color:i,outline:!0}),(0,K.jsx)(J,{size:[.48,.42,.07],position:[0,.72,.28],color:i,outline:!0}),[[-.22,-.2],[.22,-.2],[-.22,.2],[.22,.2]].map(([e,t])=>(0,K.jsx)(J,{size:[.05,.42,.05],position:[e,.2,t],color:`#444a5c`},`${e}${t}`)),r&&(0,K.jsx)(hC,{agent:r}),t&&(0,K.jsx)(Zw,{req:t})]})}function $w(){let e=q(e=>e.requests),t=(0,v.useMemo)(()=>Fb(e).filter(e=>e.kind===`hire`),[e]),n=t.length;return(0,K.jsxs)(`group`,{children:[Cx.seats.map((e,n)=>(0,K.jsx)(Qw,{z:e,req:t[n]??null},e)),(0,K.jsx)(Bw,{position:[15.97,2.5,(Cx.seats[0]+Cx.seats[Cx.seats.length-1])/2],rotationY:-Math.PI/2,size:[3.6,.62],px:[864,150],draw:e=>OS(e,864,150,[{text:n?`🪑 Waiting room · ${n} candidate${n===1?``:`s`}${n>Cx.seats.length?` (${n-Cx.seats.length} more outside)`:``}`:`🪑 Waiting room`,size:50}],`#06a77d`),deps:[n]})]})}function eT(){let e=vx,t=q(e=>e.user),n=q(e=>e.settings.managerName),r=q(e=>e.settings.companyName),i=n||t;return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(ew,{accent:Hw,floorColor:`#e2c7a3`,westWindows:[1.5,8],eastWindows:[-2.5,3.6],seed:0}),(0,K.jsx)(qC,{position:[3,.004,3],size:[14,9],color:`#ffd6a5`}),(0,K.jsx)(qC,{position:[(e.minX+e.maxX)/2,.005,(e.minZ+e.maxZ)/2],size:[e.maxX-e.minX,e.maxZ-e.minZ],color:`#cde7e1`}),(0,K.jsx)(XC,{from:[e.maxX,e.minZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(XC,{from:[e.minX,e.maxZ],to:[e.doorMinX,e.maxZ]}),(0,K.jsx)(XC,{from:[e.doorMaxX,e.maxZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(J,{size:[e.doorMaxX-e.doorMinX,.5,.1],position:[(e.doorMinX+e.doorMaxX)/2,2.55,e.maxZ],color:`#8d99ae`}),(0,K.jsx)(Bw,{position:[(e.doorMinX+e.doorMaxX)/2,3.1,e.maxZ+.06],rotationY:0,size:[3.4,.5],px:[816,120],draw:e=>OS(e,816,120,[{text:`MANAGER${i?` · ${i}`:``}`,size:52}],`#2b2d42`),deps:[i]}),(0,K.jsx)(Gw,{}),(0,K.jsx)(YC,{position:[-15.6,0,-8],rotationY:Math.PI/2}),(0,K.jsx)(HC,{position:[e.maxX-.6,0,e.minZ+.6],scale:1.1,pot:`#3a86ff`}),(0,K.jsx)(HC,{position:[e.minX+.6,0,e.maxZ-.6],scale:.9}),(0,K.jsx)(Bw,{position:[yx.x,2.3,-11.97],rotationY:0,size:[2.4,1.2],px:[512,256],draw:e=>OS(e,512,256,[{text:`⭐`,size:70},{text:`World’s Best`,size:44,weight:600},{text:`Agent Wrangler`,size:50}],`#9b5de5`),deps:[]}),(0,K.jsxs)(`group`,{position:[bx.x,0,bx.z],children:[(0,K.jsx)(J,{size:[bx.w,1.05,bx.d],position:[0,.525,0],color:`#ffffff`,outline:!0}),(0,K.jsx)(J,{size:[bx.w+.1,.08,bx.d+.1],position:[0,1.09,0],color:Hw,outline:!0}),(0,K.jsx)(J,{size:[bx.w-.4,.3,.02],position:[0,.6,bx.d/2+.01],color:lS(Hw,.15),shadow:!1}),(0,K.jsxs)(`group`,{position:[0,1.13,-.1],children:[(0,K.jsx)(_C,{r:.2,rTop:.16,h:.4,position:[0,.2,0],color:`#e9ecef`,outline:!0}),(0,K.jsx)(vC,{r:.22,position:[0,.58,0],color:`#f8f9fa`,outline:!0}),(0,K.jsx)(`mesh`,{position:[-.08,.6,.2],material:sS(`#4cc9f0`),children:(0,K.jsx)(`sphereGeometry`,{args:[.035,10,8]})}),(0,K.jsx)(`mesh`,{position:[.08,.6,.2],material:sS(`#4cc9f0`),children:(0,K.jsx)(`sphereGeometry`,{args:[.035,10,8]})}),(0,K.jsx)(_C,{r:.012,h:.2,position:[0,.88,0],color:`#adb5bd`}),(0,K.jsx)(`mesh`,{position:[0,.99,0],material:sS(Hw),children:(0,K.jsx)(`sphereGeometry`,{args:[.045,10,8]})})]})]}),(0,K.jsx)(Bw,{position:[3,2.25,-11.97],rotationY:0,size:[7,1.6],px:[1400,320],draw:e=>OS(e,1400,320,[{text:`✻ ${r||`cubefarm`}`,size:120},{text:r?`powered by a team of AI coding agents`:`a team of AI coding agents`,size:48,weight:500}],Hw),deps:[r]}),(0,K.jsx)(Yw,{}),(0,K.jsx)($w,{}),(0,K.jsx)(PC,{floorLabel:`▲ G · Lobby`,accent:Hw}),(0,K.jsx)(zw,{floor:`lobby`}),(0,K.jsx)(Kw,{}),(0,K.jsx)(qw,{}),(0,K.jsx)(JC,{position:[8.4,2.8,-11.95]}),(0,K.jsx)(WC,{position:[11.5,0,4],rotationY:Math.PI,color:`#4cc9f0`}),(0,K.jsx)(GC,{position:[11.5,0,6.2]}),(0,K.jsx)(HC,{position:[15.3,0,11.3],scale:1.2}),(0,K.jsx)(HC,{position:[-15.3,0,11.3],scale:1.2,pot:`#06d6a0`}),(0,K.jsx)(HC,{position:[-3,0,11.4]}),(0,K.jsx)(HC,{position:[3,0,-11.3],scale:.8})]})}async function tT(e,t,n){let r=await fetch(t,{method:e,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>({}));if(!r.ok){let e=i.error??`${r.status} ${r.statusText}`;throw q.getState().pushToast(`error`,e),Error(e)}return i}var nT=e=>`/api/repos/${encodeURIComponent(e)}`,Y={githubRepos:e=>tT(`GET`,`/api/github/repos${e?`?owner=${encodeURIComponent(e)}`:``}`),connectRepo:(e,t={})=>tT(`POST`,`/api/repos`,{fullName:e,...t}),createRepo:e=>tT(`POST`,`/api/repos/new`,e),folders:e=>tT(`GET`,`/api/folders${e?`?dir=${encodeURIComponent(e)}`:``}`),connectFolder:(e,t={})=>tT(`POST`,`/api/folders/connect`,{path:e,...t}),publishFolder:e=>tT(`POST`,`/api/folders/publish`,e),setup:e=>tT(`POST`,`/api/setup`,e),updateRepo:(e,t)=>tT(`PATCH`,nT(e),t),startPreview:(e,t)=>tT(`POST`,`${nT(e)}/preview`,t?{pr:t}:{}),stopPreview:e=>tT(`DELETE`,`${nT(e)}/preview`),disconnectRepo:e=>tT(`DELETE`,nT(e)),syncRepo:e=>tT(`POST`,`${nT(e)}/sync`),syncFolder:e=>tT(`POST`,`${nT(e)}/sync-folder`),createIssue:(e,t,n,r,i)=>tT(`POST`,`${nT(e)}/issues`,{title:t,body:n,assignTo:r,specialty:i}),planFloor:(e,t)=>tT(`POST`,`${nT(e)}/plan`,{mission:t}),onboardFloor:e=>tT(`POST`,`${nT(e)}/onboard`),mergePull:(e,t,n=`squash`)=>tT(`POST`,`${nT(e)}/pulls/${t}/merge`,{method:n}),closePull:(e,t)=>tT(`POST`,`${nT(e)}/pulls/${t}/close`),sendToQa:(e,t)=>tT(`POST`,`${nT(e)}/pulls/${t}/qa`),hireAgent:(e,t={})=>tT(`POST`,`${nT(e)}/agents`,t),updateAgent:(e,t)=>tT(`PATCH`,`/api/agents/${e}`,t),fireAgent:e=>tT(`DELETE`,`/api/agents/${e}`),assign:(e,t,n)=>tT(`POST`,`/api/agents/${e}/assign`,{issueNumber:t,note:n}),stop:e=>tT(`POST`,`/api/agents/${e}/stop`),reset:e=>tT(`POST`,`/api/agents/${e}/reset`),message:(e,t)=>tT(`POST`,`/api/agents/${e}/message`,{text:t}),updateSettings:e=>tT(`PATCH`,`/api/settings`,e),updateOffice:async e=>{let t=await tT(`POST`,`/api/office/update`,{action:e});return q.getState().setOfficeUpdate(t),t},messageCeo:e=>tT(`POST`,`/api/ceo/message`,{text:e}),ceoReview:()=>tT(`POST`,`/api/ceo/review`),phoneRead:e=>tT(`POST`,`/api/phone/read`,{at:e}),approveRequest:(e,t={})=>tT(`POST`,`/api/requests/${e}/approve`,t),rejectRequest:(e,t)=>tT(`POST`,`/api/requests/${e}/reject`,{note:t})},rT=.0022,iT=.2;function aT(){return{skip:3,avg:0,pending:null,dropped:0,skipped:0}}function oT(e){e.skip=3,e.avg=0,e.pending=null}var sT=(e,t)=>Math.max(Math.abs(e),Math.abs(t));function cT(e,t,n){return e.avg+=(sT(t,n)-e.avg)*iT,[t,n]}function lT(e,t,n,r){if(!Number.isFinite(t)||!Number.isFinite(n))return null;if(e.skip>0)return e.skip--,e.skipped++,null;let i=sT(t,n);if(i>1e3)return e.dropped++,null;let a=e.pending;if(e.pending=null,a){if(r-a.t<=50&&i>=sT(a.dx,a.dy)*.25)return cT(e,a.dx,a.dy),cT(e,a.dx+t,a.dy+n);e.dropped++}return i>250||i>=48&&i>8*e.avg?(e.pending={dx:t,dy:n,t:r},null):cT(e,t,n)}var uT=.25,dT=`cubefarm:look`,fT={sensitivity:1,invertY:!1,grabOnClose:!0},pT=e=>Math.min(3,Math.max(uT,e));function mT(){try{let e=JSON.parse(localStorage.getItem(dT)??`null`);return{sensitivity:typeof e?.sensitivity==`number`&&Number.isFinite(e.sensitivity)?pT(e.sensitivity):fT.sensitivity,invertY:e?.invertY===!0,grabOnClose:e?.grabOnClose!==!1}}catch{return{...fT}}}var hT=Ty((e,t)=>({...mT(),set:n=>{e({...n,...n.sensitivity===void 0?{}:{sensitivity:pT(n.sensitivity)}});let{sensitivity:r,invertY:i,grabOnClose:a}=t();try{localStorage.setItem(dT,JSON.stringify({sensitivity:r,invertY:i,grabOnClose:a}))}catch{}}})),gT=Ty(()=>({ask:null}));function _T(e){return new Promise(t=>{gT.getState().ask?.resolve(!1),gT.setState({ask:{...e,resolve:t}})})}var vT=()=>gT.getState().ask!==null,yT=e=>gT.subscribe((t,n)=>e(t.ask!==null,n.ask!==null));function bT(e){let t=gT.getState().ask;t&&(gT.setState({ask:null}),t.resolve(e))}function xT(){let e=gT(e=>e.ask);if((0,v.useEffect)(()=>{if(!e)return;let t=e=>{(e.key===`Escape`||e.key===`Enter`)&&(e.preventDefault(),e.stopImmediatePropagation(),bT(e.key===`Enter`))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]),!e)return null;let t=e.tone??`good`;return(0,K.jsx)(`div`,{className:`confirm-overlay`,onMouseDown:e=>e.target===e.currentTarget&&bT(!1),children:(0,K.jsxs)(`div`,{className:`confirm confirm-${t}`,role:`alertdialog`,"aria-modal":`true`,"aria-label":e.title,children:[(0,K.jsx)(`div`,{className:`confirm-icon`,children:e.icon??(t===`danger`?`⚠️`:t===`warn`?`🤔`:`✨`)}),(0,K.jsx)(`h3`,{children:e.title}),e.body&&(0,K.jsx)(`div`,{className:`confirm-body`,children:e.body}),(0,K.jsxs)(`div`,{className:`confirm-actions`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>bT(!1),children:e.cancel??`Cancel`}),(0,K.jsx)(`button`,{className:`btn ${t===`danger`?`btn-bad`:t===`warn`?`btn-warn`:`btn-good`}`,onClick:()=>bT(!0),autoFocus:!0,children:e.confirm??`OK`})]}),(0,K.jsxs)(`div`,{className:`confirm-keys muted small`,children:[(0,K.jsx)(`kbd`,{children:`Enter`}),` `,e.confirm??`OK`,` · `,(0,K.jsx)(`kbd`,{children:`Esc`}),` `,e.cancel??`Cancel`]})]})})}var ST=()=>{let e=q.getState().held;return e?.kind===`blaster`?e:null},CT={at:-1/0},wT=new Map,TT=[];function ET(){wT.clear(),TT=[]}function DT(e){q.getState().setHeld({kind:`blaster`,id:e,ammo:wT.get(e)??iw.mag,reloadAt:null})}q.subscribe((e,t)=>{let n=t.held;n?.kind!==`blaster`||e.held?.kind===`blaster`&&e.held.id===n.id||wT.set(n.id,aw(n,performance.now()).ammo)});function OT(){let e=q.getState(),t=ST();if(!t||e.travel)return;let n=performance.now(),r=sw(t,CT.at,n);if(!r){let e=aw(t,n);e.reloadAt===null&&e.ammo===0&&$y({freq:1400,to:900,type:`square`,dur:.03,peak:.03,attack:.002});return}CT.at=n,TT.length<iw.mag&&TT.push(t.id),e.setHeld({...t,...r}),sb()}function kT(){let e=ST();if(!e)return;let t=cw(e,performance.now());t&&(q.getState().setHeld({...e,...t}),tb({dur:.08,peak:.06,filter:`bandpass`,freq:900,q:2}),tb({at:.75,dur:.07,peak:.08,filter:`bandpass`,freq:1500,q:2}),setTimeout(()=>{let n=ST();n&&n.id===e.id&&n.reloadAt===t.reloadAt&&q.getState().setHeld({...n,...aw(n,performance.now())})},iw.reloadMs+20))}function AT(){return TT.shift()??null}var jT={tap:150,full:1e3},MT=e=>Math.min(1,Math.max(0,(e-jT.tap)/(jT.full-jT.tap))),NT={x:0,z:0},PT=null;function FT(){let e=q.getState();if(e.held?.kind===`blaster`)return OT();e.held&&e.chargeAt===null&&e.setCharge(performance.now())}function IT(){let e=q.getState();if(!e.held||e.chargeAt===null)return;let t=MT(performance.now()-e.chargeAt);PT={id:e.held.id,power:t,at:performance.now()},tb({dur:.14+t*.08,peak:.03+t*.05,filter:`bandpass`,freq:500,to:1500+t*900,q:.9}),e.setHeld(null)}function LT(){let e=q.getState();e.held&&e.setHeld(null)}function RT(e){let t=PT;return!t||t.id!==e||performance.now()-t.at>500?null:(PT=null,t.power)}function zT(e,t){return(e.overlay&&!t.overlay||e.confirm&&!t.confirm)&&!t.overlay&&!t.confirm}function BT(e,t,n){return n.enabled&&n.started&&zT(e,t)}function VT(e,t){let n=(n,r)=>{zT(n,r)&&(t(),BT(n,r,{started:q.getState().started,enabled:hT.getState().grabOnClose})&&e())},r=q.subscribe((e,t)=>{if(e.overlay===t.overlay)return;let r=vT();n({overlay:!!t.overlay,confirm:r},{overlay:!!e.overlay,confirm:r})}),i=yT((e,t)=>{let r=!!q.getState().overlay;e!==t&&n({overlay:r,confirm:t},{overlay:r,confirm:e})});return()=>{r(),i()}}var HT=new Map;function UT(e,t){return HT.set(e,t),()=>{HT.get(e)===t&&HT.delete(e)}}function WT(e){HT.get(e)?.()}var GT=null,KT=400,qT=0,JT=[`mousedown`,`mouseup`,`click`,`dblclick`],YT=()=>{qT=performance.now()+KT};function XT(){let e=q.getState();if(!GT||e.overlay||!e.started||vT())return;let t=GT;ZT(t,{unadjustedMovement:!0})?.catch?.(e=>{e instanceof DOMException&&e.name===`NotSupportedError`&&ZT(t)?.catch?.(()=>void 0)})}function ZT(e,t){try{return e.requestPointerLock?.(t)}catch{return}}var QT={dropped:0,skipped:0};window.__swarmLook=QT;function $T(e,t=`key`){let n=q.getState();if(qT=performance.now()+KT,e.action.kind===`pickup`&&rw(e.action.toyId)){DT(e.action.toyId);return}if(e.action.kind===`pickup`){n.setHeld({kind:`ball`,id:e.action.toyId});return}if(e.action.kind===`poke`){WT(e.action.toyId);return}if(e.action.kind===`hire`){let{repoId:r,role:i}=e.action,a=()=>Y.hireAgent(r,{role:i}).then(()=>n.pushToast(`success`,i===`qa`?`New QA tester hired! They will take the next free station in the QA lab.`:`New teammate hired! They will sit at the next free desk.`)).catch(()=>void 0);if(t===`key`){a();return}document.pointerLockElement&&document.exitPointerLock(),_T({icon:i===`qa`?`🔍`:`🪑`,title:i===`qa`?`Hire a QA tester for this station?`:`Hire an agent for this desk?`,confirm:`Hire`}).then(e=>{e&&a()});return}n.openOverlay(e.action)}var eE=e=>{let t=e.target;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function tE({colliders:e,floor:t}){let{camera:n,gl:r}=W_(),i=(0,v.useRef)(new Set),a=(0,v.useRef)({yaw:ex.yaw,pitch:-.05}),o=(0,v.useRef)(0),s=(0,v.useMemo)(()=>new nf,[]),c=(0,v.useMemo)(()=>new B(0,0),[]),l=(0,v.useRef)(0),u=(0,v.useMemo)(aT,[]),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{let e=d.current?null:Eb();if(d.current=!0,e&&e.floor===t){n.position.set(e.x,Zb,e.z),a.current={yaw:e.yaw,pitch:e.pitch};return}n.position.set(ex.x,Zb,ex.z),a.current={yaw:ex.yaw,pitch:-.05}},[t,n]);let f=(0,v.useRef)(0);return(0,v.useEffect)(()=>{},[n]),(0,v.useEffect)(()=>{GT=r.domElement;let e=e=>{if(e.button!==0)return;if(document.pointerLockElement!==r.domElement)return XT();let t=q.getState();!t.started||t.overlay||t.travel||vT()||(t.held?FT():t.focus&&$T(t.focus,`click`))},t=e=>{e.button===0&&IT()},n=e=>{performance.now()>=qT||(e.stopPropagation(),e.preventDefault())},o=()=>{oT(u);let e=document.pointerLockElement===r.domElement;e||LT(),q.getState().setLocked(e)},s=e=>{if(document.pointerLockElement!==r.domElement||!document.hasFocus())return;let t=lT(u,e.movementX,e.movementY,e.timeStamp);if(QT.dropped=u.dropped,QT.skipped=u.skipped,!t)return;let{sensitivity:n,invertY:i}=hT.getState(),o=rT*n;a.current.yaw-=t[0]*o,a.current.pitch=Math.max(-1.35,Math.min(1.35,a.current.pitch-t[1]*o*(i?-1:1)))},c=e=>{if(eE(e))return;let t=q.getState();e.code===`KeyM`&&!e.repeat&&!vT()&&(Qy(),t.pushToast(`info`,Yy().muted?`🔇 Sound off (M to turn it back on)`:`🔊 Sound on`)),!(t.overlay||!t.started||vT())&&(i.current.add(e.code),e.code===`KeyE`&&!e.repeat&&t.focus&&$T(t.focus),e.code===`KeyF`&&!e.repeat&&!t.travel&&FT(),e.code===`KeyG`&&!e.repeat&<(),e.code===`KeyR`&&!e.repeat&&!t.travel&&kT(),e.code===`KeyH`&&t.openOverlay({kind:`help`}),e.code===`KeyP`&&(e.preventDefault(),t.openOverlay({kind:`phone`,tab:Fb(t.requests).length&&!Pb(t.messages,t.phoneReadAt)?`hires`:`chat`})))},l=e=>{i.current.delete(e.code),e.code===`KeyF`&&IT()},d=()=>{i.current.clear(),q.getState().setCharge(null)};r.domElement.addEventListener(`mousedown`,e),window.addEventListener(`mouseup`,t);for(let e of JT)window.addEventListener(e,n,!0);document.addEventListener(`pointerlockchange`,o),document.addEventListener(`mousemove`,s),window.addEventListener(`keydown`,c),window.addEventListener(`keyup`,l),window.addEventListener(`blur`,d);let f=VT(XT,YT);return()=>{f(),r.domElement.removeEventListener(`mousedown`,e),window.removeEventListener(`mouseup`,t);for(let e of JT)window.removeEventListener(e,n,!0);document.removeEventListener(`pointerlockchange`,o),document.removeEventListener(`mousemove`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,d)}},[r,u]),G_((t,r)=>{let u=Math.min(r,.05),d=q.getState();(d.overlay||vT())&&i.current.clear();let p=i.current,m=(p.has(`KeyW`)||p.has(`ArrowUp`)?1:0)-(p.has(`KeyS`)||p.has(`ArrowDown`)?1:0),h=(p.has(`KeyD`)||p.has(`ArrowRight`)?1:0)-(p.has(`KeyA`)||p.has(`ArrowLeft`)?1:0),g=p.has(`ShiftLeft`)||p.has(`ShiftRight`)?6.5:3.6,{yaw:_,pitch:v}=a.current,y=!1;if(NT.x=0,NT.z=0,(m||h)&&!d.travel){let t=Math.hypot(m,h),r=Math.sin(_),i=Math.cos(_),a=(-r*m+i*h)/t*g*u,o=(-i*m-r*h)/t*g*u,s=Ex(n.position.x+a,n.position.z+o,e);u>0&&(NT.x=(s.x-n.position.x)/u,NT.z=(s.z-n.position.z)/u),n.position.x=s.x,n.position.z=s.z,y=!0}o.current+=y?u*g*2.2:0,n.position.y=Zb+(y?Math.sin(o.current)*.035:0),fb(o.current,y,g>5),n.rotation.set(v,_,0,`YXZ`);let b=performance.now();if(d.started&&!d.travel&&b-f.current>1e3&&(f.current=b,Db({floor:d.floor,x:n.position.x,z:n.position.z,yaw:_,pitch:v})),++l.current%3!=0)return;if(d.overlay||d.travel||vT()){d.focus&&d.setFocus(null);return}s.setFromCamera(c,n),s.far=8;let x=[...PS.keys()],S=s.intersectObjects(x,!0),C=null;for(let e of S){let t=e.object;for(;t&&!PS.has(t);)t=t.parent;if(!t)continue;let n=PS.get(t);e.distance<=n.range&&(C={id:n.id,label:n.label,action:n.action});break}d.setFocus(C)}),null}function nE(){let e=q(e=>e.travel),t=q(e=>e.finishTravel);return(0,v.useEffect)(()=>{if(!e)return;e.phase===`closing`&&ob(.75);let n=setTimeout(()=>{e.phase===`closing`?(t(`arrived`),ab()):t(`done`)},e.phase===`closing`?750:650);return()=>clearTimeout(n)},[e,t]),null}function rE(){let e=q(e=>e.floor),t=q(e=>e.repos),n=e===0?null:Ab(t,e),r=!!n,i=(0,v.useMemo)(()=>r?_x():Tx(),[r]),a=Hb(),[o,s]=(0,v.useState)(Rb);return(0,K.jsxs)(by,{shadows:!0,frameloop:a?`never`:`always`,dpr:[1,o],camera:{fov:72,near:.05,far:90,position:[0,1.65,10]},gl:{antialias:!0,powerPreference:`high-performance`},onCreated:({gl:e})=>{e.toneMapping=4,e.toneMappingExposure=1,e.shadowMap.type=2},children:[(0,K.jsx)(`color`,{attach:`background`,args:[`#bfe3ff`]}),(0,K.jsx)(`fog`,{attach:`fog`,args:[`#f3ece2`,30,70]}),(0,K.jsx)(tw,{}),(0,K.jsx)(v.Suspense,{fallback:null,children:n?(0,K.jsx)(Vw,{repo:n},n.id):(0,K.jsx)(eT,{})}),(0,K.jsx)(tE,{colliders:i,floor:e}),(0,K.jsx)(nE,{}),(0,K.jsx)(Ub,{paused:a}),(0,K.jsx)(Gb,{onChange:s}),zb&&(0,K.jsx)(Jb,{paused:a})]})}function iE({held:e}){let t=(0,v.useRef)(null),n=e.reloadAt!==null;(0,v.useEffect)(()=>{if(!n)return;let r=0,i=()=>{let n=ow(e,performance.now());t.current&&(t.current.style.transform=`scaleX(${n??1})`),n!==null&&(r=requestAnimationFrame(i))};return i(),()=>cancelAnimationFrame(r)},[e,n]);let r=e.ammo===0&&!n;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`hud-hint hud-held`,children:[(0,K.jsx)(`kbd`,{children:`Click`}),` / `,(0,K.jsx)(`kbd`,{children:`F`}),` fire · `,(0,K.jsx)(`kbd`,{children:`R`}),` reload · `,(0,K.jsx)(`kbd`,{children:`G`}),` drop`]}),(0,K.jsxs)(`div`,{className:`hud-ammo ${r?`hud-ammo-empty`:``}`,children:[(0,K.jsxs)(`span`,{className:`hud-ammo-count`,children:[`🎯 `,lw(e,performance.now())]}),n&&(0,K.jsx)(`div`,{className:`hud-ammo-bar`,children:(0,K.jsx)(`div`,{ref:t,className:`hud-ammo-fill`})}),n&&(0,K.jsx)(`span`,{className:`hud-ammo-note`,children:`Reloading…`}),r&&(0,K.jsx)(`span`,{className:`hud-ammo-note`,children:`Empty: R to reload`})]})]})}function aE({at:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let r=0,i=()=>{let a=performance.now()-e,o=MT(a);t.current&&(t.current.className=`charge ${a>jT.tap?`charge-on`:``} ${o>=1?`charge-full`:``}`),n.current&&(n.current.style.transform=`scaleX(${o})`),o<1&&(r=requestAnimationFrame(i))};return i(),()=>cancelAnimationFrame(r)},[e]),(0,K.jsx)(`div`,{ref:t,className:`charge`,children:(0,K.jsx)(`div`,{ref:n,className:`charge-fill`})})}function oE(){let e=q(e=>e.held),t=q(e=>e.chargeAt);return e?e.kind===`blaster`?(0,K.jsx)(iE,{held:e}):(0,K.jsxs)(K.Fragment,{children:[t!==null&&(0,K.jsx)(aE,{at:t}),(0,K.jsxs)(`div`,{className:`hud-hint hud-held`,children:[(0,K.jsx)(`kbd`,{children:`Click`}),` / `,(0,K.jsx)(`kbd`,{children:`F`}),` throw · hold to charge · `,(0,K.jsx)(`kbd`,{children:`G`}),` drop`]})]}):null}var sE=[`tool`,`text`,`thinking`,`error`,`done`,`manager`],cE=e=>e.status===`working`||e.status===`preparing`,lE=`cubefarm:workers`;function uE(e){for(let t=e.length-1;t>=Math.max(0,e.length-80);t--){let n=e[t];if(!sE.includes(n.kind)||!n.text.trim())continue;let r=n.text.trim().replace(/^[⏺●✻✔⎿▶]\s*/u,``).replace(/^Manager:\s*/,`you: `);return{text:n.kind===`thinking`?`thinking…`:r,kind:n.kind,t:n.t}}return null}function dE(e){return e.role===`ceo`?e.issueTitle:e.task===`qa`?`QA · PR #${e.prNumber}`:e.task===`fix`?`fixing PR #${e.prNumber}`:e.issueNumber?`#${e.issueNumber}`:null}function fE(e,t){let n=Math.max(0,Math.round((t-e)/1e3));return n<60?`${n}s`:n<3600?`${Math.round(n/60)}m`:`${Math.round(n/3600)}h`}function pE({a:e,now:t}){let n=q(e=>e.openOverlay),r=uE(q(t=>t.logs[e.id])??[]),i=r&&(!e.startedAt||r.t>=e.startedAt)?r:null,a=dE(e);return(0,K.jsxs)(`button`,{className:`wk-row`,onClick:()=>n({kind:`terminal`,agentId:e.id}),title:`Watch ${e.name}'s screen`,children:[(0,K.jsx)(`span`,{className:`wk-dot`,style:{background:e.color}}),(0,K.jsxs)(`span`,{className:`wk-main`,children:[(0,K.jsxs)(`span`,{className:`wk-name`,children:[e.name,a&&(0,K.jsx)(`span`,{className:`wk-task`,children:a})]}),(0,K.jsxs)(`span`,{className:`wk-line`,children:[(0,K.jsx)(`span`,{className:`wk-last wk-last-${i?.kind??`none`}`,title:i?.text,children:e.status===`preparing`?`setting up the worktree…`:i?.text??(e.issueTitle?`working on ${e.issueTitle}`:`starting…`)}),i&&e.status!==`preparing`&&(0,K.jsx)(`span`,{className:`wk-ago`,children:fE(i.t,t)})]})]})]})}function mE(){try{return new Set(JSON.parse(localStorage.getItem(`${lE}:collapsed`)??`[]`))}catch{return new Set}}function hE(){let e=q(e=>e.floor),t=q(e=>e.repos),n=q(e=>e.agents),r=q(e=>e.started),[i,a]=(0,v.useState)(()=>{try{return localStorage.getItem(lE)!==`closed`}catch{return!0}}),[o,s]=(0,v.useState)(mE),[c,l]=(0,v.useState)(Date.now());(0,v.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),5e3);return()=>clearInterval(e)},[]);let u=e=>s(t=>{let n=new Set(t);n.delete(e)||n.add(e);try{localStorage.setItem(`${lE}:collapsed`,JSON.stringify([...n]))}catch{}return n}),d=()=>a(e=>{try{localStorage.setItem(lE,e?`closed`:`open`)}catch{}return!e});if((0,v.useEffect)(()=>{let e=e=>{e.code!==`Tab`||e.repeat||e.altKey||e.ctrlKey||e.metaKey||q.getState().overlay||e.target?.closest?.(`input, textarea, select, [contenteditable="true"]`)||(e.preventDefault(),d())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),!r)return null;let f=n.ceo,p=[...t].sort((t,n)=>t.floor===e?-1:n.floor===e?1:t.floor-n.floor),m=[...f&&cE(f)?[{key:`hq`,label:`HQ`,title:`The CEO, in the lobby`,color:f.color,list:[f]}]:[],...p.map(e=>({key:e.id,label:`${e.floor} · ${e.fullName.split(`/`)[1]}`,title:`Floor ${e.floor}: ${e.fullName}`,color:e.color,list:jb(n,e.id).filter(cE)}))].filter(e=>e.list.length>0),h=m.reduce((e,t)=>e+t.list.length,0);return(0,K.jsxs)(`div`,{className:`workers ${i?``:`workers-closed`}`,children:[(0,K.jsxs)(`button`,{className:`wk-head`,onClick:d,title:i?`Hide the list (Tab)`:`Show who is working (Tab)`,children:[(0,K.jsxs)(`span`,{children:[`Working `,(0,K.jsx)(`b`,{children:h})]}),(0,K.jsxs)(`span`,{className:`wk-chevron`,children:[(0,K.jsx)(`kbd`,{children:`Tab`}),` `,i?`▾`:`▸`]})]}),i&&(0,K.jsxs)(`div`,{className:`wk-list`,children:[h===0&&(0,K.jsx)(`div`,{className:`wk-empty`,children:`Nobody is working right now.`}),m.map(e=>{let t=o.has(e.key);return(0,K.jsxs)(`div`,{className:`wk-group`,children:[(0,K.jsxs)(`button`,{className:`wk-group-head`,onClick:()=>u(e.key),title:`${e.title} · click to ${t?`expand`:`collapse`}`,children:[(0,K.jsx)(`span`,{className:`wk-group-arrow`,children:t?`▸`:`▾`}),(0,K.jsx)(`span`,{className:`wk-swatch`,style:{background:e.color}}),(0,K.jsx)(`span`,{className:`wk-group-name`,children:e.label}),(0,K.jsx)(`span`,{className:`wk-group-count`,children:e.list.length})]}),!t&&e.list.map(e=>(0,K.jsx)(pE,{a:e,now:c},e.id))]},e.key)})]})]})}var gE=12e5,_E=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function vE(e){switch(e.state){case`none`:return`Up to date`;case`available`:return e.behind>0?`${_E(e.behind,`update`)} ready`:`An update is ready`;case`waiting`:case`draining`:return e.running>0?`Waiting for ${_E(e.running,`session`)} to finish`:`Updating shortly…`;case`updating`:return`Updating…`;case`failed`:return`Last update failed: ${e.detail||`unknown error`}`}}function yE(e){return e?e.state===`updating`?`⟳ Updating the office…`:e.state!==`waiting`&&e.state!==`draining`?null:e.running>0?`⟳ Updating the office after ${_E(e.running,`session`)} finish${e.running===1?`es`:``}`:`⟳ Updating the office shortly`:null}var bE=e=>e.state===`draining`&&e.drainingSince?e.drainingSince+gE:null,xE=e=>e.launcher&&e.behind>0&&(e.state===`available`||e.state===`waiting`||e.state===`failed`),SE=e=>e.launcher&&(e.state===`available`||e.state===`waiting`||e.state===`draining`),CE=e=>e?.state===`draining`||e?.state===`updating`;function wE(e,t,n){return!!e&&!!t&&e!==t&&n!==t}function TE(){let e=q(e=>e.restarting?`⟳ Office restarting…`:yE(e.officeUpdate)),t=q(e=>e.overlay),n=q(e=>e.openOverlay);return!e||t?.kind===`manager`?null:(0,K.jsx)(`button`,{className:`office-chip`,onClick:()=>n({kind:`manager`,tab:`floors`}),title:`The office is updating itself. Open the manager's console`,children:e})}function EE(){let e=Ib(),t=q(e=>e.started),n=q(e=>e.overlay),r=q(e=>e.openOverlay),i=q(e=>e.agents.ceo);if(!t||n?.kind===`phone`)return null;let a=i?.status===`working`;return(0,K.jsxs)(`button`,{className:`phone-btn ${e?`phone-btn-ring`:``}`,onClick:()=>r({kind:`phone`}),title:`Your phone (P)`,children:[(0,K.jsx)(`span`,{className:`phone-btn-icon`,children:`📱`}),e>0&&(0,K.jsx)(`span`,{className:`badge phone-btn-badge`,children:e}),(0,K.jsxs)(`span`,{className:`phone-btn-label`,children:[(0,K.jsx)(`kbd`,{children:`P`}),` `,e?`${e} waiting`:a?`${i.name} is working`:`Phone`]})]})}function DE(){let e=q(e=>e.floor),t=q(e=>e.repos),n=q(e=>e.agents),r=q(e=>e.settings),i=q(e=>e.connected),a=q(e=>e.restarting),o=q(e=>e.demo),s=q(e=>e.user),c=q(e=>e.ghReady),l=q(e=>e.ghError),u=q(e=>e.focus),d=q(e=>e.held),f=q(e=>e.overlay),p=q(e=>e.locked),m=q(e=>e.started),h=q(e=>e.travel),g=q(e=>e.toasts),_=q(e=>e.dismissToast),y=e===0?null:Ab(t,e),b=(0,v.useMemo)(()=>Object.values(n).filter(e=>e.status===`working`||e.status===`preparing`).length,[n]),x=y?Object.values(n).filter(e=>e.repoId===y.id):[],S=q(e=>e.qa),C=y?Object.values(S).filter(e=>e.repoId===y.id):[];return(0,K.jsxs)(`div`,{className:`hud`,children:[(0,K.jsxs)(`div`,{className:`hud-floor`,style:{"--accent":y?.color??`#ff8a5b`},children:[(0,K.jsx)(`div`,{className:`floor-num`,children:y?y.floor:`G`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`floor-name`,children:y?y.fullName:`${r.companyName||`cubefarm`} · Lobby`}),(0,K.jsx)(`div`,{className:`floor-sub`,children:y?`${x.length} agents · ${x.filter(e=>e.status===`working`||e.status===`preparing`).length} working · ${C.filter(e=>e.status!==`passed`).length} in QA · ${C.filter(e=>e.status===`passed`).length} ready to merge`:`${t.length} floor${t.length===1?``:`s`} connected`})]})]}),(0,K.jsxs)(`div`,{className:`hud-status`,children:[o&&(0,K.jsx)(`span`,{className:`pill pill-demo`,children:`DEMO`}),(0,K.jsx)(`span`,{className:`pill ${i?`pill-ok`:a?`pill-demo`:`pill-bad`}`,children:i?`● live`:a?`○ restarting`:`○ reconnecting`}),(0,K.jsxs)(`span`,{className:`pill`,children:[`⚙️ `,r.sessionLimit?`${b}/${r.sessionLimit}`:b,` sessions`]}),s&&(0,K.jsxs)(`span`,{className:`pill`,children:[`🐙 `,s]})]}),(0,K.jsx)(hE,{}),(0,K.jsx)(TE,{}),!c&&l&&(0,K.jsxs)(`div`,{className:`hud-banner`,children:[`⚠️ `,l]}),m&&!f&&!h&&(0,K.jsx)(`div`,{className:`crosshair ${u?`crosshair-hot`:``}`}),m&&!f&&u&&(0,K.jsxs)(`div`,{className:`hud-hint`,children:[(0,K.jsx)(`kbd`,{children:`E`}),` `,!d&&(0,K.jsxs)(K.Fragment,{children:[`/ `,(0,K.jsx)(`kbd`,{children:`Click`}),` `]}),u.label]}),m&&!f&&!h&&(0,K.jsx)(oE,{}),m&&!f&&!p&&!h&&(0,K.jsx)(`div`,{className:`hud-resume`,children:`Click to look around`}),m&&!(r.setupDone&&r.tutorialStep>=0)&&(0,K.jsxs)(`div`,{className:`hud-help`,children:[(0,K.jsx)(`kbd`,{children:`WASD`}),` move · `,(0,K.jsx)(`kbd`,{children:`Shift`}),` run · `,(0,K.jsx)(`kbd`,{children:`E`}),` / `,(0,K.jsx)(`kbd`,{children:`Click`}),` interact · `,(0,K.jsx)(`kbd`,{children:`P`}),` phone · `,(0,K.jsx)(`kbd`,{children:`Tab`}),` workers · `,(0,K.jsx)(`kbd`,{children:`H`}),` help · `,(0,K.jsx)(`kbd`,{children:`Esc`}),` free mouse`]}),(0,K.jsx)(`div`,{className:`fade ${h?.phase===`closing`?`fade-in`:``}`,children:h&&(0,K.jsx)(`div`,{className:`fade-label`,children:h.to===0?`Lobby`:`Floor ${h.to}`})}),(0,K.jsx)(EE,{}),(0,K.jsx)(`div`,{className:`toasts`,children:g.map(e=>(0,K.jsx)(`div`,{className:`toast toast-${e.level}`,onClick:()=>_(e.id),children:e.text},e.id))})]})}var OE={unconfigured:`not set up`,stopped:`stopped`,preparing:`checking out`,installing:`installing`,starting:`starting`,running:`running`,error:`error`},kE=[`preparing`,`installing`,`starting`,`running`],AE=[{status:`preparing`,label:`Check out the code`},{status:`installing`,label:`Install dependencies`},{status:`starting`,label:`Start the app`}],jE=`desktop`,ME=12e3;function NE({status:e}){return(0,K.jsx)(`span`,{className:`status status-${e}`,children:OE[e]})}var PE=e=>Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
|
|
4285
|
-
`);function
|
|
4286
|
-
DATA_DIR={tmp}`,spellCheck:!1})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Runs from the repo root in the floor's own preview worktree. `,(0,K.jsx)(`code`,{children:`{port}`}),` is this floor's port (`,e.preview.port,`) and `,(0,K.jsx)(`code`,{children:`PORT`}),` is always set;`,` `,(0,K.jsx)(`code`,{children:`{tmp}`}),` is a scratch folder.`,!p&&` Leave the command empty to use the auto-detected npm script.`]}),u&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,u]}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:c||!f&&!n||p&&!i.trim(),children:c?`Saving…`:t}),f&&(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small btn-ghost`,onClick:()=>{a(r.command),s(r.env),d(null)},children:`Undo changes`})]})]})}function
|
|
4284
|
+
}`);function jy({color:e=`black`,opacity:t=1,transparent:n=!1,screenspace:r=!1,toneMapped:i=!0,polygonOffset:a=!1,polygonOffsetFactor:o=0,renderOrder:s=0,thickness:c=.05,angle:l=Math.PI,clippingPlanes:u,...d}){let f=v.useRef(null),[p]=v.useState(()=>new Ay({side:1})),{gl:m}=W_(),h=m.getDrawingBufferSize(new B);v.useMemo(()=>xv({OutlinesMaterial:Ay}),[]);let g=v.useRef(0),_=v.useRef(null);return v.useLayoutEffect(()=>{let e=f.current;if(!e)return;let t=e.parent;if(t&&t.geometry&&(g.current!==l||_.current!==t.geometry)){g.current=l,_.current=t.geometry;let n=e.children?.[0];n&&(l&&n.geometry.dispose(),e.remove(n)),t.skeleton?(n=new ro,n.material=p,n.bind(t.skeleton,t.bindMatrix),e.add(n)):t.isInstancedMesh?(n=new vo(t.geometry,p,t.count),n.instanceMatrix=t.instanceMatrix,e.add(n)):(n=new Ga,n.material=p,e.add(n)),n.geometry=l?Dy(t.geometry,l):t.geometry,n.morphTargetInfluences=t.morphTargetInfluences,n.morphTargetDictionary=t.morphTargetDictionary}}),v.useLayoutEffect(()=>{let l=f.current;if(!l)return;let d=l.children[0];if(d){d.renderOrder=s;let f=l.parent;j_(d,{morphTargetInfluences:f.morphTargetInfluences,morphTargetDictionary:f.morphTargetDictionary}),j_(d.material,{transparent:n,thickness:c,color:e,opacity:t,size:h,screenspace:r,toneMapped:i,polygonOffset:a,polygonOffsetFactor:o,clippingPlanes:u,clipping:u&&u.length>0})}}),v.useEffect(()=>()=>{let e=f.current;if(!e)return;let t=e.children[0];t&&(l&&t.geometry.dispose(),e.remove(t))},[]),v.createElement(`group`,xy({ref:f},d))}var My=`modulepreload`,Ny=function(e){return`/`+e},Py={},Fy=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ny(t,n),t=s(t),t in Py)return;Py[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:My,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Iy=(0,v.createContext)(null);function Ly({iterations:e=10,ms:t=250,threshold:n=.75,step:r=.1,factor:i=.5,flipflops:a=1/0,bounds:o=e=>e>100?[60,100]:[40,60],onIncline:s,onDecline:c,onChange:l,onFallback:u,children:d}){let[f,p]=(0,v.useState)(()=>({fps:0,index:0,factor:i,flipped:0,refreshrate:0,fallback:!1,frames:[],averages:[],subscriptions:new Map,subscribe:e=>{let t=Symbol();return f.subscriptions.set(t,e.current),()=>void f.subscriptions.delete(t)}})),m=0;return G_(()=>{let{frames:i,averages:d}=f;if(!f.fallback&&d.length<e){i.push(performance.now());let p=i[i.length-1]-i[0];if(p>=t){if(f.fps=Math.round(i.length/p*1e3*1)/1,f.refreshrate=Math.max(f.refreshrate,f.fps),d[f.index++%e]=f.fps,d.length===e){let[t,i]=o(f.refreshrate),p=d.filter(e=>e>=i),h=d.filter(e=>e<t);p.length>e*n&&(f.factor=Math.min(1,f.factor+r),f.flipped++,s&&s(f),f.subscriptions.forEach(e=>e.onIncline&&e.onIncline(f))),h.length>e*n&&(f.factor=Math.max(0,f.factor-r),f.flipped++,c&&c(f),f.subscriptions.forEach(e=>e.onDecline&&e.onDecline(f))),m!==f.factor&&(m=f.factor,l&&l(f),f.subscriptions.forEach(e=>e.onChange&&e.onChange(f))),f.flipped>a&&!f.fallback&&(f.fallback=!0,u&&u(f),f.subscriptions.forEach(e=>e.onFallback&&e.onFallback(f))),f.averages=[]}f.frames=[]}}}),v.createElement(Iy.Provider,{value:f},d)}function Ry(e,t){let n=new Set;for(let r of(e??``).matchAll(/\b(?:depends\s+on|blocked\s+by)\s*:?\s*((?:#\d+(?:\s*(?:,|and|&)\s*)?)+)/gi))for(let e of r[1].matchAll(/#(\d+)/g))t.has(Number(e[1]))&&n.add(Number(e[1]));return[...n]}var zy=[`steps`,`typing`,`toys`,`alerts`],By={volume:70,muted:!1,steps:100,typing:100,toys:100,alerts:100};function Vy(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=100?Math.round(e):t}function Hy(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={...By,volume:Vy(t.volume,By.volume),muted:t.muted===!0};for(let e of zy)n[e]=Vy(t[e],By[e]);return n}function Uy(e){try{return Hy(JSON.parse(e??`null`))}catch{return{...By}}}var Wy=e=>(e/100)**2,Gy=`cubefarm:audio`;function Ky(){try{return Uy(localStorage.getItem(Gy))}catch{return Uy(null)}}var qy=Ky(),Jy=new Set,Yy=null,Xy=null,Zy=!1,Qy={},$y={};for(let e of zy)$y[e]=Wy(qy[e]);var eb=()=>qy.muted?0:Wy(qy.volume);function tb(){if(!Zy)return null;try{if(!Yy){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Yy=new e,Xy=Yy.createGain(),Xy.gain.value=eb(),Xy.connect(Yy.destination);for(let e of zy){let t=Yy.createGain();t.gain.value=$y[e],t.connect(Xy),Qy[e]=t}}return Yy.state===`suspended`&&Yy.resume().catch(()=>void 0),Yy.state===`running`&&Xy?{ctx:Yy,out:Xy}:null}catch{return null}}function nb(){Zy=!0,tb()}for(let e of[`pointerdown`,`keydown`])window.addEventListener(e,nb,{once:!0,capture:!0});var rb=()=>qy;function ib(e){return Jy.add(e),()=>void Jy.delete(e)}function ab(e,t){if(Yy)try{e.gain.cancelScheduledValues(Yy.currentTime),e.gain.setTargetAtTime(t,Yy.currentTime,.015)}catch{}}function ob(e,t){$y[e]=Math.max(0,Math.min(1,Number.isFinite(t)?t:1));let n=Qy[e];n&&ab(n,$y[e])}function sb(e){let t={...qy,...e};for(let e of[`volume`,...zy])t[e]=Math.max(0,Math.min(100,Number(t[e])));qy=Hy(t);try{localStorage.setItem(Gy,JSON.stringify(qy))}catch{}Xy&&ab(Xy,eb());for(let e of zy)ob(e,Wy(qy[e]));for(let e of Jy)e()}var cb=()=>sb({muted:!qy.muted});function lb(e,t,n){let r=n&&Qy[n]||e.out;if(!t||!e.ctx.createStereoPanner)return r;let i=e.ctx.createStereoPanner();return i.pan.value=t,i.connect(r),i}function ub({freq:e,to:t,type:n=`sine`,at:r=0,dur:i,peak:a,attack:o=.015,group:s,pan:c}){let l=tb();if(l)try{let u=l.ctx.currentTime+r,d=l.ctx.createOscillator(),f=l.ctx.createGain();d.type=n,d.frequency.setValueAtTime(e,u),t&&d.frequency.exponentialRampToValueAtTime(t,u+i),f.gain.setValueAtTime(1e-4,u),f.gain.exponentialRampToValueAtTime(a,u+o),f.gain.exponentialRampToValueAtTime(1e-4,u+i),d.connect(f).connect(lb(l,c,s)),d.start(u),d.stop(u+i+.05)}catch{}}var db=null;function fb({at:e=0,dur:t,peak:n,filter:r=`lowpass`,freq:i,to:a,q:o=1,attack:s=.005,group:c,pan:l}){let u=tb();if(u)try{if(!db||db.sampleRate!==u.ctx.sampleRate){db=u.ctx.createBuffer(1,u.ctx.sampleRate*2,u.ctx.sampleRate);let e=db.getChannelData(0);for(let t=0;t<e.length;t++)e[t]=Math.random()*2-1}let d=u.ctx.currentTime+e,f=u.ctx.createBufferSource();f.buffer=db;let p=u.ctx.createBiquadFilter();p.type=r,p.Q.value=o,p.frequency.setValueAtTime(i,d),a&&p.frequency.exponentialRampToValueAtTime(a,d+t);let m=u.ctx.createGain();m.gain.setValueAtTime(1e-4,d),m.gain.exponentialRampToValueAtTime(n,d+s),m.gain.exponentialRampToValueAtTime(1e-4,d+t),f.connect(p).connect(m).connect(lb(u,l,c)),f.start(d,Math.random()),f.stop(d+t+.05)}catch{}}var pb=-1/0;function mb(){performance.now()-pb<800||(pb=performance.now(),[1046.5,1568].forEach((e,t)=>ub({freq:e,type:`triangle`,at:t*.11,dur:.18,peak:.12,group:`alerts`})))}function hb(){ub({freq:660,to:1320,type:`square`,dur:.12,peak:.035,group:`toys`}),ub({freq:1320,to:990,type:`triangle`,at:.12,dur:.1,peak:.08,group:`toys`}),ub({freq:1760,type:`triangle`,at:.24,dur:.18,peak:.07,group:`toys`})}function gb(){[880,1318.5].forEach((e,t)=>ub({freq:e,at:t*.16,dur:1.1,peak:.18,attack:.02,group:`alerts`}))}function _b(e=.75){fb({dur:e,peak:.1,filter:`bandpass`,freq:220,to:900,q:.8,attack:e*.45,group:`alerts`}),ub({freq:70,to:55,dur:e,peak:.05,attack:e*.4,group:`alerts`})}function vb(){fb({dur:.09,peak:.1,filter:`bandpass`,freq:2600,to:900,q:1.4,attack:.003,group:`toys`}),ub({freq:520,to:190,type:`triangle`,dur:.08,peak:.07,attack:.004,group:`toys`})}function yb(){ub({freq:520,to:330,dur:.16,peak:.13,attack:.008,group:`toys`}),ub({freq:1040,to:660,type:`triangle`,dur:.07,peak:.025,attack:.004,group:`toys`})}function bb(){fb({dur:.28,peak:.07,filter:`bandpass`,freq:350,to:2400,q:2.2,attack:.05,group:`toys`}),ub({freq:220,to:660,type:`triangle`,dur:.24,peak:.035,attack:.03,group:`toys`}),fb({at:.24,dur:.05,peak:.05,filter:`bandpass`,freq:1800,q:1.5,attack:.002,group:`toys`})}function xb(){fb({dur:.3,peak:.14,filter:`bandpass`,freq:5200,to:2600,q:.8,attack:.03,group:`toys`}),fb({at:.18,dur:.9,peak:.05,filter:`bandpass`,freq:900,to:1500,q:.5,attack:.2,group:`toys`}),[784,988,1318.5].forEach((e,t)=>ub({freq:e,type:`triangle`,at:.2+t*.08,dur:.3,peak:.06,group:`toys`}))}var Sb={error:{rank:5,play:()=>[0,.2].forEach(e=>ub({freq:110,type:`sawtooth`,at:e,dur:.16,peak:.035,attack:.02,group:`alerts`}))},qaFailed:{rank:4,play:()=>{ub({freq:392,to:370,type:`triangle`,dur:.26,peak:.12,group:`alerts`}),ub({freq:311,to:196,type:`triangle`,at:.26,dur:.55,peak:.12,group:`alerts`})}},ready:{rank:3,play:()=>[784,988,1175,1568].forEach((e,t)=>ub({freq:e,type:`triangle`,at:t*.07,dur:.28,peak:.09,group:`alerts`}))},merged:{rank:2,play:()=>{fb({dur:.07,peak:.16,filter:`bandpass`,freq:1400,q:1.2,attack:.002,group:`alerts`}),ub({freq:523,to:1046,type:`square`,at:.04,dur:.12,peak:.04,group:`alerts`}),[1046.5,1318.5,1568].forEach(e=>ub({freq:e,type:`triangle`,at:.14,dur:.5,peak:.05,group:`alerts`})),fb({at:.12,dur:.6,peak:.03,filter:`bandpass`,freq:2500,q:.6,attack:.08,group:`alerts`})}},welcome:{rank:1,play:()=>[659,784,1046.5].forEach((e,t)=>ub({freq:e,type:`sine`,at:t*.12,dur:t===2?.5:.2,peak:.12,group:`alerts`}))}},Cb=150,wb=1e3,Tb=null,Eb=null,Db=0,Ob=-1/0,kb=(e,t)=>e&&Sb[e].rank>=Sb[t].rank?e:t;function Ab(e){let t=performance.now();t-Ob<wb&&Sb[e].rank<=Db&&!Tb||(Tb=kb(Tb,e),!Eb&&(Eb=setTimeout(jb,Math.max(Cb,Ob+wb-t))))}function jb(){Eb=null;let e=Tb;Tb=null,e&&(Ob=performance.now(),Db=Sb[e].rank,Sb[e].play())}var Mb=1,Nb=`cubefarm:view`;function Pb(){try{let e=JSON.parse(localStorage.getItem(Nb)??`null`);return e&&[e.floor,e.x,e.z,e.yaw,e.pitch].every(Number.isFinite)?e:null}catch{return null}}function Fb(e){try{localStorage.setItem(Nb,JSON.stringify(e))}catch{}}var Ib=600,q=Ty((e,t)=>({connected:!1,loaded:!1,user:null,ghReady:!0,demo:!1,workspaceRoot:``,settings:{sessionLimit:0,defaultModel:`claude-opus-5-5`,defaultEffort:`medium`,runtime:`terminal`,defaultCli:`claude`,hiring:`approve`,teamCap:6,ceoHeartbeatMin:60,managerName:``,companyName:``,projectsDir:``,setupDone:!0,tutorialStep:-1,pacingSessions:3},clis:[],repos:[],agents:{},logs:{},screens:{},qa:{},requests:[],ceo:{queue:[],job:null,lastReviewAt:null,nextReviewAt:null},messages:[],phoneReadAt:0,usage:{state:`normal`,until:null},restarting:!1,floor:Pb()?.floor??0,travel:null,overlay:null,focus:null,locked:!1,started:!1,toasts:[],held:null,chargeAt:null,apply(n){let r=t().loaded;switch(n.type){case`snapshot`:{let r=n.data,i={},a={},o={};for(let{log:e,...t}of r.agents)i[t.id]=t,a[t.id]=e,t.screenshotAt&&(o[t.id]=t.screenshotAt);let s={};for(let e of r.qa)s[Lb(e.repoId,e.prNumber)]=e;let c=r.repos.some(e=>e.floor===t().floor);e({loaded:!0,user:r.user,ghReady:r.ghReady,ghError:r.ghError,demo:r.demo,workspaceRoot:r.workspaceRoot,settings:r.settings,repos:r.repos.sort((e,t)=>e.floor-t.floor),agents:i,logs:a,screens:o,qa:s,requests:r.requests,ceo:r.ceo,messages:r.messages,phoneReadAt:r.phoneReadAt,officeCommit:r.officeCommit,officeUpdate:r.officeUpdate,usage:r.usage,clis:r.clis??[],restarting:!1,floor:c?t().floor:0});break}case`repo`:{let i=t().repos.find(e=>e.id===n.repo.id),a=new Set(i?.pulls.filter(e=>e.state===`OPEN`).map(e=>e.number));r&&n.repo.pulls.some(e=>e.state===`MERGED`&&a.has(e.number))&&Ab(`merged`);let o=t().repos.filter(e=>e.id!==n.repo.id);o.push(n.repo),e({repos:o.sort((e,t)=>e.floor-t.floor)});break}case`repoRemoved`:{let r=t().repos.filter(e=>e.id!==n.repoId);e({repos:r,floor:t().floor>r.length?0:t().floor});break}case`agent`:{let i=t().agents[n.agent.id];r&&!i&&n.agent.role!==`ceo`&&Ab(`welcome`),r&&i&&i.status!==`error`&&n.agent.status===`error`&&Ab(`error`),e({agents:{...t().agents,[n.agent.id]:n.agent}});break}case`agentRemoved`:{let{[n.agentId]:r,...i}=t().agents;e({agents:i});break}case`log`:{let r=(t().logs[n.agentId]??[]).concat(n.lines);e({logs:{...t().logs,[n.agentId]:r.length>Ib?r.slice(-600):r}});break}case`screen`:{let r=t().agents[n.agentId];e({screens:{...t().screens,[n.agentId]:n.at},agents:r?{...t().agents,[n.agentId]:{...r,hasScreenshot:!0,screenshotAt:n.at,browserUrl:n.url??r.browserUrl}}:t().agents});break}case`qa`:{let i=t().qa[Lb(n.qa.repoId,n.qa.prNumber)]?.status,a=e=>e===`failed`||e===`needs-human`;r&&n.qa.status===`passed`&&i!==`passed`&&Ab(`ready`),r&&a(n.qa.status)&&!a(i)&&Ab(`qaFailed`),e({qa:{...t().qa,[Lb(n.qa.repoId,n.qa.prNumber)]:n.qa}});break}case`qaRemoved`:{let{[Lb(n.repoId,n.prNumber)]:r,...i}=t().qa;e({qa:i});break}case`settings`:e({settings:n.settings});break;case`clis`:e({clis:n.clis});break;case`request`:{let i=t().requests.find(e=>e.id===n.request.id);r&&n.request.kind===`hire`&&n.request.status===`approved`&&i?.status===`pending`&&Ab(`welcome`);let a=t().requests.filter(e=>e.id!==n.request.id);a.push(n.request),e({requests:a.sort((e,t)=>e.createdAt-t.createdAt)});break}case`ceo`:e({ceo:n.ceo});break;case`message`:{e({messages:[...t().messages.slice(-199),n.message]});let r=t().overlay,i=r?.kind===`phone`&&(r.tab??`chat`)===`chat`;if(n.message.from===`ceo`&&!i){mb();let e=t().agents.ceo?.name??`CEO`,r=n.message.text.replace(/\s+/g,` `);t().pushToast(`info`,`📱 ${e}: ${r.length>110?`${r.slice(0,109)}…`:r}`)}break}case`phoneRead`:e({phoneReadAt:Math.max(t().phoneReadAt,n.at)});break;case`toast`:t().pushToast(n.level,n.text);break;case`officeUpdate`:e({officeUpdate:n.officeUpdate});break;case`usage`:e({usage:n.usage})}},setConnected:t=>e({connected:t}),setRestarting:t=>e({restarting:t}),setOfficeUpdate:t=>e({officeUpdate:t}),openOverlay(t){e(t?{overlay:t,focus:null,held:null,chargeAt:null}:{overlay:t}),t&&document.pointerLockElement&&document.exitPointerLock()},setFocus:n=>{let r=t().focus;(r?.id!==n?.id||r?.label!==n?.label)&&e({focus:n})},setHeld:t=>e({held:t,chargeAt:null}),setCharge:t=>e({chargeAt:t}),setLocked:t=>e({locked:t}),start:()=>e({started:!0}),goToFloor(n){if(n===t().floor||t().travel){e({overlay:null});return}e({overlay:null,held:null,chargeAt:null,travel:{to:n,phase:`closing`}})},finishTravel(n){let r=t().travel;r&&e(n===`arrived`?{floor:r.to,travel:{...r,phase:`opening`}}:{travel:null})},pushToast(n,r){let i=Mb++;e({toasts:[...t().toasts.slice(-4),{id:i,level:n,text:r}]}),setTimeout(()=>t().dismissToast(i),n===`error`?9e3:5e3)},dismissToast:n=>e({toasts:t().toasts.filter(e=>e.id!==n)})})),Lb=(e,t)=>`${e}#${t}`,Rb=(e,t)=>e.find(e=>e.floor===t)??null,zb=(e,t)=>Object.values(e).filter(e=>e.repoId===t).sort((e,t)=>e.role===t.role?e.desk-t.desk:e.role===`dev`?-1:1),Bb=e=>e?.kind===`kanban`||e?.kind===`terminal`||e?.kind===`manager`,Vb=e=>e.status===`preparing`||e.status===`working`,Hb=(e,t)=>e.filter(e=>e.from===`ceo`&&!e.requestId&&e.at>t).length,Ub=e=>e.filter(e=>e.status===`pending`);function Wb(){let e=q(e=>e.requests),t=q(e=>e.messages),n=q(e=>e.phoneReadAt);return Ub(e).length+Hb(t,n)}function Gb(e,t,n){let r=e.pulls.filter(e=>e.state===`OPEN`),i=new Map(t.map(e=>[e.id,e])),a=t.filter(e=>e.role===`dev`),o=(e,t)=>a.find(t=>t.prNumber===e)??a.find(e=>e.branch&&e.branch===t),s=[];for(let e of a){if(e.issueNumber==null||e.task!==`issue`||e.status===`idle`||e.prNumber!=null&&r.some(t=>t.number===e.prNumber))continue;let t=e.status===`preparing`?`setting up`:e.status===`working`?`working`:e.status===`error`?`needs help`:e.status===`stopped`?`stopped`:`finished · no PR`;s.push({key:`a-${e.id}`,number:e.issueNumber,title:e.issueTitle??``,agent:e,note:t,tone:e.status===`error`?`bad`:e.status===`stopped`||e.status===`done`?`warn`:void 0})}let c=[],l=[];for(let t of r){let r=n[Lb(e.id,t.number)],a=(r?.devAgentId?i.get(r.devAgentId):void 0)??o(t.number,t.headRefName),s=r?.qaAgentId?i.get(r.qaAgentId):void 0,u={key:`pr-${t.number}`,number:t.number,prNumber:t.number,title:t.title,url:t.url,qa:r};if(r?.status===`passed`){l.push({...u,agent:a,note:r.mergeNote?`QA ✓ · ${r.mergeNote}`:t.mergeable===`CONFLICTING`?`QA ✓ · conflicts`:t.checks===`failing`?`QA ✓ · CI failing`:e.autoMerge&&t.checks===`pending`?`QA ✓ · waiting for checks`:`✅ QA passed`,tone:t.mergeable===`CONFLICTING`||t.checks===`failing`?`warn`:`good`});continue}let d=r?.status;c.push({...u,agent:d===`testing`?s:a,note:d===`queued`?`waiting for QA${r&&r.round>1?` · round ${r.round}`:``}`:d===`testing`?`🔍 testing · round ${r.round}`:d===`failed`?`❌ failed · back to dev`:d===`fixing`?`🔧 fixing · round ${r.round}`:d===`needs-human`?`⚠️ needs you${r.mergeNote?` · ${r.mergeNote}`:``}`:t.isDraft?`draft`:`not tested yet`,tone:d===`failed`||d===`needs-human`?`bad`:d===`fixing`||!d?`warn`:void 0})}let u=new Set([...s.map(e=>e.number),...r.flatMap(e=>e.closesIssues)]),d=new Set(e.issues.map(e=>e.number));return{backlog:e.issues.filter(e=>!u.has(e.number)).map(e=>{let t=Ry(e.body,d),n=e.labels.map(e=>e.replace(/^swarm:/i,`🎯 `)).slice(0,2).join(`, `);return{key:`i-${e.number}`,number:e.number,title:e.title,url:e.url,note:t.length?`⏳ after #${t.join(`, #`)}`:n||void 0}}),progress:s,qa:c,ready:l,merged:e.pulls.filter(e=>e.state===`MERGED`).sort((e,t)=>(t.mergedAt??``).localeCompare(e.mergedAt??``)).map(e=>({key:`m-${e.number}`,number:e.number,prNumber:e.number,title:e.title,url:e.url,agent:o(e.number,e.headRefName)}))}}var Kb=1.75,qb=new URLSearchParams(window.location.search).has(`stats`);function Jb(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function Yb(){return(0,v.useSyncExternalStore)(Jb,()=>document.hidden)}function Xb(){let e=q(e=>Bb(e.overlay)),t=Yb();return e||t}function Zb({paused:e}){let t=W_(e=>e.size),n=W_(e=>e.viewport.dpr),r=W_(e=>e.advance),i=W_(e=>e.clock),a=(0,v.useRef)({size:t,dpr:n});return(0,v.useEffect)(()=>{let o=a.current.size!==t||a.current.dpr!==n;a.current={size:t,dpr:n},e&&o&&r(i.elapsedTime)},[e,t,n,r,i]),null}function Qb(e){let t=e>130?144:e>100?120:60;return[Math.round(t*.6),Math.round(t*.9)]}function $b({onChange:e}){let t=({factor:t})=>e(Math.round((1+.75*t)*100)/100);return(0,K.jsx)(Ly,{factor:1,step:.25,bounds:Qb,onIncline:t,onDecline:t})}var ex=null,tx=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e);function nx({paused:e}){let t=W_(e=>e.gl),n=(0,v.useRef)({start:0,prev:0,frames:0});return(0,v.useEffect)(()=>{n.current.start=0},[e]),G_(()=>{let e=performance.now(),r=n.current;(!r.start||e-r.prev>1e3)&&(r.start=e,r.frames=0),r.prev=e,r.frames++;let i=e-r.start;if(i<500||!ex)return;let{calls:a,triangles:o}=t.info.render,s=r.frames*1e3/i;ex.textContent=`${Math.round(s)} fps · ${(i/r.frames).toFixed(1)} ms · ${a} calls · ${tx(o)} tris · dpr ${t.getPixelRatio().toFixed(2)}`,r.start=e,r.frames=0}),null}function rx(){let e=Xb();return(0,K.jsxs)(`div`,{className:`stats`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{ref:e=>{ex=e},hidden:e,children:`measuring…`}),e&&(0,K.jsx)(`span`,{children:`⏸ 3D view paused`})]})}var ix=3.6,ax=1.65,ox=.3,sx={doorHalf:1.2,cabinHalf:1.5,depth:2.6,doorHeight:2.5},cx={x:0,z:10.4,yaw:0},lx=(e,t,n,r,i)=>({minX:e-n/2,maxX:e+n/2,minZ:t-r/2,maxZ:t+r/2,h:i}),ux={desk:.78,seated:1.3,board:3.45,couch:.95,coffeeTable:.5,kitchen:2,cooler:1.5,bookshelf:2.2,cabinet:2.1,reception:1.13,glass:2.8};function dx(){let e=.4,{doorHalf:t,cabinHalf:n,depth:r}=sx;return[{minX:-16.4,maxX:16.4,minZ:-12.4,maxZ:-12},{minX:-16.4,maxX:-16,minZ:-12,maxZ:12},{minX:16,maxX:16.4,minZ:-12,maxZ:12},{minX:-16,maxX:-t,minZ:12,maxZ:12.4},{minX:t,maxX:16,minZ:12,maxZ:12.4},{minX:-n-e,maxX:-n,minZ:12,maxZ:12+r},{minX:n,maxX:n+e,minZ:12,maxZ:12+r},{minX:-n,maxX:n,minZ:12+r,maxZ:12+r+e}]}var fx=()=>({minX:-sx.doorHalf,maxX:sx.doorHalf,minZ:12,maxZ:12.4}),px=[-10.5,-3.5,3.5,10.5],mx=[-6.2,-1.6,3],hx=px.length*mx.length,gx={w:1.9,d:.95,h:.74},_x=mx.map(e=>lx(0,e+.35,24.4,2.9));function vx(e){let t=mx.length-1-Math.floor(e/px.length)%mx.length;return{x:px[e%px.length],z:mx[t]}}var yx={w:12,h:3,y:.45,z:-11.94},bx={x:-13.7,y:2.25,w:3.2,h:1.8,bezel:.09,depth:.12},xx={officeX:-10,lobbyX:-12.9,w:1.3,d:.3,h:1.85},Sx=e=>lx(e,12-xx.d/2,xx.w,xx.d,xx.h),Cx={x:14,stations:[-5.2,-2,1.2]},wx=-Math.PI/2,Tx=e=>({x:Cx.x,z:Cx.stations[e%Cx.stations.length]}),Ex=lx(Cx.x-.4,-2,3.4,10.4);function Dx(){let e=dx();for(let t=0;t<hx;t++){let{x:n,z:r}=vx(t);e.push(lx(n,r,gx.w+.1,gx.d+.1,ux.desk)),e.push(lx(n,r+.8,.7,.6,ux.seated))}for(let t of Cx.stations)e.push(lx(Cx.x,t,gx.d+.1,gx.w+.1,ux.desk)),e.push(lx(Cx.x-.8,t,.6,.7,ux.seated));e.push(lx(0,-11.75,yx.w+.4,.5,ux.board));let t=bx;return e.push(lx(t.x,-12+t.depth/2,t.w+t.bezel*2,t.depth,t.y+t.h/2+t.bezel)),e.push(lx(-15.1,6.5,1.1,3.2,ux.couch)),e.push(lx(-13.4,6.5,.9,1.4,ux.coffeeTable)),e.push(Sx(xx.officeX)),e.push(lx(15.55,7.4,.9,5,ux.kitchen)),e.push(lx(15.5,-9.5,.7,.7,ux.cooler)),e}var Ox={minX:-16,maxX:-6.5,minZ:-12,maxZ:-3.5,doorMinX:-11,doorMaxX:-9.2},kx={x:-11.2,z:-8.6,w:2.6,d:1.1},Ax={x:3,z:-3.5,w:5,d:1.2},jx={minX:6.5,maxX:16,minZ:-12,maxZ:-3.5,doorMinX:8.2,doorMaxX:10},Mx={x:12,z:-7.4},Nx={x:14.6,seats:[6.6,7.9,9.2,10.4]},Px=Math.PI/2,Fx=lx(3,3,14,9);function Ix(){let e=dx(),t=Ox,n=.12;e.push({minX:t.maxX-n,maxX:t.maxX+n,minZ:t.minZ,maxZ:t.maxZ,h:ux.glass}),e.push({minX:t.minX,maxX:t.doorMinX,minZ:t.maxZ-n,maxZ:t.maxZ+n,h:ux.glass}),e.push({minX:t.doorMaxX,maxX:t.maxX,minZ:t.maxZ-n,maxZ:t.maxZ+n,h:ux.glass});let r=jx;e.push({minX:r.minX-n,maxX:r.minX+n,minZ:r.minZ,maxZ:r.maxZ,h:ux.glass}),e.push({minX:r.minX,maxX:r.doorMinX,minZ:r.maxZ-n,maxZ:r.maxZ+n,h:ux.glass}),e.push({minX:r.doorMaxX,maxX:r.maxX,minZ:r.maxZ-n,maxZ:r.maxZ+n,h:ux.glass}),e.push(lx(Mx.x,Mx.z,gx.w+.1,gx.d+.1,ux.desk)),e.push(lx(Mx.x,Mx.z+.8,.7,.6,ux.seated));for(let t of Nx.seats)e.push(lx(Nx.x,t,.7,.7,ux.seated));return e.push(lx(kx.x,kx.z,kx.w,kx.d,ux.desk)),e.push(lx(kx.x,kx.z-1.1,.8,.8,ux.seated)),e.push(lx(-15.6,-8,.8,5,ux.bookshelf)),e.push(Sx(xx.lobbyX)),e.push(lx(Ax.x,Ax.z,Ax.w,Ax.d,ux.reception)),e.push(lx(11.5,4,3.2,1,ux.couch)),e.push(lx(11.5,6.2,1.6,.9,ux.coffeeTable)),e.push(lx(12,-11.45,4.4,1.1,ux.cabinet)),e}var Lx=[..._x,Ex],Rx=[Fx,Ox,jx];function zx(e,t,n){if(n>12&&Math.abs(t)<=sx.cabinHalf)return`cabin`;for(let r of e===`lobby`?Rx:Lx)if(t>=r.minX&&t<=r.maxX&&n>=r.minZ&&n<=r.maxZ)return`rug`;return e===`lobby`?`lobby`:`wood`}function Bx(e,t,n,r=ox){for(let i=0;i<2;i++)for(let i of n){let n=i.minX-r,a=i.maxX+r,o=i.minZ-r,s=i.maxZ+r;if(e<=n||e>=a||t<=o||t>=s)continue;let c=[n-e,a-e,o-t,s-t],l=c.map(Math.abs),u=l.indexOf(Math.min(...l));u<2?e+=c[u]:t+=c[u]}return{x:e,z:t}}var Vx=[`#ffffff`,`#ffd166`,`#ef476f`,`#06d6a0`,`#118ab2`,`#2b2d42`],Hx=[`quiff`,`afro`,`bun`,`curls`],Ux={feminine:[[`long`,4],[`ponytail`,3],[`bun`,3],[`curls`,2],[`afro`,2],[`sidePart`,2],[`buzz`,1]],masculine:[[`crop`,2],[`quiff`,3],[`sidePart`,3],[`buzz`,2],[`bald`,2],[`curls`,2],[`afro`,2],[`long`,1],[`ponytail`,1],[`bun`,1]]};function Wx(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Gx(e){let t=e;return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Kx(e,t){let n=e*t.reduce((e,[,t])=>e+t,0);for(let[e,r]of t)if((n-=r)<0)return e;return t[t.length-1][0]}function qx(e){let t=Gx(Wx(e.id)),[n,r,i,a,o,s,c,l,u]=Array.from({length:9},t),d=e.role===`dev`,f=e.look===`masculine`,p=Kx(n,Ux[e.look]),m=f?Kx(r,[[`none`,5],[`stubble`,2],[`beard`,2],[`moustache`,1]]):`none`,h=e.role===`qa`?`none`:Kx(i,[[`none`,6],[`round`,2],[`square`,2]]),g=d&&p!==`afro`&&a<.3;return{hair:p,facialHair:m,glasses:h,headphones:g,headwear:d&&!g&&!Hx.includes(p)?Kx(o,[[`none`,7],[`beanie`,1],[`cap`,1]]):`none`,outfit:d?Kx(s,[[`tee`,1],[`hoodie`,1],[`stripe`,1],[`sweater`,1]]):`tee`,height:+(.94+c*.12).toFixed(3),shoulders:+(.92+l*.16).toFixed(3),accent:Math.floor(u*Vx.length)}}function Jx(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new W,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=Yx(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t!==0){c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=Yx(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}}return c}function Yx(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new Pi(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var Xx=new fr,Zx=new zn,Qx=new Sr;function $x(e,{at:t=[0,0,0],rot:n=[0,0,0],scale:r=[1,1,1]}={}){return Zx.setFromEuler(Qx.set(...n)),e.applyMatrix4(Xx.compose(new V(...t),Zx,new V(...r))),e}function eS(...e){e.some(e=>!e.index)&&(e=e.map(e=>e.index?e.toNonIndexed():e));let t=Jx(e);if(!t)throw Error(`could not merge character geometry`);return e.forEach(e=>e.dispose()),t}var tS=(e,t=14,n=10)=>new al(e,t,n),nS=(e,t,n=6,r=12)=>new ws(e,t,n,r),rS=(e,t,n)=>new Cs(e,t,n),iS=()=>$x(new al(.215,24,16,0,Math.PI*2,0,1.75),{at:[0,.02,.01],rot:[.55,0,0]});function aS(e,t,n){let r=[];for(let i=0;i<e;i++){let a=1-2*(i+.5)/e,o=Math.sqrt(1-a*a),s=i*2.39996,c=new V(Math.cos(s)*o,a,Math.sin(s)*o).multiplyScalar(t);n(c)&&r.push(c)}return r}function oS(e){switch(e){case`crop`:return iS();case`long`:return eS(iS(),$x(tS(.215,20,14),{at:[0,-.1,.07],scale:[1.05,1.25,.8]}));case`ponytail`:{let e={at:[0,.08,.2],rot:[.45,0,0]},t=$x(nS(.075,.24,6,10),{at:[0,-.17,.04]});return eS(iS(),$x(tS(.085,12,10),e),$x(t,e))}case`bun`:return eS(iS(),$x(tS(.1,14,10),{at:[0,.18,.12]}));case`quiff`:{let e=[-.09,-.045,0,.045,.09].map((e,t)=>$x(new Ds(.058,.19+t%2*.04,8),{at:[e,.2-Math.abs(e)*.45,-.09+Math.abs(e)*.35],rot:[-.75,0,-e*3]}));return e.push($x(tS(.1,14,10),{at:[0,.17,-.1],scale:[1.4,.7,1]})),eS(iS(),...e)}case`afro`:{let e=new V(0,.1,.06),t=aS(26,.235,e=>e.z>-.08&&e.y>-.15).map(t=>$x(tS(.075,10,8),{at:[e.x+t.x,e.y+t.y,e.z+t.z]}));return eS($x(tS(.245,22,16),{at:[e.x,e.y,e.z]}),...t)}case`sidePart`:return eS(iS(),$x(tS(.12,16,10),{at:[.05,.16,-.1],rot:[.3,0,-.35],scale:[1.35,.5,.9]}),$x(tS(.07,12,8),{at:[-.08,.2,-.04],scale:[1,.6,1.2]}));case`buzz`:return $x(new al(.205,24,14,0,Math.PI*2,0,1.6),{at:[0,.015,.012],rot:[.5,0,0]});case`bald`:return new al(.208,24,6,-.3,Math.PI+.6,1.2,.58);case`curls`:{let e=aS(60,.2,e=>e.y>.02&&e.y+e.z*.9>-.02).map(e=>$x(tS(.055,8,6),{at:[e.x*1.02,e.y+.03,e.z*1.02+.01]}));return eS(iS(),...e)}}}function sS(e,t,n,r,i){let a=e.toNonIndexed(),o=a.attributes,s=[],c=o.position;for(let e=0;e<c.count;e+=3){let a=(c.getX(e)+c.getX(e+1)+c.getX(e+2))/3,o=(c.getY(e)+c.getY(e+1)+c.getY(e+2))/3;(c.getZ(e)+c.getZ(e+1)+c.getZ(e+2))/3<0&&((a-t)/r)**2+((o-n)/i)**2<1||s.push(e,e+1,e+2)}let l=new W;for(let e of[`position`,`normal`,`uv`]){let t=o[e],n=new Float32Array(s.length*t.itemSize);s.forEach((e,r)=>{for(let i=0;i<t.itemSize;i++)n[r*t.itemSize+i]=t.array[e*t.itemSize+i]}),l.setAttribute(e,new Pi(n,t.itemSize))}return e.dispose(),a.dispose(),l}var cS=(e,t)=>sS(new al(e,28,12,Math.PI-.15,Math.PI+.3,t,Math.PI-t),0,-.088,.07,.048),lS=()=>eS(...[-1,1].map(e=>$x(nS(.022,.05,4,8),{at:[e*.036,-.052,-.197],rot:[.25,0,e*1.2],scale:[1,1,.7]})));function uS(e){switch(e){case`none`:return null;case`stubble`:return cS(.203,2);case`moustache`:return lS();case`beard`:return eS($x(cS(.212,1.95),{at:[0,.012,-.004],scale:[1.03,1.12,1.04]}),...[-1,1].map(e=>$x(nS(.028,.09,4,8),{at:[e*.188,-.07,-.035],rot:[0,0,e*.25]})),lS())}}function dS(e,t=-.215){if(e===`none`)return null;let n=e===`round`?[-.075,.075].map(e=>$x(new sl(.047,.01,6,20),{at:[e,.02,t]})):[-.078,.078].flatMap(e=>[$x(rS(.1,.018,.016),{at:[e,.058,t]}),$x(rS(.1,.014,.016),{at:[e,-.02,t]}),$x(rS(.014,.09,.016),{at:[e-.045,.02,t]}),$x(rS(.014,.09,.016),{at:[e+.045,.02,t]})]),r=[-1,1].map(e=>$x(rS(.012,.012,.19),{at:[e*.172,.035,-.11],rot:[0,e*.4,0]}));return eS(...n,$x(rS(.05,.012,.012),{at:[0,.03,t]}),...r)}function fS(){let e=$x(new sl(.245,.018,6,28,Math.PI),{at:[0,0,.01]}),t=[-1,1].map(e=>$x(new Es(.072,.072,.055,18),{at:[e*.235,-.01,.01],rot:[0,0,Math.PI/2]})),n=[-1,1].map(e=>$x(new Es(.052,.052,.012,18),{at:[e*.266,-.01,.01],rot:[0,0,Math.PI/2]}));return{shell:eS(e,...t),covers:eS(...n)}}function pS(e){switch(e){case`none`:return null;case`beanie`:{let e=.228,t=1.42,n={at:[0,.035,.02],rot:[.35,0,0]};return eS($x(new al(e,24,12,0,Math.PI*2,0,t),n),$x($x(new sl(e*Math.sin(t),.03,8,28),{at:[0,e*Math.cos(t),0],rot:[Math.PI/2,0,0]}),n),$x(tS(.06,12,8),{at:[0,.035+.258*Math.cos(.35),.02+.258*Math.sin(.35)]}))}case`cap`:{let e=.224,t=1.35,n={at:[0,.02,.015],rot:[.18,0,0]};return eS($x(new al(e,24,12,0,Math.PI*2,0,t),n),$x($x(new Es(.14,.14,.014,24,1,!1,Math.PI/2,Math.PI),{at:[0,e*Math.cos(t),-.13],rot:[-.08,0,0],scale:[1,1,.9]}),n),$x(tS(.022,8,6),{at:[0,.02+e*Math.cos(.18),.015+e*Math.sin(.18)]}))}}}function mS(e){switch(e){case`tee`:return{main:null,trim:null};case`stripe`:return{main:null,trim:new Es(.204,.204,.075,28,1,!0).translate(0,.32,0)};case`hoodie`:return{main:eS($x(new sl(.12,.055,10,24),{at:[0,.5,.03],rot:[Math.PI/2-.35,0,0],scale:[1.05,1.15,1]}),$x(tS(.11,16,10),{at:[0,.5,.12],scale:[1.05,.9,.55]}),$x(rS(.22,.1,.02),{at:[0,.14,-.196]})),trim:eS(...[-1,1].flatMap(e=>[$x(nS(.01,.11,3,6),{at:[e*.045,.39,-.196],rot:[-.25,0,e*.08]}),$x(tS(.016,8,6),{at:[e*.05,.32,-.208]})]))};case`sweater`:{let e=[-.12,-.06,0,.06,.12].map(e=>{let t=-Math.sqrt(.2*.2-e*e)-.004;return $x(rS(.04,.04,.012),{at:[e,.33,t],rot:[0,-Math.asin(e/.2),Math.PI/4]})});return{main:null,trim:eS($x(new sl(.105,.045,10,24),{at:[0,.505,-.01],rot:[Math.PI/2,0,0]}),new Es(.206,.206,.05,28,1,!0).translate(0,.2,0),...e)}}}}function hS(e,t){return Object.fromEntries(e.map(e=>[e,t(e)]))}var gS={legs:eS(...[-.11,.11].flatMap(e=>[$x(nS(.08,.26),{at:[e,.5,-.17],rot:[Math.PI/2,0,0]}),$x(nS(.07,.3),{at:[e,.27,-.36]})])),shoes:eS(...[-.11,.11].map(e=>$x(rS(.13,.09,.22),{at:[e,.05,-.42]}))),torso:nS(.2,.24,8,16),collar:new sl(.1,.03,8,20),sleeve:nS(.065,.36,6,12),hand:tS(.07,14,10),head:tS(.2,24,18),ears:eS(...[-.2,.2].map(e=>$x(tS(.05,10,8),{at:[e,-.01,0]}))),eyes:eS(...[-.07,.07].map(e=>$x(tS(.03,10,8),{at:[e,.02,-.18]}))),nose:tS(.028,10,8),mouth:new sl(.045,.011,6,16,Math.PI),lashes:eS(...[-1,1].map(e=>$x(rS(.035,.008,.008),{at:[e*.1,.045,-.172],rot:[0,0,e*-.6]}))),cheeks:eS(...[-1,1].map(e=>$x(tS(.03,10,8),{at:[e*.115,-.045,-.165],scale:[1,.6,.3]}))),hairClip:rS(.07,.035,.035),shirtFront:rS(.11,.22,.02),tie:rS(.045,.2,.012),tieKnot:rS(.06,.04,.02),coatOpening:rS(.06,.3,.02),badge:rS(.07,.05,.015),inspectorGlasses:dS(`round`,-.2),hair:hS([`crop`,`long`,`ponytail`,`bun`,`quiff`,`afro`,`sidePart`,`buzz`,`bald`,`curls`],oS),facialHair:hS([`none`,`stubble`,`beard`,`moustache`],uS),glasses:hS([`none`,`round`,`square`],e=>dS(e)),headphones:fS(),headwear:hS([`none`,`beanie`,`cap`],pS),outfit:hS([`tee`,`hoodie`,`stripe`,`sweater`],mS)},_S=new ao(new Uint8Array([110,190,255]),3,1,ye);_S.minFilter=D,_S.magFilter=D,_S.generateMipmaps=!1,_S.needsUpdate=!0;var vS=new Map;function yS(e,t={}){let n=`${e}|${t.emissive??``}|${t.emissiveIntensity??``}|${t.opacity??``}`,r=vS.get(n);return r||(r=new Dl({color:e,gradientMap:_S,emissive:t.emissive??`#000000`,emissiveIntensity:t.emissiveIntensity??1,transparent:t.transparent??(t.opacity!==void 0&&t.opacity<1),opacity:t.opacity??1}),vS.set(n,r)),r}function bS(e,t){let n=`map|${e}`,r=vS.get(n);return r||(r=new Dl({map:t,gradientMap:_S}),vS.set(n,r)),r}function xS(e){let t=`glow|${e}`,n=vS.get(t);return n||(n=new Na({color:e,toneMapped:!1}),vS.set(t,n)),n}var SS=new Tl({color:`#bfe8ff`,transparent:!0,opacity:.22,roughness:.05,metalness:0,depthWrite:!1,side:2});function CS(e,t){let n=new H(e),r={h:0,s:0,l:0};return n.getHSL(r),n.setHSL(r.h,r.s,Math.max(0,Math.min(1,r.l+t))),`#${n.getHexString()}`}function wS(e,t,n){return`#${new H(e).lerp(new H(t),n).getHexString()}`}var TS=`"JetBrains Mono", Consolas, "Cascadia Mono", monospace`,ES=`Fredoka, "Segoe UI", system-ui, sans-serif`;function DS(e,t,n,r,i,a){e.beginPath(),e.roundRect(t,n,r,i,a)}function OS(e,t,n,r){let i=t.split(/\s+/),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n)o=i;else if(o&&a.push(o),o=t,a.length===r)break}if(a.length<r&&o&&a.push(o),a.length===r&&i.join(` `).length>a.join(` `).length){let t=a[r-1];for(;t.length>1&&e.measureText(`${t}…`).width>n;)t=t.slice(0,-1);a[r-1]=`${t}…`}return a}var kS={bg:`#1b1b29`,bar:`#2a2a3d`,text:`#e8e8f2`,tool:`#8be9fd`,result:`#8d8da8`,system:`#bd93f9`,error:`#ff6b6b`,manager:`#ffb86c`,done:`#50fa7b`,thinking:`#f1fa8c`},AS=[`·`,`✢`,`✳`,`✶`,`✻`,`✽`,`✻`,`✶`,`✳`,`✢`],jS=[`Crafting`,`Pondering`,`Tinkering`,`Brewing`,`Noodling`,`Scheming`,`Assembling`,`Percolating`];function MS(e){return e?e.startsWith(`mcp__playwright__`)?`Browsing`:e===`Bash`||e===`PowerShell`?`Running`:e===`Edit`||e===`Write`||e===`MultiEdit`?`Editing`:e===`Read`||e===`Grep`||e===`Glob`?`Reading`:e===`WebFetch`||e===`WebSearch`?`Researching`:e:``}function NS(e,t,n,r,i,a,o,s,c){e.fillStyle=kS.bg,e.fillRect(0,0,t,n),e.fillStyle=kS.bar,e.fillRect(0,0,t,30),[`#ff5f57`,`#febc2e`,`#28c840`].forEach((t,n)=>{e.fillStyle=t,e.beginPath(),e.arc(18+n*20,15,6,0,Math.PI*2),e.fill()}),e.fillStyle=`#b8b8cc`,e.font=`600 14px ${TS}`,e.textBaseline=`middle`;let l=r.status===`idle`?`idle`:r.role===`ceo`?(r.issueTitle??`running the company`).toLowerCase():r.task===`qa`?`QA of PR #${r.prNumber}`:r.task===`fix`?`fixing PR #${r.prNumber}`:r.issueNumber?`issue #${r.issueNumber}`:`idle`,u=r.role===`qa`?`qa-lab`:r.role===`ceo`?`hq`:`swarm`,d=`${r.name.toLowerCase()}@${u} — ${l} — ${c}`;e.fillText(d,84,16);let f=o?Math.round(t*.56):t;if(r.status===`idle`&&i.length<=1){PS(e,0,30,t,n-30,r,s);return}e.font=`14px ${TS}`;let p=e.measureText(`M`).width,m=Math.max(10,Math.floor((f-20)/p)),h=r.status===`working`||r.status===`preparing`?28:8,g=Math.floor((n-30-10-h)/17),_=[];for(let e=i.length-1;e>=0&&_.length<g;e--){let t=i[e],n=[],r=t.text||` `;for(let e=0;e<r.length;e+=m)n.push(r.slice(e,e+m));for(let e=n.length-1;e>=0&&_.length<g;e--)_.unshift({text:n[e],kind:t.kind})}let v=48.5;for(let t of _)t.kind===`tool`&&t.text.startsWith(`⏺`)?(e.fillStyle=kS.done,e.fillText(`⏺`,10,v),e.fillStyle=kS.tool,e.fillText(t.text.slice(1),10+p,v)):t.kind===`text`&&t.text.startsWith(`●`)?(e.fillStyle=`#ffffff`,e.fillText(`●`,10,v),e.fillStyle=kS.text,e.fillText(t.text.slice(1),10+p,v)):(e.fillStyle=kS[t.kind]??kS.text,e.fillText(t.text,10,v)),v+=17;if(r.status===`working`||r.status===`preparing`){let t=Math.floor(s/120)%AS.length,i=r.status===`preparing`?`Setting up worktree`:MS(r.currentTool)||jS[Math.floor(s/6e3)%jS.length],a=r.startedAt?Math.floor((Date.now()-r.startedAt)/1e3):0,o=Math.floor(a/60);e.fillStyle=`#ff9e64`,e.font=`600 14px ${TS}`,e.fillText(`${AS[t]} ${i}… (${o}m ${a%60}s)`,10,n-14)}o&&FS(e,f,30,t-f,n-30,r.browserUrl,a)}function PS(e,t,n,r,i,a,o){let s=o/1e3,c=e.createLinearGradient(t,n,t+r,n+i);c.addColorStop(0,`#26264a`),c.addColorStop(1,`#3b2a55`),e.fillStyle=c,e.fillRect(t,n,r,i);let l=t+r/2+Math.sin(s*.7)*r*.25,u=n+i/2+Math.cos(s*.9)*i*.18;e.textAlign=`center`,e.font=`64px ${ES}`,e.fillText(`✻`,l,u-20),e.fillStyle=`#ffd6a5`,e.font=`600 26px ${ES}`,e.fillText(`${a.name} is free`,l,u+34),e.fillStyle=`#b8b8dd`,e.font=`18px ${ES}`,e.fillText(a.role===`qa`?`waiting for a PR to test…`:a.role===`ceo`?`thinking about the company…`:`waiting for an issue…`,l,u+62),e.textAlign=`left`}function FS(e,t,n,r,i,a,o){e.fillStyle=`#e9ecf2`,e.fillRect(t,n,r,i),e.fillStyle=`#d5d9e2`,e.fillRect(t,n,r,34),DS(e,t+10,n+6,r-20,22,11),e.fillStyle=`#ffffff`,e.fill(),e.fillStyle=`#4a5160`,e.font=`13px ${ES}`,e.textBaseline=`middle`;let s=(a??`about:blank`).replace(/^https?:\/\//,``);e.fillText(`🔒 ${s.length>42?`${s.slice(0,41)}…`:s}`,t+20,n+18);let c={x:t+4,y:n+38,w:r-8,h:i-42};if(o&&o.complete&&o.naturalWidth>0){let t=Math.min(c.w/o.naturalWidth,c.h/o.naturalHeight),n=o.naturalWidth*t,r=o.naturalHeight*t;e.drawImage(o,c.x+(c.w-n)/2,c.y,n,r)}else e.fillStyle=`#9aa1b2`,e.textAlign=`center`,e.font=`16px ${ES}`,e.fillText(`🌐 loading page…`,c.x+c.w/2,c.y+c.h/2),e.textAlign=`left`}var IS=[{key:`backlog`,title:`📋 Backlog`,chip:`#ffd166`,note:`#fff3b0`},{key:`progress`,title:`🔨 In progress`,chip:`#4cc9f0`,note:`#cfeefd`},{key:`qa`,title:`🔍 In QA`,chip:`#ff9f68`,note:`#ffe3cf`},{key:`ready`,title:`✅ Ready to merge`,chip:`#80ed99`,note:`#d8f9df`},{key:`merged`,title:`🎉 Merged`,chip:`#c77dff`,note:`#eadcff`}],LS={warn:`#ffd8a8`,bad:`#ffc9c9`,good:`#d8f9df`};IS.map(e=>e.key);function RS(e,t){let n=(t-80)/IS.length;return{x0:40+e*n,colW:n}}function zS(e,t,n,r,i){e.fillStyle=`#fbfbf8`,e.fillRect(0,0,t,n),e.fillStyle=`rgba(120,140,170,0.05)`;for(let r=0;r<6;r++)e.fillRect(r*431%t,r*97%n,260,40);e.textBaseline=`middle`,e.fillStyle=`#2d3142`,e.font=`700 46px ${ES}`,e.fillText(r.fullName,40,48),e.font=`500 26px ${ES}`,e.fillStyle=`#6c7086`;let a=r.lastSync?`synced ${new Date(r.lastSync).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:`syncing…`;e.textAlign=`right`,e.fillText(`${r.autoAssign?`⚡ auto-assign on · `:``}${a}`,t-40,50),e.textAlign=`left`,IS.forEach((r,a)=>{let{x0:o,colW:s}=RS(a,t),c=i[r.key];DS(e,o+8,96,s-16,52,26),e.fillStyle=r.chip,e.fill(),e.fillStyle=`#1f2233`,e.font=`600 30px ${ES}`,e.fillText(`${r.title} ${c.length}`,o+30,123),a>0&&(e.strokeStyle=`#d9dbe3`,e.lineWidth=3,e.beginPath(),e.moveTo(o,96),e.lineTo(o,n-30),e.stroke());let l=(s-48)/2,u=Math.floor((n-96-70)/116)*2,d=c.length>u?c.slice(0,u-1):c;if(d.forEach((t,n)=>{BS(e,o+16+n%2*(l+16),164+Math.floor(n/2)*116,l,104,t,t.tone?LS[t.tone]:r.note)}),c.length>d.length){e.fillStyle=`#6c7086`,e.font=`600 26px ${ES}`;let t=d.length;e.fillText(`+${c.length-d.length} more`,o+30+t%2*(l+16),164+Math.floor(t/2)*116+52)}c.length===0&&(e.fillStyle=`#b4b7c5`,e.font=`italic 500 26px ${ES}`,e.fillText(r.key===`backlog`?`no open issues`:`nothing here yet`,o+30,206))})}function BS(e,t,n,r,i,a,o){let s=(a.number*37%7-3)*.006;e.save(),e.translate(t+r/2,n+i/2),e.rotate(s),e.translate(-r/2,-i/2),e.fillStyle=`rgba(0,0,0,0.12)`,e.fillRect(4,6,r,i),e.fillStyle=o,e.fillRect(0,0,r,i),e.fillStyle=`rgba(0,0,0,0.06)`,e.fillRect(0,0,r,10),e.fillStyle=`#2d3142`,e.font=`700 22px ${ES}`,e.textBaseline=`top`,e.fillText(`${a.prNumber?`PR `:``}#${a.number}`,14,12),e.font=`500 19px ${ES}`,OS(e,a.title,r-28,2).forEach((t,n)=>e.fillText(t,14,38+n*21)),e.textBaseline=`middle`,a.agent&&(e.fillStyle=a.agent.color,e.beginPath(),e.arc(22,i-15,8,0,Math.PI*2),e.fill(),e.fillStyle=`#2d3142`,e.font=`600 17px ${ES}`,e.fillText(a.agent.name,36,i-14)),a.note&&(e.font=`500 16px ${ES}`,e.fillStyle=`#5c6078`,e.textAlign=`right`,e.fillText(a.note,r-12,i-14),e.textAlign=`left`),e.restore(),e.textBaseline=`middle`}function VS(e,t,n,r){e.clearRect(0,0,t,n);let i=r.status===`working`?r.currentTool?.startsWith(`mcp__playwright`)?`🌐`:r.currentTool===`Bash`||r.currentTool===`PowerShell`?`▶️`:r.currentTool?`⌨️`:`💭`:r.status===`preparing`?`📦`:r.status===`done`?`✅`:r.status===`error`?`❗`:r.status===`stopped`?`⏸️`:r.role===`qa`?`🧪`:r.role===`ceo`?`🏛️`:`☕`;DS(e,4,4,t-8,n-8,(n-8)/2),e.fillStyle=`rgba(255,255,255,0.94)`,e.fill(),e.lineWidth=6,e.strokeStyle=r.color,e.stroke(),e.textBaseline=`middle`,e.font=`38px ${ES}`,e.fillText(i,22,n/2+2),e.fillStyle=`#23263a`,e.font=`700 40px ${ES}`;let a=r.status!==`idle`,o=r.role===`ceo`?`${r.name} · CEO`:r.role===`qa`?a&&r.prNumber?`${r.name} · QA PR #${r.prNumber}`:`${r.name} · ${r.title||`QA`}`:a&&r.task===`fix`&&r.prNumber?`${r.name} · 🔧 PR #${r.prNumber}`:a&&r.task===`qa`&&r.prNumber?`${r.name} · 🧪 PR #${r.prNumber}`:a&&r.issueNumber?`${r.name} · #${r.issueNumber}`:r.title?`${r.name} · ${r.title}`:r.name;for(;o.length>4&&e.measureText(o).width>t-96;)o=`${o.slice(0,-2)}…`;e.fillText(o,78,n/2+2)}function HS(e,t,n,r,i,a,o){e.clearRect(0,0,t,n),DS(e,4,4,t-8,n-8,28),e.fillStyle=`rgba(255,255,255,0.95)`,e.fill(),e.lineWidth=6,e.strokeStyle=o,e.setLineDash([14,8]),e.stroke(),e.setLineDash([]),e.textBaseline=`middle`,e.font=`44px ${ES}`,e.fillText(`📄`,20,n/2+2);let s=(t,n)=>{let r=t;for(;r.length>4&&e.measureText(r).width>n;)r=`${r.slice(0,-2)}…`;return r};e.fillStyle=`#23263a`,e.font=`700 40px ${ES}`,e.fillText(s(`${r} · candidate`,t-100),80,n*.36),e.fillStyle=`#5c6078`,e.font=`600 28px ${ES}`,e.fillText(s(`${i}${a?` · floor ${a}`:``}`,t-100),80,n*.72)}function US(e,t,n,r,i,a=`#ffffff`){DS(e,0,0,t,n,28),e.fillStyle=i,e.fill(),e.textAlign=`center`,e.textBaseline=`middle`;let o=r.reduce((e,t)=>e+t.size*1.25,0),s=n/2-o/2;for(let n of r){s+=n.size*1.25/2,e.fillStyle=n.color??a,e.font=`${n.weight??700} ${n.size}px ${ES}`;let r=n.text;for(;r.length>3&&e.measureText(r).width>t-40;)r=`${r.slice(0,-2)}…`;e.fillText(r,t/2,s),s+=n.size*1.25/2}e.textAlign=`left`}function WS(e,t,n,r){let i=e.createLinearGradient(0,0,0,n);i.addColorStop(0,`#74c0fc`),i.addColorStop(.7,`#c5e8ff`),i.addColorStop(1,`#e6f6ff`),e.fillStyle=i,e.fillRect(0,0,t,n),e.fillStyle=`rgba(255,255,255,0.9)`;for(let i=0;i<6;i++){let a=(r*131+i*223)%t+20,o=40+(r*17+i*53)%(n*.35);for(let t=0;t<4;t++)e.beginPath(),e.arc(a+t*22,o+t%2*6,18+t%3*6,0,Math.PI*2),e.fill()}let a=[`#8aa4c8`,`#9fb6d6`,`#7d95bb`,`#a8bddb`],o=0,s=0;for(;o<t;){let t=40+(r+s*37)%70,i=n*(.18+(r*7+s*29)%30/100);e.fillStyle=a[s%a.length],e.fillRect(o,n-i,t-4,i),e.fillStyle=`rgba(255,255,230,0.55)`;for(let r=n-i+10;r<n-10;r+=16)for(let n=o+6;n<o+t-12;n+=12)(n+r+s)%3&&e.fillRect(n,r,5,7);o+=t,s++}}var GS=[{status:`preparing`,label:`Checking out the code`},{status:`installing`,label:`Installing dependencies`},{status:`starting`,label:`Starting the app`}],KS={unconfigured:{text:`NOT SET UP`,bg:`#5c6078`},stopped:{text:`STOPPED`,bg:`#5c6078`},preparing:{text:`STARTING`,bg:`#f4a261`},installing:{text:`STARTING`,bg:`#f4a261`},starting:{text:`STARTING`,bg:`#f4a261`},running:{text:`● LIVE`,bg:`#ef233c`},error:{text:`ERROR`,bg:`#e63946`}};function qS(e,t,n){let r=t;for(;r.length>2&&e.measureText(r).width>n;)r=`${r.slice(0,-2)}…`;return r}function JS(e,t,n,r){let i=r.preview;e.fillStyle=kS.bg,e.fillRect(0,0,t,n),e.textBaseline=`middle`,e.textAlign=`left`,e.fillStyle=kS.bar,e.fillRect(0,0,t,118),e.fillStyle=r.color,e.fillRect(0,112,t,6),e.font=`700 34px ${ES}`;let a=`FLOOR ${r.floor}`,o=e.measureText(a).width+44;DS(e,40,30,o,54,27),e.fillStyle=r.color,e.fill(),e.fillStyle=`#ffffff`,e.fillText(a,62,58);let s=KS[i.status];e.font=`700 38px ${ES}`;let c=e.measureText(s.text).width+52;DS(e,t-40-c,28,c,58,29),e.fillStyle=s.bg,e.fill(),e.fillStyle=`#ffffff`,e.textAlign=`center`,e.fillText(s.text,t-40-c/2,58),e.textAlign=`left`,e.font=`700 50px ${ES}`;let l=40+o+26;e.fillText(qS(e,r.name,t-40-c-26-l),l,58);let u=(n,r,i,a,o=700)=>{e.font=`${o} ${i}px ${ES}`,e.fillStyle=a,e.textAlign=`center`,e.fillText(qS(e,n,t-100),t/2,r),e.textAlign=`left`},d=(e,t=`#8d8da8`)=>u(e,n-50,32,t,600),f=118+(n-118-100)/2,p=i.ref??`the app`;if(i.status===`stopped`){let n=f-70;e.fillStyle=r.color,e.beginPath(),e.arc(t/2,n,84,0,Math.PI*2),e.fill(),e.fillStyle=`#ffffff`,e.beginPath(),e.moveTo(t/2-26,n-42),e.lineTo(t/2-26,n+42),e.lineTo(t/2+44,n),e.closePath(),e.fill(),u(`Press E to open the app`,f+80,70,`#ffffff`),d(`The app isn't running. Start it from the viewer.`)}else if(i.status===`unconfigured`)u(`⚙️`,f-90,110,`#ffffff`,400),u(`No run command yet.`,f+40,66,`#ffffff`),u(`Set one in the manager's console.`,f+120,44,`#b8b8cc`,600),d(`Press E to open the app`);else if(i.status===`error`){let n=(i.error??``).split(/\r?\n/).find(e=>e.trim())?.trim()||`The app stopped unexpectedly.`;e.fillStyle=`#e63946`,e.fillRect(0,f-120,t,130),e.font=`700 44px ${ES}`,e.fillStyle=`#ffffff`,e.fillText(qS(e,`⚠ ${n}`,t-100),50,f-55),u(`The app couldn't start.`,f+90,52,`#ffffff`),d(`Press E to see the log and try again`,`#ffb4ba`)}else if(i.status!==`running`){let n=Math.max(0,GS.findIndex(e=>e.status===i.status));u(`Getting ${p} ready…`,198,46,`#b8b8cc`,600),u(`${GS[n].label}…`,f-20,72,`#ffffff`);let r=(t-200-18*(GS.length-1))/GS.length;GS.forEach((t,i)=>{let a=100+i*(r+18),o=f+90;DS(e,a,o,r,34,17),e.fillStyle=i<n?kS.done:i===n?`#f4a261`:`#3a3a52`,e.fill(),e.font=`600 28px ${ES}`,e.fillStyle=i<=n?kS.text:`#6c6c88`,e.textAlign=`center`,e.fillText(`${i<n?`✓ `:``}${t.label}`,a+r/2,o+70),e.textAlign=`left`}),d(`Step ${n+1} of ${GS.length} · press E to watch`)}else{let n=r.shot?t*.5:t-112;e.font=`600 34px ${ES}`,e.fillStyle=`#b8b8cc`,e.fillText(`Serving at`,56,190),e.font=`700 50px ${TS}`,e.fillStyle=kS.tool,e.fillText(qS(e,(i.url??``).replace(/^https?:\/\//,``).replace(/\/$/,``),n),56,258),e.font=`700 42px ${ES}`;let a=e.measureText(p).width+48;if(DS(e,56,326,a,64,32),e.fillStyle=r.color,e.fill(),e.fillStyle=`#ffffff`,e.fillText(p,80,359),i.commit&&(e.font=`600 42px ${TS}`,e.fillStyle=kS.thinking,e.fillText(i.commit,56+a+24,359)),i.startedAt&&(e.font=`500 32px ${ES}`,e.fillStyle=`#8d8da8`,e.fillText(`up since ${new Date(i.startedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`,56,448)),r.shot){let i=t-n-56-70,a=Math.round(i*.5625),o=t-40-i;e.fillStyle=`#3a3a52`,e.fillRect(o-6,162,i+12,a+12);let s=r.shot,c=Math.max(i/s.width,a/s.height);e.drawImage(s,0,0,i/c,a/c,o,168,i,a),e.font=`500 26px ${ES}`,e.fillStyle=`#8d8da8`,e.fillText(qS(e,r.shotBy?`latest from ${r.shotBy}'s browser`:`latest agent screenshot`,i),o,168+a+36)}d(`Press E to open the app`,kS.done)}}var YS=new Map;function XS(e,t=3.2){let n=(0,v.useRef)(null),r=e?`${e.id}|${e.label}`:``;return(0,v.useEffect)(()=>{let r=n.current;if(r&&e)return YS.set(r,{...e,range:t}),()=>{YS.delete(r)}},[r,t]),n}function ZS(e,t,n,r){let i=(0,v.useMemo)(()=>{let n=document.createElement(`canvas`);n.width=e,n.height=t;let r=new vs(n);return r.colorSpace=xt,r.anisotropy=8,r},[e,t]);return(0,v.useEffect)(()=>{let r=i.image.getContext(`2d`);r.clearRect(0,0,e,t),n(r),i.needsUpdate=!0;let a=!0;return document.fonts?.ready.then(()=>{a&&(r.clearRect(0,0,e,t),n(r),i.needsUpdate=!0)}),()=>{a=!1}},[i,...r]),(0,v.useEffect)(()=>()=>i.dispose(),[i]),i}var QS={gapMs:2e3,ms:1500},$S={ball:2.5,dart:3};function eC(e,t){let n=e&&typeof e==`object`?e.toy:void 0;return n===`dart`?`dart`:typeof n==`string`&&t.includes(n)?`ball`:null}function tC(e,t,n){return e!==null&&!n&&t>=$S[e]}var nC=(e,t,n=QS.gapMs)=>e===void 0||t-e>=n,rC=e=>e*e*(3-2*e);function iC(e){return!(e>=0)||e>=QS.ms?0:e<120?rC(e/120):e<850?1:1-rC((e-850)/(QS.ms-850))}function aC(e){return!(e>=0)||e>=400?0:e<70?rC(e/70):1-rC((e-70)/330)}var oC=(e,t,n)=>Math.min(n,Math.max(t,e));function sC(e,t,n=1.1,r=.5){if(e===0&&t===0)return{head:0,twist:0};let i=Math.atan2(-e,-t),a=oC(i,-n,n);return{head:a,twist:oC(i-a,-r,r)}}var cC=[],lC=1,uC=new Set,dC=new Map,fC=new Map,pC=0;function mC(e,t){let n={id:e,obj:t,key:lC++};cC=[...cC,n];for(let e of uC)e();return()=>{cC=cC.filter(e=>e!==n);for(let e of uC)e()}}var hC=()=>cC;function gC(e){return uC.add(e),()=>void uC.delete(e)}function _C(e,t){let n=dC.get(e);return n||dC.set(e,n=new Set),n.add(t),()=>{n.delete(t),n.size||dC.delete(e)}}function vC(e,t=performance.now()){if(!nC(fC.get(e),t))return!1;fC.set(e,t),pC++;for(let t of dC.get(e)??[])t();return!0}var yC=()=>pC,bC=1.16,xC=`#1f1d2b`;function SC(e,t,n,r){let i=n-8-34;e.lineWidth=8,e.lineJoin=`round`,e.strokeStyle=xC,e.fillStyle=`#ffffff`,e.beginPath(),e.roundRect(8,8,t-16,i-8,40),e.fill(),e.stroke(),e.beginPath(),e.moveTo(62,i-6),e.lineTo(28,n-8),e.lineTo(104,i-6),e.fill(),e.beginPath(),e.moveTo(62,i),e.lineTo(28,n-8),e.lineTo(104,i),e.stroke(),e.fillStyle=`#e63946`,e.font=`700 ${r.length>2?84:100}px ${ES}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(r,t/2,(8+i)/2+4)}function CC({text:e,since:t}){let n=(0,v.useRef)(null),r=ZS(256,176,t=>SC(t,256,176,e),[e]);return G_(()=>{if(!n.current)return;let e=performance.now()-t,r=QS.ms-e,i=e<90?.3+e/90*.9:e<170?1.2-(e-90)/80*.2:r<150?Math.max(.01,r/150):1;n.current.scale.setScalar(i)}),(0,K.jsx)(Oy,{position:[.18,1.45,0],children:(0,K.jsx)(`group`,{ref:n,scale:.3,children:(0,K.jsxs)(`mesh`,{position:[.195,.156,0],renderOrder:2,children:[(0,K.jsx)(`planeGeometry`,{args:[.5,.344]}),(0,K.jsx)(`meshBasicMaterial`,{map:r,transparent:!0,toneMapped:!1,depthWrite:!1})]})})})}function wC(e,t){let n=W_(e=>e.camera),r=(0,v.useRef)(-1/0),[i,a]=(0,v.useState)(null),o=(0,v.useMemo)(()=>({w:0,flinch:0,headYaw:0,headPitch:0,twist:0}),[]),s=(0,v.useMemo)(()=>new V,[]);return(0,v.useEffect)(()=>{let n=t.current;return n?mC(e,n):void 0},[e,t]),(0,v.useEffect)(()=>_C(e,()=>{let e=performance.now();r.current=e,yb(),a({text:Math.random()<.65?`hey!`:`!`,since:e})}),[e]),(0,v.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>a(null),QS.ms);return()=>clearTimeout(e)},[i]),{pose:e=>{let i=e-r.current;o.w=iC(i),o.flinch=aC(i);let a=t.current;if(o.w===0||!a)return o.w=o.flinch=o.headYaw=o.headPitch=o.twist=0,o;a.worldToLocal(s.copy(n.position));let c=sC(s.x,s.z);return o.headYaw=c.head,o.twist=c.twist,o.headPitch=Math.min(.45,Math.max(-.3,Math.atan2(s.y-bC,Math.hypot(s.x,s.z)))),o},bubble:i&&(0,K.jsx)(CC,{text:i.text,since:i.since},i.since)}}var TC={pitch:-.34,yaw:.26},EC={typing:{l:TC,r:TC,lean:.1,headPitch:-.02,headYaw:0,type:1,mouse:0},browsing:{l:TC,r:{pitch:-.4,yaw:-.22},lean:.06,headPitch:.05,headYaw:.04,type:.25,mouse:1},thinking:{l:TC,r:{pitch:.55,yaw:.95},lean:.02,headPitch:.1,headYaw:-.12,type:.3,mouse:0},relaxed:{l:{pitch:-.9,yaw:.35},r:{pitch:-.9,yaw:.35},lean:-.1,headPitch:.06,headYaw:0,type:0,mouse:0},cheer:{l:{pitch:1.45,yaw:-.35},r:{pitch:1.45,yaw:-.35},lean:-.05,headPitch:.2,headYaw:0,type:0,mouse:0},slump:{l:{pitch:-1.35,yaw:-.15},r:{pitch:-1.35,yaw:-.15},lean:.25,headPitch:-.45,headYaw:0,type:0,mouse:0}},DC=e=>({...e,l:{...e.l},r:{...e.r}}),OC=`#1f1d2b`,kC=[`#1f1d2b`,`#7f5539`,`#1f1d2b`,`#c1121f`,`#355070`,`#1f1d2b`];function AC({agent:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(null),r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(DC(EC.relaxed)),o=(0,v.useRef)(Math.random()*100),s=(0,v.useRef)({name:null,at:0}),c=(0,v.useMemo)(()=>qx(e),[e.id,e.look,e.role]),l=(0,v.useRef)(null),u=wC(e.id,l);e.currentTool&&(s.current={name:e.currentTool,at:performance.now()}),G_((l,d)=>{let f=performance.now(),p=f/1e3+o.current,m=e.status===`working`||e.status===`preparing`,h=e.status===`done`&&e.endedAt!=null&&Date.now()-e.endedAt<7e3,g=f-s.current.at,_=s.current.name?.startsWith(`mcp__playwright`)&&g<4e3,v=m?e.status===`preparing`?`typing`:_?`browsing`:!e.currentTool&&g>2500?`thinking`:`typing`:e.status===`error`?`slump`:h?`cheer`:`relaxed`,y=EC[v],b=a.current,x=1-Math.exp(-d*5);for(let e of[`l`,`r`])b[e].pitch+=(y[e].pitch-b[e].pitch)*x,b[e].yaw+=(y[e].yaw-b[e].yaw)*x;for(let e of[`lean`,`headPitch`,`headYaw`,`type`,`mouse`])b[e]+=(y[e]-b[e])*x;let S=Math.sin(p*.8)+Math.sin(p*2.1)*.6>-.35?1:.15,C=b.type*S*.1,w=e.status===`preparing`?10:19,T=Math.max(0,Math.sin(p*w))*C,E=Math.max(0,Math.sin(p*w+2.4))*C*(1-b.mouse),D=Math.sin(p*3.1)*.05*b.type,O=Math.sin(p*2.7+1)*.05*b.type,k=Math.sin(p*1.9)*.06*b.mouse,A=(Math.sin(p*5.3)>.93?.04:0)*b.mouse,j=h?Math.sin(p*9)*.35:0,M=-(c.height-1)*.55,N=u.pose(f),ee=N.flinch*.55;if(r.current&&i.current&&(r.current.rotation.set(b.l.pitch+M+T+ee,-(b.l.yaw+D)+j,0),i.current.rotation.set(b.r.pitch+M+E-A+ee,b.r.yaw+O*(1-b.mouse)+k-j,0)),t.current&&(t.current.rotation.x=-b.lean+Math.sin(p*1.6)*.015+(m?Math.sin(p*9)*.006*S:0)+N.flinch*.2,t.current.rotation.y=N.twist*N.w),n.current){let t=m&&Math.sin(p*.55+2)>.92?-.22:0,r=e.status===`preparing`?Math.sin(p*1.3)*.5:Math.sin(p*.4)*.08,i=b.headPitch+t+(m?Math.sin(p*4.5)*.02*S:0),a=r+b.headYaw;n.current.rotation.set(i+(N.headPitch-i)*N.w,a+(N.headYaw-a)*N.w,(v===`thinking`?.12:0)*(1-N.w))}});let d=yS(e.skin),f=e.role===`qa`,p=e.role===`ceo`,m=e.look===`feminine`,h=e.status===`working`||e.status===`preparing`,g=yS(f?`#f8f9fa`:p?`#2b2d42`:e.color),_=yS(c.hair===`buzz`?wS(e.hair,e.skin,.35):e.hair),y=yS(OC),b=Vx[c.accent],x=e.status===`error`,S=gS.hair[c.hair],C=gS.facialHair[c.facialHair],w=gS.glasses[c.glasses],T=gS.headwear[c.headwear],E=gS.outfit[c.outfit],D=c.hair!==`buzz`&&c.hair!==`bald`,O=m&&c.headwear===`none`&&[`long`,`ponytail`,`bun`,`sidePart`,`curls`].includes(c.hair),k=c.headphones&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{geometry:gS.headphones.shell,material:yS(`#2b2d42`),castShadow:!0}),(0,K.jsx)(`mesh`,{geometry:gS.headphones.covers,material:yS(CS(e.color,.12))})]});return(0,K.jsxs)(`group`,{ref:l,children:[u.bubble,(0,K.jsx)(`mesh`,{geometry:gS.legs,material:yS(`#3d4a6b`),castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:OC,angle:0})}),(0,K.jsx)(`mesh`,{geometry:gS.shoes,material:y,castShadow:!0}),(0,K.jsxs)(`group`,{ref:t,position:[0,.5,-(c.height-1)*.25],scale:c.height,children:[(0,K.jsxs)(`group`,{scale:[c.shoulders,1,1],children:[(0,K.jsx)(`mesh`,{position:[0,.3,0],geometry:gS.torso,material:g,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.015,color:OC,angle:0})}),c.outfit!==`sweater`&&(0,K.jsx)(`mesh`,{position:[0,.5,-.02],rotation:[Math.PI/2,0,0],geometry:gS.collar,material:yS(p?`#f8f9fa`:CS(e.color,-.15))}),E.main&&(0,K.jsx)(`mesh`,{geometry:E.main,material:yS(CS(e.color,-.08)),castShadow:!0}),E.trim&&(0,K.jsx)(`mesh`,{geometry:E.trim,material:yS(c.outfit===`stripe`?b:c.outfit===`hoodie`?`#f8f9fa`:CS(e.color,-.14))}),p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{position:[0,.36,-.192],geometry:gS.shirtFront,material:yS(`#f8f9fa`)}),(0,K.jsx)(`mesh`,{position:[0,.33,-.206],geometry:gS.tie,material:yS(e.color)}),(0,K.jsx)(`mesh`,{position:[0,.445,-.206],geometry:gS.tieKnot,material:yS(CS(e.color,-.2))})]}),f&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{position:[0,.27,-.196],geometry:gS.coatOpening,material:yS(e.color)}),(0,K.jsx)(`mesh`,{position:[.1,.38,-.19],rotation:[.1,0,0],geometry:gS.badge,material:yS(`#ffd166`)})]}),!h&&k&&(0,K.jsx)(`group`,{position:[0,.49,-.09],rotation:[Math.PI/2-.5,0,0],scale:.74,children:k})]}),[{ref:r,x:-.25},{ref:i,x:.25}].map(({ref:e,x:t})=>(0,K.jsxs)(`group`,{ref:e,position:[t*c.shoulders,.44,0],children:[(0,K.jsx)(`mesh`,{position:[0,0,-.24],rotation:[Math.PI/2,0,0],geometry:gS.sleeve,material:g,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:OC,angle:0})}),(0,K.jsx)(`mesh`,{position:[0,0,-.5],geometry:gS.hand,material:d,castShadow:!0})]},t)),(0,K.jsxs)(`group`,{ref:n,position:[0,.66,0],children:[(0,K.jsx)(`mesh`,{geometry:gS.head,material:d,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.015,color:OC,angle:0})}),S&&(0,K.jsx)(`mesh`,{geometry:S,material:_,castShadow:D,children:D&&(0,K.jsx)(jy,{thickness:.012,color:OC,angle:0})}),(0,K.jsx)(`mesh`,{geometry:gS.ears,material:d}),(0,K.jsx)(`mesh`,{geometry:gS.eyes,material:y}),(0,K.jsx)(`mesh`,{position:[0,-.02,-.2],geometry:gS.nose,material:yS(CS(e.skin,-.08))}),(0,K.jsx)(`mesh`,{position:[0,x?-.1:-.075,-.175],rotation:[.25,0,x?0:Math.PI],geometry:gS.mouth,material:y}),C&&(0,K.jsx)(`mesh`,{geometry:C,material:yS(c.facialHair===`stubble`?wS(e.skin,e.hair,.3):e.hair)}),m&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{geometry:gS.lashes,material:y}),(0,K.jsx)(`mesh`,{geometry:gS.cheeks,material:yS(`#ff9aa2`)})]}),O&&(0,K.jsx)(`mesh`,{position:[.15,.13,-.08],rotation:[0,0,.5],geometry:gS.hairClip,material:yS(f?`#ff9f68`:CS(e.color,.15))}),f&&(0,K.jsx)(`mesh`,{geometry:gS.inspectorGlasses,material:y}),w&&(0,K.jsx)(`mesh`,{geometry:w,material:yS(kC[c.accent])}),T&&(0,K.jsx)(`mesh`,{geometry:T,material:yS(c.accent===0?CS(e.color,-.2):b),castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:OC,angle:0})}),h&&k]})]})]})}var jC=`#1f1d2b`;function J({size:e,position:t,rotation:n,color:r,outline:i=!1,shadow:a=!0,children:o}){return(0,K.jsxs)(`mesh`,{position:t,rotation:n,castShadow:a,receiveShadow:!0,material:yS(r),children:[(0,K.jsx)(`boxGeometry`,{args:e}),i&&(0,K.jsx)(jy,{thickness:.018,color:jC}),o]})}function MC({r:e,rTop:t,h:n,position:r,rotation:i,color:a,outline:o=!1,shadow:s=!0,seg:c=20}){return(0,K.jsxs)(`mesh`,{position:r,rotation:i,castShadow:s,receiveShadow:!0,material:yS(a),children:[(0,K.jsx)(`cylinderGeometry`,{args:[t??e,e,n,c]}),o&&(0,K.jsx)(jy,{thickness:.018,color:jC})]})}function NC({r:e,position:t,scale:n,color:r,outline:i=!1,shadow:a=!0}){return(0,K.jsxs)(`mesh`,{position:t,scale:n,castShadow:a,material:yS(r),children:[(0,K.jsx)(`sphereGeometry`,{args:[e,20,14]}),i&&(0,K.jsx)(jy,{thickness:.018,color:jC})]})}var PC={w:1,h:.6,px:896,py:538},FC=`#f1d19b`;function IC(e,t){let n=W_(e=>e.camera),{canvas:r,tex:i}=(0,v.useMemo)(()=>{let e=document.createElement(`canvas`);e.width=PC.px,e.height=PC.py;let t=new vs(e);return t.colorSpace=xt,t.anisotropy=8,{canvas:e,tex:t}},[]);(0,v.useEffect)(()=>()=>i.dispose(),[i]);let a=(0,v.useRef)(!0),o=(0,v.useRef)(0),s=(0,v.useRef)(null),c=(0,v.useRef)(e);c.current=e,(0,v.useEffect)(()=>{a.current=!0},[e]),(0,v.useEffect)(()=>q.subscribe((t,n)=>{if(t.logs[e.id]!==n.logs[e.id]&&(a.current=!0),t.screens[e.id]!==n.screens[e.id]){let n=new Image;n.onload=()=>{s.current=n,a.current=!0},n.src=`/api/agents/${e.id}/screen?t=${t.screens[e.id]}`}}),[e.id]),(0,v.useEffect)(()=>{let t=q.getState().screens[e.id];if(!t)return;let n=new Image;n.onload=()=>{s.current=n,a.current=!0},n.src=`/api/agents/${e.id}/screen?t=${t}`},[e.id]),(0,v.useEffect)(()=>{document.fonts?.ready.then(()=>a.current=!0)},[]);let l=(0,v.useMemo)(()=>new V,[]);return G_(()=>{let e=performance.now(),u=c.current,d=u.status===`working`||u.status===`preparing`||u.status===`idle`&&(q.getState().logs[u.id]?.length??0)<=1;if(!a.current&&!(d&&e-o.current>200))return;if(t.current){t.current.getWorldPosition(l);let r=l.distanceTo(n.position);if(r>16&&o.current!==0||r>8&&e-o.current<900)return}if(e-o.current<120)return;o.current=e,a.current=!1;let f=q.getState().logs[u.id]??[],p=u.screenshotAt!=null&&Date.now()-u.screenshotAt<12e4,m=u.hasScreenshot&&u.status!==`idle`&&(u.currentTool?.startsWith(`mcp__playwright`)||p||u.status===`done`),h=q.getState().settings,g=u.role!==`ceo`&&h.runtime===`terminal`?u.cli||h.defaultCli:`claude`;NS(r.getContext(`2d`),PC.px,PC.py,u,f,s.current,!!m,e,g),i.needsUpdate=!0}),i}function LC({agent:e}){let t=ZS(512,96,t=>VS(t,512,96,e),[e.name,e.status,e.issueNumber,e.currentTool,e.color]);return(0,K.jsx)(Oy,{position:[0,1.98,-.32],children:(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`planeGeometry`,{args:[1.15,.216]}),(0,K.jsx)(`meshBasicMaterial`,{map:t,transparent:!0,toneMapped:!1,depthWrite:!1})]})})}var RC={y:1.31,z:-.3,tilt:-.06},zC=`#2b2d42`,BC=`#3d4152`;function VC({accent:e,children:t}){return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(MC,{r:.17,rTop:.15,h:.025,position:[0,.782,RC.z-.04],color:BC,outline:!0}),(0,K.jsx)(J,{size:[.07,.36,.05],position:[0,.95,RC.z-.07],color:BC,outline:!0}),(0,K.jsxs)(`group`,{position:[0,RC.y,RC.z],rotation:[RC.tilt,0,0],children:[(0,K.jsx)(J,{size:[PC.w+.07,PC.h+.07,.05],color:zC,outline:!0}),(0,K.jsx)(J,{size:[.6,.36,.07],position:[0,0,-.055],color:BC}),t,(0,K.jsx)(`mesh`,{position:[0,0,-.091],rotation:[0,Math.PI,0],material:xS(e),children:(0,K.jsx)(`circleGeometry`,{args:[.06,24]})}),(0,K.jsx)(`mesh`,{position:[PC.w/2-.02,-PC.h/2-.018,.026],material:xS(`#7CFFB2`),children:(0,K.jsx)(`circleGeometry`,{args:[.008,10]})})]})]})}function HC({agent:e,accent:t}){let n=(0,v.useRef)(null),r=IC(e,n);return(0,K.jsx)(VC,{accent:t,children:(0,K.jsxs)(`mesh`,{ref:n,position:[0,0,.026],children:[(0,K.jsx)(`planeGeometry`,{args:[PC.w,PC.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:r,toneMapped:!1})]})})}function UC({accent:e,qa:t}){let n=ZS(640,384,e=>{e.fillStyle=`#151621`,e.fillRect(0,0,640,384),US(e,640,384,[{text:t?`🔍`:`🪑`,size:70},{text:t?`QA STATION`:`VACANT`,size:70,color:`#ffd6a5`},{text:t?`press E or click to hire a tester`:`press E or click to hire an agent`,size:36,color:`#a9adc6`,weight:500}],`rgba(0,0,0,0)`)},[t]);return(0,K.jsx)(VC,{accent:e,children:(0,K.jsxs)(`mesh`,{position:[0,0,.026],children:[(0,K.jsx)(`planeGeometry`,{args:[PC.w,PC.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,toneMapped:!1})]})})}function WC(){let e=ZS(512,176,e=>{e.fillStyle=`#d7dbe3`,e.fillRect(0,0,512,176),[14,13,12,11].forEach((t,n)=>{let r=(496-(t-1)*5)/t;for(let i=0;i<t;i++)e.fillStyle=n===0&&(i===0||i===t-1)?`#ffb4a2`:`#ffffff`,e.beginPath(),e.roundRect(8+i*(r+5),8+n*34,r,28,6),e.fill()}),e.fillStyle=`#ffffff`,e.beginPath(),e.roundRect(130,144,252,26,6),e.fill()},[]);return(0,K.jsxs)(`group`,{position:[0,.77,.27],children:[(0,K.jsx)(J,{size:[.52,.03,.18],position:[0,.015,0],color:`#c3c8d3`,outline:!0}),(0,K.jsxs)(`mesh`,{position:[0,.031,0],rotation:[-Math.PI/2,0,0],children:[(0,K.jsx)(`planeGeometry`,{args:[.5,.17]}),(0,K.jsx)(`meshToonMaterial`,{map:e})]}),(0,K.jsx)(`mesh`,{position:[.46,.002,.02],rotation:[-Math.PI/2,0,0],material:yS(`#3d4152`),children:(0,K.jsx)(`planeGeometry`,{args:[.24,.2]})}),(0,K.jsx)(`mesh`,{position:[.46,.022,.02],scale:[.75,.5,1],material:yS(`#f4f4f8`),castShadow:!0,children:(0,K.jsx)(`sphereGeometry`,{args:[.05,14,10]})})]})}var GC=`#dfe7ef`,KC=`#ff9f68`;function qC({agent:e,accent:t,repoId:n,position:r,role:i=`dev`,rotationY:a=0}){let o=i===`qa`,s=XS(e?{id:`agent-${e.id}`,label:e.role===`ceo`?`Open ${e.name}'s desk (CEO) · P texts them from anywhere`:`View ${e.name}'s ${o?`test run`:`terminal`}`,action:{kind:`terminal`,agentId:e.id}}:{id:`vacant-${i}-${n}-${r.join()}`,label:o?`Hire a QA tester for this station`:`Hire an agent for this desk`,action:{kind:`hire`,repoId:n,role:i}},3.6),c=e?CS(e.color,.1):`#ffffff`,l=o?GC:FC,u=o?KC:t;return(0,K.jsxs)(`group`,{ref:s,position:r,rotation:[0,a,0],children:[(0,K.jsx)(J,{size:[1.9,.06,.95],position:[0,.74,0],color:l,outline:!0}),[[-.88,-.42],[.88,-.42],[-.88,.42],[.88,.42]].map(([e,t])=>(0,K.jsx)(J,{size:[.06,.71,.06],position:[e,.355,t],color:`#5c677d`},`${e}${t}`)),(0,K.jsx)(J,{size:[1.76,.4,.03],position:[0,.5,-.44],color:CS(l,-.08)}),e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(HC,{agent:e,accent:t}),(0,K.jsx)(WC,{}),(0,K.jsx)(MC,{r:.045,h:.1,position:[.76,.82,.02],color:c,outline:!0}),(0,K.jsx)(LC,{agent:e})]}):(0,K.jsx)(UC,{accent:t,qa:o}),o?(0,K.jsxs)(`group`,{position:[-.72,.77,-.2],children:[(0,K.jsx)(J,{size:[.3,.05,.1],position:[0,.06,0],color:`#adb5bd`,outline:!0}),[`#ff6b6b`,`#4cc9f0`,`#80ed99`].map((e,t)=>(0,K.jsx)(MC,{r:.022,h:.16,position:[-.09+t*.09,.1,0],color:e,outline:!0},e))]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(MC,{r:.06,rTop:.07,h:.09,position:[-.76,.815,-.22],color:`#e07a5f`,outline:!0}),(0,K.jsx)(NC,{r:.09,position:[-.76,.92,-.22],color:`#52b788`,outline:!0})]}),(0,K.jsxs)(`group`,{position:[0,0,e?.8:.6],children:[(0,K.jsx)(J,{size:[.52,.08,.5],position:[0,.44,0],color:u,outline:!0}),(0,K.jsx)(J,{size:[.48,.42,.07],position:[0,.72,.28],color:u,outline:!0}),(0,K.jsx)(MC,{r:.035,h:.36,position:[0,.22,0],color:`#444a5c`}),(0,K.jsx)(MC,{r:.26,h:.04,position:[0,.03,0],color:`#444a5c`}),e&&(0,K.jsx)(AC,{agent:e})]})]})}var JC=`#b9c2cf`;function YC({floorLabel:e,accent:t}){let n=W_(e=>e.camera),r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(0),{doorHalf:o,cabinHalf:s,depth:c,doorHeight:l}=sx,u=12.15,d=XS({id:`elevator`,label:`Use the elevator`,action:{kind:`elevator`}},3.5),f=XS({id:`elevator-panel`,label:`Choose a floor`,action:{kind:`elevator`}},2.5),p=ZS(512,128,t=>US(t,512,128,[{text:e,size:56,color:`#7CFFB2`}],`#15151f`),[e]);return G_((e,t)=>{let s=q.getState().travel,c=n.position.x,l=n.position.z-u,d=Math.hypot(c,l)<2.8,f=s?.phase===`closing`?0:d||s?.phase===`opening`?1:0;a.current+=(f-a.current)*(1-Math.exp(-t*5));let p=a.current*o*.98;r.current&&(r.current.position.x=-o/2-p),i.current&&(i.current.position.x=o/2+p)}),(0,K.jsxs)(`group`,{children:[(0,K.jsxs)(`group`,{ref:d,children:[(0,K.jsx)(J,{size:[.22,l+.1,.36],position:[-o-.05,(l+.1)/2,12],color:JC,outline:!0}),(0,K.jsx)(J,{size:[.22,l+.1,.36],position:[o+.05,(l+.1)/2,12],color:JC,outline:!0}),(0,K.jsx)(J,{size:[o*2+.32,.22,.36],position:[0,l+.08,12],color:JC,outline:!0}),(0,K.jsx)(`mesh`,{ref:r,position:[-o/2,l/2,u],material:yS(`#d9dee6`),castShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,l,.06]})}),(0,K.jsx)(`mesh`,{ref:i,position:[o/2,l/2,u],material:yS(`#d9dee6`),castShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,l,.06]})})]}),(0,K.jsxs)(`mesh`,{position:[0,l+.55,11.97],rotation:[0,Math.PI,0],children:[(0,K.jsx)(`planeGeometry`,{args:[1.6,.4]}),(0,K.jsx)(`meshBasicMaterial`,{map:p,toneMapped:!1})]}),(0,K.jsxs)(`group`,{position:[o+.55,1.2,11.97],rotation:[0,Math.PI,0],children:[(0,K.jsx)(J,{size:[.22,.4,.04],position:[0,0,0],color:JC,outline:!0}),(0,K.jsx)(`mesh`,{position:[0,.08,.025],material:xS(t),children:(0,K.jsx)(`circleGeometry`,{args:[.05,20]})}),(0,K.jsx)(`mesh`,{position:[0,-.08,.025],material:xS(`#ffffff`),children:(0,K.jsx)(`circleGeometry`,{args:[.05,20]})})]}),(0,K.jsxs)(`group`,{position:[0,0,12],children:[(0,K.jsx)(`mesh`,{position:[0,.01,c/2],rotation:[-Math.PI/2,0,0],receiveShadow:!0,material:yS(`#8d7b68`),children:(0,K.jsx)(`planeGeometry`,{args:[s*2,c]})}),(0,K.jsx)(`mesh`,{position:[0,l+.2,c/2],rotation:[Math.PI/2,0,0],material:yS(`#f1f3f5`),children:(0,K.jsx)(`planeGeometry`,{args:[s*2,c]})}),(0,K.jsx)(`mesh`,{position:[0,l+.18,c/2],rotation:[Math.PI/2,0,0],material:xS(`#fff6d6`),children:(0,K.jsx)(`circleGeometry`,{args:[.45,32]})}),[-1,1].map(e=>(0,K.jsx)(`mesh`,{position:[e*(s+.05),ix/2,(c+.05)/2],material:yS(`#c8ced8`),children:(0,K.jsx)(`boxGeometry`,{args:[.1,ix,c-.05]})},e)),(0,K.jsx)(`mesh`,{position:[0,ix/2,c+.05],material:yS(`#c8ced8`),children:(0,K.jsx)(`boxGeometry`,{args:[s*2+.2,ix,.1]})}),(0,K.jsx)(J,{size:[s*2-.2,.05,.08],position:[0,.95,c-.05],color:`#e9c46a`,outline:!0}),(0,K.jsxs)(`group`,{ref:f,position:[s-.02,1.25,.9],rotation:[0,-Math.PI/2,0],children:[(0,K.jsx)(J,{size:[.36,.7,.04],position:[0,0,0],color:JC,outline:!0}),[.22,.08,-.06,-.2].map((e,n)=>(0,K.jsx)(`mesh`,{position:[0,e,.025],material:xS(n===0?t:`#fdfdfd`),children:(0,K.jsx)(`circleGeometry`,{args:[.04,16]})},e))]})]})]})}var XC=[1280,720],ZC=`#2b2d42`,QC=wS(`#7CFFB2`,`#fbf3e4`,.35),$C={running:`#7CFFB2`,error:`#ff6b6b`,preparing:`#ffd166`,installing:`#ffd166`,starting:`#ffd166`};function ew(e){return q(t=>{let n=null,r=0;for(let i of e){let e=t.screens[i.id];e&&e>r&&(r=e,n=i)}return n?`${n.id}|${r}|${n.name}`:null})}function tw({repo:e,agents:t}){let n=e.preview,r=n.status===`running`,i=e.fullName.split(`/`)[1]??e.fullName,a=ew(t),[o,s]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!r||!a)return s(null);let[e,t,n]=a.split(`|`),i=!0,o=new Image;return o.onload=()=>i&&s({img:o,by:n}),o.src=`/api/agents/${e}/screen?t=${t}`,()=>{i=!1,o.onload=null}},[r,a]);let c=ZS(XC[0],XC[1],t=>JS(t,XC[0],XC[1],{floor:e.floor,name:i,color:e.color,preview:n,shot:o?.img??null,shotBy:o?.by??null}),[e.floor,i,e.color,n.status,n.url,n.ref,n.commit,n.startedAt,n.error,o]),l=XS({id:`app-${e.id}`,label:`Open the app`,action:{kind:`app`,repoId:e.id}},6),u=bx,d=u.w+u.bezel*2,f=u.h+u.bezel*2;return(0,K.jsxs)(`group`,{ref:l,position:[u.x,u.y,-12],children:[r&&(0,K.jsx)(`mesh`,{position:[0,0,.012],material:xS(QC),children:(0,K.jsx)(`planeGeometry`,{args:[d+.18,f+.18]})}),(0,K.jsx)(J,{size:[d,f,u.depth],position:[0,0,u.depth/2],color:ZC,outline:!0,shadow:!1}),(0,K.jsxs)(`mesh`,{position:[0,0,u.depth+.002],children:[(0,K.jsx)(`planeGeometry`,{args:[u.w,u.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:c,toneMapped:!1})]}),(0,K.jsx)(`mesh`,{position:[u.w/2-.04,-u.h/2-u.bezel/2,u.depth+.002],material:xS($C[n.status]??`#6c7086`),children:(0,K.jsx)(`circleGeometry`,{args:[.022,12]})})]})}function nw({repo:e,agents:t}){let n=q(e=>e.qa),r=(0,v.useMemo)(()=>Gb(e,t,n),[e,t,n]),i=(0,v.useMemo)(()=>JSON.stringify([e.fullName,e.autoAssign,e.lastSync?Math.floor(e.lastSync/6e4):0,...Object.values(r).map(e=>e.map(e=>[e.key,e.title,e.note,e.agent?.name,e.agent?.color,e.tone]))]),[r,e]),a=Math.round(2560*yx.h/yx.w),o=ZS(2560,a,t=>zS(t,2560,a,e,r),[i]),s=XS({id:`board-${e.id}`,label:`Open the Kanban board`,action:{kind:`kanban`,repoId:e.id}},7),c=yx.y+yx.h/2;return(0,K.jsxs)(`group`,{ref:s,position:[0,0,yx.z],children:[(0,K.jsx)(J,{size:[yx.w+.24,yx.h+.24,.06],position:[0,c,.03],color:`#aab4c3`,outline:!0,shadow:!1}),(0,K.jsxs)(`mesh`,{position:[0,c,.065],children:[(0,K.jsx)(`planeGeometry`,{args:[yx.w,yx.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:o,toneMapped:!1})]}),(0,K.jsx)(J,{size:[3.2,.05,.16],position:[3.5,yx.y-.12,.1],color:`#aab4c3`,outline:!0}),[`#e63946`,`#1d3557`,`#2a9d8f`].map((e,t)=>(0,K.jsx)(MC,{r:.018,h:.16,position:[2.6+t*.22,yx.y-.075,.12],rotation:[0,0,Math.PI/2],color:e},e))]})}function rw({position:e,scale:t=1,pot:n=`#e07a5f`}){return(0,K.jsxs)(`group`,{position:e,scale:t,children:[(0,K.jsx)(MC,{r:.22,rTop:.28,h:.5,position:[0,.25,0],color:n,outline:!0}),(0,K.jsx)(NC,{r:.36,position:[0,.8,0],color:`#52b788`,outline:!0}),(0,K.jsx)(NC,{r:.28,position:[.2,1.05,.08],color:`#40916c`,outline:!0}),(0,K.jsx)(NC,{r:.25,position:[-.18,1.12,-.05],color:`#74c69d`,outline:!0}),(0,K.jsx)(NC,{r:.2,position:[.02,1.35,0],color:`#52b788`,outline:!0})]})}function iw({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(J,{size:[.45,1,.45],position:[0,.5,0],color:`#f1f3f5`,outline:!0}),(0,K.jsx)(MC,{r:.18,h:.5,position:[0,1.25,0],color:`#8ecae6`,outline:!0}),(0,K.jsx)(J,{size:[.08,.06,.06],position:[0,.8,-.24],color:`#457b9d`})]})}function aw({position:e,rotationY:t=0,color:n=`#6c63ff`}){let r=CS(n,-.12);return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(J,{size:[3,.42,1],position:[0,.25,0],color:n,outline:!0}),(0,K.jsx)(J,{size:[3,.6,.25],position:[0,.7,.38],color:r,outline:!0}),(0,K.jsx)(J,{size:[.25,.55,1],position:[-1.5,.45,0],color:r,outline:!0}),(0,K.jsx)(J,{size:[.25,.55,1],position:[1.5,.45,0],color:r,outline:!0}),(0,K.jsx)(J,{size:[.5,.4,.14],position:[-.9,.62,.22],color:`#ffd166`,outline:!0}),(0,K.jsx)(J,{size:[.5,.4,.14],position:[.9,.62,.22],color:`#ef476f`,outline:!0})]})}function ow({position:e,rotationY:t=0}){return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(J,{size:[1.3,.08,.8],position:[0,.42,0],color:`#f1d19b`,outline:!0}),(0,K.jsx)(J,{size:[1.1,.38,.6],position:[0,.2,0],color:`#c9a26b`}),(0,K.jsx)(MC,{r:.05,h:.1,position:[.3,.51,.1],color:`#ffffff`,outline:!0}),(0,K.jsx)(J,{size:[.3,.04,.22],position:[-.25,.48,-.05],color:`#4cc9f0`,outline:!0})]})}function sw({position:e}){let t=(0,v.useRef)(null);return G_(()=>{if(!t.current)return;let e=performance.now()/1e3;t.current.children.forEach((t,n)=>{let r=(e*.4+n/3)%1;t.position.y=r*.4,t.scale.setScalar(.5+r),t.material.opacity=.5*(1-r)})}),(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(J,{size:[.8,.9,4],position:[0,.45,0],color:`#8ecae6`,outline:!0}),(0,K.jsx)(J,{size:[.9,.06,4.1],position:[-.02,.93,0],color:`#f8f9fa`,outline:!0}),(0,K.jsx)(J,{size:[.45,.55,.4],position:[.05,1.24,-1.1],color:`#343a40`,outline:!0}),(0,K.jsx)(J,{size:[.3,.12,.3],position:[-.1,1.1,-1.1],color:`#495057`}),(0,K.jsx)(`mesh`,{position:[-.2,1.35,-1.1],rotation:[0,-Math.PI/2,0],material:xS(`#ff6b6b`),children:(0,K.jsx)(`circleGeometry`,{args:[.03,12]})}),(0,K.jsx)(MC,{r:.05,h:.1,position:[-.15,1.01,-1.1],color:`#ffffff`,outline:!0}),(0,K.jsx)(`group`,{ref:t,position:[-.15,1.1,-1.1],children:[0,1,2].map(e=>(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`sphereGeometry`,{args:[.03,8,6]}),(0,K.jsx)(`meshBasicMaterial`,{color:`#ffffff`,transparent:!0,opacity:.4,depthWrite:!1})]},e))}),(0,K.jsx)(MC,{r:.2,rTop:.24,h:.1,position:[0,1.01,.6],color:`#f4a261`,outline:!0}),(0,K.jsx)(NC,{r:.07,position:[.05,1.1,.55],color:`#e63946`}),(0,K.jsx)(NC,{r:.07,position:[-.06,1.1,.66],color:`#ffd166`}),(0,K.jsx)(NC,{r:.07,position:[.07,1.1,.7],color:`#80ed99`}),(0,K.jsx)(MC,{r:.1,rTop:.07,h:.25,position:[0,1.08,1.4],color:`#ced4da`,outline:!0}),(0,K.jsx)(J,{size:[.8,2,.8],position:[0,1,2.45],color:`#f1f3f5`,outline:!0}),(0,K.jsx)(J,{size:[.04,.5,.05],position:[-.42,1.3,2.2],color:`#adb5bd`})]})}function cw({position:e,size:t,color:n}){return(0,K.jsx)(`mesh`,{position:e,rotation:[-Math.PI/2,0,0],receiveShadow:!0,material:yS(n),children:(0,K.jsx)(`planeGeometry`,{args:t})})}function lw({position:e,rotationY:t=0}){let n=(0,v.useRef)(null),r=(0,v.useRef)(null);return G_(()=>{let e=new Date,t=e.getMinutes()+e.getSeconds()/60,i=e.getHours()%12+t/60;r.current&&(r.current.rotation.z=-(t/60)*Math.PI*2),n.current&&(n.current.rotation.z=-(i/12)*Math.PI*2)}),(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(MC,{r:.36,h:.06,rotation:[Math.PI/2,0,0],color:`#ffffff`,outline:!0,shadow:!1}),(0,K.jsx)(`group`,{ref:n,position:[0,0,.04],children:(0,K.jsx)(`mesh`,{position:[0,.1,0],material:yS(`#1f1d2b`),children:(0,K.jsx)(`boxGeometry`,{args:[.035,.2,.01]})})}),(0,K.jsx)(`group`,{ref:r,position:[0,0,.045],children:(0,K.jsx)(`mesh`,{position:[0,.14,0],material:yS(`#e63946`),children:(0,K.jsx)(`boxGeometry`,{args:[.025,.28,.01]})})})]})}function uw({position:e,rotationY:t=0}){let n=[`#e63946`,`#457b9d`,`#2a9d8f`,`#f4a261`,`#9b5de5`,`#ffbe0b`,`#06d6a0`];return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(J,{size:[4.8,2.2,.6],position:[0,1.1,0],color:`#b08968`,outline:!0}),[.35,.95,1.55].map((e,t)=>(0,K.jsxs)(`group`,{children:[(0,K.jsx)(J,{size:[4.6,.04,.55],position:[0,e-.25,.04],color:`#9c6644`,shadow:!1}),Array.from({length:14},(r,i)=>(0,K.jsx)(J,{size:[.14+i*t%3*.03,.34+(i+t)%4*.04,.4],position:[-2.1+i*.3,e-.05,.08],color:n[(i+t*3)%n.length],shadow:!1},i))]},e))]})}function dw({from:e,to:t,height:n=2.8}){let r=t[0]-e[0],i=t[1]-e[1],a=Math.hypot(r,i),o=(e[0]+t[0])/2,s=(e[1]+t[1])/2,c=-Math.atan2(i,r);return(0,K.jsxs)(`group`,{position:[o,0,s],rotation:[0,c,0],children:[(0,K.jsx)(`mesh`,{position:[0,n/2,0],material:SS,children:(0,K.jsx)(`boxGeometry`,{args:[a,n,.04]})}),(0,K.jsx)(J,{size:[a,.08,.1],position:[0,n,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(J,{size:[a,.08,.1],position:[0,.04,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(J,{size:[.08,n,.1],position:[-a/2,n/2,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(J,{size:[.08,n,.1],position:[a/2,n/2,0],color:`#8d99ae`,shadow:!1})]})}var fw=`#fbf3e4`;function pw({position:e,rotationY:t,width:n,seed:r}){let i=ZS(512,256,e=>WS(e,512,256,r),[r]),a=1.8;return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsxs)(`mesh`,{position:[0,0,.01],children:[(0,K.jsx)(`planeGeometry`,{args:[n,a]}),(0,K.jsx)(`meshBasicMaterial`,{map:i,toneMapped:!1})]}),(0,K.jsx)(J,{size:[n+.16,.1,.1],position:[0,a/2,.04],color:`#ffffff`,outline:!0,shadow:!1}),(0,K.jsx)(J,{size:[n+.16,.14,.18],position:[0,-1.8/2,.06],color:`#ffffff`,outline:!0,shadow:!1}),[-n/2,0,n/2].map(e=>(0,K.jsx)(J,{size:[.08,a,.1],position:[e,0,.04],color:`#ffffff`,shadow:!1},e))]})}function mw({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(J,{size:[1.4,.06,.5],position:[0,0,0],color:`#e9ecef`,shadow:!1}),(0,K.jsx)(`mesh`,{position:[0,-.035,0],rotation:[Math.PI/2,0,0],material:xS(`#fffbe8`),children:(0,K.jsx)(`planeGeometry`,{args:[1.25,.38]})})]})}function hw({accent:e,floorColor:t,westWindows:n=[-8,0,8],eastWindows:r=[-8,0],seed:i=1}){let a=yS(fw),o=.3,{doorHalf:s,doorHeight:c}=sx,l=(0,v.useMemo)(()=>{let e=[];for(let t=-12;t<=12;t+=6)for(let n=-8;n<=8;n+=5.5)e.push([t,ix-.04,n]);return e},[]),u=(0,v.useMemo)(()=>{let e=document.createElement(`canvas`);e.width=e.height=512;let n=e.getContext(`2d`);for(let e=0;e<8;e++){let r=e*173%512;for(let i=-r;i<512;i+=256){let a=(e*7+Math.floor((i+r)/256)*3)%5*.012-.024;n.fillStyle=CS(t,a),n.fillRect(i,e*64,256,64),n.fillStyle=CS(t,-.1),n.fillRect(i,e*64,3,64),n.fillStyle=CS(t,a-.035);for(let t=0;t<3;t++)n.fillRect(i+30+t*70,e*64+18+t*12,60,2)}n.fillStyle=CS(t,-.12),n.fillRect(0,e*64,512,3)}let r=new vs(e);return r.colorSpace=xt,r.wrapS=r.wrapT=w,r.repeat.set(8,6),r.anisotropy=8,r},[t]),d=16-s;return(0,K.jsxs)(`group`,{children:[(0,K.jsxs)(`mesh`,{rotation:[-Math.PI/2,0,0],receiveShadow:!0,children:[(0,K.jsx)(`planeGeometry`,{args:[32,24]}),(0,K.jsx)(`meshToonMaterial`,{map:u})]}),(0,K.jsx)(`mesh`,{rotation:[Math.PI/2,0,0],position:[0,ix,0],material:yS(`#f3efe6`),children:(0,K.jsx)(`planeGeometry`,{args:[32,24]})}),l.map(e=>(0,K.jsx)(mw,{position:e},e.join())),(0,K.jsx)(`mesh`,{position:[0,ix/2,-12-o/2],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[32.6,ix,o]})}),(0,K.jsx)(`mesh`,{position:[-16-o/2,ix/2,0],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,ix,24]})}),(0,K.jsx)(`mesh`,{position:[16.15,ix/2,0],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,ix,24]})}),[-1,1].map(e=>(0,K.jsx)(`mesh`,{position:[e*(s+d/2),ix/2,12.15],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[d,ix,o]})},e)),(0,K.jsx)(`mesh`,{position:[0,(ix+c)/2,12.15],material:a,children:(0,K.jsx)(`boxGeometry`,{args:[s*2,ix-c,o]})}),[{p:[0,0,-11.98],r:0,w:32},{p:[-15.98,0,0],r:Math.PI/2,w:24},{p:[15.98,0,0],r:-Math.PI/2,w:24},{p:[-(s+d/2),0,11.98],r:Math.PI,w:d},{p:[s+d/2,0,11.98],r:Math.PI,w:d}].map(({p:t,r:n,w:r},i)=>(0,K.jsxs)(`group`,{position:[t[0],0,t[2]],rotation:[0,n,0],children:[(0,K.jsx)(`mesh`,{position:[0,.06,0],material:yS(CS(e,-.2)),children:(0,K.jsx)(`boxGeometry`,{args:[r,.12,.04]})}),(0,K.jsx)(`mesh`,{position:[0,.95,0],material:yS(e),children:(0,K.jsx)(`boxGeometry`,{args:[r,.12,.03]})})]},i)),n.map((e,t)=>(0,K.jsx)(pw,{position:[-15.98,1.95,e],rotationY:Math.PI/2,width:5.5,seed:i*3+t},`w${e}`)),r.map((e,t)=>(0,K.jsx)(pw,{position:[15.98,1.95,e],rotationY:-Math.PI/2,width:5.5,seed:i*5+t+7},`e${e}`))]})}function gw(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`hemisphereLight`,{args:[`#fffaf0`,`#a48a6a`,.95]}),(0,K.jsx)(`ambientLight`,{intensity:.18}),(0,K.jsx)(`directionalLight`,{position:[9,14,7],intensity:1.55,castShadow:!0,"shadow-mapSize":[2048,2048],"shadow-camera-left":-18,"shadow-camera-right":18,"shadow-camera-top":14,"shadow-camera-bottom":-14,"shadow-camera-near":1,"shadow-camera-far":40,"shadow-bias":-6e-4,"shadow-normalBias":.03})]})}var _w=[{id:`blaster-orange`,body:`#ff8c1a`,trim:`#3a86ff`,foam:`#3a86ff`},{id:`blaster-blue`,body:`#3a86ff`,trim:`#ff8c1a`,foam:`#ff8c1a`}],vw=e=>_w.some(t=>t.id===e),yw={mag:12,gapMs:250,reloadMs:1e3};function bw(e,t){return e.reloadAt===null||t-e.reloadAt<yw.reloadMs?e:{ammo:yw.mag,reloadAt:null}}function xw(e,t){let n=bw(e,t);return n.reloadAt===null?null:Math.min(1,Math.max(0,(t-n.reloadAt)/yw.reloadMs))}function Sw(e,t,n){let r=bw(e,n);return r.reloadAt!==null||r.ammo<=0||n-t<yw.gapMs?null:{ammo:r.ammo-1,reloadAt:null}}function Cw(e,t){let n=bw(e,t);return n.reloadAt!==null||n.ammo>=yw.mag?null:{ammo:n.ammo,reloadAt:t}}function ww(e,t){return`Darts ${bw(e,t).ammo}/${yw.mag}`}var Tw={maxAngle:28*Math.PI/180,minSpeed:6};function Ew(e,t){let n=Math.hypot(e.x,e.y,e.z);return n<Tw.minSpeed?!1:-(e.x*t.x+e.y*t.y+e.z*t.z)/n>=Math.cos(Tw.maxAngle)}function Dw(e,t=40,n=1){let r=e.length+n-t;return r<=0?[]:[...e].sort((e,t)=>e.born-t.born).slice(0,r)}var Ow=.2,kw=null;function Aw(e){kw=e}var jw=()=>kw?.count()??0,Mw=()=>kw?.stuck()??0,Nw=()=>(kw?.loose()??[]).filter(e=>e.y<Ow),Pw=e=>kw?.remove(e)??!1,Fw={reach:.1,animMs:350},Iw=e=>e!==`charging`,Lw=(e,t,n,r)=>Math.hypot(n.x-e,n.z-t)<=r;function Rw(e,t,n,r,i){return Iw(e)?r.filter(e=>Lw(t,n,e,i+Fw.reach)):[]}var zw=0,Bw=(e=1)=>void(zw+=e),Vw=()=>zw,Hw=null,Uw=null,Ww=null;function Gw(e){Hw=e}function Kw(e){Uw=e}function qw(e){Ww=e}function Jw(){let{held:e,chargeAt:t}=q.getState(),n=null;try{n=Ww?Ww():null}catch{}let r={held:e,charging:t!==null,hoop:Uw?Uw():null,roomba:n,darts:jw(),dartsStuck:Mw(),reactions:yC(),vacuumed:Vw()};try{if(Hw)return{...Hw(),...r}}catch{}return{balls:[],bodies:0,...r}}typeof window<`u`&&!Object.getOwnPropertyDescriptor(window,`__swarmToys`)&&Object.defineProperty(window,"__swarmToys",{get:Jw,enumerable:!1,configurable:!1});var Yw=!1;function Xw(e){Yw||(Yw=!0,console.warn(`Office toys are switched off: the physics engine failed to load.`,e))}var Zw=()=>null,Qw=(0,v.lazy)(async()=>{try{let[e,t]=await Promise.all([Fy(()=>import(`./ToyWorld-DQTMvcEl.js`),__vite__mapDeps([0,1])),Fy(()=>import(`./rapier-DfUh5clU.js`).then(e=>e.o),[])]);return await t.init(),e}catch(e){return Xw(e),{default:Zw}}}),$w=class extends v.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`Office toys stopped on this floor after an error (the next floor gets fresh ones):`,e)}render(){return this.state.failed?null:this.props.children}},eT=(0,v.memo)(function({floor:e}){return Yw?null:(0,K.jsx)($w,{children:(0,K.jsx)(v.Suspense,{fallback:null,children:(0,K.jsx)(Qw,{floor:e})})})});function tT({position:e,size:t,px:n,draw:r,deps:i,rotationY:a=Math.PI}){let o=ZS(n[0],n[1],r,i);return(0,K.jsxs)(`mesh`,{position:e,rotation:[0,a,0],children:[(0,K.jsx)(`planeGeometry`,{args:t}),(0,K.jsx)(`meshBasicMaterial`,{map:o,transparent:!0,toneMapped:!1})]})}function nT({repo:e}){let t=q(e=>e.agents),n=(0,v.useMemo)(()=>zb(t,e.id),[t,e.id]),r=(0,v.useMemo)(()=>new Map(n.filter(e=>e.role===`dev`).map(e=>[e.desk,e])),[n]),i=(0,v.useMemo)(()=>new Map(n.filter(e=>e.role===`qa`).map(e=>[e.desk,e])),[n]),a=n.filter(e=>e.status===`working`||e.status===`preparing`).length,o=q(e=>e.qa),s=Object.values(o).filter(t=>t.repoId===e.id&&t.status!==`passed`).length,c=Object.values(o).filter(t=>t.repoId===e.id&&t.status===`passed`).length,l=e.fullName.split(`/`)[1]??e.fullName,u=CS(e.color,.24);return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(hw,{accent:e.color,floorColor:`#d9b48a`,seed:e.floor}),_x.map(e=>(0,K.jsx)(cw,{position:[(e.minX+e.maxX)/2,.004,(e.minZ+e.maxZ)/2],size:[e.maxX-e.minX,e.maxZ-e.minZ],color:u},e.minZ)),Array.from({length:hx},(t,n)=>{let{x:i,z:a}=vx(n);return(0,K.jsx)(qC,{agent:r.get(n)??null,accent:e.color,repoId:e.id,position:[i,0,a]},n)}),(0,K.jsx)(cw,{position:[(Ex.minX+Ex.maxX)/2,.005,(Ex.minZ+Ex.maxZ)/2],size:[Ex.maxX-Ex.minX,Ex.maxZ-Ex.minZ],color:`#ffd8bf`}),Cx.stations.map((t,n)=>{let{x:r,z:a}=Tx(n);return(0,K.jsx)(qC,{role:`qa`,rotationY:wx,agent:i.get(n)??null,accent:e.color,repoId:e.id,position:[r,0,a]},`qa${n}`)}),(0,K.jsx)(tT,{position:[15.97,3.2,-2],rotationY:-Math.PI/2,size:[3.2,.55],px:[768,132],draw:e=>US(e,768,132,[{text:`🔍 QA LAB · ${s} in testing`,size:56}],`#ff9f68`),deps:[s]}),(0,K.jsx)(nw,{repo:e,agents:n}),(0,K.jsx)(tw,{repo:e,agents:n}),(0,K.jsx)(YC,{floorLabel:`▲ ${e.floor} · ${l}`,accent:e.color}),(0,K.jsx)(eT,{floor:`office`}),(0,K.jsx)(tT,{position:[-4.6,1.95,11.97],size:[4.2,1.3],px:[1024,317],draw:t=>US(t,1024,317,[{text:`FLOOR ${e.floor}`,size:58,color:`rgba(255,255,255,0.85)`,weight:600},{text:e.fullName,size:74},{text:e.description||`no description`,size:36,weight:500,color:`rgba(255,255,255,0.85)`}],e.color),deps:[e.floor,e.fullName,e.description,e.color]}),(0,K.jsx)(tT,{position:[4.6,1.95,11.97],size:[4.2,1.3],px:[1024,317],draw:t=>US(t,1024,317,[{text:`👩💻 ${n.length} on the team`,size:54,color:`#2d3142`},{text:`⚙️ ${a} busy · 🔍 ${s} in QA · ✅ ${c} to merge`,size:46,color:`#2d3142`,weight:600},{text:`📋 ${e.issues.length} open issue${e.issues.length===1?``:`s`}${e.autoAssign?` · ⚡ auto`:``}`,size:44,color:`#5c6078`,weight:500}],`#fffdf5`),deps:[n.length,a,s,c,e.issues.length,e.autoAssign]}),(0,K.jsx)(rw,{position:[-7.1,0,-11.3]}),(0,K.jsx)(rw,{position:[7.1,0,-11.3]}),(0,K.jsx)(rw,{position:[-15.3,0,11.2],scale:1.2}),(0,K.jsx)(rw,{position:[-11,0,-11.3],scale:1.1}),(0,K.jsx)(rw,{position:[15.3,0,11.3],scale:.9,pot:`#8338ec`}),(0,K.jsx)(aw,{position:[-15.1,0,6.5],rotationY:-Math.PI/2,color:CS(e.color,-.05)}),(0,K.jsx)(ow,{position:[-13.4,0,6.5],rotationY:Math.PI/2}),(0,K.jsx)(sw,{position:[15.55,0,7]}),(0,K.jsx)(iw,{position:[15.5,0,-9.5]}),(0,K.jsx)(lw,{position:[-10,2.75,-11.95]}),(0,K.jsx)(tT,{position:[10,2.2,-11.97],rotationY:0,size:[2.2,1.4],px:[512,326],draw:e=>US(e,512,326,[{text:`🚀`,size:90},{text:`SHIP IT`,size:64},{text:`small PRs, happy reviewers`,size:26,weight:500}],`#3a86ff`),deps:[]})]})}var rT=`#ff8a5b`,iT=`#9b5de5`;function aT(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.settings),r=q(e=>e.qa),i=q(e=>e.requests);return(0,v.useMemo)(()=>{let a=Object.values(t),o=a.filter(e=>e.status===`working`||e.status===`preparing`).length,s=e.reduce((e,t)=>e+t.pulls.filter(e=>e.state===`OPEN`).length,0),c=e.reduce((e,t)=>e+t.pulls.filter(e=>e.state===`MERGED`).length,0),l=e.reduce((e,t)=>e+t.issues.length,0),u=e.map(e=>({floor:e.floor,name:e.fullName,color:e.color,team:a.filter(t=>t.repoId===e.id).length,working:a.filter(t=>t.repoId===e.id&&(t.status===`working`||t.status===`preparing`)).length,prs:e.pulls.filter(e=>e.state===`OPEN`).length})),d=Object.values(r),f=d.filter(e=>e.status!==`passed`).length,p=d.filter(e=>e.status===`passed`).length,m=Ub(i).length;return{repos:e.length,agents:a.length,working:o,openPrs:s,inQa:f,readyToMerge:p,merged:c,issues:l,floors:u,max:n.sessionLimit,pending:m}},[e,t,n,r,i])}function oT(){let e=aT(),t=XS({id:`manager-console`,label:`Open the manager's console`,action:{kind:`manager`}},3.2),n=ZS(1024,640,t=>{let n=t.createLinearGradient(0,0,1024,640);n.addColorStop(0,`#20224a`),n.addColorStop(1,`#3a1f4d`),t.fillStyle=n,t.fillRect(0,0,1024,640),t.fillStyle=`#ffd6a5`,t.font=`700 54px ${ES}`,t.textBaseline=`middle`,t.fillText(`✻ Manager Console`,50,70),[[`Floors (repos)`,`${e.repos}`],[`Agents on staff`,`${e.agents}`],[`Sessions running`,e.max?`${e.working} / ${e.max}`:`${e.working}`],[`Open issues`,`${e.issues}`],[`PRs in QA / ready to merge`,`${e.inQa} / ${e.readyToMerge}`],[`📄 Hiring decisions waiting`,`${e.pending}`]].forEach(([e,n],r)=>{let i=150+r*68;DS(t,50,i-30,924,60,16),t.fillStyle=`rgba(255,255,255,0.07)`,t.fill(),t.fillStyle=`#c9c9ee`,t.font=`500 34px ${ES}`,t.fillText(e,76,i),t.fillStyle=`#ffffff`,t.font=`700 38px ${ES}`,t.textAlign=`right`,t.fillText(n,948,i),t.textAlign=`left`}),t.fillStyle=`#7CFFB2`,t.font=`600 32px ${ES}`,t.fillText(`Press E or click to manage floors, team & issues`,50,592)},[e]);return(0,K.jsxs)(`group`,{ref:t,position:[kx.x,0,kx.z],children:[(0,K.jsx)(J,{size:[kx.w,.08,kx.d],position:[0,.76,0],color:`#8d5a3b`,outline:!0}),(0,K.jsx)(J,{size:[kx.w-.1,.72,.06],position:[0,.37,-kx.d/2+.05],color:`#6f4530`}),(0,K.jsx)(J,{size:[.08,.72,kx.d-.1],position:[-kx.w/2+.08,.37,0],color:`#6f4530`}),(0,K.jsx)(J,{size:[.08,.72,kx.d-.1],position:[kx.w/2-.08,.37,0],color:`#6f4530`}),(0,K.jsx)(J,{size:[.1,.34,.1],position:[0,.97,-.15],color:`#adb5bd`}),(0,K.jsx)(J,{size:[.4,.03,.26],position:[0,.815,-.15],color:`#adb5bd`,outline:!0}),(0,K.jsx)(J,{size:[1.42,.92,.06],position:[0,1.55,-.18],color:`#343a40`,outline:!0}),(0,K.jsxs)(`mesh`,{position:[0,1.55,-.145],children:[(0,K.jsx)(`planeGeometry`,{args:[1.34,.84]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,toneMapped:!1})]}),(0,K.jsx)(J,{size:[.5,.025,.16],position:[0,.815,.25],color:`#f4f4f8`,outline:!0}),(0,K.jsx)(MC,{r:.05,h:.11,position:[.9,.855,.1],color:`#ffd166`,outline:!0}),(0,K.jsx)(J,{size:[.3,.2,.03],position:[-.95,.9,-.1],rotation:[-.3,.3,0],color:`#e9c46a`,outline:!0}),(0,K.jsxs)(`group`,{position:[0,0,-1.1],children:[(0,K.jsx)(J,{size:[.64,.12,.6],position:[0,.48,0],color:`#2b2d42`,outline:!0}),(0,K.jsx)(J,{size:[.62,.8,.12],position:[0,.95,-.3],color:`#2b2d42`,outline:!0}),(0,K.jsx)(MC,{r:.04,h:.4,position:[0,.22,0],color:`#6c757d`}),(0,K.jsx)(MC,{r:.3,h:.04,position:[0,.03,0],color:`#6c757d`})]})]})}function sT(){let e=aT(),t=XS({id:`directory`,label:`Floor directory — take the elevator`,action:{kind:`elevator`}},4),n=ZS(768,560,t=>{DS(t,0,0,768,560,30),t.fillStyle=`#23263a`,t.fill(),t.fillStyle=`#ffd6a5`,t.font=`700 46px ${ES}`,t.textBaseline=`middle`,t.fillText(`Directory`,36,52);let n=[...e.floors].sort((e,t)=>t.floor-e.floor).slice(0,7);n.forEach((e,n)=>{let r=118+n*58;t.fillStyle=e.color,DS(t,36,r-22,54,44,12),t.fill(),t.fillStyle=`#1f2233`,t.font=`700 30px ${ES}`,t.textAlign=`center`,t.fillText(String(e.floor),63,r+1),t.textAlign=`left`,t.fillStyle=`#ffffff`,t.font=`600 28px ${ES}`;let i=e.name.length>24?`${e.name.slice(0,23)}…`:e.name;t.fillText(i,108,r),t.fillStyle=`#a9adc6`,t.font=`500 24px ${ES}`,t.textAlign=`right`,t.fillText(`${e.working}/${e.team} busy · ${e.prs} PR`,740,r),t.textAlign=`left`});let r=118+n.length*58;t.fillStyle=rT,DS(t,36,r-22,54,44,12),t.fill(),t.fillStyle=`#1f2233`,t.font=`700 30px ${ES}`,t.textAlign=`center`,t.fillText(`G`,63,r+1),t.textAlign=`left`,t.fillStyle=`#ffffff`,t.font=`600 28px ${ES}`,t.fillText(`Lobby & manager's office`,108,r),e.floors.length===0&&(t.fillStyle=`#a9adc6`,t.font=`500 26px ${ES}`,t.fillText(`No floors yet: connect a repo in the`,36,r+80),t.fillText(`manager's office (back left corner).`,36,r+116))},[e]);return(0,K.jsx)(`group`,{ref:t,position:[4.4,1.75,11.97],rotation:[0,Math.PI,0],children:(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`planeGeometry`,{args:[2.6,1.9]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,transparent:!0,toneMapped:!1})]})})}function cT(){let e=aT(),t=ZS(512,160,t=>US(t,512,160,[{text:`🏆 ${e.merged} PRs merged`,size:50,color:`#2d3142`}],`#ffe8a3`),[e.merged]),n=Math.min(8,e.merged);return(0,K.jsxs)(`group`,{position:[12,0,-11.45],children:[(0,K.jsx)(J,{size:[4.4,2.1,1],position:[0,1.05,0],color:`#b08968`,outline:!0}),(0,K.jsx)(J,{size:[4.1,1.2,.8],position:[0,1.2,.12],color:`#fdf6e3`,shadow:!1}),(0,K.jsx)(J,{size:[4.1,.04,.8],position:[0,1.2,.12],color:`#b08968`,shadow:!1}),Array.from({length:n},(e,t)=>(0,K.jsxs)(`group`,{position:[-1.7+t%4*1.1,t<4?.62:1.22,.2],children:[(0,K.jsx)(MC,{r:.08,rTop:.16,h:.22,position:[0,.2,0],color:`#ffd43b`,outline:!0}),(0,K.jsx)(MC,{r:.03,h:.1,position:[0,.05,0],color:`#ffd43b`}),(0,K.jsx)(J,{size:[.2,.04,.2],position:[0,.01,0],color:`#495057`})]},t)),(0,K.jsxs)(`mesh`,{position:[0,2.45,.02],children:[(0,K.jsx)(`planeGeometry`,{args:[2.4,.75]}),(0,K.jsx)(`meshBasicMaterial`,{map:t,transparent:!0,toneMapped:!1})]})]})}function lT(){let e=q(e=>e.agents.ceo),t=q(e=>e.ceo),n=Ub(q(e=>e.requests)).length,r=e?.status===`working`?t.job?.label??`Working`:`Free for a chat (press P)`,i=t.queue.length?`${t.queue[0].label}${t.queue.length>1?` (+${t.queue.length-1})`:``}`:`nothing queued`;return(0,K.jsx)(tT,{position:[15.97,2.05,Mx.z],rotationY:-Math.PI/2,size:[3.4,1.9],px:[816,456],draw:t=>US(t,816,456,[{text:`🧠 ${e?.name??`CEO`}'s board`,size:54},{text:`Now: ${r}`,size:36,weight:600},{text:`Next: ${i}`,size:32,weight:500,color:`rgba(255,255,255,0.8)`},{text:n?`📄 ${n} candidate${n===1?``:`s`} waiting for you`:`📄 no candidates waiting`,size:34,weight:600,color:n?`#ffe066`:`#ffffff`}],`#3c2a63`),deps:[e?.name,r,i,n]})}function uT(){let e=jx,t=q(e=>e.agents.ceo);return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(cw,{position:[(e.minX+e.maxX)/2,.005,(e.minZ+e.maxZ)/2],size:[e.maxX-e.minX,e.maxZ-e.minZ],color:`#e6dcff`}),(0,K.jsx)(dw,{from:[e.minX,e.minZ],to:[e.minX,e.maxZ]}),(0,K.jsx)(dw,{from:[e.minX,e.maxZ],to:[e.doorMinX,e.maxZ]}),(0,K.jsx)(dw,{from:[e.doorMaxX,e.maxZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(J,{size:[e.doorMaxX-e.doorMinX,.5,.1],position:[(e.doorMinX+e.doorMaxX)/2,2.55,e.maxZ],color:`#8d99ae`}),(0,K.jsx)(tT,{position:[(e.doorMinX+e.doorMaxX)/2,3.1,e.maxZ+.06],rotationY:0,size:[3.4,.5],px:[816,120],draw:e=>US(e,816,120,[{text:`CEO${t?` · ${t.name}`:``}`,size:52}],iT),deps:[t?.name]}),t&&(0,K.jsx)(qC,{agent:t,accent:iT,repoId:``,position:[Mx.x,0,Mx.z]}),(0,K.jsx)(lT,{}),(0,K.jsx)(rw,{position:[e.maxX-.7,0,e.maxZ-.7],scale:1.1,pot:iT}),(0,K.jsx)(rw,{position:[e.minX+.6,0,e.maxZ-.6],scale:.9})]})}function dT(e){return{id:e.id,name:e.name,repoId:e.repoId,role:e.role,title:e.title,specialty:e.specialty,brief:e.brief,hiredBy:`ceo`,look:e.look,task:null,desk:0,color:e.color,hair:e.hair,skin:e.skin,model:e.model,effort:e.effort,cli:``,terminal:!1,status:`idle`,issueNumber:null,issueTitle:null,branch:null,prNumber:null,prUrl:null,currentTool:null,startedAt:null,endedAt:null,costUsd:0,turns:0,browserUrl:null,hasScreenshot:!1,screenshotAt:null,lastError:null}}function fT({req:e}){let t=q(t=>t.repos.find(t=>t.id===e.repoId)?.floor??null),n=ZS(512,128,n=>HS(n,512,128,e.name,e.title,t,e.color),[e.name,e.title,t,e.color]);return(0,K.jsx)(Oy,{position:[0,1.95,-.1],children:(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`planeGeometry`,{args:[1.15,.29]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,transparent:!0,toneMapped:!1,depthWrite:!1})]})})}function pT({z:e,req:t}){let n=XS(t?{id:`candidate-${t.id}`,label:`Read ${t.name}'s resume (${t.title})`,action:{kind:`phone`,tab:`hires`,requestId:t.id}}:null,3.2),r=(0,v.useMemo)(()=>t?dT(t):null,[t]),i=`#06d6a0`;return(0,K.jsxs)(`group`,{ref:n,position:[Nx.x,0,e],rotation:[0,Px,0],children:[(0,K.jsx)(J,{size:[.52,.08,.5],position:[0,.44,0],color:i,outline:!0}),(0,K.jsx)(J,{size:[.48,.42,.07],position:[0,.72,.28],color:i,outline:!0}),[[-.22,-.2],[.22,-.2],[-.22,.2],[.22,.2]].map(([e,t])=>(0,K.jsx)(J,{size:[.05,.42,.05],position:[e,.2,t],color:`#444a5c`},`${e}${t}`)),r&&(0,K.jsx)(AC,{agent:r}),t&&(0,K.jsx)(fT,{req:t})]})}function mT(){let e=q(e=>e.requests),t=(0,v.useMemo)(()=>Ub(e).filter(e=>e.kind===`hire`),[e]),n=t.length;return(0,K.jsxs)(`group`,{children:[Nx.seats.map((e,n)=>(0,K.jsx)(pT,{z:e,req:t[n]??null},e)),(0,K.jsx)(tT,{position:[15.97,2.5,(Nx.seats[0]+Nx.seats[Nx.seats.length-1])/2],rotationY:-Math.PI/2,size:[3.6,.62],px:[864,150],draw:e=>US(e,864,150,[{text:n?`🪑 Waiting room · ${n} candidate${n===1?``:`s`}${n>Nx.seats.length?` (${n-Nx.seats.length} more outside)`:``}`:`🪑 Waiting room`,size:50}],`#06a77d`),deps:[n]})]})}function hT(){let e=Ox,t=q(e=>e.user),n=q(e=>e.settings.managerName),r=q(e=>e.settings.companyName),i=n||t;return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(hw,{accent:rT,floorColor:`#e2c7a3`,westWindows:[1.5,8],eastWindows:[-2.5,3.6],seed:0}),(0,K.jsx)(cw,{position:[(Fx.minX+Fx.maxX)/2,.004,(Fx.minZ+Fx.maxZ)/2],size:[Fx.maxX-Fx.minX,Fx.maxZ-Fx.minZ],color:`#ffd6a5`}),(0,K.jsx)(cw,{position:[(e.minX+e.maxX)/2,.005,(e.minZ+e.maxZ)/2],size:[e.maxX-e.minX,e.maxZ-e.minZ],color:`#cde7e1`}),(0,K.jsx)(dw,{from:[e.maxX,e.minZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(dw,{from:[e.minX,e.maxZ],to:[e.doorMinX,e.maxZ]}),(0,K.jsx)(dw,{from:[e.doorMaxX,e.maxZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(J,{size:[e.doorMaxX-e.doorMinX,.5,.1],position:[(e.doorMinX+e.doorMaxX)/2,2.55,e.maxZ],color:`#8d99ae`}),(0,K.jsx)(tT,{position:[(e.doorMinX+e.doorMaxX)/2,3.1,e.maxZ+.06],rotationY:0,size:[3.4,.5],px:[816,120],draw:e=>US(e,816,120,[{text:`MANAGER${i?` · ${i}`:``}`,size:52}],`#2b2d42`),deps:[i]}),(0,K.jsx)(oT,{}),(0,K.jsx)(uw,{position:[-15.6,0,-8],rotationY:Math.PI/2}),(0,K.jsx)(rw,{position:[e.maxX-.6,0,e.minZ+.6],scale:1.1,pot:`#3a86ff`}),(0,K.jsx)(rw,{position:[e.minX+.6,0,e.maxZ-.6],scale:.9}),(0,K.jsx)(tT,{position:[kx.x,2.3,-11.97],rotationY:0,size:[2.4,1.2],px:[512,256],draw:e=>US(e,512,256,[{text:`⭐`,size:70},{text:`World’s Best`,size:44,weight:600},{text:`Agent Wrangler`,size:50}],`#9b5de5`),deps:[]}),(0,K.jsxs)(`group`,{position:[Ax.x,0,Ax.z],children:[(0,K.jsx)(J,{size:[Ax.w,1.05,Ax.d],position:[0,.525,0],color:`#ffffff`,outline:!0}),(0,K.jsx)(J,{size:[Ax.w+.1,.08,Ax.d+.1],position:[0,1.09,0],color:rT,outline:!0}),(0,K.jsx)(J,{size:[Ax.w-.4,.3,.02],position:[0,.6,Ax.d/2+.01],color:CS(rT,.15),shadow:!1}),(0,K.jsxs)(`group`,{position:[0,1.13,-.1],children:[(0,K.jsx)(MC,{r:.2,rTop:.16,h:.4,position:[0,.2,0],color:`#e9ecef`,outline:!0}),(0,K.jsx)(NC,{r:.22,position:[0,.58,0],color:`#f8f9fa`,outline:!0}),(0,K.jsx)(`mesh`,{position:[-.08,.6,.2],material:xS(`#4cc9f0`),children:(0,K.jsx)(`sphereGeometry`,{args:[.035,10,8]})}),(0,K.jsx)(`mesh`,{position:[.08,.6,.2],material:xS(`#4cc9f0`),children:(0,K.jsx)(`sphereGeometry`,{args:[.035,10,8]})}),(0,K.jsx)(MC,{r:.012,h:.2,position:[0,.88,0],color:`#adb5bd`}),(0,K.jsx)(`mesh`,{position:[0,.99,0],material:xS(rT),children:(0,K.jsx)(`sphereGeometry`,{args:[.045,10,8]})})]})]}),(0,K.jsx)(tT,{position:[3,2.25,-11.97],rotationY:0,size:[7,1.6],px:[1400,320],draw:e=>US(e,1400,320,[{text:`✻ ${r||`cubefarm`}`,size:120},{text:r?`powered by a team of AI coding agents`:`a team of AI coding agents`,size:48,weight:500}],rT),deps:[r]}),(0,K.jsx)(uT,{}),(0,K.jsx)(mT,{}),(0,K.jsx)(YC,{floorLabel:`▲ G · Lobby`,accent:rT}),(0,K.jsx)(eT,{floor:`lobby`}),(0,K.jsx)(sT,{}),(0,K.jsx)(cT,{}),(0,K.jsx)(lw,{position:[8.4,2.8,-11.95]}),(0,K.jsx)(aw,{position:[11.5,0,4],rotationY:Math.PI,color:`#4cc9f0`}),(0,K.jsx)(ow,{position:[11.5,0,6.2]}),(0,K.jsx)(rw,{position:[15.3,0,11.3],scale:1.2}),(0,K.jsx)(rw,{position:[-15.3,0,11.3],scale:1.2,pot:`#06d6a0`}),(0,K.jsx)(rw,{position:[-3,0,11.4]}),(0,K.jsx)(rw,{position:[3,0,-11.3],scale:.8})]})}async function gT(e,t,n){let r=await fetch(t,{method:e,headers:n===void 0?void 0:{"Content-Type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)}),i=await r.json().catch(()=>({}));if(!r.ok){let e=i.error??`${r.status} ${r.statusText}`;throw q.getState().pushToast(`error`,e),Error(e)}return i}var _T=e=>`/api/repos/${encodeURIComponent(e)}`,Y={githubRepos:e=>gT(`GET`,`/api/github/repos${e?`?owner=${encodeURIComponent(e)}`:``}`),connectRepo:(e,t={})=>gT(`POST`,`/api/repos`,{fullName:e,...t}),createRepo:e=>gT(`POST`,`/api/repos/new`,e),folders:e=>gT(`GET`,`/api/folders${e?`?dir=${encodeURIComponent(e)}`:``}`),connectFolder:(e,t={})=>gT(`POST`,`/api/folders/connect`,{path:e,...t}),publishFolder:e=>gT(`POST`,`/api/folders/publish`,e),setup:e=>gT(`POST`,`/api/setup`,e),updateRepo:(e,t)=>gT(`PATCH`,_T(e),t),startPreview:(e,t)=>gT(`POST`,`${_T(e)}/preview`,t?{pr:t}:{}),stopPreview:e=>gT(`DELETE`,`${_T(e)}/preview`),disconnectRepo:e=>gT(`DELETE`,_T(e)),syncRepo:e=>gT(`POST`,`${_T(e)}/sync`),syncFolder:e=>gT(`POST`,`${_T(e)}/sync-folder`),createIssue:(e,t,n,r,i)=>gT(`POST`,`${_T(e)}/issues`,{title:t,body:n,assignTo:r,specialty:i}),planFloor:(e,t)=>gT(`POST`,`${_T(e)}/plan`,{mission:t}),onboardFloor:e=>gT(`POST`,`${_T(e)}/onboard`),mergePull:(e,t,n=`squash`)=>gT(`POST`,`${_T(e)}/pulls/${t}/merge`,{method:n}),closePull:(e,t)=>gT(`POST`,`${_T(e)}/pulls/${t}/close`),sendToQa:(e,t)=>gT(`POST`,`${_T(e)}/pulls/${t}/qa`),hireAgent:(e,t={})=>gT(`POST`,`${_T(e)}/agents`,t),updateAgent:(e,t)=>gT(`PATCH`,`/api/agents/${e}`,t),fireAgent:e=>gT(`DELETE`,`/api/agents/${e}`),assign:(e,t,n)=>gT(`POST`,`/api/agents/${e}/assign`,{issueNumber:t,note:n}),stop:e=>gT(`POST`,`/api/agents/${e}/stop`),reset:e=>gT(`POST`,`/api/agents/${e}/reset`),message:(e,t)=>gT(`POST`,`/api/agents/${e}/message`,{text:t}),updateSettings:e=>gT(`PATCH`,`/api/settings`,e),updateOffice:async e=>{let t=await gT(`POST`,`/api/office/update`,{action:e});return q.getState().setOfficeUpdate(t),t},messageCeo:e=>gT(`POST`,`/api/ceo/message`,{text:e}),ceoReview:()=>gT(`POST`,`/api/ceo/review`),phoneRead:e=>gT(`POST`,`/api/phone/read`,{at:e}),approveRequest:(e,t={})=>gT(`POST`,`/api/requests/${e}/approve`,t),rejectRequest:(e,t)=>gT(`POST`,`/api/requests/${e}/reject`,{note:t})},vT=.0022,yT=.2;function bT(){return{skip:3,avg:0,pending:null,dropped:0,skipped:0}}function xT(e){e.skip=3,e.avg=0,e.pending=null}var ST=(e,t)=>Math.max(Math.abs(e),Math.abs(t));function CT(e,t,n){return e.avg+=(ST(t,n)-e.avg)*yT,[t,n]}function wT(e,t,n,r){if(!Number.isFinite(t)||!Number.isFinite(n))return null;if(e.skip>0)return e.skip--,e.skipped++,null;let i=ST(t,n);if(i>1e3)return e.dropped++,null;let a=e.pending;if(e.pending=null,a){if(r-a.t<=50&&i>=ST(a.dx,a.dy)*.25)return CT(e,a.dx,a.dy),CT(e,a.dx+t,a.dy+n);e.dropped++}return i>250||i>=48&&i>8*e.avg?(e.pending={dx:t,dy:n,t:r},null):CT(e,t,n)}var TT=.25,ET=`cubefarm:look`,DT={sensitivity:1,invertY:!1,grabOnClose:!0},OT=e=>Math.min(3,Math.max(TT,e));function kT(){try{let e=JSON.parse(localStorage.getItem(ET)??`null`);return{sensitivity:typeof e?.sensitivity==`number`&&Number.isFinite(e.sensitivity)?OT(e.sensitivity):DT.sensitivity,invertY:e?.invertY===!0,grabOnClose:e?.grabOnClose!==!1}}catch{return{...DT}}}var AT=Ty((e,t)=>({...kT(),set:n=>{e({...n,...n.sensitivity===void 0?{}:{sensitivity:OT(n.sensitivity)}});let{sensitivity:r,invertY:i,grabOnClose:a}=t();try{localStorage.setItem(ET,JSON.stringify({sensitivity:r,invertY:i,grabOnClose:a}))}catch{}}})),jT=Ty(()=>({ask:null}));function MT(e){return new Promise(t=>{jT.getState().ask?.resolve(!1),jT.setState({ask:{...e,resolve:t}})})}var NT=()=>jT.getState().ask!==null,PT=e=>jT.subscribe((t,n)=>e(t.ask!==null,n.ask!==null));function FT(e){let t=jT.getState().ask;t&&(jT.setState({ask:null}),t.resolve(e))}function IT(){let e=jT(e=>e.ask);if((0,v.useEffect)(()=>{if(!e)return;let t=e=>{(e.key===`Escape`||e.key===`Enter`)&&(e.preventDefault(),e.stopImmediatePropagation(),FT(e.key===`Enter`))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e]),!e)return null;let t=e.tone??`good`;return(0,K.jsx)(`div`,{className:`confirm-overlay`,onMouseDown:e=>e.target===e.currentTarget&&FT(!1),children:(0,K.jsxs)(`div`,{className:`confirm confirm-${t}`,role:`alertdialog`,"aria-modal":`true`,"aria-label":e.title,children:[(0,K.jsx)(`div`,{className:`confirm-icon`,children:e.icon??(t===`danger`?`⚠️`:t===`warn`?`🤔`:`✨`)}),(0,K.jsx)(`h3`,{children:e.title}),e.body&&(0,K.jsx)(`div`,{className:`confirm-body`,children:e.body}),(0,K.jsxs)(`div`,{className:`confirm-actions`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>FT(!1),children:e.cancel??`Cancel`}),(0,K.jsx)(`button`,{className:`btn ${t===`danger`?`btn-bad`:t===`warn`?`btn-warn`:`btn-good`}`,onClick:()=>FT(!0),autoFocus:!0,children:e.confirm??`OK`})]}),(0,K.jsxs)(`div`,{className:`confirm-keys muted small`,children:[(0,K.jsx)(`kbd`,{children:`Enter`}),` `,e.confirm??`OK`,` · `,(0,K.jsx)(`kbd`,{children:`Esc`}),` `,e.cancel??`Cancel`]})]})})}var LT=()=>({half:0,walked:0,wasMoving:!1,foot:1});function RT(e,t,n){let r=Math.floor(t/Math.PI),i=null;return n&&r!==e.half?(i=`step`,e.walked++,e.foot=+(e.foot===0)):!n&&e.wasMoving&&e.walked>0&&(i=`scuff`),n||(e.walked=0),e.half=r,e.wasMoving=n,i}var zT=e=>.9+e*.2,BT={wood:({p:e,v:t,f:n,d:r,pan:i})=>{ub({freq:165*e,to:110*e,dur:.07*r,peak:.028*t,attack:.004,pan:i,group:`steps`}),fb({dur:.06*r,peak:.026*t,freq:650*n,q:.8,attack:.003,pan:i,group:`steps`}),fb({at:.05*r,dur:.04*r,peak:.012*t,filter:`bandpass`,freq:1300*n,q:1.2,attack:.003,pan:i,group:`steps`})},rug:({p:e,v:t,f:n,d:r,pan:i})=>{fb({dur:.11*r,peak:.03*t,freq:260*n,q:.6,attack:.012,pan:i,group:`steps`}),ub({freq:85*e,to:60*e,dur:.08*r,peak:.016*t,attack:.01,pan:i,group:`steps`})},lobby:({p:e,v:t,f:n,d:r,pan:i})=>{fb({dur:.04*r,peak:.02*t,filter:`bandpass`,freq:2400*n,q:1.3,attack:.0015,pan:i,group:`steps`}),fb({dur:.05*r,peak:.016*t,freq:900*n,q:.8,attack:.002,pan:i,group:`steps`}),ub({freq:520*e,to:380*e,type:`triangle`,dur:.03*r,peak:.007*t,attack:.002,pan:i,group:`steps`})},cabin:({p:e,v:t,f:n,d:r,pan:i})=>{ub({freq:196*e,to:186*e,type:`triangle`,dur:.18*r,peak:.018*t,attack:.003,pan:i,group:`steps`}),ub({freq:296*e,dur:.12*r,peak:.007*t,attack:.003,pan:i,group:`steps`}),fb({dur:.05*r,peak:.02*t,freq:420*n,q:.7,attack:.003,pan:i,group:`steps`})}},VT={wood:1,rug:.55,lobby:1.4,cabin:.85},HT={p:1,v:1,f:1,d:1,pan:0};function UT(e,t=!1,n=0){HT.p=zT(Math.random())*(n?1.03:.97)*(t?1.03:1),HT.v=zT(Math.random())*(t?1.2:1),HT.f=zT(Math.random())*(t?1.25:1),HT.d=t?.85:1,HT.pan=n?.12:-.12,BT[e](HT)}function WT(e){let t=VT[e]*zT(Math.random());fb({dur:.2,peak:.012*zT(Math.random()),filter:`bandpass`,freq:1100*t,to:450*t,q:.7,attack:.05,group:`steps`})}var GT=LT();function KT(e,t,n,r){let i=RT(GT,e,t);i===`step`?UT(r,n,GT.foot):i===`scuff`&&WT(r)}var qT=()=>{let e=q.getState().held;return e?.kind===`blaster`?e:null},JT={at:-1/0},YT=new Map,XT=[];function ZT(){YT.clear(),XT=[]}function QT(e){q.getState().setHeld({kind:`blaster`,id:e,ammo:YT.get(e)??yw.mag,reloadAt:null})}q.subscribe((e,t)=>{let n=t.held;n?.kind!==`blaster`||e.held?.kind===`blaster`&&e.held.id===n.id||YT.set(n.id,bw(n,performance.now()).ammo)});function $T(){let e=q.getState(),t=qT();if(!t||e.travel)return;let n=performance.now(),r=Sw(t,JT.at,n);if(!r){let e=bw(t,n);e.reloadAt===null&&e.ammo===0&&ub({freq:1400,to:900,type:`square`,dur:.03,peak:.03,attack:.002,group:`toys`});return}JT.at=n,XT.length<yw.mag&&XT.push(t.id),e.setHeld({...t,...r}),vb()}function eE(){let e=qT();if(!e)return;let t=Cw(e,performance.now());t&&(q.getState().setHeld({...e,...t}),fb({dur:.08,peak:.06,filter:`bandpass`,freq:900,q:2,group:`toys`}),fb({at:.75,dur:.07,peak:.08,filter:`bandpass`,freq:1500,q:2,group:`toys`}),setTimeout(()=>{let n=qT();n&&n.id===e.id&&n.reloadAt===t.reloadAt&&q.getState().setHeld({...n,...bw(n,performance.now())})},yw.reloadMs+20))}function tE(){return XT.shift()??null}var nE={tap:150,full:1e3},rE=e=>Math.min(1,Math.max(0,(e-nE.tap)/(nE.full-nE.tap))),iE={x:0,z:0},aE=null;function oE(){let e=q.getState();if(e.held?.kind===`blaster`)return $T();e.held&&e.chargeAt===null&&e.setCharge(performance.now())}function sE(){let e=q.getState();if(!e.held||e.chargeAt===null)return;let t=rE(performance.now()-e.chargeAt);aE={id:e.held.id,power:t,at:performance.now()},fb({dur:.14+t*.08,peak:.03+t*.05,filter:`bandpass`,freq:500,to:1500+t*900,q:.9,group:`toys`}),e.setHeld(null)}function cE(){let e=q.getState();e.held&&e.setHeld(null)}function lE(e){let t=aE;return!t||t.id!==e||performance.now()-t.at>500?null:(aE=null,t.power)}function uE(e,t){return(e.overlay&&!t.overlay||e.confirm&&!t.confirm)&&!t.overlay&&!t.confirm}function dE(e,t,n){return n.enabled&&n.started&&uE(e,t)}function fE(e,t){let n=(n,r)=>{uE(n,r)&&(t(),dE(n,r,{started:q.getState().started,enabled:AT.getState().grabOnClose})&&e())},r=q.subscribe((e,t)=>{if(e.overlay===t.overlay)return;let r=NT();n({overlay:!!t.overlay,confirm:r},{overlay:!!e.overlay,confirm:r})}),i=PT((e,t)=>{let r=!!q.getState().overlay;e!==t&&n({overlay:r,confirm:t},{overlay:r,confirm:e})});return()=>{r(),i()}}var pE=new Map;function mE(e,t){return pE.set(e,t),()=>{pE.get(e)===t&&pE.delete(e)}}function hE(e){pE.get(e)?.()}var gE=null,_E=400,vE=0,yE=[`mousedown`,`mouseup`,`click`,`dblclick`],bE=()=>{vE=performance.now()+_E};function xE(){let e=q.getState();if(!gE||e.overlay||!e.started||NT())return;let t=gE;SE(t,{unadjustedMovement:!0})?.catch?.(e=>{e instanceof DOMException&&e.name===`NotSupportedError`&&SE(t)?.catch?.(()=>void 0)})}function SE(e,t){try{return e.requestPointerLock?.(t)}catch{return}}var CE={dropped:0,skipped:0};window.__swarmLook=CE;function wE(e,t=`key`){let n=q.getState();if(vE=performance.now()+_E,e.action.kind===`pickup`&&vw(e.action.toyId)){QT(e.action.toyId);return}if(e.action.kind===`pickup`){n.setHeld({kind:`ball`,id:e.action.toyId});return}if(e.action.kind===`poke`){hE(e.action.toyId);return}if(e.action.kind===`hire`){let{repoId:r,role:i}=e.action,a=()=>Y.hireAgent(r,{role:i}).then(()=>n.pushToast(`success`,i===`qa`?`New QA tester hired! They will take the next free station in the QA lab.`:`New teammate hired! They will sit at the next free desk.`)).catch(()=>void 0);if(t===`key`){a();return}document.pointerLockElement&&document.exitPointerLock(),MT({icon:i===`qa`?`🔍`:`🪑`,title:i===`qa`?`Hire a QA tester for this station?`:`Hire an agent for this desk?`,confirm:`Hire`}).then(e=>{e&&a()});return}n.openOverlay(e.action)}var TE=e=>{let t=e.target;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function EE({colliders:e,floor:t}){let{camera:n,gl:r}=W_(),i=(0,v.useRef)(new Set),a=(0,v.useRef)({yaw:cx.yaw,pitch:-.05}),o=(0,v.useRef)(0),s=(0,v.useMemo)(()=>new nf,[]),c=(0,v.useMemo)(()=>new B(0,0),[]),l=(0,v.useRef)(0),u=(0,v.useMemo)(bT,[]),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{let e=d.current?null:Pb();if(d.current=!0,e&&e.floor===t){n.position.set(e.x,ax,e.z),a.current={yaw:e.yaw,pitch:e.pitch};return}n.position.set(cx.x,ax,cx.z),a.current={yaw:cx.yaw,pitch:-.05}},[t,n]);let f=(0,v.useRef)(0);return(0,v.useEffect)(()=>{},[n]),(0,v.useEffect)(()=>{gE=r.domElement;let e=e=>{if(e.button!==0)return;if(document.pointerLockElement!==r.domElement)return xE();let t=q.getState();!t.started||t.overlay||t.travel||NT()||(t.held?oE():t.focus&&wE(t.focus,`click`))},t=e=>{e.button===0&&sE()},n=e=>{performance.now()>=vE||(e.stopPropagation(),e.preventDefault())},o=()=>{xT(u);let e=document.pointerLockElement===r.domElement;e||cE(),q.getState().setLocked(e)},s=e=>{if(document.pointerLockElement!==r.domElement||!document.hasFocus())return;let t=wT(u,e.movementX,e.movementY,e.timeStamp);if(CE.dropped=u.dropped,CE.skipped=u.skipped,!t)return;let{sensitivity:n,invertY:i}=AT.getState(),o=vT*n;a.current.yaw-=t[0]*o,a.current.pitch=Math.max(-1.35,Math.min(1.35,a.current.pitch-t[1]*o*(i?-1:1)))},c=e=>{if(TE(e))return;let t=q.getState();e.code===`KeyM`&&!e.repeat&&!NT()&&(cb(),t.pushToast(`info`,rb().muted?`🔇 Sound off (M to turn it back on)`:`🔊 Sound on`)),!(t.overlay||!t.started||NT())&&(i.current.add(e.code),e.code===`KeyE`&&!e.repeat&&t.focus&&wE(t.focus),e.code===`KeyF`&&!e.repeat&&!t.travel&&oE(),e.code===`KeyG`&&!e.repeat&&cE(),e.code===`KeyR`&&!e.repeat&&!t.travel&&eE(),e.code===`KeyH`&&t.openOverlay({kind:`help`}),e.code===`KeyP`&&(e.preventDefault(),t.openOverlay({kind:`phone`,tab:Ub(t.requests).length&&!Hb(t.messages,t.phoneReadAt)?`hires`:`chat`})))},l=e=>{i.current.delete(e.code),e.code===`KeyF`&&sE()},d=()=>{i.current.clear(),q.getState().setCharge(null)};r.domElement.addEventListener(`mousedown`,e),window.addEventListener(`mouseup`,t);for(let e of yE)window.addEventListener(e,n,!0);document.addEventListener(`pointerlockchange`,o),document.addEventListener(`mousemove`,s),window.addEventListener(`keydown`,c),window.addEventListener(`keyup`,l),window.addEventListener(`blur`,d);let f=fE(xE,bE);return()=>{f(),r.domElement.removeEventListener(`mousedown`,e),window.removeEventListener(`mouseup`,t);for(let e of yE)window.removeEventListener(e,n,!0);document.removeEventListener(`pointerlockchange`,o),document.removeEventListener(`mousemove`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,d)}},[r,u]),G_((r,u)=>{let d=Math.min(u,.05),p=q.getState();(p.overlay||NT())&&i.current.clear();let m=i.current,h=(m.has(`KeyW`)||m.has(`ArrowUp`)?1:0)-(m.has(`KeyS`)||m.has(`ArrowDown`)?1:0),g=(m.has(`KeyD`)||m.has(`ArrowRight`)?1:0)-(m.has(`KeyA`)||m.has(`ArrowLeft`)?1:0),_=m.has(`ShiftLeft`)||m.has(`ShiftRight`)?6.5:3.6,{yaw:v,pitch:y}=a.current,b=!1;if(iE.x=0,iE.z=0,(h||g)&&!p.travel){let t=Math.hypot(h,g),r=Math.sin(v),i=Math.cos(v),a=(-r*h+i*g)/t*_*d,o=(-i*h-r*g)/t*_*d,s=Bx(n.position.x+a,n.position.z+o,e);d>0&&(iE.x=(s.x-n.position.x)/d,iE.z=(s.z-n.position.z)/d),n.position.x=s.x,n.position.z=s.z,b=!0}o.current+=b?d*_*2.2:0,n.position.y=ax+(b?Math.sin(o.current)*.035:0),KT(o.current,b,_>5,zx(t===0?`lobby`:`office`,n.position.x,n.position.z)),n.rotation.set(y,v,0,`YXZ`);let x=performance.now();if(p.started&&!p.travel&&x-f.current>1e3&&(f.current=x,Fb({floor:p.floor,x:n.position.x,z:n.position.z,yaw:v,pitch:y})),++l.current%3!=0)return;if(p.overlay||p.travel||NT()){p.focus&&p.setFocus(null);return}s.setFromCamera(c,n),s.far=8;let S=[...YS.keys()],C=s.intersectObjects(S,!0),w=null;for(let e of C){let t=e.object;for(;t&&!YS.has(t);)t=t.parent;if(!t)continue;let n=YS.get(t);e.distance<=n.range&&(w={id:n.id,label:n.label,action:n.action});break}p.setFocus(w)}),null}function DE(){let e=q(e=>e.travel),t=q(e=>e.finishTravel);return(0,v.useEffect)(()=>{if(!e)return;e.phase===`closing`&&_b(.75);let n=setTimeout(()=>{e.phase===`closing`?(t(`arrived`),gb()):t(`done`)},e.phase===`closing`?750:650);return()=>clearTimeout(n)},[e,t]),null}function OE(){let e=q(e=>e.floor),t=q(e=>e.repos),n=e===0?null:Rb(t,e),r=!!n,i=(0,v.useMemo)(()=>r?Dx():Ix(),[r]),a=Xb(),[o,s]=(0,v.useState)(Kb);return(0,K.jsxs)(by,{shadows:!0,frameloop:a?`never`:`always`,dpr:[1,o],camera:{fov:72,near:.05,far:90,position:[0,1.65,10]},gl:{antialias:!0,powerPreference:`high-performance`},onCreated:({gl:e})=>{e.toneMapping=4,e.toneMappingExposure=1,e.shadowMap.type=2},children:[(0,K.jsx)(`color`,{attach:`background`,args:[`#bfe3ff`]}),(0,K.jsx)(`fog`,{attach:`fog`,args:[`#f3ece2`,30,70]}),(0,K.jsx)(gw,{}),(0,K.jsx)(v.Suspense,{fallback:null,children:n?(0,K.jsx)(nT,{repo:n},n.id):(0,K.jsx)(hT,{})}),(0,K.jsx)(EE,{colliders:i,floor:e}),(0,K.jsx)(DE,{}),(0,K.jsx)(Zb,{paused:a}),(0,K.jsx)($b,{onChange:s}),qb&&(0,K.jsx)(nx,{paused:a})]})}function kE({held:e}){let t=(0,v.useRef)(null),n=e.reloadAt!==null;(0,v.useEffect)(()=>{if(!n)return;let r=0,i=()=>{let n=xw(e,performance.now());t.current&&(t.current.style.transform=`scaleX(${n??1})`),n!==null&&(r=requestAnimationFrame(i))};return i(),()=>cancelAnimationFrame(r)},[e,n]);let r=e.ammo===0&&!n;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`hud-hint hud-held`,children:[(0,K.jsx)(`kbd`,{children:`Click`}),` / `,(0,K.jsx)(`kbd`,{children:`F`}),` fire · `,(0,K.jsx)(`kbd`,{children:`R`}),` reload · `,(0,K.jsx)(`kbd`,{children:`G`}),` drop`]}),(0,K.jsxs)(`div`,{className:`hud-ammo ${r?`hud-ammo-empty`:``}`,children:[(0,K.jsxs)(`span`,{className:`hud-ammo-count`,children:[`🎯 `,ww(e,performance.now())]}),n&&(0,K.jsx)(`div`,{className:`hud-ammo-bar`,children:(0,K.jsx)(`div`,{ref:t,className:`hud-ammo-fill`})}),n&&(0,K.jsx)(`span`,{className:`hud-ammo-note`,children:`Reloading…`}),r&&(0,K.jsx)(`span`,{className:`hud-ammo-note`,children:`Empty: R to reload`})]})]})}function AE({at:e}){let t=(0,v.useRef)(null),n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let r=0,i=()=>{let a=performance.now()-e,o=rE(a);t.current&&(t.current.className=`charge ${a>nE.tap?`charge-on`:``} ${o>=1?`charge-full`:``}`),n.current&&(n.current.style.transform=`scaleX(${o})`),o<1&&(r=requestAnimationFrame(i))};return i(),()=>cancelAnimationFrame(r)},[e]),(0,K.jsx)(`div`,{ref:t,className:`charge`,children:(0,K.jsx)(`div`,{ref:n,className:`charge-fill`})})}function jE(){let e=q(e=>e.held),t=q(e=>e.chargeAt);return e?e.kind===`blaster`?(0,K.jsx)(kE,{held:e}):(0,K.jsxs)(K.Fragment,{children:[t!==null&&(0,K.jsx)(AE,{at:t}),(0,K.jsxs)(`div`,{className:`hud-hint hud-held`,children:[(0,K.jsx)(`kbd`,{children:`Click`}),` / `,(0,K.jsx)(`kbd`,{children:`F`}),` throw · hold to charge · `,(0,K.jsx)(`kbd`,{children:`G`}),` drop`]})]}):null}var ME=[`tool`,`text`,`thinking`,`error`,`done`,`manager`],NE=e=>e.status===`working`||e.status===`preparing`,PE=`cubefarm:workers`;function FE(e){for(let t=e.length-1;t>=Math.max(0,e.length-80);t--){let n=e[t];if(!ME.includes(n.kind)||!n.text.trim())continue;let r=n.text.trim().replace(/^[⏺●✻✔⎿▶]\s*/u,``).replace(/^Manager:\s*/,`you: `);return{text:n.kind===`thinking`?`thinking…`:r,kind:n.kind,t:n.t}}return null}function IE(e){return e.role===`ceo`?e.issueTitle:e.task===`qa`?`QA · PR #${e.prNumber}`:e.task===`fix`?`fixing PR #${e.prNumber}`:e.issueNumber?`#${e.issueNumber}`:null}function LE(e,t){let n=Math.max(0,Math.round((t-e)/1e3));return n<60?`${n}s`:n<3600?`${Math.round(n/60)}m`:`${Math.round(n/3600)}h`}function RE({a:e,now:t}){let n=q(e=>e.openOverlay),r=FE(q(t=>t.logs[e.id])??[]),i=r&&(!e.startedAt||r.t>=e.startedAt)?r:null,a=IE(e);return(0,K.jsxs)(`button`,{className:`wk-row`,onClick:()=>n({kind:`terminal`,agentId:e.id}),title:`Watch ${e.name}'s screen`,children:[(0,K.jsx)(`span`,{className:`wk-dot`,style:{background:e.color}}),(0,K.jsxs)(`span`,{className:`wk-main`,children:[(0,K.jsxs)(`span`,{className:`wk-name`,children:[e.name,a&&(0,K.jsx)(`span`,{className:`wk-task`,children:a})]}),(0,K.jsxs)(`span`,{className:`wk-line`,children:[(0,K.jsx)(`span`,{className:`wk-last wk-last-${i?.kind??`none`}`,title:i?.text,children:e.status===`preparing`?`setting up the worktree…`:i?.text??(e.issueTitle?`working on ${e.issueTitle}`:`starting…`)}),i&&e.status!==`preparing`&&(0,K.jsx)(`span`,{className:`wk-ago`,children:LE(i.t,t)})]})]})]})}function zE(){try{return new Set(JSON.parse(localStorage.getItem(`${PE}:collapsed`)??`[]`))}catch{return new Set}}function BE(){let e=q(e=>e.floor),t=q(e=>e.repos),n=q(e=>e.agents),r=q(e=>e.started),[i,a]=(0,v.useState)(()=>{try{return localStorage.getItem(PE)!==`closed`}catch{return!0}}),[o,s]=(0,v.useState)(zE),[c,l]=(0,v.useState)(Date.now());(0,v.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),5e3);return()=>clearInterval(e)},[]);let u=e=>s(t=>{let n=new Set(t);n.delete(e)||n.add(e);try{localStorage.setItem(`${PE}:collapsed`,JSON.stringify([...n]))}catch{}return n}),d=()=>a(e=>{try{localStorage.setItem(PE,e?`closed`:`open`)}catch{}return!e});if((0,v.useEffect)(()=>{let e=e=>{e.code!==`Tab`||e.repeat||e.altKey||e.ctrlKey||e.metaKey||q.getState().overlay||e.target?.closest?.(`input, textarea, select, [contenteditable="true"]`)||(e.preventDefault(),d())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),!r)return null;let f=n.ceo,p=[...t].sort((t,n)=>t.floor===e?-1:n.floor===e?1:t.floor-n.floor),m=[...f&&NE(f)?[{key:`hq`,label:`HQ`,title:`The CEO, in the lobby`,color:f.color,list:[f]}]:[],...p.map(e=>({key:e.id,label:`${e.floor} · ${e.fullName.split(`/`)[1]}`,title:`Floor ${e.floor}: ${e.fullName}`,color:e.color,list:zb(n,e.id).filter(NE)}))].filter(e=>e.list.length>0),h=m.reduce((e,t)=>e+t.list.length,0);return(0,K.jsxs)(`div`,{className:`workers ${i?``:`workers-closed`}`,children:[(0,K.jsxs)(`button`,{className:`wk-head`,onClick:d,title:i?`Hide the list (Tab)`:`Show who is working (Tab)`,children:[(0,K.jsxs)(`span`,{children:[`Working `,(0,K.jsx)(`b`,{children:h})]}),(0,K.jsxs)(`span`,{className:`wk-chevron`,children:[(0,K.jsx)(`kbd`,{children:`Tab`}),` `,i?`▾`:`▸`]})]}),i&&(0,K.jsxs)(`div`,{className:`wk-list`,children:[h===0&&(0,K.jsx)(`div`,{className:`wk-empty`,children:`Nobody is working right now.`}),m.map(e=>{let t=o.has(e.key);return(0,K.jsxs)(`div`,{className:`wk-group`,children:[(0,K.jsxs)(`button`,{className:`wk-group-head`,onClick:()=>u(e.key),title:`${e.title} · click to ${t?`expand`:`collapse`}`,children:[(0,K.jsx)(`span`,{className:`wk-group-arrow`,children:t?`▸`:`▾`}),(0,K.jsx)(`span`,{className:`wk-swatch`,style:{background:e.color}}),(0,K.jsx)(`span`,{className:`wk-group-name`,children:e.label}),(0,K.jsx)(`span`,{className:`wk-group-count`,children:e.list.length})]}),!t&&e.list.map(e=>(0,K.jsx)(RE,{a:e,now:c},e.id))]},e.key)})]})]})}var VE=12e5,HE=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function UE(e){switch(e.state){case`none`:return`Up to date`;case`available`:return e.behind>0?`${HE(e.behind,`update`)} ready`:`An update is ready`;case`waiting`:case`draining`:return e.running>0?`Waiting for ${HE(e.running,`session`)} to finish`:`Updating shortly…`;case`updating`:return`Updating…`;case`failed`:return`Last update failed: ${e.detail||`unknown error`}`}}function WE(e){return e?e.state===`updating`?`⟳ Updating the office…`:e.state!==`waiting`&&e.state!==`draining`?null:e.running>0?`⟳ Updating the office after ${HE(e.running,`session`)} finish${e.running===1?`es`:``}`:`⟳ Updating the office shortly`:null}var GE=e=>e.state===`draining`&&e.drainingSince?e.drainingSince+VE:null,KE=e=>e.launcher&&e.behind>0&&(e.state===`available`||e.state===`waiting`||e.state===`failed`),qE=e=>e.launcher&&(e.state===`available`||e.state===`waiting`||e.state===`draining`),JE=e=>e?.state===`draining`||e?.state===`updating`;function YE(e,t,n){return!!e&&!!t&&e!==t&&n!==t}function XE(){let e=q(e=>e.restarting?`⟳ Office restarting…`:WE(e.officeUpdate)),t=q(e=>e.overlay),n=q(e=>e.openOverlay);return!e||t?.kind===`manager`?null:(0,K.jsx)(`button`,{className:`office-chip`,onClick:()=>n({kind:`manager`,tab:`floors`}),title:`The office is updating itself. Open the manager's console`,children:e})}function ZE(){let e=Wb(),t=q(e=>e.started),n=q(e=>e.overlay),r=q(e=>e.openOverlay),i=q(e=>e.agents.ceo);if(!t||n?.kind===`phone`)return null;let a=i?.status===`working`;return(0,K.jsxs)(`button`,{className:`phone-btn ${e?`phone-btn-ring`:``}`,onClick:()=>r({kind:`phone`}),title:`Your phone (P)`,children:[(0,K.jsx)(`span`,{className:`phone-btn-icon`,children:`📱`}),e>0&&(0,K.jsx)(`span`,{className:`badge phone-btn-badge`,children:e}),(0,K.jsxs)(`span`,{className:`phone-btn-label`,children:[(0,K.jsx)(`kbd`,{children:`P`}),` `,e?`${e} waiting`:a?`${i.name} is working`:`Phone`]})]})}function QE(){let e=q(e=>e.floor),t=q(e=>e.repos),n=q(e=>e.agents),r=q(e=>e.settings),i=q(e=>e.connected),a=q(e=>e.restarting),o=q(e=>e.demo),s=q(e=>e.user),c=q(e=>e.ghReady),l=q(e=>e.ghError),u=q(e=>e.focus),d=q(e=>e.held),f=q(e=>e.overlay),p=q(e=>e.locked),m=q(e=>e.started),h=q(e=>e.travel),g=q(e=>e.toasts),_=q(e=>e.dismissToast),y=e===0?null:Rb(t,e),b=(0,v.useMemo)(()=>Object.values(n).filter(e=>e.status===`working`||e.status===`preparing`).length,[n]),x=y?Object.values(n).filter(e=>e.repoId===y.id):[],S=q(e=>e.qa),C=y?Object.values(S).filter(e=>e.repoId===y.id):[];return(0,K.jsxs)(`div`,{className:`hud`,children:[(0,K.jsxs)(`div`,{className:`hud-floor`,style:{"--accent":y?.color??`#ff8a5b`},children:[(0,K.jsx)(`div`,{className:`floor-num`,children:y?y.floor:`G`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`floor-name`,children:y?y.fullName:`${r.companyName||`cubefarm`} · Lobby`}),(0,K.jsx)(`div`,{className:`floor-sub`,children:y?`${x.length} agents · ${x.filter(e=>e.status===`working`||e.status===`preparing`).length} working · ${C.filter(e=>e.status!==`passed`).length} in QA · ${C.filter(e=>e.status===`passed`).length} ready to merge`:`${t.length} floor${t.length===1?``:`s`} connected`})]})]}),(0,K.jsxs)(`div`,{className:`hud-status`,children:[o&&(0,K.jsx)(`span`,{className:`pill pill-demo`,children:`DEMO`}),(0,K.jsx)(`span`,{className:`pill ${i?`pill-ok`:a?`pill-demo`:`pill-bad`}`,children:i?`● live`:a?`○ restarting`:`○ reconnecting`}),(0,K.jsxs)(`span`,{className:`pill`,children:[`⚙️ `,r.sessionLimit?`${b}/${r.sessionLimit}`:b,` sessions`]}),s&&(0,K.jsxs)(`span`,{className:`pill`,children:[`🐙 `,s]})]}),(0,K.jsx)(BE,{}),(0,K.jsx)(XE,{}),!c&&l&&(0,K.jsxs)(`div`,{className:`hud-banner`,children:[`⚠️ `,l]}),m&&!f&&!h&&(0,K.jsx)(`div`,{className:`crosshair ${u?`crosshair-hot`:``}`}),m&&!f&&u&&(0,K.jsxs)(`div`,{className:`hud-hint`,children:[(0,K.jsx)(`kbd`,{children:`E`}),` `,!d&&(0,K.jsxs)(K.Fragment,{children:[`/ `,(0,K.jsx)(`kbd`,{children:`Click`}),` `]}),u.label]}),m&&!f&&!h&&(0,K.jsx)(jE,{}),m&&!f&&!p&&!h&&(0,K.jsx)(`div`,{className:`hud-resume`,children:`Click to look around`}),m&&!(r.setupDone&&r.tutorialStep>=0)&&(0,K.jsxs)(`div`,{className:`hud-help`,children:[(0,K.jsx)(`kbd`,{children:`WASD`}),` move · `,(0,K.jsx)(`kbd`,{children:`Shift`}),` run · `,(0,K.jsx)(`kbd`,{children:`E`}),` / `,(0,K.jsx)(`kbd`,{children:`Click`}),` interact · `,(0,K.jsx)(`kbd`,{children:`P`}),` phone · `,(0,K.jsx)(`kbd`,{children:`Tab`}),` workers · `,(0,K.jsx)(`kbd`,{children:`H`}),` help · `,(0,K.jsx)(`kbd`,{children:`Esc`}),` free mouse`]}),(0,K.jsx)(`div`,{className:`fade ${h?.phase===`closing`?`fade-in`:``}`,children:h&&(0,K.jsx)(`div`,{className:`fade-label`,children:h.to===0?`Lobby`:`Floor ${h.to}`})}),(0,K.jsx)(ZE,{}),(0,K.jsx)(`div`,{className:`toasts`,children:g.map(e=>(0,K.jsx)(`div`,{className:`toast toast-${e.level}`,onClick:()=>_(e.id),children:e.text},e.id))})]})}var $E={unconfigured:`not set up`,stopped:`stopped`,preparing:`checking out`,installing:`installing`,starting:`starting`,running:`running`,error:`error`},eD=[`preparing`,`installing`,`starting`,`running`],tD=[{status:`preparing`,label:`Check out the code`},{status:`installing`,label:`Install dependencies`},{status:`starting`,label:`Start the app`}],nD=`desktop`,rD=12e3;function iD({status:e}){return(0,K.jsx)(`span`,{className:`status status-${e}`,children:$E[e]})}var aD=e=>Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
|
|
4285
|
+
`);function oD(e){let t={},n=e.split(/\r?\n/);for(let e=0;e<n.length;e++){let r=n[e].trim();if(!r||r.startsWith(`#`))continue;let i=r.indexOf(`=`),a=i>0?r.slice(0,i).trim():``;if(!a)return{env:t,error:`Line ${e+1}: write it as KEY=value.`};if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(a))return{env:t,error:`Line ${e+1}: “${a}” is not a valid variable name.`};t[a]=r.slice(i+1).trim()}return{env:t,error:null}}function sD({repo:e,saveLabel:t=`Save`,onSaved:n}){let r={command:e.previewConfig.command??``,env:aD(e.previewConfig.env)},[i,a]=(0,v.useState)(r.command),[o,s]=(0,v.useState)(r.env),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{a(r.command),s(r.env)},[r.command,r.env]);let f=i.trim()!==r.command||o.trim()!==r.env,p=e.preview.status===`unconfigured`;return(0,K.jsxs)(`form`,{className:`preview-form`,onSubmit:async t=>{t.preventDefault();let r=oD(o);if(r.error)return d(r.error);d(null),l(!0);try{await Y.updateRepo(e.id,{previewCommand:i.trim()||null,previewEnv:r.env}),n?.()}catch(e){d(e.message)}finally{l(!1)}},children:[(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Run command`}),(0,K.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:p?`e.g. python -m http.server {port}`:`Auto-detected: npm run dev, else npm start, else npm run preview`,spellCheck:!1})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Environment (KEY=value, one per line)`}),(0,K.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),rows:3,placeholder:`API_URL=http://localhost:{port}/api
|
|
4286
|
+
DATA_DIR={tmp}`,spellCheck:!1})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Runs from the repo root in the floor's own preview worktree. `,(0,K.jsx)(`code`,{children:`{port}`}),` is this floor's port (`,e.preview.port,`) and `,(0,K.jsx)(`code`,{children:`PORT`}),` is always set;`,` `,(0,K.jsx)(`code`,{children:`{tmp}`}),` is a scratch folder.`,!p&&` Leave the command empty to use the auto-detected npm script.`]}),u&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,u]}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:c||!f&&!n||p&&!i.trim(),children:c?`Saving…`:t}),f&&(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small btn-ghost`,onClick:()=>{a(r.command),s(r.env),d(null)},children:`Undo changes`})]})]})}function cD({repoId:e}){let t=q(t=>t.repos.find(t=>t.id===e)),n=t?.preview,[r,i]=(0,v.useState)(n?.pr??null),[a,o]=(0,v.useState)(nD),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),_=(0,v.useRef)(null);(0,v.useEffect)(()=>{n&&eD.includes(n.status)&&i(n.pr)},[n?.pr,n?.startedAt]);let y=`${n?.url}|${n?.startedAt}|${l}`;if((0,v.useEffect)(()=>{if(f(!1),m(!1),n?.status!==`running`)return;let e=setTimeout(()=>m(!0),rD);return()=>clearTimeout(e)},[y,n?.status]),(0,v.useEffect)(()=>{_.current?.querySelector(`select, button`)?.focus()},[]),!t||!n)return(0,K.jsx)(KJ,{title:`App`,children:(0,K.jsx)(`p`,{className:`muted`,children:`This floor no longer exists.`})});let b=async e=>{c(!0);try{await e()}catch{}finally{c(!1)}},x=(e=r)=>b(()=>Y.startPreview(t.id,e??void 0)),S=()=>b(()=>Y.stopPreview(t.id)),C=e=>{nD=e,o(e)},w=eD.includes(n.status),T=t.pulls.filter(e=>e.state===`OPEN`),E=e=>e?`PR #${e}`:t.defaultBranch,D=t.fullName.split(`/`)[1];return(0,K.jsxs)(KJ,{wide:!0,className:`panel-app`,accent:t.color,title:(0,K.jsxs)(`span`,{className:`app-title`,children:[(0,K.jsxs)(`span`,{className:`app-title-name`,children:[`🖥️ `,D]}),(0,K.jsx)(iD,{status:n.status}),n.ref&&n.status!==`stopped`&&n.status!==`unconfigured`&&(0,K.jsxs)(`span`,{className:`muted small app-title-ref`,children:[n.ref,n.commit?` · ${n.commit}`:``]})]}),children:[(0,K.jsxs)(`div`,{className:`app-toolbar`,ref:_,role:`toolbar`,"aria-label":`App controls`,children:[(0,K.jsxs)(`select`,{className:`app-ref`,"aria-label":`Version to run`,value:r??``,disabled:s,onChange:e=>{let t=e.target.value?Number(e.target.value):null;i(t),w&&x(t)},children:[(0,K.jsx)(`option`,{value:``,children:t.defaultBranch}),T.map(e=>(0,K.jsxs)(`option`,{value:e.number,children:[`#`,e.number,` `,e.title]},e.number)),r&&!T.some(e=>e.number===r)&&(0,K.jsxs)(`option`,{value:r,children:[`PR #`,r,` (no longer open)`]})]}),w?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:s,onClick:()=>void x(),title:`Restart on ${E(r)}`,children:`↻ Restart`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-bad`,disabled:s,onClick:()=>void S(),children:`■ Stop`})]}):(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:s||n.status===`unconfigured`,onClick:()=>void x(),children:`▶ Start`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:n.status!==`running`,onClick:()=>u(e=>e+1),title:`Reload the app`,children:`⟳ Reload`}),(0,K.jsxs)(`div`,{className:`seg`,role:`group`,"aria-label":`Viewport width`,children:[(0,K.jsx)(`button`,{className:`seg-btn ${a===`desktop`?`seg-on`:``}`,"aria-pressed":a===`desktop`,onClick:()=>C(`desktop`),children:`🖥 Desktop`}),(0,K.jsx)(`button`,{className:`seg-btn ${a===`phone`?`seg-on`:``}`,"aria-pressed":a===`phone`,onClick:()=>C(`phone`),title:`390px wide`,children:`📱 Phone`})]}),(0,K.jsx)(`span`,{className:`spacer`}),n.url?(0,K.jsx)(`a`,{className:`btn btn-small`,href:n.url,target:`_blank`,rel:`noreferrer`,children:`Open in new tab ↗`}):(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:!0,children:`Open in new tab ↗`})]}),n.status===`running`&&n.url?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`app-stage ${a===`phone`?`app-stage-phone`:``}`,children:[(0,K.jsx)(`iframe`,{className:`app-frame`,src:n.url,title:`${D} app (${E(n.pr)})`,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals allow-downloads allow-pointer-lock`,allow:`clipboard-read; clipboard-write; fullscreen; autoplay`,onLoad:()=>f(!0),onError:()=>m(!0)},y),p&&!d&&(0,K.jsxs)(`div`,{className:`app-frame-hint`,role:`status`,children:[(0,K.jsx)(`b`,{children:`The app isn't showing up here.`}),` It may refuse to be shown inside another page (X-Frame-Options or a CSP frame-ancestors rule).`,` `,(0,K.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,children:`Open it in a new tab ↗`})]})]}),(0,K.jsxs)(`p`,{className:`muted small app-foot`,children:[`Blank, or “refused to connect”? The app may block being framed: use `,(0,K.jsx)(`b`,{children:`Open in new tab`}),`. Keys typed in the app stay in the app, so `,(0,K.jsx)(`kbd`,{children:`Esc`}),` only closes this panel when focus is outside it; `,(0,K.jsx)(`b`,{children:`✕`}),` always does.`]})]}):w?(0,K.jsxs)(`div`,{className:`app-state`,role:`status`,children:[(0,K.jsx)(`div`,{className:`app-state-icon app-spin`,children:`⚙️`}),(0,K.jsxs)(`h3`,{children:[`Getting `,E(n.pr),` ready…`]}),(0,K.jsx)(`ol`,{className:`app-steps`,children:tD.map((e,t)=>{let r=tD.findIndex(e=>e.status===n.status);return(0,K.jsxs)(`li`,{className:t<r?`app-step-done`:t===r?`app-step-now`:``,children:[t<r?`✓`:t===r?`●`:`○`,` `,e.label,e.status===`starting`?` on port ${n.port}`:``]},e.status)})}),n.logTail.length>0&&(0,K.jsx)(`pre`,{className:`term app-log`,children:n.logTail.slice(-8).join(`
|
|
4287
4287
|
`)})]}):n.status===`error`?(0,K.jsxs)(`div`,{className:`app-state app-state-left`,children:[(0,K.jsx)(`h3`,{children:`⚠️ The app didn't run`}),(0,K.jsx)(`div`,{className:`term-error`,children:n.error??`The app stopped unexpectedly.`}),(0,K.jsx)(`pre`,{className:`term app-log`,"aria-label":`Last output`,children:n.logTail.length?n.logTail.join(`
|
|
4288
|
-
`):`(no output)`}),(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:s,onClick:()=>void x(),children:`↻ Try again`}),(0,K.jsx)(`button`,{className:`btn`,"aria-expanded":h,onClick:()=>g(e=>!e),children:`⚙️ Run settings`})]}),h&&(0,K.jsx)(IE,{repo:t})]}):n.status===`unconfigured`?(0,K.jsxs)(`div`,{className:`app-state app-state-left`,children:[(0,K.jsx)(`h3`,{children:`🛠️ How should the office run this app?`}),(0,K.jsxs)(`p`,{className:`muted`,children:[n.error??`This floor has no package.json to fall back on.`,` Give it a command that serves the app on the floor's port.`]}),(0,K.jsx)(IE,{repo:t,saveLabel:`Save & start`,onSaved:()=>void x()})]}):(0,K.jsxs)(`div`,{className:`app-state`,children:[(0,K.jsx)(`div`,{className:`app-state-icon`,children:`🖥️`}),(0,K.jsx)(`h3`,{children:`The app isn't running`}),(0,K.jsxs)(`p`,{className:`muted`,children:[`Start it on `,(0,K.jsx)(`b`,{children:E(r)}),` to use it right here. It runs from the floor's own preview worktree on port `,n.port,`.`]}),(0,K.jsxs)(`button`,{className:`btn btn-good`,disabled:s,onClick:()=>void x(),children:[`▶ Start `,E(r)]}),(0,K.jsx)(`button`,{className:`btn btn-ghost btn-small`,"aria-expanded":h,onClick:()=>g(e=>!e),children:`⚙️ Run settings`}),h&&(0,K.jsx)(`div`,{className:`app-state-left app-settings`,children:(0,K.jsx)(IE,{repo:t})})]})]})}function RE(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.floor),r=q(e=>e.goToFloor);(0,v.useEffect)(()=>{let t=t=>{t.key.toLowerCase()===`g`||t.key===`0`?r(0):/^[1-9]$/.test(t.key)&&e.some(e=>e.floor===Number(t.key))&&r(Number(t.key))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let i=[...e].sort((e,t)=>t.floor-e.floor);return(0,K.jsx)(xJ,{title:`🛗 Elevator`,children:(0,K.jsxs)(`div`,{className:`elevator`,children:[i.map(e=>{let i=Object.values(t).filter(t=>t.repoId===e.id),a=i.filter(e=>e.status===`working`||e.status===`preparing`).length,o=e.pulls.filter(e=>e.state===`OPEN`).length;return(0,K.jsxs)(`button`,{className:`floor-btn ${e.floor===n?`floor-btn-here`:``}`,style:{"--accent":e.color},onClick:()=>r(e.floor),children:[(0,K.jsx)(`span`,{className:`floor-btn-num`,children:e.floor}),(0,K.jsx)(`span`,{className:`floor-btn-name`,children:e.fullName}),(0,K.jsxs)(`span`,{className:`floor-btn-meta`,children:[a,`/`,i.length,` busy · `,e.issues.length,` issues · `,o,` PR`,o===1?``:`s`]})]},e.id)}),(0,K.jsxs)(`button`,{className:`floor-btn ${n===0?`floor-btn-here`:``}`,style:{"--accent":`#ff8a5b`},onClick:()=>r(0),children:[(0,K.jsx)(`span`,{className:`floor-btn-num`,children:`G`}),(0,K.jsx)(`span`,{className:`floor-btn-name`,children:`Lobby & manager's office`}),(0,K.jsx)(`span`,{className:`floor-btn-meta`,children:`connect repos · hire · file issues`})]}),e.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No floors yet. Head to the manager's office to connect a GitHub repo or start a new project.`}),(0,K.jsx)(`p`,{className:`muted small`,children:`Tip: press a floor number (or G) while this panel is open.`})]})})}function zE({agent:e}){return e?(0,K.jsxs)(`span`,{className:`agent-chip`,children:[(0,K.jsx)(`span`,{className:`dot`,style:{background:e.color}}),e.name,e.role===`qa`&&(0,K.jsx)(`span`,{className:`chip`,children:`QA`})]}):null}function BE({repoId:e,agents:t,onDone:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),d=t.filter(e=>e.role===`dev`&&e.status!==`working`&&e.status!==`preparing`);return(0,K.jsxs)(`form`,{className:`issue-form`,onSubmit:async t=>{if(t.preventDefault(),r.trim()){u(!0);try{await Y.createIssue(e,r,a,s||void 0),i(``),o(``),c(``),n?.()}catch{}finally{u(!1)}}},children:[(0,K.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Issue title, e.g. Add a dark mode toggle`,autoFocus:!0}),(0,K.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Describe what you want. Acceptance criteria help the developer and the QA tester a lot.`,rows:5}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:`Leave in backlog (auto-assign picks it up if enabled)`}),d.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[`Give it to `,e.name,` right away`]},e.id))]}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:l||!r.trim(),children:l?`Filing…`:`File issue on GitHub`})]})]})}function VE({card:e}){return e.qa?.commentUrl?(0,K.jsx)(`a`,{className:`small`,href:e.qa.commentUrl,target:`_blank`,rel:`noreferrer`,title:e.qa.summary??``,children:`QA report ↗`}):null}function HE({repoId:e}){let t=q(t=>t.repos.find(t=>t.id===e)),n=q(e=>e.agents),r=q(e=>e.qa),i=q(e=>e.openOverlay),a=(0,v.useMemo)(()=>jb(n,e),[n,e]),o=(0,v.useMemo)(()=>t?Lb(t,a,r):null,[t,a,r]),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null);if(!t||!o)return(0,K.jsx)(xJ,{title:`Kanban`,children:(0,K.jsx)(`p`,{className:`muted`,children:`This floor no longer exists.`})});let d=async(e,t)=>{u(e);try{await t()}catch{}finally{u(null)}},f=a.filter(e=>e.role===`dev`),p=f.filter(e=>e.status===`idle`||e.status===`done`||e.status===`stopped`||e.status===`error`),m=async e=>{await _T(e.qa?.status===`passed`?{icon:`🎉`,title:`Merge PR #${e.number}?`,body:`“${e.title}” passed QA. It will be squash-merged into ${t.defaultBranch}.`,confirm:`Squash & merge`}:{tone:`warn`,title:`Merge PR #${e.number} without QA?`,body:`“${e.title}” has not passed QA yet. Merge it into ${t.defaultBranch} anyway?`,confirm:`Merge anyway`})&&d(e.key,()=>Y.mergePull(t.id,e.number))},h=e=>(0,K.jsx)(`button`,{className:`btn btn-small`,title:`Run PR #${e.number} and open it in the app viewer`,onClick:()=>{i({kind:`app`,repoId:t.id}),(t.preview.pr!==e.number||t.preview.status===`stopped`||t.preview.status===`error`||t.preview.status===`unconfigured`)&&Y.startPreview(t.id,e.number).catch(()=>void 0)},children:`Preview`}),g=e=>e.agent&&(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`terminal`,agentId:e.agent.id}),children:`Terminal`}),_=(e,t,n,r,i)=>(0,K.jsxs)(`div`,{className:`kcol ${t}`,children:[(0,K.jsxs)(`div`,{className:`kcol-head`,children:[e,` `,(0,K.jsx)(`span`,{className:`count`,children:n.length})]}),(0,K.jsxs)(`div`,{className:`kcol-body`,children:[n.length===0&&(0,K.jsx)(`div`,{className:`muted small kempty`,children:i}),n.map(e=>(0,K.jsxs)(`div`,{className:`kcard ${e.tone?`kcard-${e.tone}`:``}`,children:[(0,K.jsxs)(`div`,{className:`kcard-title`,children:[e.url?(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.prNumber?`PR `:``,`#`,e.number]}):(0,K.jsxs)(`b`,{children:[`#`,e.number]}),` `,e.title]}),r(e)]},e.key))]})]});return(0,K.jsxs)(xJ,{wide:!0,accent:t.color,title:(0,K.jsxs)(`span`,{children:[`📋 `,t.fullName,` `,(0,K.jsx)(`a`,{className:`small`,href:t.url,target:`_blank`,rel:`noreferrer`,children:`GitHub ↗`})]}),children:[(0,K.jsxs)(`div`,{className:`kanban-toolbar`,children:[(0,K.jsx)(`button`,{className:`btn btn-good`,onClick:()=>c(e=>!e),children:s?`Cancel`:`+ New issue`}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t.autoAssign,onChange:e=>void Y.updateRepo(t.id,{autoAssign:e.target.checked}).catch(()=>void 0)}),`⚡ Auto-assign backlog to free developers`]}),(0,K.jsxs)(`label`,{className:`toggle`,title:`Merge a PR as soon as QA has signed off on its latest commit and GitHub's checks are green`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t.autoMerge,onChange:e=>void Y.updateRepo(t.id,{autoMerge:e.target.checked}).catch(()=>void 0)}),`🔀 Auto-merge when QA and checks pass`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn`,onClick:()=>i({kind:`app`,repoId:t.id}),title:`Open this floor's running app`,children:`🖥️ View app`}),(0,K.jsx)(`span`,{className:`muted small`,children:t.lastSync?`Synced ${new Date(t.lastSync).toLocaleTimeString()}`:`Syncing…`}),(0,K.jsx)(`button`,{className:`btn`,disabled:l===`sync`,onClick:()=>d(`sync`,()=>Y.syncRepo(t.id)),children:`⟳ Sync`})]}),t.syncError&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,t.syncError]}),s&&(0,K.jsx)(BE,{repoId:t.id,agents:f,onDone:()=>c(!1)}),(0,K.jsxs)(`div`,{className:`kanban kanban-5`,children:[_(`📋 Backlog`,`kcol-backlog`,o.backlog,e=>(0,K.jsxs)(`div`,{className:`kcard-foot`,children:[e.note&&(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsxs)(`select`,{value:``,disabled:l===e.key||p.length===0,onChange:t=>t.target.value&&d(e.key,()=>Y.assign(t.target.value,e.number)),children:[(0,K.jsx)(`option`,{value:``,children:p.length?`Assign to…`:`Everyone is busy`}),p.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),`No open issues. File one above!`),_(`🔨 In progress`,`kcol-progress`,o.progress,e=>(0,K.jsxs)(`div`,{className:`kcard-foot`,children:[(0,K.jsx)(zE,{agent:e.agent}),(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsx)(`span`,{className:`spacer`}),g(e)]}),`Nobody is coding right now.`),_(`🔍 In QA`,`kcol-qa`,o.qa,e=>{let n=e.qa?.status;return(0,K.jsxs)(`div`,{className:`kcard-foot kcard-foot-wrap`,children:[(0,K.jsx)(zE,{agent:e.agent}),(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(VE,{card:e}),h(e),(n===`testing`||n===`fixing`)&&g(e),(!n||n===`needs-human`)&&(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:l===e.key,onClick:()=>d(e.key,()=>Y.sendToQa(t.id,e.number)),children:n===`needs-human`?`Retry QA`:`Send to QA`}),n===`needs-human`&&(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:l===e.key,onClick:()=>m(e),children:`Merge anyway`})]})},`Nothing waiting for testing.`),_(`✅ Ready to merge`,`kcol-review`,o.ready,e=>{let n=t.pulls.find(t=>t.number===e.prNumber);return(0,K.jsxs)(`div`,{className:`kcard-foot kcard-foot-wrap`,children:[(0,K.jsx)(zE,{agent:e.agent}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.note,n?` · +${n.additions} −${n.deletions}`:``]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(VE,{card:e}),h(e),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:l===e.key||n?.isDraft,onClick:()=>m(e),children:`Merge`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:l===e.key,onClick:async()=>{await _T({tone:`danger`,title:`Close PR #${e.number}?`,body:`“${e.title}” will be closed without merging. The branch stays on GitHub.`,confirm:`Close PR`})&&d(e.key,()=>Y.closePull(t.id,e.number))},children:`Close`})]})},`No tested pull requests yet.`),_(`🎉 Merged`,`kcol-merged`,o.merged,e=>(0,K.jsx)(`div`,{className:`kcard-foot`,children:(0,K.jsx)(zE,{agent:e.agent})}),`Nothing merged yet.`)]})]})}var UE=e=>/^(claude|opus|sonnet|haiku|fable|default|best|opusplan)\b/i.test(e.trim());function WE(e,t,n,r){let i=e=>e.trim()!==``&&t===`claude`===UE(e);return i(e)?e.trim():t===n.defaultCli&&i(n.defaultModel)?n.defaultModel.trim():t===`claude`?r:``}var GE=Object.defineProperty,KE=Object.getOwnPropertyDescriptor,qE=(e,t)=>{for(var n in t)GE(e,n,{get:t[n],enumerable:!0})},JE=(e,t,n,r)=>{for(var i=r>1?void 0:r?KE(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&GE(t,n,i),i},X=(e,t)=>(n,r)=>t(n,r,e),YE=`Terminal input`,XE={get:()=>YE,set:e=>YE=e},ZE=`Too much output to announce, navigate to rows manually to read`,QE={get:()=>ZE,set:e=>ZE=e};function $E(e){return e.replace(/\r?\n/g,`\r`)}function eD(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function tD(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function nD(e,t,n,r){e.stopPropagation(),e.clipboardData&&rD(e.clipboardData.getData(`text/plain`),t,n,r)}function rD(e,t,n,r){e=$E(e),e=eD(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function iD(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function aD(e,t,n,r,i){iD(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function oD(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function sD(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var cD=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},lD=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},uD=``,dD=` `,fD=class e{constructor(){this.fg=0,this.bg=0,this.extended=new pD}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pD=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},mD=class e extends fD{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pD,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?oD(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},hD=`di$target`,gD=`di$dependencies`,_D=new Map;function vD(e){return e[gD]||[]}function yD(e){if(_D.has(e))return _D.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);bD(t,e,r)};return t._id=e,_D.set(e,t),t}function bD(e,t,n){t[hD]===t?t[gD].push({id:e,index:n}):(t[gD]=[{id:e,index:n}],t[hD]=t)}var xD=yD(`BufferService`),SD=yD(`CoreMouseService`),CD=yD(`CoreService`),wD=yD(`CharsetService`),TD=yD(`InstantiationService`),ED=yD(`LogService`),DD=yD(`OptionsService`),OD=yD(`OscLinkService`),kD=yD(`UnicodeService`),AD=yD(`DecorationService`),jD=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new mD,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):MD(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};jD=JE([X(0,xD),X(1,DD),X(2,OD)],jD);function MD(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
4288
|
+
`):`(no output)`}),(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:s,onClick:()=>void x(),children:`↻ Try again`}),(0,K.jsx)(`button`,{className:`btn`,"aria-expanded":h,onClick:()=>g(e=>!e),children:`⚙️ Run settings`})]}),h&&(0,K.jsx)(sD,{repo:t})]}):n.status===`unconfigured`?(0,K.jsxs)(`div`,{className:`app-state app-state-left`,children:[(0,K.jsx)(`h3`,{children:`🛠️ How should the office run this app?`}),(0,K.jsxs)(`p`,{className:`muted`,children:[n.error??`This floor has no package.json to fall back on.`,` Give it a command that serves the app on the floor's port.`]}),(0,K.jsx)(sD,{repo:t,saveLabel:`Save & start`,onSaved:()=>void x()})]}):(0,K.jsxs)(`div`,{className:`app-state`,children:[(0,K.jsx)(`div`,{className:`app-state-icon`,children:`🖥️`}),(0,K.jsx)(`h3`,{children:`The app isn't running`}),(0,K.jsxs)(`p`,{className:`muted`,children:[`Start it on `,(0,K.jsx)(`b`,{children:E(r)}),` to use it right here. It runs from the floor's own preview worktree on port `,n.port,`.`]}),(0,K.jsxs)(`button`,{className:`btn btn-good`,disabled:s,onClick:()=>void x(),children:[`▶ Start `,E(r)]}),(0,K.jsx)(`button`,{className:`btn btn-ghost btn-small`,"aria-expanded":h,onClick:()=>g(e=>!e),children:`⚙️ Run settings`}),h&&(0,K.jsx)(`div`,{className:`app-state-left app-settings`,children:(0,K.jsx)(sD,{repo:t})})]})]})}function lD(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.floor),r=q(e=>e.goToFloor);(0,v.useEffect)(()=>{let t=t=>{t.key.toLowerCase()===`g`||t.key===`0`?r(0):/^[1-9]$/.test(t.key)&&e.some(e=>e.floor===Number(t.key))&&r(Number(t.key))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let i=[...e].sort((e,t)=>t.floor-e.floor);return(0,K.jsx)(KJ,{title:`🛗 Elevator`,children:(0,K.jsxs)(`div`,{className:`elevator`,children:[i.map(e=>{let i=Object.values(t).filter(t=>t.repoId===e.id),a=i.filter(e=>e.status===`working`||e.status===`preparing`).length,o=e.pulls.filter(e=>e.state===`OPEN`).length;return(0,K.jsxs)(`button`,{className:`floor-btn ${e.floor===n?`floor-btn-here`:``}`,style:{"--accent":e.color},onClick:()=>r(e.floor),children:[(0,K.jsx)(`span`,{className:`floor-btn-num`,children:e.floor}),(0,K.jsx)(`span`,{className:`floor-btn-name`,children:e.fullName}),(0,K.jsxs)(`span`,{className:`floor-btn-meta`,children:[a,`/`,i.length,` busy · `,e.issues.length,` issues · `,o,` PR`,o===1?``:`s`]})]},e.id)}),(0,K.jsxs)(`button`,{className:`floor-btn ${n===0?`floor-btn-here`:``}`,style:{"--accent":`#ff8a5b`},onClick:()=>r(0),children:[(0,K.jsx)(`span`,{className:`floor-btn-num`,children:`G`}),(0,K.jsx)(`span`,{className:`floor-btn-name`,children:`Lobby & manager's office`}),(0,K.jsx)(`span`,{className:`floor-btn-meta`,children:`connect repos · hire · file issues`})]}),e.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No floors yet. Head to the manager's office to connect a GitHub repo or start a new project.`}),(0,K.jsx)(`p`,{className:`muted small`,children:`Tip: press a floor number (or G) while this panel is open.`})]})})}function uD({agent:e}){return e?(0,K.jsxs)(`span`,{className:`agent-chip`,children:[(0,K.jsx)(`span`,{className:`dot`,style:{background:e.color}}),e.name,e.role===`qa`&&(0,K.jsx)(`span`,{className:`chip`,children:`QA`})]}):null}function dD({repoId:e,agents:t,onDone:n}){let[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),d=t.filter(e=>e.role===`dev`&&e.status!==`working`&&e.status!==`preparing`);return(0,K.jsxs)(`form`,{className:`issue-form`,onSubmit:async t=>{if(t.preventDefault(),r.trim()){u(!0);try{await Y.createIssue(e,r,a,s||void 0),i(``),o(``),c(``),n?.()}catch{}finally{u(!1)}}},children:[(0,K.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Issue title, e.g. Add a dark mode toggle`,autoFocus:!0}),(0,K.jsx)(`textarea`,{value:a,onChange:e=>o(e.target.value),placeholder:`Describe what you want. Acceptance criteria help the developer and the QA tester a lot.`,rows:5}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:`Leave in backlog (auto-assign picks it up if enabled)`}),d.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[`Give it to `,e.name,` right away`]},e.id))]}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:l||!r.trim(),children:l?`Filing…`:`File issue on GitHub`})]})]})}function fD({card:e}){return e.qa?.commentUrl?(0,K.jsx)(`a`,{className:`small`,href:e.qa.commentUrl,target:`_blank`,rel:`noreferrer`,title:e.qa.summary??``,children:`QA report ↗`}):null}function pD({repoId:e}){let t=q(t=>t.repos.find(t=>t.id===e)),n=q(e=>e.agents),r=q(e=>e.qa),i=q(e=>e.openOverlay),a=(0,v.useMemo)(()=>zb(n,e),[n,e]),o=(0,v.useMemo)(()=>t?Gb(t,a,r):null,[t,a,r]),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null);if(!t||!o)return(0,K.jsx)(KJ,{title:`Kanban`,children:(0,K.jsx)(`p`,{className:`muted`,children:`This floor no longer exists.`})});let d=async(e,t)=>{u(e);try{await t()}catch{}finally{u(null)}},f=a.filter(e=>e.role===`dev`),p=f.filter(e=>e.status===`idle`||e.status===`done`||e.status===`stopped`||e.status===`error`),m=async e=>{await MT(e.qa?.status===`passed`?{icon:`🎉`,title:`Merge PR #${e.number}?`,body:`“${e.title}” passed QA. It will be squash-merged into ${t.defaultBranch}.`,confirm:`Squash & merge`}:{tone:`warn`,title:`Merge PR #${e.number} without QA?`,body:`“${e.title}” has not passed QA yet. Merge it into ${t.defaultBranch} anyway?`,confirm:`Merge anyway`})&&d(e.key,()=>Y.mergePull(t.id,e.number))},h=e=>(0,K.jsx)(`button`,{className:`btn btn-small`,title:`Run PR #${e.number} and open it in the app viewer`,onClick:()=>{i({kind:`app`,repoId:t.id}),(t.preview.pr!==e.number||t.preview.status===`stopped`||t.preview.status===`error`||t.preview.status===`unconfigured`)&&Y.startPreview(t.id,e.number).catch(()=>void 0)},children:`Preview`}),g=e=>e.agent&&(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`terminal`,agentId:e.agent.id}),children:`Terminal`}),_=(e,t,n,r,i)=>(0,K.jsxs)(`div`,{className:`kcol ${t}`,children:[(0,K.jsxs)(`div`,{className:`kcol-head`,children:[e,` `,(0,K.jsx)(`span`,{className:`count`,children:n.length})]}),(0,K.jsxs)(`div`,{className:`kcol-body`,children:[n.length===0&&(0,K.jsx)(`div`,{className:`muted small kempty`,children:i}),n.map(e=>(0,K.jsxs)(`div`,{className:`kcard ${e.tone?`kcard-${e.tone}`:``}`,children:[(0,K.jsxs)(`div`,{className:`kcard-title`,children:[e.url?(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[e.prNumber?`PR `:``,`#`,e.number]}):(0,K.jsxs)(`b`,{children:[`#`,e.number]}),` `,e.title]}),r(e)]},e.key))]})]});return(0,K.jsxs)(KJ,{wide:!0,accent:t.color,title:(0,K.jsxs)(`span`,{children:[`📋 `,t.fullName,` `,(0,K.jsx)(`a`,{className:`small`,href:t.url,target:`_blank`,rel:`noreferrer`,children:`GitHub ↗`})]}),children:[(0,K.jsxs)(`div`,{className:`kanban-toolbar`,children:[(0,K.jsx)(`button`,{className:`btn btn-good`,onClick:()=>c(e=>!e),children:s?`Cancel`:`+ New issue`}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t.autoAssign,onChange:e=>void Y.updateRepo(t.id,{autoAssign:e.target.checked}).catch(()=>void 0)}),`⚡ Auto-assign backlog to free developers`]}),(0,K.jsxs)(`label`,{className:`toggle`,title:`Merge a PR as soon as QA has signed off on its latest commit and GitHub's checks are green`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t.autoMerge,onChange:e=>void Y.updateRepo(t.id,{autoMerge:e.target.checked}).catch(()=>void 0)}),`🔀 Auto-merge when QA and checks pass`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn`,onClick:()=>i({kind:`app`,repoId:t.id}),title:`Open this floor's running app`,children:`🖥️ View app`}),(0,K.jsx)(`span`,{className:`muted small`,children:t.lastSync?`Synced ${new Date(t.lastSync).toLocaleTimeString()}`:`Syncing…`}),(0,K.jsx)(`button`,{className:`btn`,disabled:l===`sync`,onClick:()=>d(`sync`,()=>Y.syncRepo(t.id)),children:`⟳ Sync`})]}),t.syncError&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,t.syncError]}),s&&(0,K.jsx)(dD,{repoId:t.id,agents:f,onDone:()=>c(!1)}),(0,K.jsxs)(`div`,{className:`kanban kanban-5`,children:[_(`📋 Backlog`,`kcol-backlog`,o.backlog,e=>(0,K.jsxs)(`div`,{className:`kcard-foot`,children:[e.note&&(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsxs)(`select`,{value:``,disabled:l===e.key||p.length===0,onChange:t=>t.target.value&&d(e.key,()=>Y.assign(t.target.value,e.number)),children:[(0,K.jsx)(`option`,{value:``,children:p.length?`Assign to…`:`Everyone is busy`}),p.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),`No open issues. File one above!`),_(`🔨 In progress`,`kcol-progress`,o.progress,e=>(0,K.jsxs)(`div`,{className:`kcard-foot`,children:[(0,K.jsx)(uD,{agent:e.agent}),(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsx)(`span`,{className:`spacer`}),g(e)]}),`Nobody is coding right now.`),_(`🔍 In QA`,`kcol-qa`,o.qa,e=>{let n=e.qa?.status;return(0,K.jsxs)(`div`,{className:`kcard-foot kcard-foot-wrap`,children:[(0,K.jsx)(uD,{agent:e.agent}),(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(fD,{card:e}),h(e),(n===`testing`||n===`fixing`)&&g(e),(!n||n===`needs-human`)&&(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:l===e.key,onClick:()=>d(e.key,()=>Y.sendToQa(t.id,e.number)),children:n===`needs-human`?`Retry QA`:`Send to QA`}),n===`needs-human`&&(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:l===e.key,onClick:()=>m(e),children:`Merge anyway`})]})},`Nothing waiting for testing.`),_(`✅ Ready to merge`,`kcol-review`,o.ready,e=>{let n=t.pulls.find(t=>t.number===e.prNumber);return(0,K.jsxs)(`div`,{className:`kcard-foot kcard-foot-wrap`,children:[(0,K.jsx)(uD,{agent:e.agent}),(0,K.jsxs)(`span`,{className:`muted small`,children:[e.note,n?` · +${n.additions} −${n.deletions}`:``]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(fD,{card:e}),h(e),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:l===e.key||n?.isDraft,onClick:()=>m(e),children:`Merge`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:l===e.key,onClick:async()=>{await MT({tone:`danger`,title:`Close PR #${e.number}?`,body:`“${e.title}” will be closed without merging. The branch stays on GitHub.`,confirm:`Close PR`})&&d(e.key,()=>Y.closePull(t.id,e.number))},children:`Close`})]})},`No tested pull requests yet.`),_(`🎉 Merged`,`kcol-merged`,o.merged,e=>(0,K.jsx)(`div`,{className:`kcard-foot`,children:(0,K.jsx)(uD,{agent:e.agent})}),`Nothing merged yet.`)]})]})}var mD=e=>/^(claude|opus|sonnet|haiku|fable|default|best|opusplan)\b/i.test(e.trim());function hD(e,t,n,r){let i=e=>e.trim()!==``&&t===`claude`===mD(e);return i(e)?e.trim():t===n.defaultCli&&i(n.defaultModel)?n.defaultModel.trim():t===`claude`?r:``}var gD=Object.defineProperty,_D=Object.getOwnPropertyDescriptor,vD=(e,t)=>{for(var n in t)gD(e,n,{get:t[n],enumerable:!0})},yD=(e,t,n,r)=>{for(var i=r>1?void 0:r?_D(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&gD(t,n,i),i},X=(e,t)=>(n,r)=>t(n,r,e),bD=`Terminal input`,xD={get:()=>bD,set:e=>bD=e},SD=`Too much output to announce, navigate to rows manually to read`,CD={get:()=>SD,set:e=>SD=e};function wD(e){return e.replace(/\r?\n/g,`\r`)}function TD(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ED(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function DD(e,t,n,r){e.stopPropagation(),e.clipboardData&&OD(e.clipboardData.getData(`text/plain`),t,n,r)}function OD(e,t,n,r){e=wD(e),e=TD(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function kD(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function AD(e,t,n,r,i){kD(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function jD(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function MD(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var ND=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},PD=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},FD=``,ID=` `,LD=class e{constructor(){this.fg=0,this.bg=0,this.extended=new RD}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},RD=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},zD=class e extends LD{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new RD,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?jD(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},BD=`di$target`,VD=`di$dependencies`,HD=new Map;function UD(e){return e[VD]||[]}function WD(e){if(HD.has(e))return HD.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);GD(t,e,r)};return t._id=e,HD.set(e,t),t}function GD(e,t,n){t[BD]===t?t[VD].push({id:e,index:n}):(t[VD]=[{id:e,index:n}],t[BD]=t)}var KD=WD(`BufferService`),qD=WD(`CoreMouseService`),JD=WD(`CoreService`),YD=WD(`CharsetService`),XD=WD(`InstantiationService`),ZD=WD(`LogService`),QD=WD(`OptionsService`),$D=WD(`OscLinkService`),eO=WD(`UnicodeService`),tO=WD(`DecorationService`),nO=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new zD,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):rO(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};nO=yD([X(0,KD),X(1,QD),X(2,$D)],nO);function rO(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
4289
4289
|
|
|
4290
|
-
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var
|
|
4290
|
+
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var iO=WD(`CharSizeService`),aO=WD(`CoreBrowserService`),oO=WD(`MouseService`),sO=WD(`RenderService`),cO=WD(`SelectionService`),lO=WD(`CharacterJoinerService`),uO=WD(`ThemeService`),dO=WD(`LinkProviderService`),fO=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?vO.isErrorNoTelemetry(e)?new vO(e.message+`
|
|
4291
4291
|
|
|
4292
4292
|
`+e.stack):Error(e.message+`
|
|
4293
4293
|
|
|
4294
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function HD(e){WD(e)||VD.onUnexpectedError(e)}var UD=`Canceled`;function WD(e){return e instanceof GD||e instanceof Error&&e.name===UD&&e.message===UD}var GD=class extends Error{constructor(){super(UD),this.name=this.message}};function KD(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var qD=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},JD=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function YD(e,t=0){return e[e.length-(1+t)]}var XD;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(XD||={});var ZD=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||XD.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};ZD.empty=new ZD(e=>{});function QD(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var $D;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})($D||={});var eO=null;function tO(e){return eO?.trackDisposable(e),e}function nO(e){eO?.markAsDisposed(e)}function rO(e,t){eO?.setParent(e,t)}function iO(e){return eO?.markAsSingleton(e),e}function aO(e){if($D.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function oO(...e){return sO(()=>aO(e))}function sO(e){let t=tO({dispose:QD(()=>{nO(t),e()})});return t}var cO=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,tO(this)}dispose(){this._isDisposed||(nO(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{aO(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return rO(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),rO(e,null))}};cO.DISABLE_DISPOSED_WARNING=!1;var lO=cO,uO=class{constructor(){this._store=new lO,tO(this),rO(this._store,this)}dispose(){nO(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};uO.None=Object.freeze({dispose(){}});var dO=class{constructor(){this._isDisposed=!1,tO(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&rO(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,nO(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&rO(e,null),e}},fO=typeof window==`object`?window:globalThis,pO=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};pO.Undefined=new pO(void 0);var mO=pO,hO=class{constructor(){this._first=mO.Undefined,this._last=mO.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===mO.Undefined}clear(){let e=this._first;for(;e!==mO.Undefined;){let t=e.next;e.prev=mO.Undefined,e.next=mO.Undefined,e=t}this._first=mO.Undefined,this._last=mO.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new mO(e);if(this._first===mO.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==mO.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==mO.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==mO.Undefined&&e.next!==mO.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===mO.Undefined&&e.next===mO.Undefined?(this._first=mO.Undefined,this._last=mO.Undefined):e.next===mO.Undefined?(this._last=this._last.prev,this._last.next=mO.Undefined):e.prev===mO.Undefined&&(this._first=this._first.next,this._first.prev=mO.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==mO.Undefined;)yield e.element,e=e.next}},gO=globalThis.performance&&typeof globalThis.performance.now==`function`,_O=class e{static create(t){return new e(t)}constructor(e){this._now=gO&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},vO;(e=>{e.None=()=>uO.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(oO(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Z({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Z({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Z({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Z;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Z(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof lO?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(vO||={});var yO=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new _O,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};yO.all=new Set,yO._idPool=0;var bO=yO,xO=-1,SO=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new TO(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};SO._idPool=1;var CO=SO,wO=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
4294
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function pO(e){hO(e)||fO.onUnexpectedError(e)}var mO=`Canceled`;function hO(e){return e instanceof gO||e instanceof Error&&e.name===mO&&e.message===mO}var gO=class extends Error{constructor(){super(mO),this.name=this.message}};function _O(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var vO=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},yO=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function bO(e,t=0){return e[e.length-(1+t)]}var xO;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(xO||={});var SO=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||xO.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};SO.empty=new SO(e=>{});function CO(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var wO;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t<n;t++)yield e[t]}e.slice=_;function v(t,n=1/0){let r=[];if(n===0)return[r,t];let i=t[Symbol.iterator]();for(let t=0;t<n;t++){let t=i.next();if(t.done)return[r,e.empty()];r.push(t.value)}return[r,{[Symbol.iterator](){return i}}]}e.consume=v;async function y(e){let t=[];for await(let n of e)t.push(n);return Promise.resolve(t)}e.asyncToArray=y})(wO||={});var TO=null;function EO(e){return TO?.trackDisposable(e),e}function DO(e){TO?.markAsDisposed(e)}function OO(e,t){TO?.setParent(e,t)}function kO(e){return TO?.markAsSingleton(e),e}function AO(e){if(wO.is(e)){let t=[];for(let n of e)if(n)try{n.dispose()}catch(e){t.push(e)}if(t.length===1)throw t[0];if(t.length>1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function jO(...e){return MO(()=>AO(e))}function MO(e){let t=EO({dispose:CO(()=>{DO(t),e()})});return t}var NO=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,EO(this)}dispose(){this._isDisposed||(DO(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{AO(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return OO(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),OO(e,null))}};NO.DISABLE_DISPOSED_WARNING=!1;var PO=NO,FO=class{constructor(){this._store=new PO,EO(this),OO(this._store,this)}dispose(){DO(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};FO.None=Object.freeze({dispose(){}});var IO=class{constructor(){this._isDisposed=!1,EO(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&OO(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,DO(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&OO(e,null),e}},LO=typeof window==`object`?window:globalThis,RO=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};RO.Undefined=new RO(void 0);var zO=RO,BO=class{constructor(){this._first=zO.Undefined,this._last=zO.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===zO.Undefined}clear(){let e=this._first;for(;e!==zO.Undefined;){let t=e.next;e.prev=zO.Undefined,e.next=zO.Undefined,e=t}this._first=zO.Undefined,this._last=zO.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new zO(e);if(this._first===zO.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==zO.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==zO.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==zO.Undefined&&e.next!==zO.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===zO.Undefined&&e.next===zO.Undefined?(this._first=zO.Undefined,this._last=zO.Undefined):e.next===zO.Undefined?(this._last=this._last.prev,this._last.next=zO.Undefined):e.prev===zO.Undefined&&(this._first=this._first.next,this._first.prev=zO.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==zO.Undefined;)yield e.element,e=e.next}},VO=globalThis.performance&&typeof globalThis.performance.now==`function`,HO=class e{static create(t){return new e(t)}constructor(e){this._now=VO&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},UO;(e=>{e.None=()=>FO.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(jO(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new Z({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new Z({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new Z({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new Z({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new Z;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function C(e,t){return e(e=>t.fire(e))}e.forward=C;function w(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=w;class T{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new Z(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function E(e,t){return new T(e,t).emitter.event}e.fromObservable=E;function D(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof PO?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(UO||={});var WO=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new HO,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};WO.all=new Set,WO._idPool=0;var GO=WO,KO=-1,qO=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t<n)return;this._stacks||=new Map;let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),--this._warnCountdown,this._warnCountdown<=0){this._warnCountdown=n*.5;let[e,r]=this.getMostFrequentStack(),i=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${r}):`;console.warn(i),console.warn(e);let a=new XO(i,e);this._errorHandler(a)}return()=>{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t<r)&&(e=[n,r],t=r);return e}};qO._idPool=1;var JO=qO,YO=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
4295
4295
|
`).slice(2).join(`
|
|
4296
|
-
`))}},TO=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},EO=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},DO=0,OO=class{constructor(e){this.value=e,this.id=DO++}},kO=2,Z=class{constructor(e){this._size=0,this._options=e,this._leakageMon=xO>0||this._options?.leakWarningThreshold?new CO(e?.onListenerError??HD,this._options?.leakWarningThreshold??xO):void 0,this._perfMon=this._options?._profName?new bO(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new EO(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||HD)(n),uO.None}if(this._disposed)return uO.None;t&&(e=e.bind(t));let r=new OO(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=wO.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof OO?(this._deliveryQueue??=new AO,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=sO(()=>{i?.(),this._removeListener(r)});return n instanceof lO?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*kO<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||HD;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof OO)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},AO=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},jO=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};jO.INSTANCE=new jO;var MO=jO;function NO(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}MO.INSTANCE.onDidChangeZoomLevel;function PO(e){return MO.INSTANCE.getZoomFactor(e)}MO.INSTANCE.onDidChangeFullscreen;var FO=typeof navigator==`object`?navigator.userAgent:``,IO=FO.indexOf(`Firefox`)>=0,LO=FO.indexOf(`AppleWebKit`)>=0,RO=FO.indexOf(`Chrome`)>=0,zO=!RO&&FO.indexOf(`Safari`)>=0;FO.indexOf(`Electron/`),FO.indexOf(`Android`);var BO=!1;if(typeof fO.matchMedia==`function`){let e=fO.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=fO.matchMedia(`(display-mode: fullscreen)`);BO=e.matches,NO(fO,e,({matches:e})=>{BO&&t.matches||(BO=e)})}function VO(){return BO}var HO=`en`,UO=!1,WO=!1,GO=!1,KO=!1,qO=!1,JO=HO,YO,XO=globalThis,ZO;typeof XO.vscode<`u`&&typeof XO.vscode.process<`u`?ZO=XO.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(ZO=process);var QO=typeof ZO?.versions?.electron==`string`&&ZO?.type===`renderer`;if(typeof ZO==`object`){UO=ZO.platform===`win32`,WO=ZO.platform===`darwin`,GO=ZO.platform===`linux`,GO&&ZO.env.SNAP&&ZO.env.SNAP_REVISION,ZO.env.CI||ZO.env.BUILD_ARTIFACTSTAGINGDIRECTORY,JO=HO;let e=ZO.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,JO=t.resolvedLanguage||HO,t.languagePack?.translationsConfigFile}catch{}KO=!0}else typeof navigator==`object`&&!QO?(YO=navigator.userAgent,UO=YO.indexOf(`Windows`)>=0,WO=YO.indexOf(`Macintosh`)>=0,(YO.indexOf(`Macintosh`)>=0||YO.indexOf(`iPad`)>=0||YO.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,GO=YO.indexOf(`Linux`)>=0,YO?.indexOf(`Mobi`),qO=!0,JO=globalThis._VSCODE_NLS_LANGUAGE||HO,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var $O=UO,ek=WO,tk=GO,nk=KO;qO&&typeof XO.importScripts==`function`&&XO.origin;var rk=YO,ik=JO,ak;(e=>{function t(){return ik}e.value=t;function n(){return ik.length===2?ik===`en`:ik.length>=3&&ik[0]===`e`&&ik[1]===`n`&&ik[2]===`-`}e.isDefaultVariant=n;function r(){return ik===`en`}e.isDefault=r})(ak||={});var ok=typeof XO.postMessage==`function`&&!XO.importScripts;(()=>{if(ok){let e=[];XO.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),XO.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var sk=!!(rk&&rk.indexOf(`Chrome`)>=0);rk&&rk.indexOf(`Firefox`),!sk&&rk&&rk.indexOf(`Safari`),rk&&rk.indexOf(`Edg/`),rk&&rk.indexOf(`Android`);var ck=typeof navigator==`object`?navigator:{};nk||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||ck&&ck.clipboard&&ck.clipboard.writeText,nk||ck&&ck.clipboard&&ck.clipboard.readText,nk||VO()||ck.keyboard,`ontouchstart`in fO||ck.maxTouchPoints,fO.PointerEvent&&(`ontouchstart`in fO||navigator.maxTouchPoints);var lk=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},uk=new lk,dk=new lk,fk=new lk,pk=Array(230),mk;(e=>{function t(e){return uk.keyCodeToStr(e)}e.toString=t;function n(e){return uk.strToKeyCode(e)}e.fromString=n;function r(e){return dk.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return fk.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return dk.strToKeyCode(e)||fk.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return uk.keyCodeToStr(e)}e.toElectronAccelerator=o})(mk||={});var hk=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new gk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},gk=class{constructor(e){if(e.length===0)throw KD(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function _k(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return mk.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(IO)switch(t){case 59:return 85;case 60:if(tk)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ek)return 57}else if(LO&&(ek&&t===93||!ek&&t===92))return 57;return pk[t]||0}var vk=ek?256:2048,yk=512,bk=1024,xk=ek?2048:256,Sk=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=_k(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=vk),this.altKey&&(t|=yk),this.shiftKey&&(t|=bk),this.metaKey&&(t|=xk),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new hk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ck=new WeakMap;function wk(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Tk=class{static getSameOriginWindowChain(e){let t=Ck.get(e);if(!t){t=[],Ck.set(e,t);let n=e,r;do r=wk(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Ek=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Tk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Dk=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(RO){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?IO&&!ek?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=zO&&$O?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?IO&&!ek?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Ok=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),kk;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Ak?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:vO.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Ok})})(kk||={});var Ak=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Ok:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},jk=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new JD(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new JD(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Mk=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new JD(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=sO(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Nk;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(Nk||={});var Pk=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await vO.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Pk.EMPTY=Pk.fromArray([]);function Fk(e){return Ik(e,0)}function Ik(e,t){switch(typeof e){case`object`:return e===null?Lk(349,t):Array.isArray(e)?Bk(e,t):Vk(e,t);case`string`:return zk(e,t);case`boolean`:return Rk(e,t);case`number`:return Lk(e,t);case`undefined`:return Lk(937,t);default:return Lk(617,t)}}function Lk(e,t){return(t<<5)-t+e|0}function Rk(e,t){return Lk(e?433:863,t)}function zk(e,t){t=Lk(149417,t);for(let n=0,r=e.length;n<r;n++)t=Lk(e.charCodeAt(n),t);return t}function Bk(e,t){return t=Lk(104579,t),e.reduce((e,t)=>Ik(t,e),t)}function Vk(e,t){return t=Lk(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=zk(n,t),Ik(e[n],t)),t)}var{registerWindow:Hk,getWindow:Uk,getDocument:Wk,getWindows:Gk,getWindowsCount:Kk,getWindowId:qk,getWindowById:Jk,hasWindow:Yk,onDidRegisterWindow:Xk,onWillUnregisterWindow:Zk,onDidUnregisterWindow:Qk}=function(){let e=new Map,t={window:fO,disposables:new lO};e.set(fO.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return uO.None;let a=new lO,o={window:t,disposables:a.add(new lO)};return e.set(t.vscodeWindowId,o),a.add(sO(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(eA(t,lA.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:fO},getDocument(e){return Uk(e).document}}}(),$k=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function eA(e,t,n,r){return new $k(e,t,n,r)}function tA(e,t){return function(n){return t(new Ek(e,n))}}function nA(e){return function(t){return e(new Sk(t))}}var rA=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=tA(Uk(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=nA(n)),eA(e,t,i,r)},iA,aA=class extends Mk{constructor(e){super(),this.defaultTarget=e&&Uk(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},oA=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){HD(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(oA.sort),a.shift().execute();r.set(i,!1)};iA=(t,r,a=0)=>{let o=qk(t),s=new oA(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var sA=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};sA.None=new sA(0,0);function cA(e){let t=e.getBoundingClientRect(),n=Uk(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Fk(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(sO(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var lA={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:LO?`webkitAnimationStart`:`animationstart`,ANIMATION_END:LO?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:LO?`webkitAnimationIteration`:`animationiteration`},uA=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=dA(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=dA(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=dA(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=dA(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=dA(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=dA(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=dA(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=dA(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=dA(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=dA(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=dA(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=dA(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=dA(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=dA(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function dA(e){return typeof e==`number`?`${e}px`:e}function fA(e){return new uA(e)}var pA=class{constructor(){this._hooks=new lO,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(sO(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=Uk(e)}this._hooks.add(eA(a,lA.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(eA(a,lA.POINTER_UP,e=>this.stopMonitoring(!0)))}};function mA(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var hA;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(hA||={});var gA=class e extends uO{constructor(){super(),this.dispatched=!1,this.targets=new hO,this.ignoreTargets=new hO,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(vO.runAndSubscribe(Xk,({window:e,disposables:t})=>{t.add(eA(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(eA(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(eA(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:fO,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=iO(new e),sO(e.INSTANCE.targets.push(t))):uO.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=iO(new e),sO(e.INSTANCE.ignoreTargets.push(t))):uO.None}static isTouchDevice(){return`ontouchstart`in fO||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(hA.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-YD(s.rollingPageX))<30&&Math.abs(s.initialPageY-YD(s.rollingPageY))<30){let e=this.newGestureEvent(hA.Tap,s.initialTarget);e.pageX=YD(s.rollingPageX),e.pageY=YD(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-YD(s.rollingPageX))<30&&Math.abs(s.initialPageY-YD(s.rollingPageY))<30){let e=this.newGestureEvent(hA.Contextmenu,s.initialTarget);e.pageX=YD(s.rollingPageX),e.pageY=YD(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=YD(s.rollingPageX),n=YD(s.rollingPageY),i=YD(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(hA.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===hA.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===hA.Change||t.type===hA.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=iA(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(hA.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(hA.Change,i.initialTarget);a.translationX=r.pageX-YD(i.rollingPageX),a.translationY=r.pageY-YD(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};gA.SCROLL_FRICTION=-.005,gA.HOLD_DELAY=700,gA.CLEAR_TAP_COUNT_TIME=400,JE([mA],gA,`isTouchDevice`,1);var _A=gA,vA=class extends uO{onclick(e,t){this._register(eA(e,lA.CLICK,n=>t(new Ek(Uk(e),n))))}onmousedown(e,t){this._register(eA(e,lA.MOUSE_DOWN,n=>t(new Ek(Uk(e),n))))}onmouseover(e,t){this._register(eA(e,lA.MOUSE_OVER,n=>t(new Ek(Uk(e),n))))}onmouseleave(e,t){this._register(eA(e,lA.MOUSE_LEAVE,n=>t(new Ek(Uk(e),n))))}onkeydown(e,t){this._register(eA(e,lA.KEY_DOWN,e=>t(new Sk(e))))}onkeyup(e,t){this._register(eA(e,lA.KEY_UP,e=>t(new Sk(e))))}oninput(e,t){this._register(eA(e,lA.INPUT,t))}onblur(e,t){this._register(eA(e,lA.BLUR,t))}onfocus(e,t){this._register(eA(e,lA.FOCUS,t))}onchange(e,t){this._register(eA(e,lA.CHANGE,t))}ignoreGesture(e){return _A.ignoreTarget(e)}},yA=11,bA=class extends vA{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=yA+`px`,this.domNode.style.height=yA+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new pA),this._register(rA(this.bgDomNode,lA.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(rA(this.domNode,lA.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new aA),this._pointerdownScheduleRepeatTimer=this._register(new jk)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Uk(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},xA=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},SA=class extends uO{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new xA(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new EA(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=EA.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},CA=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function wA(e,t){let n=t-e;return function(t){return e+n*OA(t)}}function TA(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var EA=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),TA(wA(e,r),wA(i,t),.33)}return wA(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new CA(this.scrollLeft(t),this.scrollTop(t),!1):new CA(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function DA(e){return e**3}function OA(e){return 1-DA(1-e)}var kA=class extends uO{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new jk)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},AA=140,jA=class extends vA{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new kA(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pA),this._shouldRender=!0,this.domNode=fA(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(eA(this.domNode.domNode,lA.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new bA(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=fA(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(eA(this.slider.domNode,lA.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=cA(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if($O&&a>AA){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},MA=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},NA=class extends jA{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new MA(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},PA=class extends jA{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new MA(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},FA=500,IA=50,LA=!0,RA=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},zA=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(1);return t<=.5}acceptStandardWheelEvent(e){if(RO){let t=PO(Uk(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new RA(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};zA.INSTANCE=new zA;var BA=zA,VA=class extends vA{constructor(e,t,n){super(),this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Z),this.onWillScroll=this._onWillScroll.event,this._options=UA(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new PA(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new NA(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=fA(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=fA(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=fA(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new jk),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=aO(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ek&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Dk(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=aO(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(eA(this._listenOnDomNode,lA.MOUSE_WHEEL,e=>{this._onMouseWheel(new Dk(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=BA.INSTANCE;LA&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!ek&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=IA*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=IA*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(LA&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),FA)}},HA=class extends VA{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function UA(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,ek&&(t.className+=` mac`),t}var WA=class extends uO{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new SA({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>iA(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new HA(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(vO.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(sO(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(sO(()=>this._styleElement.remove())),this._register(vO.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
4297
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};WA=JE([X(2,xD),X(3,PD),X(4,SD),X(5,zD),X(6,DD),X(7,ID)],WA);var GA=class extends uO{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(sO(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};GA=JE([X(1,xD),X(2,PD),X(3,AD),X(4,ID)],GA);var KA=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},qA={full:0,left:0,center:0,right:0},JA={full:0,left:0,center:0,right:0},YA={full:0,left:0,center:0,right:0},XA=class extends uO{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new KA,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(sO(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);JA.full=this._canvas.width,JA.left=e,JA.center=t,JA.right=e,this._refreshDrawHeightConstants(),YA.full=1,YA.left=1,YA.center=1+JA.left,YA.right=1+JA.left+JA.center}_refreshDrawHeightConstants(){qA.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);qA.left=t,qA.center=t,qA.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qA.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qA.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qA.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*qA.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(YA[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-qA[e.position||`full`]/2),JA[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+qA[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};XA=JE([X(2,xD),X(3,AD),X(4,ID),X(5,DD),X(6,zD),X(7,PD)],XA);var Q;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
4298
|
-
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(Q||={});var ZA;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(ZA||={});var QA;(e=>e.ST=`${Q.ESC}\\`)(QA||={});var $A=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Q.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};$A=JE([X(2,xD),X(3,DD),X(4,CD),X(5,ID)],$A);var ej=0,tj=0,nj=0,rj=0,ij={css:`#00000000`,rgba:0},aj;(e=>{function t(e,t,n,r){return r===void 0?`#${uj(e)}${uj(t)}${uj(n)}`:`#${uj(e)}${uj(t)}${uj(n)}${uj(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(aj||={});var oj;(e=>{function t(e,t){if(rj=(t.rgba&255)/255,rj===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return ej=a+Math.round((n-a)*rj),tj=o+Math.round((r-o)*rj),nj=s+Math.round((i-s)*rj),{css:aj.toCss(ej,tj,nj),rgba:aj.toRgba(ej,tj,nj)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=lj.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return aj.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[ej,tj,nj]=lj.toChannels(t),{css:aj.toCss(ej,tj,nj),rgba:t}}e.opaque=i;function a(e,t){return rj=Math.round(t*255),[ej,tj,nj]=lj.toChannels(e.rgba),{css:aj.toCss(ej,tj,nj,rj),rgba:aj.toRgba(ej,tj,nj,rj)}}e.opacity=a;function o(e,t){return rj=e.rgba&255,a(e,rj*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(oj||={});var sj;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return ej=parseInt(e.slice(1,2).repeat(2),16),tj=parseInt(e.slice(2,3).repeat(2),16),nj=parseInt(e.slice(3,4).repeat(2),16),aj.toColor(ej,tj,nj);case 5:return ej=parseInt(e.slice(1,2).repeat(2),16),tj=parseInt(e.slice(2,3).repeat(2),16),nj=parseInt(e.slice(3,4).repeat(2),16),rj=parseInt(e.slice(4,5).repeat(2),16),aj.toColor(ej,tj,nj,rj);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return ej=parseInt(r[1]),tj=parseInt(r[2]),nj=parseInt(r[3]),rj=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),aj.toColor(ej,tj,nj,rj);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[ej,tj,nj,rj]=t.getImageData(0,0,1,1).data,rj!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:aj.toRgba(ej,tj,nj,rj),css:e}}e.toColor=r})(sj||={});var cj;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(cj||={});var lj;(e=>{function t(e,t){if(rj=(t&255)/255,rj===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return ej=a+Math.round((n-a)*rj),tj=o+Math.round((r-o)*rj),nj=s+Math.round((i-s)*rj),aj.toRgba(ej,tj,nj)}e.blend=t;function n(e,t,n){let a=cj.relativeLuminance(e>>8),o=cj.relativeLuminance(t>>8);if(dj(a,o)<n){if(o<a){let o=r(e,t,n),s=dj(a,cj.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>dj(a,cj.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=dj(a,cj.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>dj(a,cj.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=dj(cj.relativeLuminance2(o,s,c),cj.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=dj(cj.relativeLuminance2(o,s,c),cj.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=dj(cj.relativeLuminance2(o,s,c),cj.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=dj(cj.relativeLuminance2(o,s,c),cj.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(lj||={});function uj(e){let t=e.toString(16);return t.length<2?`0`+t:t}function dj(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var fj=class extends fD{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},pj=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new mD}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||dD.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)pj._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||dD.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};pj=JE([X(0,xD)],pj);function mj(e){return 57508<=e&&e<=57558}function hj(e){return 9472<=e&&e<=9631}function gj(e){return mj(e)||hj(e)}function _j(){return{css:{canvas:vj(),cell:vj()},device:{canvas:vj(),cell:vj(),char:{width:0,height:0,left:0,top:0}}}}function vj(){return{width:0,height:0}}var yj=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new mD,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new fj(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let ee=this._isCellInSelection(k,t),P=n&&k===a,te=O&&k>=l&&k<=u,ne=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{ne=!0});let re=N.getChars()||dD;if(re===` `&&(N.isUnderline()||N.isOverline())&&(re=`\xA0`),T=m*s-c.get(re,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(ee&&w||!ee&&!w&&N.bg===y)&&(ee&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&te===S&&T===C&&!P&&!A&&!ne&&j){N.isInvisible()?_+=dD:_+=re,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=te,C=T,w=ee,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&P&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?dD:N.getChars()||dD,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${fD.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),te&&(h.style.textDecoration=`underline`);let ie=N.getFgColor(),ae=N.getFgColorMode(),oe=N.getBgColor(),se=N.getBgColorMode(),ce=!!N.isInverse();if(ce){let e=ie;ie=oe,oe=e;let t=ae;ae=se,se=t}let le,ue,de=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&de||(e.backgroundColorRGB&&(se=50331648,oe=e.backgroundColorRGB.rgba>>8&16777215,le=e.backgroundColorRGB),e.foregroundColorRGB&&(ae=50331648,ie=e.foregroundColorRGB.rgba>>8&16777215,ue=e.foregroundColorRGB),de=e.options.layer===`top`)}),!de&&ee&&(le=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,oe=le.rgba>>8&16777215,se=50331648,de=!0,p.selectionForeground&&(ae=50331648,ie=p.selectionForeground.rgba>>8&16777215,ue=p.selectionForeground)),de&&D.push(`xterm-decoration-top`);let fe;switch(se){case 16777216:case 33554432:fe=p.ansi[oe],D.push(`xterm-bg-${oe}`);break;case 50331648:fe=aj.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(h,`background-color:#${bj((oe>>>0).toString(16),`0`,6)}`);break;default:ce?(fe=p.foreground,D.push(`xterm-bg-257`)):fe=p.background}switch(le||N.isDim()&&(le=oj.multiplyOpacity(fe,.5)),ae){case 16777216:case 33554432:N.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(h,fe,p.ansi[ie],N,le,void 0)||D.push(`xterm-fg-${ie}`);break;case 50331648:let e=aj.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(h,fe,e,N,le,ue)||this._addStyle(h,`color:#${bj(ie.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,fe,p.foreground,N,le,ue)||ce&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!P&&!A&&!ne&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||gj(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=oj.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};yj=JE([X(1,RD),X(2,DD),X(3,PD),X(4,CD),X(5,AD),X(6,zD)],yj);function bj(e,t,n){for(;e.length<n;)e=t+e;return e}var xj=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Sj=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Cj(){return new Sj}var wj=`xterm-dom-renderer-owner-`,Tj=`xterm-rows`,Ej=`xterm-fg-`,Dj=`xterm-bg-`,Oj=`xterm-focus`,kj=`xterm-selection`,Aj=1,jj=class extends uO{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=Aj++,this._rowElements=[],this._selectionRenderModel=Cj(),this.onRequestRedraw=this._register(new Z).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Tj),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(kj),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=_j(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(yj,document),this._element.classList.add(wj+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(sO(()=>{this._element.classList.remove(wj+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new xj(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Tj} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Tj} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Tj} .xterm-dim { color: ${oj.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Tj}.${Oj} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Tj}.${Oj} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Tj}.${Oj} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Tj} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Tj} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Tj} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Tj} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Tj} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${kj} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${kj} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${kj} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Ej}${n} { color: ${r.css}; }${this._terminalSelector} .${Ej}${n}.xterm-dim { color: ${oj.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Dj}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Ej}257 { color: ${oj.opaque(e.background).css}; }${this._terminalSelector} .${Ej}257.xterm-dim { color: ${oj.multiplyOpacity(oj.opaque(e.background),.5).css}; }${this._terminalSelector} .${Dj}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Oj),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Oj),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${wj}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};jj=JE([X(7,TD),X(8,ND),X(9,DD),X(10,xD),X(11,CD),X(12,PD),X(13,zD)],jj);var Mj=class extends uO{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Z),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Fj(this._optionsService))}catch{this._measureStrategy=this._register(new Pj(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Mj=JE([X(2,DD)],Mj);var Nj=class extends uO{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Pj=class extends Nj{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Fj=class extends Nj{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Ij=class extends uO{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Lj(this._window)),this._onDprChange=this._register(new Z),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Z),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(vO.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(eA(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(eA(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},Lj=class extends uO{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new dO),this._onDprChange=this._register(new Z),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(sO(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=eA(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Rj=class extends uO{constructor(){super(),this.linkProviders=[],this._register(sO(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function zj(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function Bj(e,t,n,r,i,a,o,s,c){if(!a)return;let l=zj(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var Vj=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Bj(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=zj(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};Vj=JE([X(0,ID),X(1,ND)],Vj);var Hj=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Uj={};qE(Uj,{getSafariVersion:()=>Xj,isChromeOS:()=>nM,isFirefox:()=>qj,isIpad:()=>Qj,isIphone:()=>$j,isLegacyEdge:()=>Jj,isLinux:()=>tM,isMac:()=>Zj,isNode:()=>Wj,isSafari:()=>Yj,isWindows:()=>eM});var Wj=typeof process<`u`&&`title`in process,Gj=Wj?`node`:navigator.userAgent,Kj=Wj?`node`:navigator.platform,qj=Gj.includes(`Firefox`),Jj=Gj.includes(`Edge`),Yj=/^((?!chrome|android).)*safari/i.test(Gj);function Xj(){if(!Yj)return 0;let e=Gj.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Zj=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(Kj),Qj=Kj===`iPad`,$j=Kj===`iPhone`,eM=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(Kj),tM=Kj.indexOf(`Linux`)>=0,nM=/\bCrOS\b/.test(Gj),rM=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},iM=class extends rM{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},aM=class extends rM{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},oM=!Wj&&`requestIdleCallback`in window?aM:iM,sM=class{constructor(){this._queue=new oM}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},cM=class extends uO{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new dO),this._pausedResizeTask=new sM,this._observerDisposable=this._register(new dO),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Z),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Z),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Z),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Hj((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new lM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(sO(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=sO(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};cM=JE([X(2,DD),X(3,ND),X(4,CD),X(5,AD),X(6,xD),X(7,PD),X(8,zD)],cM);var lM=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function uM(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return pM(i,a,e,t,n,r)+mM(a,t,n,r)+hM(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,SM(Math.abs(i-e),xM(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return SM(fM(a>t?e:i,n)+(s-1)*n.cols+1+dM(a>t?i:e,n),xM(o,r))}function dM(e,t){return e-1}function fM(e,t){return t.cols-e}function pM(e,t,n,r,i,a){return mM(t,r,i,a).length===0?``:SM(bM(e,t,e,t-_M(t,i),!1,i).length,xM(`D`,a))}function mM(e,t,n,r){let i=e-_M(e,n),a=t-_M(t,n);return SM(Math.abs(i-a)-gM(e,t,n),xM(yM(e,t),r))}function hM(e,t,n,r,i,a){let o;o=mM(t,r,i,a).length>0?r-_M(r,i):t;let s=r,c=vM(e,t,n,r,i,a);return SM(bM(e,o,n,s,c===`C`,i).length,xM(c,a))}function gM(e,t,n){let r=0,i=e-_M(e,n),a=t-_M(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=yM(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function _M(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function vM(e,t,n,r,i,a){let o;return o=mM(n,r,i,a).length>0?r-_M(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function yM(e,t){return e>t?`A`:`B`}function bM(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function xM(e,t){let n=t?`O`:`[`;return Q.ESC+n+e}function SM(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var CM=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function wM(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var TM=50,EM=15,DM=50,OM=500,kM=RegExp(`\xA0`,`g`),AM=class extends uO{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new mD,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Z),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Z),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new CM(this._bufferService),this._activeSelectionMode=0,this._register(sO(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(kM,` `)).join(eM?`\r
|
|
4296
|
+
`))}},XO=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},ZO=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},QO=0,$O=class{constructor(e){this.value=e,this.id=QO++}},ek=2,Z=class{constructor(e){this._size=0,this._options=e,this._leakageMon=KO>0||this._options?.leakWarningThreshold?new JO(e?.onListenerError??pO,this._options?.leakWarningThreshold??KO):void 0,this._perfMon=this._options?._profName?new GO(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new ZO(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||pO)(n),FO.None}if(this._disposed)return FO.None;t&&(e=e.bind(t));let r=new $O(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=YO.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof $O?(this._deliveryQueue??=new tk,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=MO(()=>{i?.(),this._removeListener(r)});return n instanceof PO?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ek<=t.length){let e=0;for(let n=0;n<t.length;n++)t[n]?t[e++]=t[n]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=e}}_deliver(e,t){if(!e)return;let n=this._options?.onListenerError||pO;if(!n){e.value(t);return}try{e.value(t)}catch(e){n(e)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners){if(this._listeners instanceof $O)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}}this._perfMon?.stop()}hasListeners(){return this._size>0}},tk=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},nk=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};nk.INSTANCE=new nk;var rk=nk;function ik(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}rk.INSTANCE.onDidChangeZoomLevel;function ak(e){return rk.INSTANCE.getZoomFactor(e)}rk.INSTANCE.onDidChangeFullscreen;var ok=typeof navigator==`object`?navigator.userAgent:``,sk=ok.indexOf(`Firefox`)>=0,ck=ok.indexOf(`AppleWebKit`)>=0,lk=ok.indexOf(`Chrome`)>=0,uk=!lk&&ok.indexOf(`Safari`)>=0;ok.indexOf(`Electron/`),ok.indexOf(`Android`);var dk=!1;if(typeof LO.matchMedia==`function`){let e=LO.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=LO.matchMedia(`(display-mode: fullscreen)`);dk=e.matches,ik(LO,e,({matches:e})=>{dk&&t.matches||(dk=e)})}function fk(){return dk}var pk=`en`,mk=!1,hk=!1,gk=!1,_k=!1,vk=!1,yk=pk,bk,xk=globalThis,Sk;typeof xk.vscode<`u`&&typeof xk.vscode.process<`u`?Sk=xk.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Sk=process);var Ck=typeof Sk?.versions?.electron==`string`&&Sk?.type===`renderer`;if(typeof Sk==`object`){mk=Sk.platform===`win32`,hk=Sk.platform===`darwin`,gk=Sk.platform===`linux`,gk&&Sk.env.SNAP&&Sk.env.SNAP_REVISION,Sk.env.CI||Sk.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yk=pk;let e=Sk.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,yk=t.resolvedLanguage||pk,t.languagePack?.translationsConfigFile}catch{}_k=!0}else typeof navigator==`object`&&!Ck?(bk=navigator.userAgent,mk=bk.indexOf(`Windows`)>=0,hk=bk.indexOf(`Macintosh`)>=0,(bk.indexOf(`Macintosh`)>=0||bk.indexOf(`iPad`)>=0||bk.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,gk=bk.indexOf(`Linux`)>=0,bk?.indexOf(`Mobi`),vk=!0,yk=globalThis._VSCODE_NLS_LANGUAGE||pk,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var wk=mk,Tk=hk,Ek=gk,Dk=_k;vk&&typeof xk.importScripts==`function`&&xk.origin;var Ok=bk,kk=yk,Ak;(e=>{function t(){return kk}e.value=t;function n(){return kk.length===2?kk===`en`:kk.length>=3&&kk[0]===`e`&&kk[1]===`n`&&kk[2]===`-`}e.isDefaultVariant=n;function r(){return kk===`en`}e.isDefault=r})(Ak||={});var jk=typeof xk.postMessage==`function`&&!xk.importScripts;(()=>{if(jk){let e=[];xk.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),xk.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Mk=!!(Ok&&Ok.indexOf(`Chrome`)>=0);Ok&&Ok.indexOf(`Firefox`),!Mk&&Ok&&Ok.indexOf(`Safari`),Ok&&Ok.indexOf(`Edg/`),Ok&&Ok.indexOf(`Android`);var Nk=typeof navigator==`object`?navigator:{};Dk||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Nk&&Nk.clipboard&&Nk.clipboard.writeText,Dk||Nk&&Nk.clipboard&&Nk.clipboard.readText,Dk||fk()||Nk.keyboard,`ontouchstart`in LO||Nk.maxTouchPoints,LO.PointerEvent&&(`ontouchstart`in LO||navigator.maxTouchPoints);var Pk=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Fk=new Pk,Ik=new Pk,Lk=new Pk,Rk=Array(230),zk;(e=>{function t(e){return Fk.keyCodeToStr(e)}e.toString=t;function n(e){return Fk.strToKeyCode(e)}e.fromString=n;function r(e){return Ik.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Lk.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Ik.strToKeyCode(e)||Lk.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Fk.keyCodeToStr(e)}e.toElectronAccelerator=o})(zk||={});var Bk=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Vk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Vk=class{constructor(e){if(e.length===0)throw _O(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t<n;t++)t!==0&&(e+=`;`),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Hk(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return zk.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(sk)switch(t){case 59:return 85;case 60:if(Ek)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Tk)return 57}else if(ck&&(Tk&&t===93||!Tk&&t===92))return 57;return Rk[t]||0}var Uk=Tk?256:2048,Wk=512,Gk=1024,Kk=Tk?2048:256,qk=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.(`AltGraph`),this.keyCode=Hk(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Uk),this.altKey&&(t|=Wk),this.shiftKey&&(t|=Gk),this.metaKey&&(t|=Kk),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Bk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Jk=new WeakMap;function Yk(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,n=e.parent.location;if(t.origin!==`null`&&n.origin!==`null`&&t.origin!==n.origin)return null}catch{return null}return e.parent}var Xk=class{static getSameOriginWindowChain(e){let t=Jk.get(e);if(!t){t=[],Jk.set(e,t);let n=e,r;do r=Yk(n),r?t.push({window:new WeakRef(n),iframeElement:n.frameElement||null}):t.push({window:new WeakRef(n),iframeElement:null}),n=r;while(n)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let n=0,r=0,i=this.getSameOriginWindowChain(e);for(let e of i){let i=e.window.deref();if(n+=i?.scrollY??0,r+=i?.scrollX??0,i===t||!e.iframeElement)break;let a=e.iframeElement.getBoundingClientRect();n+=a.top,r+=a.left}return{top:n,left:r}}},Zk=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type===`dblclick`&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX==`number`?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let n=Xk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Qk=class{constructor(e,t=0,n=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=n,this.deltaX=t;let r=!1;if(lk){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let t=e,n=e,i=e.view?.devicePixelRatio||1;if(typeof t.wheelDeltaY<`u`)this.deltaY=r?t.wheelDeltaY/(120*i):t.wheelDeltaY/120;else if(typeof n.VERTICAL_AXIS<`u`&&n.axis===n.VERTICAL_AXIS)this.deltaY=-n.detail/3;else if(e.type===`wheel`){let t=e;this.deltaY=t.deltaMode===t.DOM_DELTA_LINE?sk&&!Tk?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=uk&&wk?-(t.wheelDeltaX/120):r?t.wheelDeltaX/(120*i):t.wheelDeltaX/120;else if(typeof n.HORIZONTAL_AXIS<`u`&&n.axis===n.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type===`wheel`){let t=e;this.deltaX=t.deltaMode===t.DOM_DELTA_LINE?sk&&!Tk?-e.deltaX/3:-e.deltaX:-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(this.deltaY=r?e.wheelDelta/(120*i):e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},$k=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),eA;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof tA?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:UO.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:$k})})(eA||={});var tA=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?$k:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},nA=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new yO(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new yO(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},rA=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new yO(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=MO(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var iA;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(iA||={});var aA=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await UO.toPromise(this._onStateChanged.event)}while(1)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};aA.EMPTY=aA.fromArray([]);function oA(e){return sA(e,0)}function sA(e,t){switch(typeof e){case`object`:return e===null?cA(349,t):Array.isArray(e)?dA(e,t):fA(e,t);case`string`:return uA(e,t);case`boolean`:return lA(e,t);case`number`:return cA(e,t);case`undefined`:return cA(937,t);default:return cA(617,t)}}function cA(e,t){return(t<<5)-t+e|0}function lA(e,t){return cA(e?433:863,t)}function uA(e,t){t=cA(149417,t);for(let n=0,r=e.length;n<r;n++)t=cA(e.charCodeAt(n),t);return t}function dA(e,t){return t=cA(104579,t),e.reduce((e,t)=>sA(t,e),t)}function fA(e,t){return t=cA(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=uA(n,t),sA(e[n],t)),t)}var{registerWindow:pA,getWindow:mA,getDocument:hA,getWindows:gA,getWindowsCount:_A,getWindowId:vA,getWindowById:yA,hasWindow:bA,onDidRegisterWindow:xA,onWillUnregisterWindow:SA,onDidUnregisterWindow:CA}=function(){let e=new Map,t={window:LO,disposables:new PO};e.set(LO.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return FO.None;let a=new PO,o={window:t,disposables:a.add(new PO)};return e.set(t.vscodeWindowId,o),a.add(MO(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(TA(t,PA.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:LO},getDocument(e){return mA(e).document}}}(),wA=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function TA(e,t,n,r){return new wA(e,t,n,r)}function EA(e,t){return function(n){return t(new Zk(e,n))}}function DA(e){return function(t){return e(new qk(t))}}var OA=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=EA(mA(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=DA(n)),TA(e,t,i,r)},kA,AA=class extends rA{constructor(e){super(),this.defaultTarget=e&&mA(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},jA=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){pO(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(jA.sort),a.shift().execute();r.set(i,!1)};kA=(t,r,a=0)=>{let o=vA(t),s=new jA(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var MA=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};MA.None=new MA(0,0);function NA(e){let t=e.getBoundingClientRect(),n=mA(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=oA(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(MO(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var PA={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:ck?`webkitAnimationStart`:`animationstart`,ANIMATION_END:ck?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:ck?`webkitAnimationIteration`:`animationiteration`},FA=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=IA(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=IA(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=IA(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=IA(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=IA(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=IA(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=IA(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=IA(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=IA(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=IA(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=IA(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=IA(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=IA(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=IA(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function IA(e){return typeof e==`number`?`${e}px`:e}function LA(e){return new FA(e)}var RA=class{constructor(){this._hooks=new PO,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(MO(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=mA(e)}this._hooks.add(TA(a,PA.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(TA(a,PA.POINTER_UP,e=>this.stopMonitoring(!0)))}};function zA(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var BA;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(BA||={});var VA=class e extends FO{constructor(){super(),this.dispatched=!1,this.targets=new BO,this.ignoreTargets=new BO,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(UO.runAndSubscribe(xA,({window:e,disposables:t})=>{t.add(TA(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(TA(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(TA(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:LO,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=kO(new e),MO(e.INSTANCE.targets.push(t))):FO.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=kO(new e),MO(e.INSTANCE.ignoreTargets.push(t))):FO.None}static isTouchDevice(){return`ontouchstart`in LO||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n<r;n++){let r=e.targetTouches.item(n);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:t,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[t],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let i=this.newGestureEvent(BA.Start,r.target);i.pageX=r.pageX,i.pageY=r.pageY,this.dispatchEvent(i)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}onTouchEnd(t,n){let r=Date.now(),i=Object.keys(this.activeTouches).length;for(let a=0,o=n.changedTouches.length;a<o;a++){let o=n.changedTouches.item(a);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn(`move of an UNKNOWN touch`,o);continue}let s=this.activeTouches[o.identifier],c=Date.now()-s.initialTimeStamp;if(c<e.HOLD_DELAY&&Math.abs(s.initialPageX-bO(s.rollingPageX))<30&&Math.abs(s.initialPageY-bO(s.rollingPageY))<30){let e=this.newGestureEvent(BA.Tap,s.initialTarget);e.pageX=bO(s.rollingPageX),e.pageY=bO(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-bO(s.rollingPageX))<30&&Math.abs(s.initialPageY-bO(s.rollingPageY))<30){let e=this.newGestureEvent(BA.Contextmenu,s.initialTarget);e.pageX=bO(s.rollingPageX),e.pageY=bO(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=bO(s.rollingPageX),n=bO(s.rollingPageY),i=bO(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(BA.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===BA.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===BA.Change||t.type===BA.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=kA(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(BA.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn(`end of an UNKNOWN touch`,r);continue}let i=this.activeTouches[r.identifier],a=this.newGestureEvent(BA.Change,i.initialTarget);a.translationX=r.pageX-bO(i.rollingPageX),a.translationY=r.pageY-bO(i.rollingPageY),a.pageX=r.pageX,a.pageY=r.pageY,this.dispatchEvent(a),i.rollingPageX.length>3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};VA.SCROLL_FRICTION=-.005,VA.HOLD_DELAY=700,VA.CLEAR_TAP_COUNT_TIME=400,yD([zA],VA,`isTouchDevice`,1);var HA=VA,UA=class extends FO{onclick(e,t){this._register(TA(e,PA.CLICK,n=>t(new Zk(mA(e),n))))}onmousedown(e,t){this._register(TA(e,PA.MOUSE_DOWN,n=>t(new Zk(mA(e),n))))}onmouseover(e,t){this._register(TA(e,PA.MOUSE_OVER,n=>t(new Zk(mA(e),n))))}onmouseleave(e,t){this._register(TA(e,PA.MOUSE_LEAVE,n=>t(new Zk(mA(e),n))))}onkeydown(e,t){this._register(TA(e,PA.KEY_DOWN,e=>t(new qk(e))))}onkeyup(e,t){this._register(TA(e,PA.KEY_UP,e=>t(new qk(e))))}oninput(e,t){this._register(TA(e,PA.INPUT,t))}onblur(e,t){this._register(TA(e,PA.BLUR,t))}onfocus(e,t){this._register(TA(e,PA.FOCUS,t))}onchange(e,t){this._register(TA(e,PA.CHANGE,t))}ignoreGesture(e){return HA.ignoreTarget(e)}},WA=11,GA=class extends UA{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=WA+`px`,this.domNode.style.height=WA+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new RA),this._register(OA(this.bgDomNode,PA.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(OA(this.domNode,PA.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new AA),this._pointerdownScheduleRepeatTimer=this._register(new nA)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,mA(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},KA=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},qA=class extends FO{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new KA(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new ZA(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=ZA.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},JA=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function YA(e,t){let n=t-e;return function(t){return e+n*$A(t)}}function XA(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var ZA=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.duration=r,this.startTime=n,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,n){if(Math.abs(e-t)>2.5*n){let r,i;return e<t?(r=e+.75*n,i=t-.75*n):(r=e-.75*n,i=t+.75*n),XA(YA(e,r),YA(i,t),.33)}return YA(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;return t<1?new JA(this.scrollLeft(t),this.scrollTop(t),!1):new JA(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,n,r){return e.start(t,n,r)}static start(t,n,r){r+=10;let i=Date.now()-10;return new e(t,n,i,r)}};function QA(e){return e**3}function $A(e){return 1-QA(1-e)}var ej=class extends FO{constructor(e,t,n){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=n,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new nA)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3||this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},tj=140,nj=class extends UA{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new ej(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new RA),this._shouldRender=!0,this.domNode=LA(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(TA(this.domNode.domNode,PA.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new GA(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=LA(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(TA(this.slider.domNode,PA.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=NA(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(wk&&a>tj){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},rj=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t<this._computedSliderPosition?n-=this._visibleSize:n+=this._visibleSize,n}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},ij=class extends nj{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new rj(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,i.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:`horizontal`,scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},aj=class extends nj{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new rj(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,r.height,r.scrollHeight,i.scrollTop),visibility:t.vertical,extraScrollbarClassName:`vertical`,scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw Error(`horizontalHasArrows is not supported in xterm.js`);this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},oj=500,sj=50,cj=!0,lj=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},uj=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,n=1,r=this._rear;do{let i=r===this._front?e:2**-n;if(e-=i,t+=this._memory[r].score*i,r===this._front)break;r=(this._capacity+r-1)%this._capacity,n++}while(1);return t<=.5}acceptStandardWheelEvent(e){if(lk){let t=ak(mA(e.browserEvent));this.accept(Date.now(),e.deltaX*t,e.deltaY*t)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,n){let r=null,i=new lj(e,t,n);this._front===-1&&this._rear===-1?(this._memory[0]=i,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=i),i.score=this._computeScore(i,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};uj.INSTANCE=new uj;var dj=uj,fj=class extends UA{constructor(e,t,n){super(),this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new Z),this.onWillScroll=this._onWillScroll.event,this._options=mj(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new aj(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new ij(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=LA(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=LA(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=LA(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new nA),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=AO(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Tk&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Qk(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=AO(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(TA(this._listenOnDomNode,PA.MOUSE_WHEEL,e=>{this._onMouseWheel(new Qk(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=dj.INSTANCE;cj&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!Tk&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=sj*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=sj*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(cj&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),oj)}},pj=class extends fj{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function mj(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,Tk&&(t.className+=` mac`),t}var hj=class extends FO{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new Z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new qA({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>kA(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new pj(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(UO.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(MO(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(MO(()=>this._styleElement.remove())),this._register(UO.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(`
|
|
4297
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};hj=yD([X(2,KD),X(3,aO),X(4,qD),X(5,uO),X(6,QD),X(7,sO)],hj);var gj=class extends FO{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(MO(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};gj=yD([X(1,KD),X(2,aO),X(3,tO),X(4,sO)],gj);var _j=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},vj={full:0,left:0,center:0,right:0},yj={full:0,left:0,center:0,right:0},bj={full:0,left:0,center:0,right:0},xj=class extends FO{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new _j,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(MO(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);yj.full=this._canvas.width,yj.left=e,yj.center=t,yj.right=e,this._refreshDrawHeightConstants(),bj.full=1,bj.left=1,bj.center=1+yj.left,bj.right=1+yj.left+yj.center}_refreshDrawHeightConstants(){vj.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);vj.left=t,vj.center=t,vj.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vj.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vj.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vj.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*vj.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(bj[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-vj[e.position||`full`]/2),yj[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+vj[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};xj=yD([X(2,KD),X(3,tO),X(4,sO),X(5,QD),X(6,uO),X(7,aO)],xj);var Q;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=`
|
|
4298
|
+
`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(Q||={});var Sj;(e=>(e.PAD=``,e.HOP=``,e.BPH=``,e.NBH=``,e.IND=``,e.NEL=`
`,e.SSA=``,e.ESA=``,e.HTS=``,e.HTJ=``,e.VTS=``,e.PLD=``,e.PLU=``,e.RI=``,e.SS2=``,e.SS3=``,e.DCS=``,e.PU1=``,e.PU2=``,e.STS=``,e.CCH=``,e.MW=``,e.SPA=``,e.EPA=``,e.SOS=``,e.SGCI=``,e.SCI=``,e.CSI=``,e.ST=``,e.OSC=``,e.PM=``,e.APC=``))(Sj||={});var Cj;(e=>e.ST=`${Q.ESC}\\`)(Cj||={});var wj=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${Q.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};wj=yD([X(2,KD),X(3,QD),X(4,JD),X(5,sO)],wj);var Tj=0,Ej=0,Dj=0,Oj=0,kj={css:`#00000000`,rgba:0},Aj;(e=>{function t(e,t,n,r){return r===void 0?`#${Fj(e)}${Fj(t)}${Fj(n)}`:`#${Fj(e)}${Fj(t)}${Fj(n)}${Fj(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(Aj||={});var jj;(e=>{function t(e,t){if(Oj=(t.rgba&255)/255,Oj===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Tj=a+Math.round((n-a)*Oj),Ej=o+Math.round((r-o)*Oj),Dj=s+Math.round((i-s)*Oj),{css:Aj.toCss(Tj,Ej,Dj),rgba:Aj.toRgba(Tj,Ej,Dj)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Pj.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Aj.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Tj,Ej,Dj]=Pj.toChannels(t),{css:Aj.toCss(Tj,Ej,Dj),rgba:t}}e.opaque=i;function a(e,t){return Oj=Math.round(t*255),[Tj,Ej,Dj]=Pj.toChannels(e.rgba),{css:Aj.toCss(Tj,Ej,Dj,Oj),rgba:Aj.toRgba(Tj,Ej,Dj,Oj)}}e.opacity=a;function o(e,t){return Oj=e.rgba&255,a(e,Oj*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(jj||={});var Mj;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Tj=parseInt(e.slice(1,2).repeat(2),16),Ej=parseInt(e.slice(2,3).repeat(2),16),Dj=parseInt(e.slice(3,4).repeat(2),16),Aj.toColor(Tj,Ej,Dj);case 5:return Tj=parseInt(e.slice(1,2).repeat(2),16),Ej=parseInt(e.slice(2,3).repeat(2),16),Dj=parseInt(e.slice(3,4).repeat(2),16),Oj=parseInt(e.slice(4,5).repeat(2),16),Aj.toColor(Tj,Ej,Dj,Oj);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Tj=parseInt(r[1]),Ej=parseInt(r[2]),Dj=parseInt(r[3]),Oj=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Aj.toColor(Tj,Ej,Dj,Oj);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Tj,Ej,Dj,Oj]=t.getImageData(0,0,1,1).data,Oj!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Aj.toRgba(Tj,Ej,Dj,Oj),css:e}}e.toColor=r})(Mj||={});var Nj;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Nj||={});var Pj;(e=>{function t(e,t){if(Oj=(t&255)/255,Oj===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Tj=a+Math.round((n-a)*Oj),Ej=o+Math.round((r-o)*Oj),Dj=s+Math.round((i-s)*Oj),Aj.toRgba(Tj,Ej,Dj)}e.blend=t;function n(e,t,n){let a=Nj.relativeLuminance(e>>8),o=Nj.relativeLuminance(t>>8);if(Ij(a,o)<n){if(o<a){let o=r(e,t,n),s=Ij(a,Nj.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>Ij(a,Nj.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Ij(a,Nj.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>Ij(a,Nj.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ij(Nj.relativeLuminance2(o,s,c),Nj.relativeLuminance2(r,i,a));for(;l<n&&(o>0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Ij(Nj.relativeLuminance2(o,s,c),Nj.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Ij(Nj.relativeLuminance2(o,s,c),Nj.relativeLuminance2(r,i,a));for(;l<n&&(o<255||s<255||c<255);)o=Math.min(255,o+Math.ceil((255-o)*.1)),s=Math.min(255,s+Math.ceil((255-s)*.1)),c=Math.min(255,c+Math.ceil((255-c)*.1)),l=Ij(Nj.relativeLuminance2(o,s,c),Nj.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Pj||={});function Fj(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Ij(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Lj=class extends LD{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Rj=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new zD}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,o=0,s=t.getFg(0),c=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==s||this._workCell.bg!==c){if(e-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,o=a,s=this._workCell.fg,c=this._workCell.bg}a+=this._workCell.getChars().length||ID.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(e,t,n,r,i){let a=e.substring(t,n),o=[];try{o=this._characterJoiners[0].handler(a)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let t=this._characterJoiners[e].handler(a);for(let e=0;e<t.length;e++)Rj._mergeRanges(o,t[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(o,r,i),o}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,o=e[r];if(o){for(let s=n;s<this._bufferService.cols;s++){let n=t.getWidth(s),c=t.getString(s).length||ID.length;if(n!==0){if(!i&&o[0]<=a&&(o[0]=s,i=!0),o[1]<=a){if(o[1]=s,o=e[++r],!o)break;o[0]<=a?(o[0]=s,i=!0):i=!1}a+=c}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0);continue}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};Rj=yD([X(0,KD)],Rj);function zj(e){return 57508<=e&&e<=57558}function Bj(e){return 9472<=e&&e<=9631}function Vj(e){return zj(e)||Bj(e)}function Hj(){return{css:{canvas:Uj(),cell:Uj()},device:{canvas:Uj(),cell:Uj(),char:{width:0,height:0,left:0,top:0}}}}function Uj(){return{width:0,height:0}}var Wj=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new zD,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,a,o,s,c,l,u){let d=[],f=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,m=e.getNoBgTrimmedLength();n&&m<a+1&&(m=a+1);let h,g=0,_=``,v=0,y=0,b=0,x=0,S=!1,C=0,w=!1,T=0,E=0,D=[],O=l!==-1&&u!==-1;for(let k=0;k<m;k++){e.loadCell(k,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let A=!1,j=k>=E,M=k,N=this._workCell;if(f.length>0&&k===f[0][0]&&j){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)j&&=i===this._isCellInSelection(v,t);j&&=!n||a<r[0]||a>=r[1],j?(A=!0,N=new Lj(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),M=r[1]-1,m=N.getWidth()):E=r[1]}let ee=this._isCellInSelection(k,t),P=n&&k===a,te=O&&k>=l&&k<=u,ne=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{ne=!0});let re=N.getChars()||ID;if(re===` `&&(N.isUnderline()||N.isOverline())&&(re=`\xA0`),T=m*s-c.get(re,N.isBold(),N.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(ee&&w||!ee&&!w&&N.bg===y)&&(ee&&w&&p.selectionForeground||N.fg===b)&&N.extended.ext===x&&te===S&&T===C&&!P&&!A&&!ne&&j){N.isInvisible()?_+=ID:_+=re,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=N.bg,b=N.fg,x=N.extended.ext,S=te,C=T,w=ee,A&&a>=k&&a<=M&&(a=k),!this._coreService.isCursorHidden&&P&&this._coreService.isCursorInitialized){if(D.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&D.push(`xterm-cursor-blink`),D.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:D.push(`xterm-cursor-outline`);break;case`block`:D.push(`xterm-cursor-block`);break;case`bar`:D.push(`xterm-cursor-bar`);break;case`underline`:D.push(`xterm-cursor-underline`)}}if(N.isBold()&&D.push(`xterm-bold`),N.isItalic()&&D.push(`xterm-italic`),N.isDim()&&D.push(`xterm-dim`),_=N.isInvisible()?ID:N.getChars()||ID,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${LD.toColorRGB(N.getUnderlineColor()).join(`,`)})`;else{let e=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}N.isOverline()&&(D.push(`xterm-overline`),_===` `&&(_=`\xA0`)),N.isStrikethrough()&&D.push(`xterm-strikethrough`),te&&(h.style.textDecoration=`underline`);let ie=N.getFgColor(),ae=N.getFgColorMode(),oe=N.getBgColor(),se=N.getBgColorMode(),ce=!!N.isInverse();if(ce){let e=ie;ie=oe,oe=e;let t=ae;ae=se,se=t}let le,ue,de=!1;this._decorationService.forEachDecorationAtCell(k,t,void 0,e=>{e.options.layer!==`top`&&de||(e.backgroundColorRGB&&(se=50331648,oe=e.backgroundColorRGB.rgba>>8&16777215,le=e.backgroundColorRGB),e.foregroundColorRGB&&(ae=50331648,ie=e.foregroundColorRGB.rgba>>8&16777215,ue=e.foregroundColorRGB),de=e.options.layer===`top`)}),!de&&ee&&(le=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,oe=le.rgba>>8&16777215,se=50331648,de=!0,p.selectionForeground&&(ae=50331648,ie=p.selectionForeground.rgba>>8&16777215,ue=p.selectionForeground)),de&&D.push(`xterm-decoration-top`);let fe;switch(se){case 16777216:case 33554432:fe=p.ansi[oe],D.push(`xterm-bg-${oe}`);break;case 50331648:fe=Aj.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(h,`background-color:#${Gj((oe>>>0).toString(16),`0`,6)}`);break;default:ce?(fe=p.foreground,D.push(`xterm-bg-257`)):fe=p.background}switch(le||N.isDim()&&(le=jj.multiplyOpacity(fe,.5)),ae){case 16777216:case 33554432:N.isBold()&&ie<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ie+=8),this._applyMinimumContrast(h,fe,p.ansi[ie],N,le,void 0)||D.push(`xterm-fg-${ie}`);break;case 50331648:let e=Aj.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(h,fe,e,N,le,ue)||this._addStyle(h,`color:#${Gj(ie.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,fe,p.foreground,N,le,ue)||ce&&D.push(`xterm-fg-257`)}D.length&&=(h.className=D.join(` `),0),!P&&!A&&!ne&&j?g++:h.textContent=_,T!==this.defaultSpacing&&(h.style.letterSpacing=`${T}px`),d.push(h),k=M}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Vj(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=jj.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0]}};Wj=yD([X(1,lO),X(2,QD),X(3,aO),X(4,JD),X(5,tO),X(6,uO)],Wj);function Gj(e,t,n){for(;e.length<n;)e=t+e;return e}var Kj=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},qj=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);if(s>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0]}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol):!1}};function Jj(){return new qj}var Yj=`xterm-dom-renderer-owner-`,Xj=`xterm-rows`,Zj=`xterm-fg-`,Qj=`xterm-bg-`,$j=`xterm-focus`,eM=`xterm-selection`,tM=1,nM=class extends FO{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=tM++,this._rowElements=[],this._selectionRenderModel=Jj(),this.onRequestRedraw=this._register(new Z).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Xj),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(eM),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Hj(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Wj,document),this._element.classList.add(Yj+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(MO(()=>{this._element.classList.remove(Yj+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Kj(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Xj} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Xj} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Xj} .xterm-dim { color: ${jj.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Xj}.${$j} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Xj}.${$j} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Xj}.${$j} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Xj} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Xj} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Xj} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Xj} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Xj} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${eM} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${eM} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${eM} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Zj}${n} { color: ${r.css}; }${this._terminalSelector} .${Zj}${n}.xterm-dim { color: ${jj.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Qj}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Zj}257 { color: ${jj.opaque(e.background).css}; }${this._terminalSelector} .${Zj}257.xterm-dim { color: ${jj.multiplyOpacity(jj.opaque(e.background),.5).css}; }${this._terminalSelector} .${Qj}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove($j),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add($j),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Yj}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};nM=yD([X(7,XD),X(8,iO),X(9,QD),X(10,KD),X(11,JD),X(12,aO),X(13,uO)],nM);var rM=class extends FO{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new Z),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new oM(this._optionsService))}catch{this._measureStrategy=this._register(new aM(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};rM=yD([X(2,QD)],rM);var iM=class extends FO{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},aM=class extends iM{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},oM=class extends iM{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},sM=class extends FO{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new cM(this._window)),this._onDprChange=this._register(new Z),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new Z),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(UO.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(TA(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(TA(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},cM=class extends FO{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new IO),this._onDprChange=this._register(new Z),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(MO(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=TA(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},lM=class extends FO{constructor(){super(),this.linkProviders=[],this._register(MO(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function uM(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function dM(e,t,n,r,i,a,o,s,c){if(!a)return;let l=uM(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var fM=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return dM(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=uM(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};fM=yD([X(0,sO),X(1,iO)],fM);var pM=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},mM={};vD(mM,{getSafariVersion:()=>xM,isChromeOS:()=>DM,isFirefox:()=>vM,isIpad:()=>CM,isIphone:()=>wM,isLegacyEdge:()=>yM,isLinux:()=>EM,isMac:()=>SM,isNode:()=>hM,isSafari:()=>bM,isWindows:()=>TM});var hM=typeof process<`u`&&`title`in process,gM=hM?`node`:navigator.userAgent,_M=hM?`node`:navigator.platform,vM=gM.includes(`Firefox`),yM=gM.includes(`Edge`),bM=/^((?!chrome|android).)*safari/i.test(gM);function xM(){if(!bM)return 0;let e=gM.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var SM=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(_M),CM=_M===`iPad`,wM=_M===`iPhone`,TM=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(_M),EM=_M.indexOf(`Linux`)>=0,DM=/\bCrOS\b/.test(gM),OM=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&=(this._cancelCallback(this._idleCallback),void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||=this._requestCallback(this._process.bind(this))}_process(e){this._idleCallback=void 0;let t=0,n=0,r=e.timeRemaining(),i=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),n=Math.max(t,n),i=e.timeRemaining(),n*1.5>i){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},kM=class extends OM{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},AM=class extends OM{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},jM=!hM&&`requestIdleCallback`in window?AM:kM,MM=class{constructor(){this._queue=new jM}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},NM=class extends FO{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new IO),this._pausedResizeTask=new MM,this._observerDisposable=this._register(new IO),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new Z),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new Z),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new Z),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new pM((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new PM(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(MO(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=MO(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};NM=yD([X(2,QD),X(3,iO),X(4,JD),X(5,tO),X(6,KD),X(7,aO),X(8,uO)],NM);var PM=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function FM(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return RM(i,a,e,t,n,r)+zM(a,t,n,r)+BM(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,qM(Math.abs(i-e),KM(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return qM(LM(a>t?e:i,n)+(s-1)*n.cols+1+IM(a>t?i:e,n),KM(o,r))}function IM(e,t){return e-1}function LM(e,t){return t.cols-e}function RM(e,t,n,r,i,a){return zM(t,r,i,a).length===0?``:qM(GM(e,t,e,t-HM(t,i),!1,i).length,KM(`D`,a))}function zM(e,t,n,r){let i=e-HM(e,n),a=t-HM(t,n);return qM(Math.abs(i-a)-VM(e,t,n),KM(WM(e,t),r))}function BM(e,t,n,r,i,a){let o;o=zM(t,r,i,a).length>0?r-HM(r,i):t;let s=r,c=UM(e,t,n,r,i,a);return qM(GM(e,o,n,s,c===`C`,i).length,KM(c,a))}function VM(e,t,n){let r=0,i=e-HM(e,n),a=t-HM(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=WM(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function HM(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function UM(e,t,n,r,i,a){let o;return o=zM(n,r,i,a).length>0?r-HM(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function WM(e,t){return e>t?`A`:`B`}function GM(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&s<a.buffer.lines.length;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function KM(e,t){let n=t?`O`:`[`;return Q.ESC+n+e}function qM(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var JM=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function YM(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var XM=50,ZM=15,QM=50,$M=500,eN=RegExp(`\xA0`,`g`),tN=class extends FO{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new zD,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new Z),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new Z),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new Z),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new JM(this._bufferService),this._activeSelectionMode=0,this._register(MO(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map(e=>e.replace(eN,` `)).join(TM?`\r
|
|
4299
4299
|
`:`
|
|
4300
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),tM&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=wM(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=zj(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-TM),TM),t/=TM,t/Math.abs(t)+Math.round(t*(EM-1)))}shouldForceSelection(e){return Zj?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),DM)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Zj&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<OM&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=uM(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=wM(n,this._bufferService.cols)}};AM=JE([X(3,xD),X(4,CD),X(5,FD),X(6,DD),X(7,ID),X(8,PD)],AM);var jM=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},MM=class{constructor(){this._color=new jM,this._css=new jM}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},NM=Object.freeze((()=>{let e=[sj.toColor(`#2e3436`),sj.toColor(`#cc0000`),sj.toColor(`#4e9a06`),sj.toColor(`#c4a000`),sj.toColor(`#3465a4`),sj.toColor(`#75507b`),sj.toColor(`#06989a`),sj.toColor(`#d3d7cf`),sj.toColor(`#555753`),sj.toColor(`#ef2929`),sj.toColor(`#8ae234`),sj.toColor(`#fce94f`),sj.toColor(`#729fcf`),sj.toColor(`#ad7fa8`),sj.toColor(`#34e2e2`),sj.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:aj.toCss(r,i,a),rgba:aj.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:aj.toCss(n,n,n),rgba:aj.toRgba(n,n,n)})}return e})()),PM=sj.toColor(`#ffffff`),FM=sj.toColor(`#000000`),IM=sj.toColor(`#ffffff`),LM=FM,RM={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},zM=PM,BM=class extends uO{constructor(e){super(),this._optionsService=e,this._contrastCache=new MM,this._halfContrastCache=new MM,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:PM,background:FM,cursor:IM,cursorAccent:LM,selectionForeground:void 0,selectionBackgroundTransparent:RM,selectionBackgroundOpaque:oj.blend(FM,RM),selectionInactiveBackgroundTransparent:RM,selectionInactiveBackgroundOpaque:oj.blend(FM,RM),scrollbarSliderBackground:oj.opacity(PM,.2),scrollbarSliderHoverBackground:oj.opacity(PM,.4),scrollbarSliderActiveBackground:oj.opacity(PM,.5),overviewRulerBorder:PM,ansi:NM.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=VM(e.foreground,PM),t.background=VM(e.background,FM),t.cursor=oj.blend(t.background,VM(e.cursor,IM)),t.cursorAccent=oj.blend(t.background,VM(e.cursorAccent,LM)),t.selectionBackgroundTransparent=VM(e.selectionBackground,RM),t.selectionBackgroundOpaque=oj.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=VM(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=oj.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?VM(e.selectionForeground,ij):void 0,t.selectionForeground===ij&&(t.selectionForeground=void 0),oj.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=oj.opacity(t.selectionBackgroundTransparent,.3)),oj.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=oj.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=VM(e.scrollbarSliderBackground,oj.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=VM(e.scrollbarSliderHoverBackground,oj.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=VM(e.scrollbarSliderActiveBackground,oj.opacity(t.foreground,.5)),t.overviewRulerBorder=VM(e.overviewRulerBorder,zM),t.ansi=NM.slice(),t.ansi[0]=VM(e.black,NM[0]),t.ansi[1]=VM(e.red,NM[1]),t.ansi[2]=VM(e.green,NM[2]),t.ansi[3]=VM(e.yellow,NM[3]),t.ansi[4]=VM(e.blue,NM[4]),t.ansi[5]=VM(e.magenta,NM[5]),t.ansi[6]=VM(e.cyan,NM[6]),t.ansi[7]=VM(e.white,NM[7]),t.ansi[8]=VM(e.brightBlack,NM[8]),t.ansi[9]=VM(e.brightRed,NM[9]),t.ansi[10]=VM(e.brightGreen,NM[10]),t.ansi[11]=VM(e.brightYellow,NM[11]),t.ansi[12]=VM(e.brightBlue,NM[12]),t.ansi[13]=VM(e.brightMagenta,NM[13]),t.ansi[14]=VM(e.brightCyan,NM[14]),t.ansi[15]=VM(e.brightWhite,NM[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=VM(e.extendedAnsi[r],NM[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};BM=JE([X(0,DD)],BM);function VM(e,t){if(e!==void 0)try{return sj.toColor(e)}catch{}return t}var HM=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},UM=class{constructor(){this._services=new HM,this._services.set(TD,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=vD(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},WM={trace:0,debug:1,info:2,warn:3,error:4,off:5},GM=`xterm.js: `,KM=class extends uO{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),qM=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=WM[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:GM)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};KM=JE([X(0,DD)],KM);var qM,JM=class extends uO{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Z),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},YM=3,XM=Object.freeze(new fD),ZM=0,QM=2,$M=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*YM);let r=t||mD.fromCharData([0,uD,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*YM+0],n=t&2097151;return[this._data[e*YM+1],t&2097152?this._combined[e]:n?oD(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*YM+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*YM+0]=e|2097152|t[2]<<22):this._data[e*YM+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*YM+0]>>22}hasWidth(e){return this._data[e*YM+0]&12582912}getFg(e){return this._data[e*YM+1]}getBg(e){return this._data[e*YM+2]}hasContent(e){return this._data[e*YM+0]&4194303}getCodePoint(e){let t=this._data[e*YM+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*YM+0]&2097152}getString(e){let t=this._data[e*YM+0];return t&2097152?this._combined[e]:t&2097151?oD(t&2097151):``}isProtected(e){return this._data[e*YM+2]&536870912}loadCell(e,t){return ZM=e*YM,t.content=this._data[ZM+0],t.fg=this._data[ZM+1],t.bg=this._data[ZM+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*YM+0]=t.content,this._data[e*YM+1]=t.fg,this._data[e*YM+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*YM+0]=t|n<<22,this._data[e*YM+1]=r.fg,this._data[e*YM+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*YM+0];r&2097152?this._combined[e]+=oD(t):r&2097151?(this._combined[e]=oD(r&2097151)+oD(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*YM+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new mD;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new mD;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*QM<this._data.buffer.byteLength;let n=e*YM;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*QM<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*QM<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*YM+0]&4194303)return e+(this._data[e*YM+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*YM+0]&4194303||this._data[e*YM+2]&50331648)return e+(this._data[e*YM+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<YM;e++)this._data[(n+i)*YM+e]=a[(t+i)*YM+e];a[(t+i)*YM+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<YM;e++)this._data[(n+i)*YM+e]=a[(t+i)*YM+e];a[(t+i)*YM+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*YM+0],n=e&2097151,a=e&2097152?this._combined[t]:n?oD(n):dD;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function eN(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=iN(u,d,t),p=1,m=0;for(;p<u.length;){let e=iN(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function tN(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function nN(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function rN(e,t,n){let r=[],i=e.map((n,r)=>iN(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=iN(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function iN(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var aN=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),aO(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};aN._nextId=1;var oN=aN,sN={},cN=sN.B;sN[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},sN.A={"#":`£`},sN.B=void 0,sN[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},sN.C=sN[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},sN.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},sN.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},sN.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},sN.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},sN.E=sN[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},sN.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},sN.H=sN[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},sN[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var lN=4294967295,uN=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=XM.clone(),this.savedCharset=cN,this.markers=[],this._nullCell=mD.fromCharData([0,uD,1,0]),this._whitespaceCell=mD.fromCharData([0,dD,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new oM,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new JM(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new pD),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new pD),this._whitespaceCell}getBlankLine(e,t){return new $M(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>lN?lN:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=XM);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new JM(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(XM),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new $M(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new $M(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=eN(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(XM),n);if(r.length>0){let n=tN(this.lines,r);nN(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(XM),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new $M(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(XM),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=rN(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(XM,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=iN(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new oN(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},dN=class extends uO{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Z),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new uN(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new uN(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},fN=2,pN=1,mN=class extends uO{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,fN),this.rows=Math.max(e.rawOptions.rows||0,pN),this.buffers=this._register(new dN(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};mN=JE([X(0,DD)],mN);var hN={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Zj,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},gN=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],_N=class extends uO{constructor(e){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let t={...hN};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(sO(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in hN))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in hN))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=hN[e],!vN(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=hN[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=gN.includes(t)?t:hN[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function vN(e){return e===`block`||e===`underline`||e===`bar`}function yN(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&yN(e[r],t-1);return n}var bN=Object.freeze({insertMode:!1}),xN=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),SN=class extends uO{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Z),this.onData=this._onData.event,this._onUserInput=this._register(new Z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=yN(bN),this.decPrivateModes=yN(xN)}reset(){this.modes=yN(bN),this.decPrivateModes=yN(xN)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};SN=JE([X(0,xD),X(1,ED),X(2,DD)],SN);var CN={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function wN(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var TN=String.fromCharCode,EN={DEFAULT:e=>{let t=[wN(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${TN(t[0])}${TN(t[1])}${TN(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${wN(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${wN(e,!0)};${e.x};${e.y}${t}`}},DN=class extends uO{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Z),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(CN))this.addProtocol(e,CN[e]);for(let e of Object.keys(EN))this.addEncoding(e,EN[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};DN=JE([X(0,xD),X(1,CD),X(2,DD)],DN);var ON=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],kN=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],AN;function jN(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var MN=class{constructor(){if(this.version=`6`,!AN){AN=new Uint8Array(65536),AN.fill(1),AN[0]=0,AN.fill(0,1,32),AN.fill(0,127,160),AN.fill(2,4352,4448),AN[9001]=2,AN[9002]=2,AN.fill(2,11904,42192),AN[12351]=1,AN.fill(2,44032,55204),AN.fill(2,63744,64256),AN.fill(2,65040,65050),AN.fill(2,65072,65136),AN.fill(2,65280,65377),AN.fill(2,65504,65511);for(let e=0;e<ON.length;++e)AN.fill(0,ON[e][0],ON[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?AN[e]:jN(e,kN)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=NN.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return NN.createPropertyValue(0,n,r)}},NN=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Z,this.onChange=this._onChange.event;let e=new MN;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},PN=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function FN(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var IN=2147483647,LN=256,RN=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>LN)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>IN?IN:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>IN?IN:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,IN):e}},zN=[],BN=class{constructor(){this._state=0,this._active=zN,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=zN}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=zN,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||zN,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,sD(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=zN,this._id=-1,this._state=0}}},VN=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=sD(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},HN=[],UN=class{constructor(){this._handlers=Object.create(null),this._active=HN,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=HN}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=HN,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||HN,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,sD(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=HN,this._ident=0}},WN=new RN;WN.addParam(0);var GN=class{constructor(e){this._handler=e,this._data=``,this._params=WN,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():WN,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=sD(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=WN,this._data=``,this._hitLimit=!1,e));return this._params=WN,this._data=``,this._hitLimit=!1,t}},KN=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},qN=160,JN=function(){let e=new KN(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(qN,0,2,0),e.add(qN,8,5,8),e.add(qN,6,0,6),e.add(qN,11,0,11),e.add(qN,13,13,13),e}(),YN=class extends uO{constructor(e=JN){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new RN,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(sO(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new BN),this._dcsParser=this._register(new UN),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:qN)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<qN){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<qN){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<qN){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<qN){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<qN){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<qN){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},XN=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,ZN=/^[\da-f]+$/;function QN(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=XN.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),ZN.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function $N(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function eP(e,t=16){let[n,r,i]=e;return`rgb:${$N(n,t)}/${$N(r,t)}/${$N(i,t)}`}var tP={"(":0,")":1,"*":2,"+":3,"-":1,".":2},nP=131072,rP=10;function iP(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var aP=5e3,oP=0,sP=class extends uO{constructor(e,t,n,r,i,a,o,s,c=new YN){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new cD,this._utf8Decoder=new lD,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=XM.clone(),this._eraseAttrDataInternal=XM.clone(),this._onRequestBell=this._register(new Z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Z),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new cP(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ZA.IND,()=>this.index()),this._parser.setExecuteHandler(ZA.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ZA.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new VN(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new VN(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new VN(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new VN(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new VN(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new VN(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new VN(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new VN(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new VN(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new VN(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new VN(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new VN(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in sN)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new GN((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),aP))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${aP} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>nP&&(a=this._parseStack.position+nP)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<nP&&(this._parseBuffer=new Uint32Array(Math.min(e.length,nP))),o||this._dirtyRowTracker.clearRange(),e.length>nP)for(let t=a;t<e.length;t+=nP){let a=t+nP<e.length?t+nP:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=NN.extractWidth(t);let n=NN.extractShouldJoin(t),m=n?NN.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(oD(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof $M&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!iP(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new GN(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new VN(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(XM));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=NN.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(Q.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Q.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Q.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Q.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Q.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,cN),this._charsetService.setgCharset(1,cN),this._charsetService.setgCharset(2,cN),this._charsetService.setgCharset(3,cN);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${Q.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=fD.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=XM.fg,e.bg=XM.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=XM.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=XM.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=XM.fg&16777215,r.bg&=-67108864,r.bg|=XM.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=XM.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!iP(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>rP&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>rP&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(lP(n)){if(r===`?`)t.push({type:0,index:n});else{let e=QN(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=QN(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);lP(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,cN),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(tP[e[0]],sN[e[1]]||cN),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=XM.clone(),this._eraseAttrDataInternal=XM.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new mD;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${Q.ESC}${e}${Q.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},cP=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(oP=e,e=t,t=oP),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};cP=JE([X(0,xD)],cP);function lP(e){return 0<=e&&e<256}var uP=5e7,dP=12,fP=50,pP=class extends uO{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>uP)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=dP?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=dP)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>fP&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},mP=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};mP=JE([X(0,xD)],mP);var hP=!1,gP=class extends uO{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new dO),this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onData=this._register(new Z),this.onData=this._onData.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Z),this._instantiationService=new UM,this.optionsService=this._register(new _N(e)),this._instantiationService.setService(DD,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(mN)),this._instantiationService.setService(xD,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(KM)),this._instantiationService.setService(ED,this._logService),this.coreService=this._register(this._instantiationService.createInstance(SN)),this._instantiationService.setService(CD,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(DN)),this._instantiationService.setService(SD,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(NN)),this._instantiationService.setService(kD,this.unicodeService),this._charsetService=this._instantiationService.createInstance(PN),this._instantiationService.setService(wD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(mP),this._instantiationService.setService(OD,this._oscLinkService),this._inputHandler=this._register(new sP(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(vO.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(vO.forward(this._bufferService.onResize,this._onResize)),this._register(vO.forward(this.coreService.onData,this._onData)),this._register(vO.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new pP((e,t)=>this._inputHandler.parse(e,t))),this._register(vO.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!hP&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),hP=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,fN),t=Math.max(t,pN),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(FN.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(FN(this._bufferService),!1))),this._windowsWrappingHeuristics.value=sO(()=>{for(let t of e)t.dispose()})}}},_P={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function vP(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?Q.ESC+`OA`:Q.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?Q.ESC+`OD`:Q.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?Q.ESC+`OC`:Q.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?Q.ESC+`OB`:Q.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+`[Z`;break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`D`:t?Q.ESC+`OD`:Q.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`C`:t?Q.ESC+`OC`:Q.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`A`:t?Q.ESC+`OA`:Q.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`B`:t?Q.ESC+`OB`:Q.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+`[2~`);break;case 46:i.key=a?Q.ESC+`[3;`+(a+1)+`~`:Q.ESC+`[3~`;break;case 36:i.key=a?Q.ESC+`[1;`+(a+1)+`H`:t?Q.ESC+`OH`:Q.ESC+`[H`;break;case 35:i.key=a?Q.ESC+`[1;`+(a+1)+`F`:t?Q.ESC+`OF`:Q.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?Q.ESC+`[5;`+(a+1)+`~`:Q.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?Q.ESC+`[6;`+(a+1)+`~`:Q.ESC+`[6~`;break;case 112:i.key=a?Q.ESC+`[1;`+(a+1)+`P`:Q.ESC+`OP`;break;case 113:i.key=a?Q.ESC+`[1;`+(a+1)+`Q`:Q.ESC+`OQ`;break;case 114:i.key=a?Q.ESC+`[1;`+(a+1)+`R`:Q.ESC+`OR`;break;case 115:i.key=a?Q.ESC+`[1;`+(a+1)+`S`:Q.ESC+`OS`;break;case 116:i.key=a?Q.ESC+`[15;`+(a+1)+`~`:Q.ESC+`[15~`;break;case 117:i.key=a?Q.ESC+`[17;`+(a+1)+`~`:Q.ESC+`[17~`;break;case 118:i.key=a?Q.ESC+`[18;`+(a+1)+`~`:Q.ESC+`[18~`;break;case 119:i.key=a?Q.ESC+`[19;`+(a+1)+`~`:Q.ESC+`[19~`;break;case 120:i.key=a?Q.ESC+`[20;`+(a+1)+`~`:Q.ESC+`[20~`;break;case 121:i.key=a?Q.ESC+`[21;`+(a+1)+`~`:Q.ESC+`[21~`;break;case 122:i.key=a?Q.ESC+`[23;`+(a+1)+`~`:Q.ESC+`[23~`;break;case 123:i.key=a?Q.ESC+`[24;`+(a+1)+`~`:Q.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=_P[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=Q.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=Q.ESC+n}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Q.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=Q.US),e.key===`@`&&(i.key=Q.NUL))}return i}var yP=0,bP=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new oM,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new oM,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(yP=this._search(t),yP===-1)||this._getKey(this._array[yP])!==t)return!1;do if(this._array[yP]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(yP),!0;while(++yP<this._array.length&&this._getKey(this._array[yP])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(yP=this._search(e),!(yP<0||yP>=this._array.length)&&this._getKey(this._array[yP])===e))do yield this._array[yP];while(++yP<this._array.length&&this._getKey(this._array[yP])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(yP=this._search(e),!(yP<0||yP>=this._array.length)&&this._getKey(this._array[yP])===e))do t(this._array[yP]);while(++yP<this._array.length&&this._getKey(this._array[yP])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},xP=0,SP=0,CP=class extends uO{constructor(){super(),this._decorations=new bP(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(sO(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new wP(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{xP=t.options.x??0,SP=xP+(t.options.width??1),e>=xP&&e<SP&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},wP=class extends lO{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?sj.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?sj.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},TP=1e3,EP=class{constructor(e,t=TP){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},DP=20,OP=class extends uO{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new EP(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
4301
|
-
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(
|
|
4302
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===DP+1&&(this._liveRegion.textContent+=QE.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};OP=JE([X(1,TD),X(2,PD),X(3,ID)],OP);var kP=class extends uO{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(sO(()=>{aO(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(eA(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(eA(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(eA(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(eA(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&AP(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,aO(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};kP=JE([X(1,FD),X(2,ID),X(3,xD),X(4,BD)],kP);function AP(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var jP=class extends gP{constructor(e={}){super(e),this._linkifier=this._register(new dO),this.browser=Uj,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new dO),this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Z),this.onKey=this._onKey.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Z),this.onBell=this._onBell.event,this._onFocus=this._register(new Z),this._onBlur=this._register(new Z),this._onA11yCharEmitter=this._register(new Z),this._onA11yTabEmitter=this._register(new Z),this._onWillOpen=this._register(new Z),this._setup(),this._decorationService=this._instantiationService.createInstance(CP),this._instantiationService.setService(AD,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Rj),this._instantiationService.setService(BD,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(jD)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(vO.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(vO.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(vO.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(vO.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(sO(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=oj.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${eP(r)}${QA.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=aj.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=aj.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(OP,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(eA(this.element,`copy`,e=>{this.hasSelection()&&tD(e,this._selectionService)}));let e=e=>nD(e,this.textarea,this.coreService,this.optionsService);this._register(eA(this.textarea,`paste`,e)),this._register(eA(this.element,`paste`,e)),qj?this._register(eA(this.element,`mousedown`,e=>{e.button===2&&aD(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(eA(this.element,`contextmenu`,e=>{aD(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),tM&&this._register(eA(this.element,`auxclick`,e=>{e.button===1&&iD(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(eA(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(eA(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(eA(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(eA(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(eA(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(eA(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(eA(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(eA(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,XE.get()),nM||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Ij,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(PD,this._coreBrowserService),this._register(eA(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(eA(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Mj,this._document,this._helperContainer),this._instantiationService.setService(ND,this._charSizeService),this._themeService=this._instantiationService.createInstance(BM),this._instantiationService.setService(zD,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(pj),this._instantiationService.setService(RD,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(cM,this.rows,this.screenElement)),this._instantiationService.setService(ID,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance($A,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Vj),this._instantiationService.setService(FD,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(kP,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(WA,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(AM,this.element,this.screenElement,r)),this._instantiationService.setService(LD,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(vO.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(GA,this.screenElement)),this._register(eA(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(OP,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(XA,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(XA,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(jj,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(eA(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(eA(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){rD(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=vP(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Q.ETX||n.key===Q.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(MP(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(XM));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Q.ESC+`[I`):this.coreService.triggerDataEvent(Q.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function MP(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var NP=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},PP=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new mD)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},FP=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new PP(t)}getNullCell(){return new mD}},IP=class extends uO{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new FP(this._core.buffers.normal,`normal`),this._alternate=new FP(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},LP=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},RP=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},zP=[`cols`,`rows`],BP=0,VP=class extends uO{constructor(e){super(),this._core=this._register(new jP(e)),this._addonManager=this._register(new NP),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(zP.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new LP(this._core),this._parser}get unicode(){return this._checkProposedApi(),new RP(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new IP(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
4303
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return XE.get()},set promptLabel(e){XE.set(e)},get tooMuchOutput(){return QE.get()},set tooMuchOutput(e){QE.set(e)}}}_verifyIntegers(...e){for(BP of e)if(BP===1/0||isNaN(BP)||BP%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(BP of e)if(BP&&(BP===1/0||isNaN(BP)||BP%1!=0||BP<0))throw Error(`This API only accepts positive integers`)}},HP=2,UP=1,WP=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(HP,Math.floor(u/e.css.cell.width)),rows:Math.max(UP,Math.floor(l/e.css.cell.height))}}},GP=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=qP.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function KP(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var qP=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!KP(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},JP=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function YP(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var XP=class{constructor(e=YP,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||JP;this._linkProvider=this._terminal.registerLinkProvider(new GP(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},ZP={background:`#1b1b29`,foreground:`#e8e8f2`,cursor:`#ff9e64`,cursorAccent:`#1b1b29`,selectionBackground:`#44475a`,black:`#21222c`,red:`#ff6b6b`,green:`#50fa7b`,yellow:`#f1fa8c`,blue:`#8aa4ff`,magenta:`#ff79c6`,cyan:`#8be9fd`,white:`#e8e8f2`,brightBlack:`#6c6f93`,brightRed:`#ff8787`,brightGreen:`#69ff94`,brightYellow:`#ffffa5`,brightBlue:`#a4b9ff`,brightMagenta:`#ff92df`,brightCyan:`#a4ffff`,brightWhite:`#ffffff`};function QP({agentId:e,className:t}){let n=(0,v.useRef)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=n.current,r=new VP({fontFamily:`'JetBrains Mono', Consolas, monospace`,fontSize:13,cursorBlink:!0,cursorInactiveStyle:`none`,scrollback:5e3,allowProposedApi:!0,scrollOnEraseInDisplay:!0,theme:ZP}),a=new WP;r.loadAddon(a),r.loadAddon(new XP((e,t)=>window.open(t,`_blank`,`noopener`))),r.open(t);let s=null,l=!1,u=!1,d,f=0,p=e=>{s?.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))},m=()=>{try{a.fit()}catch{return}u&&p({t:`resize`,cols:r.cols,rows:r.rows})},h=()=>{let t=location.protocol===`https:`?`wss`:`ws`,n=new WebSocket(`${t}://${location.host}/ws/term?agent=${encodeURIComponent(e)}`);s=n,n.onopen=()=>o(!0),n.onmessage=e=>{let t=JSON.parse(String(e.data));t.t===`snapshot`?(u=!1,r.reset(),r.resize(t.cols,t.rows),r.write(t.data,()=>{u=!0,m(),r.scrollToBottom()}),i(t.live)):t.t===`data`?r.write(t.data):t.t===`size`&&(t.cols!==r.cols||t.rows!==r.rows)?r.resize(t.cols,t.rows):t.t===`live`&&i(t.live)},n.onclose=e=>{s===n&&(s=null),!l&&(o(!1),e.code!==4404&&(d=window.setTimeout(h,1500)))}};h();let g=r.onData(e=>p({t:`input`,data:e})),_=e=>{e.key===`Escape`&&e.stopPropagation()};t.addEventListener(`keydown`,_),r.textarea?.addEventListener(`focus`,()=>c(!0)),r.textarea?.addEventListener(`blur`,()=>c(!1));let v=new ResizeObserver(()=>{cancelAnimationFrame(f),f=requestAnimationFrame(m)});return v.observe(t),document.fonts?.ready.then(()=>!l&&m()),()=>{l=!0,clearTimeout(d),cancelAnimationFrame(f),v.disconnect(),g.dispose(),t.removeEventListener(`keydown`,_),s?.close(),r.dispose()}},[e]),(0,K.jsxs)(`div`,{className:`live-term ${t??``}`,children:[(0,K.jsx)(`div`,{className:`live-term-screen`,ref:n}),(0,K.jsxs)(`div`,{className:`live-term-foot`,children:[(0,K.jsx)(`span`,{className:`live-dot ${r?`live-dot-on`:``}`}),a?r?s?`Typing goes straight to the agent · Esc goes to them too; click outside to use the office keys`:`Live · click the terminal to type into it`:`Not running · a message below picks the session back up`:`Reconnecting…`]})]})}function $P(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var eF=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tF=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nF={};function rF(e,t){return((t||nF).jsx?tF:eF).test(e)}var iF=/[ \t\n\f\r]/g;function aF(e){return typeof e==`object`?e.type===`text`&&oF(e.value):oF(e)}function oF(e){return e.replace(iF,``)===``}var sF=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};sF.prototype.normal={},sF.prototype.property={},sF.prototype.space=void 0;function cF(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new sF(n,r,t)}function lF(e){return e.toLowerCase()}var uF=class{constructor(e,t){this.attribute=t,this.property=e}};uF.prototype.attribute=``,uF.prototype.booleanish=!1,uF.prototype.boolean=!1,uF.prototype.commaOrSpaceSeparated=!1,uF.prototype.commaSeparated=!1,uF.prototype.defined=!1,uF.prototype.mustUseProperty=!1,uF.prototype.number=!1,uF.prototype.overloadedBoolean=!1,uF.prototype.property=``,uF.prototype.spaceSeparated=!1,uF.prototype.space=void 0;var dF=s({boolean:()=>pF,booleanish:()=>mF,commaOrSpaceSeparated:()=>vF,commaSeparated:()=>_F,number:()=>$,overloadedBoolean:()=>hF,spaceSeparated:()=>gF}),fF=0,pF=yF(),mF=yF(),hF=yF(),$=yF(),gF=yF(),_F=yF(),vF=yF();function yF(){return 2**++fF}var bF=Object.keys(dF),xF=class extends uF{constructor(e,t,n,r){let i=-1;if(super(e,t),SF(this,`space`,r),typeof n==`number`)for(;++i<bF.length;){let e=bF[i];SF(this,bF[i],(n&dF[e])===dF[e])}}};xF.prototype.defined=!0;function SF(e,t,n){n&&(e[t]=n)}function CF(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new xF(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[lF(r)]=r,n[lF(a.attribute)]=r}return new sF(t,n,e.space)}var wF=CF({properties:{ariaActiveDescendant:null,ariaAtomic:mF,ariaAutoComplete:null,ariaBusy:mF,ariaChecked:mF,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:gF,ariaCurrent:null,ariaDescribedBy:gF,ariaDetails:null,ariaDisabled:mF,ariaDropEffect:gF,ariaErrorMessage:null,ariaExpanded:mF,ariaFlowTo:gF,ariaGrabbed:mF,ariaHasPopup:null,ariaHidden:mF,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:gF,ariaLevel:$,ariaLive:null,ariaModal:mF,ariaMultiLine:mF,ariaMultiSelectable:mF,ariaOrientation:null,ariaOwns:gF,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:mF,ariaReadOnly:mF,ariaRelevant:null,ariaRequired:mF,ariaRoleDescription:gF,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:mF,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function TF(e,t){return t in e?e[t]:t}function EF(e,t){return TF(e,t.toLowerCase())}var DF=CF({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:_F,acceptCharset:gF,accessKey:gF,action:null,allow:null,allowFullScreen:pF,allowPaymentRequest:pF,allowUserMedia:pF,alpha:pF,alt:null,as:null,async:pF,autoCapitalize:null,autoComplete:gF,autoFocus:pF,autoPlay:pF,blocking:gF,capture:null,charSet:null,checked:pF,cite:null,className:gF,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:mF,controls:pF,controlsList:gF,coords:$|_F,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pF,defer:pF,dir:null,dirName:null,disabled:pF,download:hF,draggable:mF,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pF,formTarget:null,headers:gF,height:$,hidden:hF,high:$,href:null,hrefLang:null,htmlFor:gF,httpEquiv:gF,id:null,imageSizes:null,imageSrcSet:null,inert:pF,inputMode:null,integrity:null,is:null,isMap:pF,itemId:null,itemProp:gF,itemRef:gF,itemScope:pF,itemType:gF,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pF,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:pF,muted:pF,name:null,nonce:null,noModule:pF,noValidate:pF,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:pF,optimum:$,pattern:null,ping:gF,placeholder:null,playsInline:pF,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pF,referrerPolicy:null,rel:gF,required:pF,reversed:pF,rows:$,rowSpan:$,sandbox:gF,scope:null,scoped:pF,seamless:pF,selected:pF,shadowRootClonable:pF,shadowRootCustomElementRegistry:pF,shadowRootDelegatesFocus:pF,shadowRootMode:null,shadowRootSerializable:pF,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:mF,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:pF,useMap:null,value:mF,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:gF,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pF,declare:pF,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:pF,noHref:pF,noShade:pF,noWrap:pF,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:mF,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:pF,disablePictureInPicture:pF,disableRemotePlayback:pF,exportParts:_F,part:gF,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:EF}),OF=CF({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:vF,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:gF,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:pF,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_F,g2:_F,glyphName:_F,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:vF,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:gF,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:vF,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:vF,rev:vF,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:vF,requiredFeatures:vF,requiredFonts:vF,requiredFormats:vF,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:vF,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:vF,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:vF,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:TF}),kF=CF({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),AF=CF({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:EF}),jF=CF({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),MF={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},NF=/[A-Z]/g,PF=/-[a-z]/g,FF=/^data[-\w.:]+$/i;function IF(e,t){let n=lF(t),r=t,i=uF;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&FF.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(PF,RF);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!PF.test(e)){let n=e.replace(NF,LF);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=xF}return new i(r,t)}function LF(e){return`-`+e.toLowerCase()}function RF(e){return e.charAt(1).toUpperCase()}var zF=cF([wF,DF,kF,AF,jF],`html`),BF=cF([wF,OF,kF,AF,jF],`svg`);function VF(e){return e.join(` `).trim()}var HF=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
4304
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),UF=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(HF());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),WF=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),GF=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(UF()),r=WF();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),KF=JF(`end`),qF=JF(`start`);function JF(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function YF(e){let t=qF(e),n=KF(e);if(t&&n)return{start:t,end:n}}function XF(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?QF(e.position):`start`in e||`end`in e?QF(e):`line`in e||`column`in e?ZF(e):``}function ZF(e){return $F(e&&e.line)+`:`+$F(e&&e.column)}function QF(e){return ZF(e&&e.start)+`-`+ZF(e&&e.end)}function $F(e){return e&&typeof e==`number`?e:1}var eI=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=XF(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};eI.prototype.file=``,eI.prototype.name=``,eI.prototype.reason=``,eI.prototype.message=``,eI.prototype.stack=``,eI.prototype.column=void 0,eI.prototype.line=void 0,eI.prototype.ancestors=void 0,eI.prototype.cause=void 0,eI.prototype.fatal=void 0,eI.prototype.place=void 0,eI.prototype.ruleId=void 0,eI.prototype.source=void 0;var tI=l(GF(),1),nI={}.hasOwnProperty,rI=new Map,iI=/[A-Z]/g,aI=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),oI=new Set([`td`,`th`]),sI=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function cI(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=yI(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=vI(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?BF:zF,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=lI(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function lI(e,t,n){if(t.type===`element`)return uI(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return dI(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return pI(e,t,n);if(t.type===`mdxjsEsm`)return fI(e,t);if(t.type===`root`)return mI(e,t,n);if(t.type===`text`)return hI(e,t)}function uI(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=BF,e.schema=i),e.ancestors.push(t);let a=TI(e,t.tagName,!1),o=bI(e,t),s=SI(e,t);return aI.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!aF(e)})),gI(e,o,a,t),_I(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function dI(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}EI(e,t.position)}function fI(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);EI(e,t.position)}function pI(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=BF,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:TI(e,t.name,!0),o=xI(e,t),s=SI(e,t);return gI(e,o,a,t),_I(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function mI(e,t,n){let r={};return _I(r,SI(e,t)),e.create(t,e.Fragment,r,n)}function hI(e,t){return t.value}function gI(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function _I(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function vI(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function yI(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=qF(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function bI(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&nI.call(t.properties,i)){let a=CI(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&oI.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function xI(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else EI(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else EI(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function SI(e,t){let n=[],r=-1,i=e.passKeys?new Map:rI;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=lI(e,a,o);s!==void 0&&n.push(s)}return n}function CI(e,t,n){let r=IF(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?$P(n):VF(n)),r.property===`style`){let t=typeof n==`object`?n:wI(e,String(n));return e.stylePropertyNameCase===`css`&&(t=DI(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?MF[r.property]||r.property:r.attribute,n]}}function wI(e,t){try{return(0,tI.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new eI("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=sI+`#cannot-parse-style-attribute`,r}}function TI(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=rF(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=rF(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return nI.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);EI(e)}function EI(e,t){let n=new eI("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=sI+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function DI(e){let t={},n;for(n in e)nI.call(e,n)&&(t[OI(n)]=e[n]);return t}function OI(e){let t=e.replace(iI,kI);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function kI(e){return`-`+e.toLowerCase()}var AI={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},jI={};function MI(e,t){let n=t||jI;return NI(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function NI(e,t,n){if(FI(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return PI(e.children,t,n)}return Array.isArray(e)?PI(e,t,n):``}function PI(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=NI(e[i],t,n);return r.join(``)}function FI(e){return!!(e&&typeof e==`object`)}var II=document.createElement(`i`);function LI(e){let t=`&`+e+`;`;II.innerHTML=t;let n=II.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function RI(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function zI(e,t){return e.length>0?(RI(e,e.length,0,t),e):t}var BI={}.hasOwnProperty;function VI(e){let t={},n=-1;for(;++n<e.length;)HI(t,e[n]);return t}function HI(e,t){let n;for(n in t){let r=(BI.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){BI.call(r,a)||(r[a]=[]);let e=i[a];UI(r[a],Array.isArray(e)?e:e?[e]:[])}}}function UI(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);RI(e,0,0,r)}function WI(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function GI(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var KI=iL(/[A-Za-z]/),qI=iL(/[\dA-Za-z]/),JI=iL(/[#-'*+\--9=?A-Z^-~]/);function YI(e){return e!==null&&(e<32||e===127)}var XI=iL(/\d/),ZI=iL(/[\dA-Fa-f]/),QI=iL(/[!-/:-@[-`{-~]/);function $I(e){return e!==null&&e<-2}function eL(e){return e!==null&&(e<0||e===32)}function tL(e){return e===-2||e===-1||e===32}var nL=iL(/\p{P}|\p{S}/u),rL=iL(/\s/);function iL(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function aL(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&qI(e.charCodeAt(n+1))&&qI(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function oL(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return tL(r)?(e.enter(n),s(r)):t(r)}function s(r){return tL(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function sL(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&tL(t)?(e.enter(r),c(t)):l(t)}function c(t){return tL(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var cL={tokenize:lL};function lL(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),oL(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return $I(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var uL=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){dL(this,e,t,n,!1)}addBefore(e,t,n){dL(this,e,t,n,!0)}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,this.index.clear()}};function dL(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var fL={tokenize:mL},pL={tokenize:hL};function mL(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new uL;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(pL,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(pL,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return $I(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new uL;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function hL(e,t,n){return oL(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function gL(e){if(e===null||eL(e)||rL(e))return 1;if(nL(e))return 2}function _L(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var vL={name:`attention`,resolveAll:yL,tokenize:bL};function yL(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};xL(o,-a),xL(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=zI(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=zI(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=zI(r,_L(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=zI(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=zI(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),RI(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function bL(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=gL(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=gL(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function xL(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var SL={name:`autolink`,tokenize:CL};function CL(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return KI(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||qI(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||qI(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||YI(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):JI(t)?(e.consume(t),l):n(t)}function u(e){return qI(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||qI(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var wL={partial:!0,tokenize:TL};function TL(e,t,n){return r;function r(t){return tL(t)?oL(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$I(e)?t(e):n(e)}}var EL={continuation:{tokenize:OL},exit:kL,name:`blockQuote`,tokenize:DL};function DL(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return tL(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function OL(e,t,n){let r=this;return i;function i(t){return tL(t)?oL(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(EL,t,n)(r)}}function kL(e){e.exit(`blockQuote`)}var AL={name:`characterEscape`,tokenize:jL};function jL(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return QI(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var ML={name:`characterReference`,tokenize:NL};function NL(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=qI,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=ZI,u):(e.enter(`characterReferenceValue`),a=7,o=XI,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===qI&&!LI(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var PL={partial:!0,tokenize:FL};function FL(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var IL={concrete:!0,name:`codeFenced`,tokenize:LL};function LL(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),tL(t)?oL(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$I(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(PL,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$I(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):tL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),oL(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$I(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$I(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&tL(t)?oL(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$I(t)?e.check(PL,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$I(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),tL(t)?oL(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),tL(t)?oL(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$I(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var RL={name:`codeIndented`,tokenize:BL},zL={partial:!0,tokenize:VL};function BL(e,t,n){return r;function r(t){return e.enter(`codeIndented`),sL(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):$I(t)?e.attempt(zL,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||$I(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function VL(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):$I(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):sL(e,t,a,`linePrefix`,4,4)(o)}function a(e){return $I(e)?i(e):n(e)}}var HL={name:`codeText`,previous:WL,resolve:UL,tokenize:GL};function UL(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function WL(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function GL(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$I(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$I(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var KL=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&qL(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),qL(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),qL(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);qL(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);qL(this.left,t.reverse())}}}};function qL(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function JL(e){let t={},n=-1,r,i,a,o,s,c,l,u=new KL(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,YL(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return RI(e,0,1/0,u.slice(0)),!l}function YL(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var XL={resolve:QL,tokenize:$L},ZL={partial:!0,tokenize:eR};function QL(e){return JL(e),e}function $L(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$I(t)?e.check(ZL,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function eR(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oL(e,a,`linePrefix`)}function a(i){if(i===null||$I(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function tR(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||YI(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$I(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||eL(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||YI(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function nR(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$I(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$I(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!tL(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function rR(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$I(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oL(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$I(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function iR(e,t){let n;return r;function r(i){return $I(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):tL(i)?oL(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var aR={name:`definition`,tokenize:sR},oR={partial:!0,tokenize:cR};function sR(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return nR.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=GI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return eL(t)?iR(e,l)(t):l(t)}function l(t){return tR(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(oR,d,d)(t)}function d(t){return tL(t)?oL(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$I(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function cR(e,t,n){return r;function r(t){return eL(t)?iR(e,i)(t):n(t)}function i(t){return rR(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return tL(t)?oL(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$I(e)?t(e):n(e)}}var lR={name:`hardBreakEscape`,tokenize:uR};function uR(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $I(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var dR={name:`headingAtx`,resolve:fR,tokenize:pR};function fR(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};RI(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function pR(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||eL(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$I(n)?(e.exit(`atxHeading`),t(n)):tL(n)?oL(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||eL(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var mR=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),hR=[`pre`,`script`,`style`,`textarea`],gR={concrete:!0,name:`htmlFlow`,resolveTo:vR,tokenize:yR},_R={partial:!0,tokenize:bR};function vR(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function yR(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:te):KI(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):KI(a)?(e.consume(a),i=4,r.interrupt?t:te):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:te):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return KI(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||eL(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&hR.includes(l)?(i=1,r.interrupt?t(s):O(s)):mR.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||qI(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return tL(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||KI(t)?(e.consume(t),b):tL(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||qI(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):tL(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):tL(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$I(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||eL(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||tL(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$I(t)?O(t):tL(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),ne):t===63&&i===3?(e.consume(t),te):t===93&&i===5?(e.consume(t),P):$I(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(_R,re,k)(t)):t===null||$I(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(PL,A,re)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$I(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),te):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return hR.includes(n)?(e.consume(t),ne):O(t)}return KI(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function P(t){return t===93?(e.consume(t),te):O(t)}function te(t){return t===62?(e.consume(t),ne):t===45&&i===2?(e.consume(t),te):O(t)}function ne(t){return t===null||$I(t)?(e.exit(`htmlFlowData`),re(t)):(e.consume(t),ne)}function re(n){return e.exit(`htmlFlow`),t(n)}}function bR(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(wL,t,n)}}var xR={name:`htmlText`,tokenize:SR};function SR(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):KI(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):KI(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$I(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$I(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$I(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$I(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return KI(t)?(e.consume(t),S):n(t)}function S(t){return t===45||qI(t)?(e.consume(t),S):C(t)}function C(t){return $I(t)?(o=C,N(t)):tL(t)?(e.consume(t),C):M(t)}function w(t){return t===45||qI(t)?(e.consume(t),w):t===47||t===62||eL(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||KI(t)?(e.consume(t),E):$I(t)?(o=T,N(t)):tL(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||qI(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$I(t)?(o=D,N(t)):tL(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$I(t)?(o=O,N(t)):tL(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$I(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||eL(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||eL(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return tL(t)?oL(e,P,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):P(t)}function P(t){return e.enter(`htmlTextData`),o(t)}}var CR={name:`labelEnd`,resolveAll:DR,resolveTo:OR,tokenize:kR},wR={tokenize:AR},TR={tokenize:jR},ER={tokenize:MR};function DR(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&RI(e,0,e.length,n),e}function OR(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=zI(o,e.slice(i+1,i+r+3)),o=zI(o,[[`enter`,l,t]]),o=zI(o,_L(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=zI(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=zI(o,e.slice(a+1)),o=zI(o,[[`exit`,s,t]]),RI(e,i,e.length,o),e}function kR(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(GI(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(wR,u,o?u:d)(t):t===91?e.attempt(TR,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ER,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function AR(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return eL(t)?iR(e,a)(t):a(t)}function a(t){return t===41?u(t):tR(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return eL(t)?iR(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?rR(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return eL(t)?iR(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function jR(e,t,n){let r=this;return i;function i(t){return nR.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(GI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function MR(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var NR={name:`labelStartImage`,resolveAll:CR.resolveAll,tokenize:PR};function PR(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var FR={name:`labelStartLink`,resolveAll:CR.resolveAll,tokenize:IR};function IR(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var LR={name:`lineEnding`,tokenize:RR};function RR(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),oL(e,t,`linePrefix`)}}var zR={name:`thematicBreak`,tokenize:BR};function BR(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$I(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),tL(t)?oL(e,s,`whitespace`)(t):s(t))}}var VR={continuation:{tokenize:GR},exit:qR,name:`list`,tokenize:WR},HR={partial:!0,tokenize:JR},UR={partial:!0,tokenize:KR};function WR(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:XI(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(zR,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return XI(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(wL,r.interrupt?n:u,e.attempt(HR,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return tL(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function GR(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(wL,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,oL(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!tL(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(UR,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,oL(e,e.attempt(VR,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function KR(e,t,n){let r=this;return oL(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function qR(e){e.exit(this.containerState.type)}function JR(e,t,n){let r=this;return oL(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!tL(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var YR={name:`setextUnderline`,resolveTo:XR,tokenize:ZR};function XR(e,t){let n=new uL,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function ZR(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),tL(t)?oL(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$I(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var QR={tokenize:$R};function $R(e){let t=this,n=e.attempt(wL,r,e.attempt(this.parser.constructs.flowInitial,i,oL(e,e.attempt(this.parser.constructs.flow,i,e.attempt(XL,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var ez={resolveAll:iz()},tz=rz(`string`),nz=rz(`text`);function rz(e){return{resolveAll:iz(e===`text`?az:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function iz(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function az(e,t){let n=new uL,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var oz=s({attentionMarkers:()=>mz,contentInitial:()=>cz,disable:()=>hz,document:()=>sz,flow:()=>uz,flowInitial:()=>lz,insideSpan:()=>pz,string:()=>dz,text:()=>fz}),sz={42:VR,43:VR,45:VR,48:VR,49:VR,50:VR,51:VR,52:VR,53:VR,54:VR,55:VR,56:VR,57:VR,62:EL},cz={91:aR},lz={[-2]:RL,[-1]:RL,32:RL},uz={35:dR,42:zR,45:[YR,zR],60:gR,61:YR,95:zR,96:IL,126:IL},dz={38:ML,92:AL},fz={[-5]:LR,[-4]:LR,[-3]:LR,33:NR,38:ML,42:vL,60:[SL,xR],91:FR,92:[lR,AL],93:CR,95:vL,96:HL},pz={null:[vL,ez]},mz={null:[42,95]},hz={null:[]};function gz(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=zI(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=_L(a,l.events,l),l.events):[]}function f(e,t){return vz(p(e),t)}function p(e){return _z(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){$I(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&RI(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function _z(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function vz(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
4300
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),EM&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=YM(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=uM(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-XM),XM),t/=XM,t/Math.abs(t)+Math.round(t*(ZM-1)))}shouldForceSelection(e){return SM?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),QM)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(SM&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<$M&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=FM(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=YM(n,this._bufferService.cols)}};tN=yD([X(3,KD),X(4,JD),X(5,oO),X(6,QD),X(7,sO),X(8,aO)],tN);var nN=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},rN=class{constructor(){this._color=new nN,this._css=new nN}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},iN=Object.freeze((()=>{let e=[Mj.toColor(`#2e3436`),Mj.toColor(`#cc0000`),Mj.toColor(`#4e9a06`),Mj.toColor(`#c4a000`),Mj.toColor(`#3465a4`),Mj.toColor(`#75507b`),Mj.toColor(`#06989a`),Mj.toColor(`#d3d7cf`),Mj.toColor(`#555753`),Mj.toColor(`#ef2929`),Mj.toColor(`#8ae234`),Mj.toColor(`#fce94f`),Mj.toColor(`#729fcf`),Mj.toColor(`#ad7fa8`),Mj.toColor(`#34e2e2`),Mj.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:Aj.toCss(r,i,a),rgba:Aj.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Aj.toCss(n,n,n),rgba:Aj.toRgba(n,n,n)})}return e})()),aN=Mj.toColor(`#ffffff`),oN=Mj.toColor(`#000000`),sN=Mj.toColor(`#ffffff`),cN=oN,lN={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},uN=aN,dN=class extends FO{constructor(e){super(),this._optionsService=e,this._contrastCache=new rN,this._halfContrastCache=new rN,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:aN,background:oN,cursor:sN,cursorAccent:cN,selectionForeground:void 0,selectionBackgroundTransparent:lN,selectionBackgroundOpaque:jj.blend(oN,lN),selectionInactiveBackgroundTransparent:lN,selectionInactiveBackgroundOpaque:jj.blend(oN,lN),scrollbarSliderBackground:jj.opacity(aN,.2),scrollbarSliderHoverBackground:jj.opacity(aN,.4),scrollbarSliderActiveBackground:jj.opacity(aN,.5),overviewRulerBorder:aN,ansi:iN.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=fN(e.foreground,aN),t.background=fN(e.background,oN),t.cursor=jj.blend(t.background,fN(e.cursor,sN)),t.cursorAccent=jj.blend(t.background,fN(e.cursorAccent,cN)),t.selectionBackgroundTransparent=fN(e.selectionBackground,lN),t.selectionBackgroundOpaque=jj.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=fN(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=jj.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?fN(e.selectionForeground,kj):void 0,t.selectionForeground===kj&&(t.selectionForeground=void 0),jj.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=jj.opacity(t.selectionBackgroundTransparent,.3)),jj.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=jj.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=fN(e.scrollbarSliderBackground,jj.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=fN(e.scrollbarSliderHoverBackground,jj.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=fN(e.scrollbarSliderActiveBackground,jj.opacity(t.foreground,.5)),t.overviewRulerBorder=fN(e.overviewRulerBorder,uN),t.ansi=iN.slice(),t.ansi[0]=fN(e.black,iN[0]),t.ansi[1]=fN(e.red,iN[1]),t.ansi[2]=fN(e.green,iN[2]),t.ansi[3]=fN(e.yellow,iN[3]),t.ansi[4]=fN(e.blue,iN[4]),t.ansi[5]=fN(e.magenta,iN[5]),t.ansi[6]=fN(e.cyan,iN[6]),t.ansi[7]=fN(e.white,iN[7]),t.ansi[8]=fN(e.brightBlack,iN[8]),t.ansi[9]=fN(e.brightRed,iN[9]),t.ansi[10]=fN(e.brightGreen,iN[10]),t.ansi[11]=fN(e.brightYellow,iN[11]),t.ansi[12]=fN(e.brightBlue,iN[12]),t.ansi[13]=fN(e.brightMagenta,iN[13]),t.ansi[14]=fN(e.brightCyan,iN[14]),t.ansi[15]=fN(e.brightWhite,iN[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=fN(e.extendedAnsi[r],iN[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};dN=yD([X(0,QD)],dN);function fN(e,t){if(e!==void 0)try{return Mj.toColor(e)}catch{}return t}var pN=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},mN=class{constructor(){this._services=new pN,this._services.set(XD,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=UD(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},hN={trace:0,debug:1,info:2,warn:3,error:4,off:5},gN=`xterm.js: `,_N=class extends FO{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),vN=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=hN[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:gN)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};_N=yD([X(0,QD)],_N);var vN,yN=class extends FO{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Z),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},bN=3,xN=Object.freeze(new LD),SN=0,CN=2,wN=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*bN);let r=t||zD.fromCharData([0,FD,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*bN+0],n=t&2097151;return[this._data[e*bN+1],t&2097152?this._combined[e]:n?jD(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*bN+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*bN+0]=e|2097152|t[2]<<22):this._data[e*bN+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*bN+0]>>22}hasWidth(e){return this._data[e*bN+0]&12582912}getFg(e){return this._data[e*bN+1]}getBg(e){return this._data[e*bN+2]}hasContent(e){return this._data[e*bN+0]&4194303}getCodePoint(e){let t=this._data[e*bN+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*bN+0]&2097152}getString(e){let t=this._data[e*bN+0];return t&2097152?this._combined[e]:t&2097151?jD(t&2097151):``}isProtected(e){return this._data[e*bN+2]&536870912}loadCell(e,t){return SN=e*bN,t.content=this._data[SN+0],t.fg=this._data[SN+1],t.bg=this._data[SN+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*bN+0]=t.content,this._data[e*bN+1]=t.fg,this._data[e*bN+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*bN+0]=t|n<<22,this._data[e*bN+1]=r.fg,this._data[e*bN+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*bN+0];r&2097152?this._combined[e]+=jD(t):r&2097151?(this._combined[e]=jD(r&2097151)+jD(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*bN+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new zD;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new zD;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*CN<this._data.buffer.byteLength;let n=e*bN;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*CN<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*CN<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);return}this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*bN+0]&4194303)return e+(this._data[e*bN+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*bN+0]&4194303||this._data[e*bN+2]&50331648)return e+(this._data[e*bN+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<bN;e++)this._data[(n+i)*bN+e]=a[(t+i)*bN+e];a[(t+i)*bN+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<bN;e++)this._data[(n+i)*bN+e]=a[(t+i)*bN+e];a[(t+i)*bN+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*bN+0],n=e&2097151,a=e&2097152?this._combined[t]:n?jD(n):ID;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function TN(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=kN(u,d,t),p=1,m=0;for(;p<u.length;){let e=kN(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function EN(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function DN(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function ON(e,t,n){let r=[],i=e.map((n,r)=>kN(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=kN(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function kN(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var AN=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),AO(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};AN._nextId=1;var jN=AN,MN={},NN=MN.B;MN[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},MN.A={"#":`£`},MN.B=void 0,MN[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},MN.C=MN[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},MN.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},MN.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},MN.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},MN.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},MN.E=MN[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},MN.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},MN.H=MN[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},MN[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var PN=4294967295,FN=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=xN.clone(),this.savedCharset=NN,this.markers=[],this._nullCell=zD.fromCharData([0,FD,1,0]),this._whitespaceCell=zD.fromCharData([0,ID,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new jM,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new yN(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new RD),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new RD),this._whitespaceCell}getBlankLine(e,t){return new wN(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>PN?PN:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=xN);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new yN(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(xN),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new wN(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new wN(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=TN(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(xN),n);if(r.length>0){let n=EN(this.lines,r);DN(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(xN),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new wN(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(xN),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=ON(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(xN,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=kN(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new jN(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},IN=class extends FO{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Z),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new FN(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new FN(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},LN=2,RN=1,zN=class extends FO{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,LN),this.rows=Math.max(e.rawOptions.rows||0,RN),this.buffers=this._register(new IN(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};zN=yD([X(0,QD)],zN);var BN={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:SM,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},VN=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],HN=class extends FO{constructor(e){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let t={...BN};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(MO(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in BN))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in BN))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=BN[e],!UN(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=BN[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=VN.includes(t)?t:BN[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function UN(e){return e===`block`||e===`underline`||e===`bar`}function WN(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&WN(e[r],t-1);return n}var GN=Object.freeze({insertMode:!1}),KN=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),qN=class extends FO{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Z),this.onData=this._onData.event,this._onUserInput=this._register(new Z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=WN(GN),this.decPrivateModes=WN(KN)}reset(){this.modes=WN(GN),this.decPrivateModes=WN(KN)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};qN=yD([X(0,KD),X(1,ZD),X(2,QD)],qN);var JN={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function YN(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var XN=String.fromCharCode,ZN={DEFAULT:e=>{let t=[YN(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${XN(t[0])}${XN(t[1])}${XN(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${YN(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${YN(e,!0)};${e.x};${e.y}${t}`}},QN=class extends FO{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Z),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(JN))this.addProtocol(e,JN[e]);for(let e of Object.keys(ZN))this.addEncoding(e,ZN[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};QN=yD([X(0,KD),X(1,JD),X(2,QD)],QN);var $N=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],eP=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],tP;function nP(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var rP=class{constructor(){if(this.version=`6`,!tP){tP=new Uint8Array(65536),tP.fill(1),tP[0]=0,tP.fill(0,1,32),tP.fill(0,127,160),tP.fill(2,4352,4448),tP[9001]=2,tP[9002]=2,tP.fill(2,11904,42192),tP[12351]=1,tP.fill(2,44032,55204),tP.fill(2,63744,64256),tP.fill(2,65040,65050),tP.fill(2,65072,65136),tP.fill(2,65280,65377),tP.fill(2,65504,65511);for(let e=0;e<$N.length;++e)tP.fill(0,$N[e][0],$N[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?tP[e]:nP(e,eP)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=iP.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return iP.createPropertyValue(0,n,r)}},iP=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Z,this.onChange=this._onChange.event;let e=new rP;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},aP=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function oP(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var sP=2147483647,cP=256,lP=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>cP)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>sP?sP:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>sP?sP:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,sP):e}},uP=[],dP=class{constructor(){this._state=0,this._active=uP,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=uP}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=uP,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||uP,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,MD(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=uP,this._id=-1,this._state=0}}},fP=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=MD(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},pP=[],mP=class{constructor(){this._handlers=Object.create(null),this._active=pP,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=pP}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=pP,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||pP,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,MD(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=pP,this._ident=0}},hP=new lP;hP.addParam(0);var gP=class{constructor(e){this._handler=e,this._data=``,this._params=hP,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():hP,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=MD(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=hP,this._data=``,this._hitLimit=!1,e));return this._params=hP,this._data=``,this._hitLimit=!1,t}},_P=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},vP=160,yP=function(){let e=new _P(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(vP,0,2,0),e.add(vP,8,5,8),e.add(vP,6,0,6),e.add(vP,11,0,11),e.add(vP,13,13,13),e}(),bP=class extends FO{constructor(e=yP){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new lP,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(MO(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new dP),this._dcsParser=this._register(new mP),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:vP)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<vP){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<vP){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<vP){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<vP){this._printHandler(e,n,i),n=i-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<vP){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<vP){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},xP=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,SP=/^[\da-f]+$/;function CP(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=xP.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),SP.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function wP(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function TP(e,t=16){let[n,r,i]=e;return`rgb:${wP(n,t)}/${wP(r,t)}/${wP(i,t)}`}var EP={"(":0,")":1,"*":2,"+":3,"-":1,".":2},DP=131072,OP=10;function kP(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var AP=5e3,jP=0,MP=class extends FO{constructor(e,t,n,r,i,a,o,s,c=new bP){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new ND,this._utf8Decoder=new PD,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=xN.clone(),this._eraseAttrDataInternal=xN.clone(),this._onRequestBell=this._register(new Z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Z),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new NP(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(Q.BEL,()=>this.bell()),this._parser.setExecuteHandler(Q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(Q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(Q.BS,()=>this.backspace()),this._parser.setExecuteHandler(Q.HT,()=>this.tab()),this._parser.setExecuteHandler(Q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(Q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Sj.IND,()=>this.index()),this._parser.setExecuteHandler(Sj.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Sj.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new fP(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new fP(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new fP(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new fP(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new fP(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new fP(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new fP(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new fP(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new fP(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new fP(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new fP(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new fP(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in MN)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new gP((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),AP))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${AP} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>DP&&(a=this._parseStack.position+DP)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<DP&&(this._parseBuffer=new Uint32Array(Math.min(e.length,DP))),o||this._dirtyRowTracker.clearRange(),e.length>DP)for(let t=a;t<e.length;t+=DP){let a=t+DP<e.length?t+DP:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=iP.extractWidth(t);let n=iP.extractShouldJoin(t),m=n?iP.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(jD(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof wN&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!kP(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new gP(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new fP(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(xN));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=iP.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(Q.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(Q.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(Q.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(Q.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(Q.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,NN),this._charsetService.setgCharset(1,NN),this._charsetService.setgCharset(2,NN),this._charsetService.setgCharset(3,NN);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${Q.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=LD.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=xN.fg,e.bg=xN.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=xN.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=xN.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=xN.fg&16777215,r.bg&=-67108864,r.bg|=xN.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${Q.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${Q.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=xN.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!kP(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${Q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>OP&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>OP&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(PP(n)){if(r===`?`)t.push({type:0,index:n});else{let e=CP(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=CP(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);PP(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,NN),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(EP[e[0]],MN[e[1]]||NN),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=xN.clone(),this._eraseAttrDataInternal=xN.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new zD;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${Q.ESC}${e}${Q.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},NP=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(jP=e,e=t,t=jP),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};NP=yD([X(0,KD)],NP);function PP(e){return 0<=e&&e<256}var FP=5e7,IP=12,LP=50,RP=class extends FO{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>FP)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=IP?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=IP)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>LP&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},zP=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};zP=yD([X(0,KD)],zP);var BP=!1,VP=class extends FO{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new IO),this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onData=this._register(new Z),this.onData=this._onData.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Z),this._instantiationService=new mN,this.optionsService=this._register(new HN(e)),this._instantiationService.setService(QD,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(zN)),this._instantiationService.setService(KD,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(_N)),this._instantiationService.setService(ZD,this._logService),this.coreService=this._register(this._instantiationService.createInstance(qN)),this._instantiationService.setService(JD,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(QN)),this._instantiationService.setService(qD,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(iP)),this._instantiationService.setService(eO,this.unicodeService),this._charsetService=this._instantiationService.createInstance(aP),this._instantiationService.setService(YD,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(zP),this._instantiationService.setService($D,this._oscLinkService),this._inputHandler=this._register(new MP(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(UO.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(UO.forward(this._bufferService.onResize,this._onResize)),this._register(UO.forward(this.coreService.onData,this._onData)),this._register(UO.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new RP((e,t)=>this._inputHandler.parse(e,t))),this._register(UO.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!BP&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),BP=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,LN),t=Math.max(t,RN),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(oP.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(oP(this._bufferService),!1))),this._windowsWrappingHeuristics.value=MO(()=>{for(let t of e)t.dispose()})}}},HP={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function UP(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?Q.ESC+`OA`:Q.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?Q.ESC+`OD`:Q.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?Q.ESC+`OC`:Q.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?Q.ESC+`OB`:Q.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:Q.DEL,e.altKey&&(i.key=Q.ESC+i.key);break;case 9:if(e.shiftKey){i.key=Q.ESC+`[Z`;break}i.key=Q.HT,i.cancel=!0;break;case 13:i.key=e.altKey?Q.ESC+Q.CR:Q.CR,i.cancel=!0;break;case 27:i.key=Q.ESC,e.altKey&&(i.key=Q.ESC+Q.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`D`:t?Q.ESC+`OD`:Q.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`C`:t?Q.ESC+`OC`:Q.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`A`:t?Q.ESC+`OA`:Q.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?Q.ESC+`[1;`+(a+1)+`B`:t?Q.ESC+`OB`:Q.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=Q.ESC+`[2~`);break;case 46:i.key=a?Q.ESC+`[3;`+(a+1)+`~`:Q.ESC+`[3~`;break;case 36:i.key=a?Q.ESC+`[1;`+(a+1)+`H`:t?Q.ESC+`OH`:Q.ESC+`[H`;break;case 35:i.key=a?Q.ESC+`[1;`+(a+1)+`F`:t?Q.ESC+`OF`:Q.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?Q.ESC+`[5;`+(a+1)+`~`:Q.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?Q.ESC+`[6;`+(a+1)+`~`:Q.ESC+`[6~`;break;case 112:i.key=a?Q.ESC+`[1;`+(a+1)+`P`:Q.ESC+`OP`;break;case 113:i.key=a?Q.ESC+`[1;`+(a+1)+`Q`:Q.ESC+`OQ`;break;case 114:i.key=a?Q.ESC+`[1;`+(a+1)+`R`:Q.ESC+`OR`;break;case 115:i.key=a?Q.ESC+`[1;`+(a+1)+`S`:Q.ESC+`OS`;break;case 116:i.key=a?Q.ESC+`[15;`+(a+1)+`~`:Q.ESC+`[15~`;break;case 117:i.key=a?Q.ESC+`[17;`+(a+1)+`~`:Q.ESC+`[17~`;break;case 118:i.key=a?Q.ESC+`[18;`+(a+1)+`~`:Q.ESC+`[18~`;break;case 119:i.key=a?Q.ESC+`[19;`+(a+1)+`~`:Q.ESC+`[19~`;break;case 120:i.key=a?Q.ESC+`[20;`+(a+1)+`~`:Q.ESC+`[20~`;break;case 121:i.key=a?Q.ESC+`[21;`+(a+1)+`~`:Q.ESC+`[21~`;break;case 122:i.key=a?Q.ESC+`[23;`+(a+1)+`~`:Q.ESC+`[23~`;break;case 123:i.key=a?Q.ESC+`[24;`+(a+1)+`~`:Q.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=Q.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=Q.DEL:e.keyCode===219?i.key=Q.ESC:e.keyCode===220?i.key=Q.FS:e.keyCode===221&&(i.key=Q.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=HP[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=Q.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=Q.ESC+n}else if(e.keyCode===32)i.key=Q.ESC+(e.ctrlKey?Q.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=Q.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=Q.US),e.key===`@`&&(i.key=Q.NUL))}return i}var WP=0,GP=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new jM,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new jM,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(WP=this._search(t),WP===-1)||this._getKey(this._array[WP])!==t)return!1;do if(this._array[WP]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(WP),!0;while(++WP<this._array.length&&this._getKey(this._array[WP])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(WP=this._search(e),!(WP<0||WP>=this._array.length)&&this._getKey(this._array[WP])===e))do yield this._array[WP];while(++WP<this._array.length&&this._getKey(this._array[WP])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(WP=this._search(e),!(WP<0||WP>=this._array.length)&&this._getKey(this._array[WP])===e))do t(this._array[WP]);while(++WP<this._array.length&&this._getKey(this._array[WP])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},KP=0,qP=0,JP=class extends FO{constructor(){super(),this._decorations=new GP(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(MO(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new YP(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{KP=t.options.x??0,qP=KP+(t.options.width??1),e>=KP&&e<qP&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},YP=class extends PO{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?Mj.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?Mj.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},XP=1e3,ZP=class{constructor(e,t=XP){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},QP=20,$P=class extends FO{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new ZP(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
4301
|
+
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(TA(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(MO(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<QP+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
4302
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===QP+1&&(this._liveRegion.textContent+=CD.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};$P=yD([X(1,XD),X(2,aO),X(3,sO)],$P);var eF=class extends FO{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(MO(()=>{AO(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(TA(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(TA(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(TA(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(TA(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&tF(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,AO(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};eF=yD([X(1,oO),X(2,sO),X(3,KD),X(4,dO)],eF);function tF(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var nF=class extends VP{constructor(e={}){super(e),this._linkifier=this._register(new IO),this.browser=mM,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new IO),this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Z),this.onKey=this._onKey.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Z),this.onBell=this._onBell.event,this._onFocus=this._register(new Z),this._onBlur=this._register(new Z),this._onA11yCharEmitter=this._register(new Z),this._onA11yTabEmitter=this._register(new Z),this._onWillOpen=this._register(new Z),this._setup(),this._decorationService=this._instantiationService.createInstance(JP),this._instantiationService.setService(tO,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(lM),this._instantiationService.setService(dO,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(nO)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(UO.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(UO.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(UO.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(UO.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(MO(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=jj.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${TP(r)}${Cj.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Aj.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Aj.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($P,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(TA(this.element,`copy`,e=>{this.hasSelection()&&ED(e,this._selectionService)}));let e=e=>DD(e,this.textarea,this.coreService,this.optionsService);this._register(TA(this.textarea,`paste`,e)),this._register(TA(this.element,`paste`,e)),vM?this._register(TA(this.element,`mousedown`,e=>{e.button===2&&AD(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(TA(this.element,`contextmenu`,e=>{AD(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),EM&&this._register(TA(this.element,`auxclick`,e=>{e.button===1&&kD(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(TA(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(TA(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(TA(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(TA(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(TA(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(TA(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(TA(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(TA(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,xD.get()),DM||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sM,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(aO,this._coreBrowserService),this._register(TA(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(TA(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(rM,this._document,this._helperContainer),this._instantiationService.setService(iO,this._charSizeService),this._themeService=this._instantiationService.createInstance(dN),this._instantiationService.setService(uO,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Rj),this._instantiationService.setService(lO,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(NM,this.rows,this.screenElement)),this._instantiationService.setService(sO,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(wj,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(fM),this._instantiationService.setService(oO,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(eF,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(hj,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(tN,this.element,this.screenElement,r)),this._instantiationService.setService(cO,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(UO.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(gj,this.screenElement)),this._register(TA(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance($P,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xj,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(xj,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(nM,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(TA(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(TA(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=Q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){OD(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=UP(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===Q.ETX||n.key===Q.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(rF(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(xN));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(Q.ESC+`[I`):this.coreService.triggerDataEvent(Q.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function rF(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var iF=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},aF=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new zD)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},oF=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new aF(t)}getNullCell(){return new zD}},sF=class extends FO{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new oF(this._core.buffers.normal,`normal`),this._alternate=new oF(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},cF=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},lF=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},uF=[`cols`,`rows`],dF=0,fF=class extends FO{constructor(e){super(),this._core=this._register(new nF(e)),this._addonManager=this._register(new iF),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(uF.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new cF(this._core),this._parser}get unicode(){return this._checkProposedApi(),new lF(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new sF(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
4303
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return xD.get()},set promptLabel(e){xD.set(e)},get tooMuchOutput(){return CD.get()},set tooMuchOutput(e){CD.set(e)}}}_verifyIntegers(...e){for(dF of e)if(dF===1/0||isNaN(dF)||dF%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(dF of e)if(dF&&(dF===1/0||isNaN(dF)||dF%1!=0||dF<0))throw Error(`This API only accepts positive integers`)}},pF=2,mF=1,hF=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(pF,Math.floor(u/e.css.cell.width)),rows:Math.max(mF,Math.floor(l/e.css.cell.height))}}},gF=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=vF.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map(e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){let{range:r}=e;this._options.hover(t,n,r)}},e))}};function _F(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var vF=class e{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||``)+`g`),[o,s]=e._getWindowedLineStrings(t-1,r),c=o.join(``),l,u=[];for(;l=a.exec(c);){let t=l[0];if(!_F(t))continue;let[n,a]=e._mapStrIdx(r,s,0,l.index),[o,c]=e._mapStrIdx(r,n,a,t.length);if(n===-1||a===-1||o===-1||c===-1)continue;let d={start:{x:a+1,y:n+1},end:{x:c,y:o+1}};u.push({range:d,text:t,activate:i})}return u}static _getWindowedLineStrings(e,t){let n,r=e,i=e,a=0,o=``,s=[];if(n=t.buffer.active.getLine(e)){let e=n.translateToString(!0);if(n.isWrapped&&e[0]!==` `){for(a=0;(n=t.buffer.active.getLine(--r))&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),n.isWrapped&&o.indexOf(` `)===-1););s.reverse()}for(s.push(e),a=0;(n=t.buffer.active.getLine(++i))&&n.isWrapped&&a<2048&&(o=n.translateToString(!0),a+=o.length,s.push(o),o.indexOf(` `)===-1););}return[s,r]}static _mapStrIdx(e,t,n,r){let i=e.buffer.active,a=i.getNullCell(),o=n;for(;r;){let e=i.getLine(t);if(!e)return[-1,-1];for(let n=o;n<e.length;++n){e.getCell(n,a);let o=a.getChars();if(a.getWidth()&&(r-=o.length||1,n===e.length-1&&o===``)){let e=i.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[t,n]}t++,o=0}return[t,o]}},yF=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function bF(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}var xF=class{constructor(e=bF,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||yF;this._linkProvider=this._terminal.registerLinkProvider(new gF(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},SF={background:`#1b1b29`,foreground:`#e8e8f2`,cursor:`#ff9e64`,cursorAccent:`#1b1b29`,selectionBackground:`#44475a`,black:`#21222c`,red:`#ff6b6b`,green:`#50fa7b`,yellow:`#f1fa8c`,blue:`#8aa4ff`,magenta:`#ff79c6`,cyan:`#8be9fd`,white:`#e8e8f2`,brightBlack:`#6c6f93`,brightRed:`#ff8787`,brightGreen:`#69ff94`,brightYellow:`#ffffa5`,brightBlue:`#a4b9ff`,brightMagenta:`#ff92df`,brightCyan:`#a4ffff`,brightWhite:`#ffffff`};function CF({agentId:e,className:t}){let n=(0,v.useRef)(null),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(!0),[s,c]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let t=n.current,r=new fF({fontFamily:`'JetBrains Mono', Consolas, monospace`,fontSize:13,cursorBlink:!0,cursorInactiveStyle:`none`,scrollback:5e3,allowProposedApi:!0,scrollOnEraseInDisplay:!0,theme:SF}),a=new hF;r.loadAddon(a),r.loadAddon(new xF((e,t)=>window.open(t,`_blank`,`noopener`))),r.open(t);let s=null,l=!1,u=!1,d,f=0,p=e=>{s?.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))},m=()=>{try{a.fit()}catch{return}u&&p({t:`resize`,cols:r.cols,rows:r.rows})},h=()=>{let t=location.protocol===`https:`?`wss`:`ws`,n=new WebSocket(`${t}://${location.host}/ws/term?agent=${encodeURIComponent(e)}`);s=n,n.onopen=()=>o(!0),n.onmessage=e=>{let t=JSON.parse(String(e.data));t.t===`snapshot`?(u=!1,r.reset(),r.resize(t.cols,t.rows),r.write(t.data,()=>{u=!0,m(),r.scrollToBottom()}),i(t.live)):t.t===`data`?r.write(t.data):t.t===`size`&&(t.cols!==r.cols||t.rows!==r.rows)?r.resize(t.cols,t.rows):t.t===`live`&&i(t.live)},n.onclose=e=>{s===n&&(s=null),!l&&(o(!1),e.code!==4404&&(d=window.setTimeout(h,1500)))}};h();let g=r.onData(e=>p({t:`input`,data:e})),_=e=>{e.key===`Escape`&&e.stopPropagation()};t.addEventListener(`keydown`,_),r.textarea?.addEventListener(`focus`,()=>c(!0)),r.textarea?.addEventListener(`blur`,()=>c(!1));let v=new ResizeObserver(()=>{cancelAnimationFrame(f),f=requestAnimationFrame(m)});return v.observe(t),document.fonts?.ready.then(()=>!l&&m()),()=>{l=!0,clearTimeout(d),cancelAnimationFrame(f),v.disconnect(),g.dispose(),t.removeEventListener(`keydown`,_),s?.close(),r.dispose()}},[e]),(0,K.jsxs)(`div`,{className:`live-term ${t??``}`,children:[(0,K.jsx)(`div`,{className:`live-term-screen`,ref:n}),(0,K.jsxs)(`div`,{className:`live-term-foot`,children:[(0,K.jsx)(`span`,{className:`live-dot ${r?`live-dot-on`:``}`}),a?r?s?`Typing goes straight to the agent · Esc goes to them too; click outside to use the office keys`:`Live · click the terminal to type into it`:`Not running · a message below picks the session back up`:`Reconnecting…`]})]})}function wF(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var TF=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,EF=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,DF={};function OF(e,t){return((t||DF).jsx?EF:TF).test(e)}var kF=/[ \t\n\f\r]/g;function AF(e){return typeof e==`object`?e.type===`text`&&jF(e.value):jF(e)}function jF(e){return e.replace(kF,``)===``}var MF=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};MF.prototype.normal={},MF.prototype.property={},MF.prototype.space=void 0;function NF(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new MF(n,r,t)}function PF(e){return e.toLowerCase()}var FF=class{constructor(e,t){this.attribute=t,this.property=e}};FF.prototype.attribute=``,FF.prototype.booleanish=!1,FF.prototype.boolean=!1,FF.prototype.commaOrSpaceSeparated=!1,FF.prototype.commaSeparated=!1,FF.prototype.defined=!1,FF.prototype.mustUseProperty=!1,FF.prototype.number=!1,FF.prototype.overloadedBoolean=!1,FF.prototype.property=``,FF.prototype.spaceSeparated=!1,FF.prototype.space=void 0;var IF=s({boolean:()=>RF,booleanish:()=>zF,commaOrSpaceSeparated:()=>UF,commaSeparated:()=>HF,number:()=>$,overloadedBoolean:()=>BF,spaceSeparated:()=>VF}),LF=0,RF=WF(),zF=WF(),BF=WF(),$=WF(),VF=WF(),HF=WF(),UF=WF();function WF(){return 2**++LF}var GF=Object.keys(IF),KF=class extends FF{constructor(e,t,n,r){let i=-1;if(super(e,t),qF(this,`space`,r),typeof n==`number`)for(;++i<GF.length;){let e=GF[i];qF(this,GF[i],(n&IF[e])===IF[e])}}};KF.prototype.defined=!0;function qF(e,t,n){n&&(e[t]=n)}function JF(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new KF(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[PF(r)]=r,n[PF(a.attribute)]=r}return new MF(t,n,e.space)}var YF=JF({properties:{ariaActiveDescendant:null,ariaAtomic:zF,ariaAutoComplete:null,ariaBusy:zF,ariaChecked:zF,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:VF,ariaCurrent:null,ariaDescribedBy:VF,ariaDetails:null,ariaDisabled:zF,ariaDropEffect:VF,ariaErrorMessage:null,ariaExpanded:zF,ariaFlowTo:VF,ariaGrabbed:zF,ariaHasPopup:null,ariaHidden:zF,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:VF,ariaLevel:$,ariaLive:null,ariaModal:zF,ariaMultiLine:zF,ariaMultiSelectable:zF,ariaOrientation:null,ariaOwns:VF,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:zF,ariaReadOnly:zF,ariaRelevant:null,ariaRequired:zF,ariaRoleDescription:VF,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:zF,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function XF(e,t){return t in e?e[t]:t}function ZF(e,t){return XF(e,t.toLowerCase())}var QF=JF({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:HF,acceptCharset:VF,accessKey:VF,action:null,allow:null,allowFullScreen:RF,allowPaymentRequest:RF,allowUserMedia:RF,alpha:RF,alt:null,as:null,async:RF,autoCapitalize:null,autoComplete:VF,autoFocus:RF,autoPlay:RF,blocking:VF,capture:null,charSet:null,checked:RF,cite:null,className:VF,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:zF,controls:RF,controlsList:VF,coords:$|HF,crossOrigin:null,data:null,dateTime:null,decoding:null,default:RF,defer:RF,dir:null,dirName:null,disabled:RF,download:BF,draggable:zF,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:RF,formTarget:null,headers:VF,height:$,hidden:BF,high:$,href:null,hrefLang:null,htmlFor:VF,httpEquiv:VF,id:null,imageSizes:null,imageSrcSet:null,inert:RF,inputMode:null,integrity:null,is:null,isMap:RF,itemId:null,itemProp:VF,itemRef:VF,itemScope:RF,itemType:VF,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:RF,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:RF,muted:RF,name:null,nonce:null,noModule:RF,noValidate:RF,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:RF,optimum:$,pattern:null,ping:VF,placeholder:null,playsInline:RF,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:RF,referrerPolicy:null,rel:VF,required:RF,reversed:RF,rows:$,rowSpan:$,sandbox:VF,scope:null,scoped:RF,seamless:RF,selected:RF,shadowRootClonable:RF,shadowRootCustomElementRegistry:RF,shadowRootDelegatesFocus:RF,shadowRootMode:null,shadowRootSerializable:RF,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:zF,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:RF,useMap:null,value:zF,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:VF,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:RF,declare:RF,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:RF,noHref:RF,noShade:RF,noWrap:RF,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:zF,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:RF,disablePictureInPicture:RF,disableRemotePlayback:RF,exportParts:HF,part:VF,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:ZF}),$F=JF({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:UF,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:VF,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:RF,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:HF,g2:HF,glyphName:HF,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:UF,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:VF,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:UF,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:UF,rev:UF,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:UF,requiredFeatures:UF,requiredFonts:UF,requiredFormats:UF,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:UF,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:UF,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:UF,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:XF}),eI=JF({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),tI=JF({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:ZF}),nI=JF({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),rI={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},iI=/[A-Z]/g,aI=/-[a-z]/g,oI=/^data[-\w.:]+$/i;function sI(e,t){let n=PF(t),r=t,i=FF;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&oI.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(aI,lI);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!aI.test(e)){let n=e.replace(iI,cI);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=KF}return new i(r,t)}function cI(e){return`-`+e.toLowerCase()}function lI(e){return e.charAt(1).toUpperCase()}var uI=NF([YF,QF,eI,tI,nI],`html`),dI=NF([YF,$F,eI,tI,nI],`svg`);function fI(e){return e.join(` `).trim()}var pI=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
4304
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),mI=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(pI());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),hI=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),gI=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(mI()),r=hI();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),_I=yI(`end`),vI=yI(`start`);function yI(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function bI(e){let t=vI(e),n=_I(e);if(t&&n)return{start:t,end:n}}function xI(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?CI(e.position):`start`in e||`end`in e?CI(e):`line`in e||`column`in e?SI(e):``}function SI(e){return wI(e&&e.line)+`:`+wI(e&&e.column)}function CI(e){return SI(e&&e.start)+`-`+SI(e&&e.end)}function wI(e){return e&&typeof e==`number`?e:1}var TI=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=xI(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};TI.prototype.file=``,TI.prototype.name=``,TI.prototype.reason=``,TI.prototype.message=``,TI.prototype.stack=``,TI.prototype.column=void 0,TI.prototype.line=void 0,TI.prototype.ancestors=void 0,TI.prototype.cause=void 0,TI.prototype.fatal=void 0,TI.prototype.place=void 0,TI.prototype.ruleId=void 0,TI.prototype.source=void 0;var EI=l(gI(),1),DI={}.hasOwnProperty,OI=new Map,kI=/[A-Z]/g,AI=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),jI=new Set([`td`,`th`]),MI=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function NI(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=WI(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=UI(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?dI:uI,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=PI(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function PI(e,t,n){if(t.type===`element`)return FI(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return II(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return RI(e,t,n);if(t.type===`mdxjsEsm`)return LI(e,t);if(t.type===`root`)return zI(e,t,n);if(t.type===`text`)return BI(e,t)}function FI(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=dI,e.schema=i),e.ancestors.push(t);let a=XI(e,t.tagName,!1),o=GI(e,t),s=qI(e,t);return AI.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!AF(e)})),VI(e,o,a,t),HI(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function II(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}ZI(e,t.position)}function LI(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ZI(e,t.position)}function RI(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=dI,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:XI(e,t.name,!0),o=KI(e,t),s=qI(e,t);return VI(e,o,a,t),HI(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function zI(e,t,n){let r={};return HI(r,qI(e,t)),e.create(t,e.Fragment,r,n)}function BI(e,t){return t.value}function VI(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function HI(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function UI(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function WI(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=vI(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function GI(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&DI.call(t.properties,i)){let a=JI(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&jI.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function KI(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else ZI(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else ZI(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function qI(e,t){let n=[],r=-1,i=e.passKeys?new Map:OI;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=PI(e,a,o);s!==void 0&&n.push(s)}return n}function JI(e,t,n){let r=sI(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?wF(n):fI(n)),r.property===`style`){let t=typeof n==`object`?n:YI(e,String(n));return e.stylePropertyNameCase===`css`&&(t=QI(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?rI[r.property]||r.property:r.attribute,n]}}function YI(e,t){try{return(0,EI.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new TI("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=MI+`#cannot-parse-style-attribute`,r}}function XI(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=OF(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=OF(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return DI.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);ZI(e)}function ZI(e,t){let n=new TI("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=MI+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function QI(e){let t={},n;for(n in e)DI.call(e,n)&&(t[$I(n)]=e[n]);return t}function $I(e){let t=e.replace(kI,eL);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function eL(e){return`-`+e.toLowerCase()}var tL={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},nL={};function rL(e,t){let n=t||nL;return iL(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function iL(e,t,n){if(oL(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return aL(e.children,t,n)}return Array.isArray(e)?aL(e,t,n):``}function aL(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=iL(e[i],t,n);return r.join(``)}function oL(e){return!!(e&&typeof e==`object`)}var sL=document.createElement(`i`);function cL(e){let t=`&`+e+`;`;sL.innerHTML=t;let n=sL.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function lL(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function uL(e,t){return e.length>0?(lL(e,e.length,0,t),e):t}var dL={}.hasOwnProperty;function fL(e){let t={},n=-1;for(;++n<e.length;)pL(t,e[n]);return t}function pL(e,t){let n;for(n in t){let r=(dL.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){dL.call(r,a)||(r[a]=[]);let e=i[a];mL(r[a],Array.isArray(e)?e:e?[e]:[])}}}function mL(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);lL(e,0,0,r)}function hL(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function gL(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var _L=kL(/[A-Za-z]/),vL=kL(/[\dA-Za-z]/),yL=kL(/[#-'*+\--9=?A-Z^-~]/);function bL(e){return e!==null&&(e<32||e===127)}var xL=kL(/\d/),SL=kL(/[\dA-Fa-f]/),CL=kL(/[!-/:-@[-`{-~]/);function wL(e){return e!==null&&e<-2}function TL(e){return e!==null&&(e<0||e===32)}function EL(e){return e===-2||e===-1||e===32}var DL=kL(/\p{P}|\p{S}/u),OL=kL(/\s/);function kL(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function AL(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&vL(e.charCodeAt(n+1))&&vL(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function jL(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return EL(r)?(e.enter(n),s(r)):t(r)}function s(r){return EL(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function ML(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&EL(t)?(e.enter(r),c(t)):l(t)}function c(t){return EL(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var NL={tokenize:PL};function PL(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),jL(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return wL(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var FL=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){IL(this,e,t,n,!1)}addBefore(e,t,n){IL(this,e,t,n,!0)}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,this.index.clear()}};function IL(e,t,n,r,i){if(n===0&&r.length===0)return;let a=e.index.get(t);if(a){a[1]+=n,i?(r.push(...a[2]),a[2]=r):a[2].push(...r);return}let o=[t,n,r];e.map.push(o),e.index.set(t,o)}var LL={tokenize:zL},RL={tokenize:BL};function zL(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;let c=new FL;return c.add(a+1,0,t.events.slice(n)),c.add(n,s-n,[]),c.consume(t.events),l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(RL,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(RL,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return wL(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;let l=new FL;l.add(a+1,0,t.events.slice(n)),l.add(n,e-n,[]),l.consume(t.events)}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function BL(e,t,n){return jL(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function VL(e){if(e===null||TL(e)||OL(e))return 1;if(DL(e))return 2}function HL(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var UL={name:`attention`,resolveAll:WL,tokenize:GL};function WL(e,t){let n=-1,r;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){let i=n;for(;i--;)if(e[i][0]===`exit`&&e[i][1].type===`attentionSequence`&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;let a=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1,o={...e[i][1].end},s={...e[n][1].start};KL(o,-a),KL(s,a);let c={type:a>1?`strongSequence`:`emphasisSequence`,start:o,end:{...e[i][1].end}},l={type:a>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:s},u={type:a>1?`strongText`:`emphasisText`,start:{...e[i][1].end},end:{...e[n][1].start}},d={type:a>1?`strong`:`emphasis`,start:{...c.start},end:{...l.end}};e[i][1].end={...c.start},e[n][1].start={...l.end},r=[],e[i][1].end.offset-e[i][1].start.offset&&(r=uL(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=uL(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=uL(r,HL(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=uL(r,[[`exit`,u,t],[`enter`,l,t],[`exit`,l,t],[`exit`,d,t]]);let f=0;e[n][1].end.offset-e[n][1].start.offset&&(f=2,r=uL(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),lL(e,i-1,n-i+3,r),n=i+r.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function GL(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=VL(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=VL(o),u=!l||l===2&&i||n.includes(o)&&o!==42&&o!==95,d=!i||i===2&&l||n.includes(r)&&r!==42&&r!==95;return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function KL(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var qL={name:`autolink`,tokenize:JL};function JL(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return _L(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||vL(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||vL(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||bL(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):yL(t)?(e.consume(t),l):n(t)}function u(e){return vL(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||vL(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var YL={partial:!0,tokenize:XL};function XL(e,t,n){return r;function r(t){return EL(t)?jL(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||wL(e)?t(e):n(e)}}var ZL={continuation:{tokenize:$L},exit:eR,name:`blockQuote`,tokenize:QL};function QL(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return EL(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function $L(e,t,n){let r=this;return i;function i(t){return EL(t)?jL(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(ZL,t,n)(r)}}function eR(e){e.exit(`blockQuote`)}var tR={name:`characterEscape`,tokenize:nR};function nR(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return CL(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var rR={name:`characterReference`,tokenize:iR};function iR(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=vL,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=SL,u):(e.enter(`characterReferenceValue`),a=7,o=xL,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===vL&&!cL(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var aR={partial:!0,tokenize:oR};function oR(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var sR={concrete:!0,name:`codeFenced`,tokenize:cR};function cR(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),EL(t)?jL(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||wL(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(aR,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||wL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):EL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),jL(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||wL(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||wL(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&EL(t)?jL(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||wL(t)?e.check(aR,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||wL(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),EL(t)?jL(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),EL(t)?jL(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||wL(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var lR={name:`codeIndented`,tokenize:dR},uR={partial:!0,tokenize:fR};function dR(e,t,n){return r;function r(t){return e.enter(`codeIndented`),ML(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):wL(t)?e.attempt(uR,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||wL(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function fR(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):wL(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):ML(e,t,a,`linePrefix`,4,4)(o)}function a(e){return wL(e)?i(e):n(e)}}var pR={name:`codeText`,previous:hR,resolve:mR,tokenize:gR};function mR(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function hR(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function gR(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):wL(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||wL(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var _R=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&vR(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),vR(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vR(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);vR(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);vR(this.left,t.reverse())}}}};function vR(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function yR(e){let t={},n=-1,r,i,a,o,s,c,l,u=new _R(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,bR(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return lL(e,0,1/0,u.slice(0)),!l}function bR(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var xR={resolve:CR,tokenize:wR},SR={partial:!0,tokenize:TR};function CR(e){return yR(e),e}function wR(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):wL(t)?e.check(SR,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function TR(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),jL(e,a,`linePrefix`)}function a(i){if(i===null||wL(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function ER(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||bL(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||wL(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||TL(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||bL(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function DR(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):wL(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||wL(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!EL(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function OR(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):wL(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),jL(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||wL(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function kR(e,t){let n;return r;function r(i){return wL(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):EL(i)?jL(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var AR={name:`definition`,tokenize:MR},jR={partial:!0,tokenize:NR};function MR(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return DR.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=gL(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return TL(t)?kR(e,l)(t):l(t)}function l(t){return ER(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(jR,d,d)(t)}function d(t){return EL(t)?jL(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||wL(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function NR(e,t,n){return r;function r(t){return TL(t)?kR(e,i)(t):n(t)}function i(t){return OR(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return EL(t)?jL(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||wL(e)?t(e):n(e)}}var PR={name:`hardBreakEscape`,tokenize:FR};function FR(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return wL(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var IR={name:`headingAtx`,resolve:LR,tokenize:RR};function LR(e,t){let n=e.length-2,r=3;if(e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r){let i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`};lL(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function RR(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||TL(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||wL(n)?(e.exit(`atxHeading`),t(n)):EL(n)?jL(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||TL(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var zR=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),BR=[`pre`,`script`,`style`,`textarea`],VR={concrete:!0,name:`htmlFlow`,resolveTo:UR,tokenize:WR},HR={partial:!0,tokenize:GR};function UR(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function WR(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:te):_L(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):_L(a)?(e.consume(a),i=4,r.interrupt?t:te):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:te):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return _L(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||TL(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&BR.includes(l)?(i=1,r.interrupt?t(s):O(s)):zR.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||vL(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return EL(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||_L(t)?(e.consume(t),b):EL(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||vL(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):EL(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):EL(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||wL(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||TL(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||EL(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||wL(t)?O(t):EL(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),ne):t===63&&i===3?(e.consume(t),te):t===93&&i===5?(e.consume(t),P):wL(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(HR,re,k)(t)):t===null||wL(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(aR,A,re)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||wL(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),te):O(t)}function N(t){return t===47?(e.consume(t),o=``,ee):O(t)}function ee(t){if(t===62){let n=o.toLowerCase();return BR.includes(n)?(e.consume(t),ne):O(t)}return _L(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),ee):O(t)}function P(t){return t===93?(e.consume(t),te):O(t)}function te(t){return t===62?(e.consume(t),ne):t===45&&i===2?(e.consume(t),te):O(t)}function ne(t){return t===null||wL(t)?(e.exit(`htmlFlowData`),re(t)):(e.consume(t),ne)}function re(n){return e.exit(`htmlFlow`),t(n)}}function GR(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(YL,t,n)}}var KR={name:`htmlText`,tokenize:qR};function qR(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):_L(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):_L(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):wL(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):wL(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):wL(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):wL(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return _L(t)?(e.consume(t),S):n(t)}function S(t){return t===45||vL(t)?(e.consume(t),S):C(t)}function C(t){return wL(t)?(o=C,N(t)):EL(t)?(e.consume(t),C):M(t)}function w(t){return t===45||vL(t)?(e.consume(t),w):t===47||t===62||TL(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||_L(t)?(e.consume(t),E):wL(t)?(o=T,N(t)):EL(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||vL(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):wL(t)?(o=D,N(t)):EL(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):wL(t)?(o=O,N(t)):EL(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):wL(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||TL(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||TL(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ee}function ee(t){return EL(t)?jL(e,P,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):P(t)}function P(t){return e.enter(`htmlTextData`),o(t)}}var JR={name:`labelEnd`,resolveAll:QR,resolveTo:$R,tokenize:ez},YR={tokenize:tz},XR={tokenize:nz},ZR={tokenize:rz};function QR(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&lL(e,0,e.length,n),e}function $R(e,t){let n=e.length,r=0,i,a,o;for(;n--;){let t=e[n][1];if(i){if(t.type===`link`||t.type===`labelLink`&&t._inactive)break;e[n][0]===`enter`&&t.type===`labelLink`&&(t._inactive=!0)}else if(a){if(e[n][0]===`enter`&&(t.type===`labelImage`||t.type===`labelLink`)&&!t._balanced&&(i=n,t.type!==`labelLink`)){r=2;break}}else t.type===`labelEnd`&&(a=n)}let s={type:e[i][1].type===`labelLink`?`link`:`image`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}},c={type:`label`,start:{...e[i][1].start},end:{...e[a][1].end}},l={type:`labelText`,start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return o=[[`enter`,s,t],[`enter`,c,t]],o=uL(o,e.slice(i+1,i+r+3)),o=uL(o,[[`enter`,l,t]]),o=uL(o,HL(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=uL(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=uL(o,e.slice(a+1)),o=uL(o,[[`exit`,s,t]]),lL(e,i,e.length,o),e}function ez(e,t,n){let r=this,i=r._labelStarts,a,o;if(i){for(;i.length>0&&i[i.length-1]._balanced;)i.pop();a=i[i.length-1]}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(gL(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(YR,u,o?u:d)(t):t===91?e.attempt(XR,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ZR,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function tz(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return TL(t)?kR(e,a)(t):a(t)}function a(t){return t===41?u(t):ER(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return TL(t)?kR(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?OR(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return TL(t)?kR(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function nz(e,t,n){let r=this;return i;function i(t){return DR.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(gL(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function rz(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var iz={name:`labelStartImage`,resolveAll:JR.resolveAll,tokenize:az};function az(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),o}function o(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelImage`),s):n(t)}function s(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var oz={name:`labelStartLink`,resolveAll:JR.resolveAll,tokenize:sz};function sz(e,t,n){let r=this,i;return a;function a(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),i=e.exit(`labelLink`),o}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):(r._labelStarts=r._labelStarts||[],r._labelStarts.push(i),t(e))}}var cz={name:`lineEnding`,tokenize:lz};function lz(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),jL(e,t,`linePrefix`)}}var uz={name:`thematicBreak`,tokenize:dz};function dz(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||wL(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),EL(t)?jL(e,s,`whitespace`)(t):s(t))}}var fz={continuation:{tokenize:gz},exit:vz,name:`list`,tokenize:hz},pz={partial:!0,tokenize:yz},mz={partial:!0,tokenize:_z};function hz(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:xL(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(uz,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return xL(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(YL,r.interrupt?n:u,e.attempt(pz,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return EL(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function gz(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(YL,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,jL(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!EL(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(mz,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,jL(e,e.attempt(fz,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function _z(e,t,n){let r=this;return jL(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function vz(e){e.exit(this.containerState.type)}function yz(e,t,n){let r=this;return jL(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!EL(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var bz={name:`setextUnderline`,resolveTo:xz,tokenize:Sz};function xz(e,t){let n=new FL,r=e.length,i,a,o;for(;r--;)if(e[r][0]===`enter`){if(e[r][1].type===`content`){i=r;break}e[r][1].type===`paragraph`&&(a=r)}else e[r][1].type===`content`&&n.add(r,1,[]),!o&&e[r][1].type===`definition`&&(o=r);let s={type:`setextHeading`,start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type=`setextHeadingText`,o?(n.add(a,0,[[`enter`,s,t]]),n.add(o+1,0,[[`exit`,e[i][1],t]]),e[i][1].end={...e[o][1].end}):e[i][1]=s,n.add(e.length,0,[[`exit`,s,t]]),n.consume(e),e}function Sz(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),EL(t)?jL(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||wL(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Cz={tokenize:wz};function wz(e){let t=this,n=e.attempt(YL,r,e.attempt(this.parser.constructs.flowInitial,i,jL(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xR,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Tz={resolveAll:kz()},Ez=Oz(`string`),Dz=Oz(`text`);function Oz(e){return{resolveAll:kz(e===`text`?Az:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function kz(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Az(e,t){let n=new FL,r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type===`lineEnding`)&&e[r-1][1].type===`data`){let i=e[r-1][1],a=t.sliceStream(i),o=a.length,s=-1,c=0,l;for(;o--;){let e=a[o];if(typeof e==`string`){for(s=e.length;e.charCodeAt(s-1)===32;)c++,s--;if(s)break;s=-1}else if(e===-2)l=!0,c++;else if(e!==-1){o++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let a={type:r===e.length||l||c<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:o?s:i.start._bufferIndex+s,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...a.start},i.start.offset===i.end.offset?Object.assign(i,a):n.add(r,0,[[`enter`,a,t],[`exit`,a,t]])}r++}return n.consume(e),e}var jz=s({attentionMarkers:()=>zz,contentInitial:()=>Nz,disable:()=>Bz,document:()=>Mz,flow:()=>Fz,flowInitial:()=>Pz,insideSpan:()=>Rz,string:()=>Iz,text:()=>Lz}),Mz={42:fz,43:fz,45:fz,48:fz,49:fz,50:fz,51:fz,52:fz,53:fz,54:fz,55:fz,56:fz,57:fz,62:ZL},Nz={91:AR},Pz={[-2]:lR,[-1]:lR,32:lR},Fz={35:IR,42:uz,45:[bz,uz],60:VR,61:bz,95:uz,96:sR,126:sR},Iz={38:rR,92:tR},Lz={[-5]:cz,[-4]:cz,[-3]:cz,33:iz,38:rR,42:UL,60:[qL,KR],91:oz,92:[PR,tR],93:JR,95:UL,96:pR},Rz={null:[UL,Tz]},zz={null:[42,95]},Bz={null:[]};function Vz(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=uL(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=HL(a,l.events,l),l.events):[]}function f(e,t){return Uz(p(e),t)}function p(e){return Hz(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){for(;r._index<o.length;){let e=o[r._index];if(typeof e==`string`){let t=r._index;for(r._bufferIndex<0&&(r._bufferIndex=0);r._index===t&&r._bufferIndex<e.length;)_(e.charCodeAt(r._bufferIndex))}else _(e)}}function _(e){u=u(e)}function v(e){wL(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&lL(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Hz(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Uz(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
4305
4305
|
`;break;case-3:o=`\r
|
|
4306
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function yz(e){let t={constructs:VI([oz,...(e||{}).extensions||[]]),content:n(cL),defined:[],document:n(fL),flow:n(QR),lazy:{},string:n(tz),text:n(nz)};return t;function n(e){return n;function n(n){return gz(t,e,n)}}}function bz(e){for(;!JL(e););return e}var xz=/[\0\t\n\r]/g;function Sz(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){xz.lastIndex=c;let n=xz.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Cz=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function wz(e){return e.replace(Cz,Tz)}function Tz(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return WI(n.slice(t?2:1),t?16:10)}return LI(n)||e}var Ez={}.hasOwnProperty;function Dz(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Oz(n)(bz(yz(n).document().write(Sz()(e,t,!0))))}function Oz(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ye),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(F),blockQuote:a(de),characterEscape:T,characterReference:T,codeFenced:a(fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(fe,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(ge),hardBreakTrailing:a(ge),htmlFlow:a(_e,o),htmlFlowData:T,htmlText:a(_e,o),htmlTextData:T,image:a(ve),label:o,link:a(ye),listItem:a(xe),listItemValue:f,listOrdered:a(be,d),listUnordered:a(be),paragraph:a(Se),reference:ie,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(F),strong:a(Ce),thematicBreak:a(Te)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ue,autolinkProtocol:le,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:se,characterReference:ce,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:P,labelText:ee,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ae,resourceDestinationString:te,resourceTitleString:ne,resource:re,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};Az(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Ez.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||Mz).call(a,void 0,e[0])}for(r.position={start:kz(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:kz(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:kz(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Mz).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+XF({start:e.start,end:e.end})+`): it’s not open`);n.position.end=kz(e.end)}function u(){return MI(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=GI(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=we(),n.position={start:kz(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=kz(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=kz(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=wz(t),n.identifier=GI(t).toLowerCase()}function P(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function re(){this.data.inReference=void 0}function ie(){this.data.referenceType=`collapsed`}function ae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=GI(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function oe(e){this.data.characterReferenceType=e.type}function se(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=WI(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=LI(t);let i=this.stack[this.stack.length-1];i.value+=r}function ce(e){let t=this.stack.pop();t.position.end=kz(e.end)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function de(){return{type:`blockquote`,children:[]}}function fe(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function F(){return{type:`heading`,depth:0,children:[]}}function ge(){return{type:`break`}}function _e(){return{type:`html`,value:``}}function ve(){return{type:`image`,title:null,url:``,alt:null}}function ye(){return{type:`link`,title:null,url:``,children:[]}}function be(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function xe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Se(){return{type:`paragraph`,children:[]}}function Ce(){return{type:`strong`,children:[]}}function we(){return{type:`text`,value:``}}function Te(){return{type:`thematicBreak`}}}function kz(e){return{line:e.line,column:e.column,offset:e.offset}}function Az(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?Az(e,r):jz(e,r)}}function jz(e,t){let n;for(n in t)if(Ez.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function Mz(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+XF({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+XF({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+XF({start:t.start,end:t.end})+`) is still open`)}function Nz(e){let t=this;t.parser=n;function n(n){return Dz(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Pz(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Fz(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
4307
|
-
`}]}function
|
|
4308
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function
|
|
4306
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Wz(e){let t={constructs:fL([jz,...(e||{}).extensions||[]]),content:n(NL),defined:[],document:n(LL),flow:n(Cz),lazy:{},string:n(Ez),text:n(Dz)};return t;function n(e){return n;function n(n){return Vz(t,e,n)}}}function Gz(e){for(;!yR(e););return e}var Kz=/[\0\t\n\r]/g;function qz(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i));let s=[],c=0;for(t=``,n&&=(i.charCodeAt(0)===65279&&c++,void 0);c<i.length;){Kz.lastIndex=c;let n=Kz.exec(i),a=n&&n.index!==void 0?n.index:i.length,o=i.charCodeAt(a);if(!n){t=i.slice(c);break}if(o===10&&c===a&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),c<a&&(s.push(i.slice(c,a)),e+=a-c),o){case 0:s.push(65533),e++;break;case 9:{let t=Math.ceil(e/4)*4;for(s.push(-2);e++<t;)s.push(-1);break}case 10:s.push(-4),e=1;break;default:r=!0,e=1}c=a+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Jz=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Yz(e){return e.replace(Jz,Xz)}function Xz(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return hL(n.slice(t?2:1),t?16:10)}return cL(n)||e}var Zz={}.hasOwnProperty;function Qz(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),$z(n)(Gz(Wz(n).document().write(qz()(e,t,!0))))}function $z(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ye),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(F),blockQuote:a(de),characterEscape:T,characterReference:T,codeFenced:a(fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(fe,o),codeText:a(pe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(me),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(he),hardBreakEscape:a(ge),hardBreakTrailing:a(ge),htmlFlow:a(_e,o),htmlFlowData:T,htmlText:a(_e,o),htmlTextData:T,image:a(ve),label:o,link:a(ye),listItem:a(xe),listItemValue:f,listOrdered:a(be,d),listUnordered:a(be),paragraph:a(Se),reference:ie,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(F),strong:a(Ce),thematicBreak:a(Te)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ue,autolinkProtocol:le,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:se,characterReference:ce,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:P,labelText:ee,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ae,resourceDestinationString:te,resourceTitleString:ne,resource:re,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};tB(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Zz.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||rB).call(a,void 0,e[0])}for(r.position={start:eB(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:eB(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:eB(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||rB).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+xI({start:e.start,end:e.end})+`): it’s not open`);n.position.end=eB(e.end)}function u(){return rL(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=gL(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=we(),n.position={start:eB(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=eB(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=eB(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Yz(t),n.identifier=gL(t).toLowerCase()}function P(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ne(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function re(){this.data.inReference=void 0}function ie(){this.data.referenceType=`collapsed`}function ae(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=gL(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function oe(e){this.data.characterReferenceType=e.type}function se(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=hL(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=cL(t);let i=this.stack[this.stack.length-1];i.value+=r}function ce(e){let t=this.stack.pop();t.position.end=eB(e.end)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function de(){return{type:`blockquote`,children:[]}}function fe(){return{type:`code`,lang:null,meta:null,value:``}}function pe(){return{type:`inlineCode`,value:``}}function me(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function he(){return{type:`emphasis`,children:[]}}function F(){return{type:`heading`,depth:0,children:[]}}function ge(){return{type:`break`}}function _e(){return{type:`html`,value:``}}function ve(){return{type:`image`,title:null,url:``,alt:null}}function ye(){return{type:`link`,title:null,url:``,children:[]}}function be(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function xe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Se(){return{type:`paragraph`,children:[]}}function Ce(){return{type:`strong`,children:[]}}function we(){return{type:`text`,value:``}}function Te(){return{type:`thematicBreak`}}}function eB(e){return{line:e.line,column:e.column,offset:e.offset}}function tB(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?tB(e,r):nB(e,r)}}function nB(e,t){let n;for(n in t)if(Zz.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function rB(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+xI({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+xI({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+xI({start:t.start,end:t.end})+`) is still open`)}function iB(e){let t=this;t.parser=n;function n(n){return Qz(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function aB(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function oB(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
4307
|
+
`}]}function sB(e,t){let n=t.value?t.value+`
|
|
4308
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function cB(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lB(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uB(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=AL(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function dB(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fB(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function pB(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function mB(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return pB(e,t);let i={src:AL(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function hB(e,t){let n={src:AL(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function gB(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function _B(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return pB(e,t);let i={href:AL(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function vB(e,t){let n={href:AL(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function yB(e,t,n){let r=e.all(t),i=n?bB(n):xB(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
4309
4309
|
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
4310
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function
|
|
4310
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function bB(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=xB(n[r])}return t}function xB(e){return e.spread??e.children.length>1}function SB(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function CB(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wB(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function TB(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EB(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=vI(t.children[1]),o=_I(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function DB(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function OB(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var kB=9,AB=32;function jB(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(MB(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(MB(t.slice(i),i>0,!1)),a.join(``)}function MB(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===kB||t===AB;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===kB||t===AB;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function NB(e,t){let n={type:`text`,value:jB(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function PB(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var FB={blockquote:aB,break:oB,code:sB,delete:cB,emphasis:lB,footnoteReference:uB,heading:dB,html:fB,imageReference:mB,image:hB,inlineCode:gB,linkReference:_B,link:vB,listItem:yB,list:SB,paragraph:CB,root:wB,strong:TB,table:EB,tableCell:OB,tableRow:DB,text:NB,thematicBreak:PB,toml:IB,yaml:IB,definition:IB,footnoteDefinition:IB};function IB(){}var{defineProperty:LB}=Object,RB=typeof self==`object`?self:globalThis,zB=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new RB[e](t)},BB=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?LB(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof RB[e]==`function`?zB(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(zB(a,o),i)};return r},VB=e=>BB(new Map,e)(0),HB=``,{toString:UB}={},{keys:WB,is:GB}=Object,KB=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=UB.call(e).slice(8,-1);switch(n){case`Array`:return[1,HB];case`Object`:return[2,HB];case`Date`:return[3,HB];case`RegExp`:return[4,HB];case`Map`:return[5,HB];case`Set`:return[6,HB];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},qB=([e,t])=>e===0&&(t===`function`||t===`symbol`),JB=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=KB(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&GB(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of WB(o))(e||!qB(KB(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?HB:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(qB(KB(n))||qB(KB(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!qB(KB(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},YB=(e,{json:t,lossy:n}={})=>{let r=[];return JB(!(t||n),!!t,new Map,r)(e),r},XB=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?VB(YB(e,t)):structuredClone(e):(e,t)=>VB(YB(e,t));function ZB(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function QB(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function $B(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||ZB,r=e.options.footnoteBackLabel||QB,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=AL(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...XB(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
4311
4311
|
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
4312
|
-
`}]}}var
|
|
4312
|
+
`}]}}var eV=(function(e){if(e==null)return aV;if(typeof e==`function`)return iV(e);if(typeof e==`object`)return Array.isArray(e)?tV(e):nV(e);if(typeof e==`string`)return rV(e);throw Error(`Expected function, string, or object as test`)});function tV(e){let t=[],n=-1;for(;++n<e.length;)t[n]=eV(e[n]);return iV(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function nV(e){let t=e;return iV(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function rV(e){return iV(t);function t(t){return t&&t.type===e}}function iV(e){return t;function t(t,n,r){return!!(oV(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function aV(){return!0}function oV(e){return typeof e==`object`&&!!e&&`type`in e}function sV(e){return e}var cV=[];function lV(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=eV(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+sV(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=cV,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=uV(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function uV(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?cV:[e]}function dV(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),lV(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var fV={}.hasOwnProperty,pV={};function mV(e,t){let n=t||pV,r=new Map,i=new Map,a={all:s,applyData:gV,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...FB,...n.handlers},one:o,options:n,patch:hV,wrap:vV};return dV(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(fV.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=XB(n);return r.children=a.all(e),r}return XB(e)}return(a.options.unknownHandler||_V)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=yV(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=yV(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function hV(e,t){e.position&&(t.position=bI(e))}function gV(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,XB(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function _V(e,t){let n=t.data||{},r=`value`in t&&!(fV.call(n,`hProperties`)||fV.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function vV(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
4313
4313
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
4314
4314
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
4315
|
-
`}),n}function
|
|
4316
|
-
`},i)),a}function XB(e,t){return e&&`run`in e?async function(n,r){let i=YB(n,{file:r,...t});await e.run(i,r)}:function(n,r){return YB(n,{file:r,...e||t})}}function ZB(e){if(e)throw e}var QB=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function $B(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function eV(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?tV(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function tV(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var nV={basename:rV,dirname:iV,extname:aV,join:oV,sep:`/`};function rV(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);lV(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function iV(e){if(lV(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function aV(e){lV(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function oV(...e){let t=-1,n;for(;++t<e.length;)lV(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:sV(n)}function sV(e){lV(e);let t=e.codePointAt(0)===47,n=cV(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function cV(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function lV(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var uV={cwd:dV};function dV(){return`/`}function fV(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function pV(e){if(typeof e==`string`)e=new URL(e);else if(!fV(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return mV(e)}function mV(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var hV=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],gV=class{constructor(e){let t;t=e?fV(e)?{path:e}:typeof e==`string`||bV(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:uV.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<hV.length;){let e=hV[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)hV.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?nV.basename(this.path):void 0}set basename(e){vV(e,`basename`),_V(e,`basename`),this.path=nV.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?nV.dirname(this.path):void 0}set dirname(e){yV(this.basename,`dirname`),this.path=nV.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?nV.extname(this.path):void 0}set extname(e){if(_V(e,`extname`),yV(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=nV.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){fV(e)&&(e=pV(e)),vV(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?nV.basename(this.path,this.extname):void 0}set stem(e){vV(e,`stem`),_V(e,`stem`),this.path=nV.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new eI(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function _V(e,t){if(e&&e.includes(nV.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+nV.sep+"`")}function vV(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function yV(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function bV(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var xV=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),SV=l(QB(),1),CV={}.hasOwnProperty,wV=new class e extends xV{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=eV()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,SV.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(DV(`data`,this.frozen),this.namespace[e]=t,this):CV.call(this.namespace,e)&&this.namespace[e]||void 0:e?(DV(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=AV(e),n=this.parser||this.Parser;return TV(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),TV(`process`,this.parser||this.Parser),EV(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=AV(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);MV(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),TV(`processSync`,this.parser||this.Parser),EV(`processSync`,this.compiler||this.Compiler),this.process(e,r),kV(`processSync`,`process`,t),n;function r(e,r){t=!0,ZB(e),n=r}}run(e,t,n){OV(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=AV(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),kV(`runSync`,`run`,n),r;function i(e,t){ZB(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=AV(t),r=this.compiler||this.Compiler;return EV(`stringify`,r),OV(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(DV(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,SV.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];$B(o)&&$B(r)&&(r=(0,SV.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function TV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function EV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function DV(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function OV(e){if(!$B(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function kV(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function AV(e){return jV(e)?e:new gV(e)}function jV(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function MV(e){return typeof e==`string`||NV(e)}function NV(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var PV=[],FV={allowDangerousHtml:!0},IV=/^(https?|ircs?|mailto|xmpp)$/i,LV=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function RV(e){let t=zV(e),n=BV(e);return VV(t.runSync(t.parse(n),n),e)}function zV(e){let t=e.rehypePlugins||PV,n=e.remarkPlugins||PV,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...FV}:FV;return wV().use(Nz).use(n).use(XB,r).use(t)}function BV(e){let t=e.children||``,n=new gV;return typeof t==`string`?n.value=t:``+t,n}function VV(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||HV;for(let e of LV)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return BB(e,l),cI(e,{Fragment:K.Fragment,components:i,ignoreInvalidStyle:!0,jsx:K.jsx,jsxs:K.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in AI)if(Object.hasOwn(AI,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=AI[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function HV(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||IV.test(e.slice(0,t))?e:``}function UV(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function WV(e,t,n){let r=kB((n||{}).ignore||[]),i=GV(t),a=-1;for(;++a<i.length;)RB(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function GV(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([KV(e[0]),qV(e[1])])}return t}function KV(e){return typeof e==`string`?new RegExp(UV(e),`g`):e}function qV(e){return typeof e==`function`?e:function(){return e}}function JV(e){WV(e,[/\r?\n|\r/g,YV])}function YV(){return{type:`break`}}function XV(){return function(e){JV(e)}}function ZV(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}var QV=`phrasing`,$V=[`autolink`,`link`,`image`,`label`];function eH(){return{transforms:[cH],enter:{literalAutolink:nH,literalAutolinkEmail:rH,literalAutolinkHttp:rH,literalAutolinkWww:rH},exit:{literalAutolink:sH,literalAutolinkEmail:oH,literalAutolinkHttp:iH,literalAutolinkWww:aH}}}function tH(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:QV,notInConstruct:$V},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:QV,notInConstruct:$V},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:QV,notInConstruct:$V}]}}function nH(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function rH(e){this.config.enter.autolinkProtocol.call(this,e)}function iH(e){this.config.exit.autolinkProtocol.call(this,e)}function aH(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function oH(e){this.config.exit.autolinkEmail.call(this,e)}function sH(e){this.exit(e)}function cH(e){WV(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,lH],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,uH]],{ignore:[`link`,`linkReference`]})}function lH(e,t,n,r,i){let a=``;if(!pH(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!dH(n)))return!1;let o=fH(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function uH(e,t,n,r){return!pH(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function dH(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function fH(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=ZV(e,`(`),a=ZV(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function pH(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||rL(n)||nL(n))&&(!t||n!==47)}CH.peek=SH;function mH(){this.buffer()}function hH(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function gH(){this.buffer()}function _H(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function vH(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=GI(this.sliceSerialize(e)).toLowerCase(),n.label=t}function yH(e){this.exit(e)}function bH(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=GI(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xH(e){this.exit(e)}function SH(){return`[`}function CH(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function wH(){return{enter:{gfmFootnoteCallString:mH,gfmFootnoteCall:hH,gfmFootnoteDefinitionLabelString:gH,gfmFootnoteDefinition:_H},exit:{gfmFootnoteCallString:vH,gfmFootnoteCall:yH,gfmFootnoteDefinitionLabelString:bH,gfmFootnoteDefinition:xH}}}function TH(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:CH},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
4317
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?
|
|
4318
|
-
`)}function
|
|
4319
|
-
`&&!e.before&&!e.after&&
|
|
4320
|
-
`}function
|
|
4315
|
+
`}),n}function yV(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function bV(e,t){let n=mV(e,t),r=n.one(e,void 0),i=$B(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
4316
|
+
`},i)),a}function xV(e,t){return e&&`run`in e?async function(n,r){let i=bV(n,{file:r,...t});await e.run(i,r)}:function(n,r){return bV(n,{file:r,...e||t})}}function SV(e){if(e)throw e}var CV=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function wV(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function TV(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?EV(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function EV(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var DV={basename:OV,dirname:kV,extname:AV,join:jV,sep:`/`};function OV(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);PV(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function kV(e){if(PV(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function AV(e){PV(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function jV(...e){let t=-1,n;for(;++t<e.length;)PV(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:MV(n)}function MV(e){PV(e);let t=e.codePointAt(0)===47,n=NV(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function NV(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function PV(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var FV={cwd:IV};function IV(){return`/`}function LV(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function RV(e){if(typeof e==`string`)e=new URL(e);else if(!LV(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return zV(e)}function zV(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var BV=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],VV=class{constructor(e){let t;t=e?LV(e)?{path:e}:typeof e==`string`||GV(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:FV.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<BV.length;){let e=BV[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)BV.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?DV.basename(this.path):void 0}set basename(e){UV(e,`basename`),HV(e,`basename`),this.path=DV.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?DV.dirname(this.path):void 0}set dirname(e){WV(this.basename,`dirname`),this.path=DV.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?DV.extname(this.path):void 0}set extname(e){if(HV(e,`extname`),WV(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=DV.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){LV(e)&&(e=RV(e)),UV(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?DV.basename(this.path,this.extname):void 0}set stem(e){UV(e,`stem`),HV(e,`stem`),this.path=DV.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new TI(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function HV(e,t){if(e&&e.includes(DV.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+DV.sep+"`")}function UV(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function WV(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function GV(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var KV=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),qV=l(CV(),1),JV={}.hasOwnProperty,YV=new class e extends KV{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=TV()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,qV.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(QV(`data`,this.frozen),this.namespace[e]=t,this):JV.call(this.namespace,e)&&this.namespace[e]||void 0:e?(QV(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=tH(e),n=this.parser||this.Parser;return XV(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),XV(`process`,this.parser||this.Parser),ZV(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=tH(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);rH(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),XV(`processSync`,this.parser||this.Parser),ZV(`processSync`,this.compiler||this.Compiler),this.process(e,r),eH(`processSync`,`process`,t),n;function r(e,r){t=!0,SV(e),n=r}}run(e,t,n){$V(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=tH(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),eH(`runSync`,`run`,n),r;function i(e,t){SV(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=tH(t),r=this.compiler||this.Compiler;return ZV(`stringify`,r),$V(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(QV(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,qV.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];wV(o)&&wV(r)&&(r=(0,qV.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function XV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function ZV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function QV(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function $V(e){if(!wV(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function eH(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function tH(e){return nH(e)?e:new VV(e)}function nH(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function rH(e){return typeof e==`string`||iH(e)}function iH(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var aH=[],oH={allowDangerousHtml:!0},sH=/^(https?|ircs?|mailto|xmpp)$/i,cH=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function lH(e){let t=uH(e),n=dH(e);return fH(t.runSync(t.parse(n),n),e)}function uH(e){let t=e.rehypePlugins||aH,n=e.remarkPlugins||aH,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...oH}:oH;return YV().use(iB).use(n).use(xV,r).use(t)}function dH(e){let t=e.children||``,n=new VV;return typeof t==`string`?n.value=t:``+t,n}function fH(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||pH;for(let e of cH)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return dV(e,l),NI(e,{Fragment:K.Fragment,components:i,ignoreInvalidStyle:!0,jsx:K.jsx,jsxs:K.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in tL)if(Object.hasOwn(tL,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=tL[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function pH(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||sH.test(e.slice(0,t))?e:``}function mH(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function hH(e,t,n){let r=eV((n||{}).ignore||[]),i=gH(t),a=-1;for(;++a<i.length;)lV(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function gH(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([_H(e[0]),vH(e[1])])}return t}function _H(e){return typeof e==`string`?new RegExp(mH(e),`g`):e}function vH(e){return typeof e==`function`?e:function(){return e}}function yH(e){hH(e,[/\r?\n|\r/g,bH])}function bH(){return{type:`break`}}function xH(){return function(e){yH(e)}}function SH(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}var CH=`phrasing`,wH=[`autolink`,`link`,`image`,`label`];function TH(){return{transforms:[NH],enter:{literalAutolink:DH,literalAutolinkEmail:OH,literalAutolinkHttp:OH,literalAutolinkWww:OH},exit:{literalAutolink:MH,literalAutolinkEmail:jH,literalAutolinkHttp:kH,literalAutolinkWww:AH}}}function EH(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:CH,notInConstruct:wH},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:CH,notInConstruct:wH},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:CH,notInConstruct:wH}]}}function DH(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function OH(e){this.config.enter.autolinkProtocol.call(this,e)}function kH(e){this.config.exit.autolinkProtocol.call(this,e)}function AH(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function jH(e){this.config.exit.autolinkEmail.call(this,e)}function MH(e){this.exit(e)}function NH(e){hH(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,PH],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,FH]],{ignore:[`link`,`linkReference`]})}function PH(e,t,n,r,i){let a=``;if(!RH(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!IH(n)))return!1;let o=LH(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function FH(e,t,n,r){return!RH(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function IH(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function LH(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=SH(e,`(`),a=SH(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function RH(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||OL(n)||DL(n))&&(!t||n!==47)}JH.peek=qH;function zH(){this.buffer()}function BH(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function VH(){this.buffer()}function HH(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function UH(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=gL(this.sliceSerialize(e)).toLowerCase(),n.label=t}function WH(e){this.exit(e)}function GH(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=gL(this.sliceSerialize(e)).toLowerCase(),n.label=t}function KH(e){this.exit(e)}function qH(){return`[`}function JH(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function YH(){return{enter:{gfmFootnoteCallString:zH,gfmFootnoteCall:BH,gfmFootnoteDefinitionLabelString:VH,gfmFootnoteDefinition:HH},exit:{gfmFootnoteCallString:UH,gfmFootnoteCall:WH,gfmFootnoteDefinitionLabelString:GH,gfmFootnoteDefinition:KH}}}function XH(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:JH},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
4317
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?QH:ZH))),s(),o}}function ZH(e,t,n){return t===0?e:QH(e,t,n)}function QH(e,t,n){return(n?``:` `)+e}var $H=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];iU.peek=aU;function eU(){return{canContainEols:[`delete`],enter:{strikethrough:nU},exit:{strikethrough:rU}}}function tU(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:$H}],handlers:{delete:iU}}}function nU(e){this.enter({type:`delete`,children:[]},e)}function rU(e){this.exit(e)}function iU(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function aU(){return`~`}function oU(e){return e.length}function sU(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||oU,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=cU(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=lU(r[d]);else{let e=lU(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
4318
|
+
`)}function cU(e){return e==null?``:String(e)}function lU(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}var uU=eV([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function dU(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),fU);return i(),o}function fU(e,t,n){return`>`+(n?``:` `)+e}function pU(e,t){return mU(e,t.inConstruct,!0)&&!mU(e,t.notInConstruct,!1)}function mU(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function hU(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;){let e=n.unsafe[i];if(e.character===`
|
|
4319
|
+
`&&!e.before&&!e.after&&pU(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
|
|
4320
|
+
`}function gU(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function _U(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^\n\r ]/.test(e.value)||/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(e.value))}function vU(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function yU(e,t,n,r){let i=vU(n),a=e.value||``;if(_U(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,bU);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(gU(a,i)+1,3)),c=n.enter(`codeFenced`),l=i==="`"?`GraveAccent`:`Tilde`,u=o.move(s);if(e.lang){let t=n.enter(`codeFencedLang${l}`);u+=o.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${l}`);u+=o.move(` `),u+=o.move(n.safe(e.meta,{before:u,after:`
|
|
4321
4321
|
`,encode:["`"],...o.current()})),t()}return u+=o.move(`
|
|
4322
4322
|
`),a&&(u+=o.move(a+`
|
|
4323
|
-
`)),u+=o.move(s),c(),u}function
|
|
4324
|
-
`,...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()),o(),l}function
|
|
4323
|
+
`)),u+=o.move(s),c(),u}function bU(e,t,n){return(n?``:` `)+e}function xU(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function SU(e,t,n,r){let i=xU(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\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?` `:`
|
|
4324
|
+
`,...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()),o(),l}function CU(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}wU.attention=TU,wU.peek=EU;function wU(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function TU(e,t){return{construct:`emphasis`,markers:CU(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function EU(e,t,n){return n.options.emphasis||`*`}function DU(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function OU(e,t){let n=!1;return dV(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&rL(e)&&(t.options.setext||n))}function kU(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(OU(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
4325
4325
|
`,after:`
|
|
4326
4326
|
`});return r(),t(),o+`
|
|
4327
4327
|
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
4328
4328
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
4329
|
-
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=
|
|
4329
|
+
`,...a.current()}),u=l.charCodeAt(0);return(u===9||u===32)&&(l=DU(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}AU.peek=jU;function AU(e){return e.value||``}function jU(){return`<`}MU.peek=NU;function MU(e,t,n,r){let i=xU(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 NU(){return`!`}PU.peek=FU;function PU(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=u.filter(function(e){return e!==`phrasing`}),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 FU(){return`!`}IU.peek=LU;function IU(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^\n\r ]/.test(r)&&(/^[\n\r ]/.test(r)&&/[\n\r ]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e);if(!e.atBreak)continue;let i;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 LU(){return"`"}function RU(e,t){let n=rL(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))}zU.peek=BU;function zU(e,t,n,r){let i=xU(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(RU(e,n)){let t=n.stack;n.stack=t.filter(function(e){return e!==`phrasing`});let r=n.enter(`autolink`),i=o.move(`<`);return i+=o.move(n.containerPhrasing(e,{before:i,after:`>`,...o.current()})),i+=o.move(`>`),r(),n.stack=t,i}let s=n.enter(`link`),c=n.enter(`label`),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 BU(e,t,n){return RU(e,n)?`<`:`[`}VU.peek=HU;function VU(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=u.filter(function(e){return e!==`phrasing`}),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 HU(){return`[`}function UU(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 WU(e){let t=UU(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 GU(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function KU(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 qU(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?GU(n):UU(n),s=e.ordered?o===`.`?`)`:`.`:WU(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),KU(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 JU(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 YU(e,t,n,r){let i=JU(n),a=n.bulletCurrent||UU(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 XU(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function ZU(e,t,n,r){if(!e.children.some(function(e){return uU(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function QU(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}$U.attention=eW,$U.peek=tW;function $U(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function eW(e,t){return{construct:`strong`,markers:QU(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function tW(e,t,n){return n.options.strong||`*`}function nW(e,t,n,r){return n.safe(e.value,r)}function rW(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 iW(e,t,n){let r=(KU(n)+(n.options.ruleSpaces?` `:``)).repeat(rW(n));return n.options.ruleSpaces?r.slice(0,-1):r}var aW={blockquote:dU,break:hU,code:yU,definition:SU,emphasis:wU,hardBreak:hU,heading:kU,html:AU,image:MU,imageReference:PU,inlineCode:IU,link:zU,linkReference:VU,list:qU,listItem:YU,paragraph:XU,root:ZU,strong:$U,text:nW,thematicBreak:iW};function oW(){return{enter:{table:sW,tableData:dW,tableHeader:dW,tableRow:lW},exit:{codeText:fW,table:cW,tableData:uW,tableHeader:uW,tableRow:uW}}}function sW(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 cW(e){this.exit(e),this.data.inTable=void 0}function lW(e){this.enter({type:`tableRow`,children:[]},e)}function uW(e){this.exit(e)}function dW(e){this.enter({type:`tableCell`,children:[]},e)}function fW(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,pW));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function pW(e,t){return t===`|`?t:e}function mW(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
4330
4330
|
`,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(`
|
|
4331
|
-
`))}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 IH(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=PU.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function WU(){return{exit:{taskListCheckValueChecked:KU,taskListCheckValueUnchecked:KU,paragraph:qU}}}function GU(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:JU}}}function KU(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function qU(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 JU(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=PU.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 YU(){return[eH(),wH(),kH(),FU(),WU()]}function XU(e){return{extensions:[tH(),TH(e),AH(),UU(e),GU()]}}var ZU={tokenize:dW,partial:!0},QU={tokenize:fW,partial:!0},$U={tokenize:pW,partial:!0},eW={tokenize:mW,partial:!0},tW={tokenize:hW,partial:!0},nW={name:`wwwAutolink`,tokenize:lW,previous:gW},rW={name:`protocolAutolink`,tokenize:uW,previous:_W},iW={name:`emailAutolink`,tokenize:cW,previous:vW},aW={};function oW(){return{text:aW}}for(var sW=48;sW<123;)aW[sW]=iW,sW++,sW===58?sW=65:sW===91&&(sW=97);aW[43]=iW,aW[45]=iW,aW[46]=iW,aW[95]=iW,aW[72]=[iW,rW],aW[104]=[iW,rW],aW[87]=[iW,nW],aW[119]=[iW,nW];function cW(e,t,n){let r=this,i,a;return o;function o(t){return!yW(t)||!vW.call(r,r.previous)||bW(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return yW(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(tW,u,l)(t):t===45||t===95||qI(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&&KI(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function lW(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!gW.call(r,r.previous)||bW(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(ZU,e.attempt(QU,e.attempt($U,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function uW(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&_W.call(r,r.previous)&&!bW(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(KI(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||YI(t)||eL(t)||rL(t)||nL(t)?n(t):e.attempt(QU,e.attempt($U,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function dW(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 fW(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(eW,c,s)(t):t===null||eL(t)||rL(t)||t!==45&&nL(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 pW(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(eW,t,a)(o):o===null||eL(o)||rL(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function mW(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||eL(o)||rL(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||eL(e)||rL(e)?t(e):r(e)}function a(e){return KI(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):KI(t)?(e.consume(t),o):n(t)}}function hW(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return qI(e)?n(e):t(e)}}function gW(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||eL(e)}function _W(e){return!KI(e)}function vW(e){return!(e===47||yW(e))}function yW(e){return e===43||e===45||e===46||e===95||qI(e)}function bW(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 xW={tokenize:kW,partial:!0};function SW(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:EW,continuation:{tokenize:DW},exit:OW}},text:{91:{name:`gfmFootnoteCall`,tokenize:TW},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:CW,resolveTo:wW}}}}function CW(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=GI(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 wW(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 TW(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||eL(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(GI(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return eL(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 EW(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||eL(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=GI(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return eL(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),oL(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function DW(e,t,n){return e.check(wL,t,e.attempt(xW,t,n))}function OW(e){e.exit(`gfmFootnoteDefinition`)}function kW(e,t,n){let r=this;return oL(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 AW(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&&RI(o,o.length,0,_L(s,e.slice(r+1,n),t)),RI(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),RI(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=gL(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=gL(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var jW=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){MW(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,this.index.clear()}};function MW(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function NW(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 PW(){return{flow:{null:{name:`table`,tokenize:FW,resolveAll:IW}}}}function FW(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{type:e}=r.events[t][1];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):$I(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):tL(t)?oL(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||eL(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,tL(t)?oL(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 tL(t)?oL(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||$I(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 tL(t)?oL(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$I(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||$I(n)?(e.exit(`tableRow`),t(n)):tL(n)?oL(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||eL(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 IW(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 jW;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(RW(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=LW(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=LW(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=LW(f,t,o,i,n,d)):(o[0]=o[1],d=LW(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&RW(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=NW(t.events,n))}return e}function LW(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},zW(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=zW(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=zW(t.events,n[2]),a=zW(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({},zW(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function RW(e,t,n,r,i){let a=[],o=zW(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 zW(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var BW={name:`tasklistCheck`,tokenize:HW};function VW(){return{text:{91:BW}}}function HW(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 eL(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 $I(r)?t(r):tL(r)?e.check({tokenize:UW},t,n)(r):n(r)}}function UW(e,t,n){return oL(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function WW(e){return VI([oW(),SW(),AW(e),PW(),VW()])}var GW={};function KW(e){let t=this,n=e||GW,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(WW(n)),a.push(YU()),o.push(XU(n))}function qW(){let e=t=>{t.type===`html`&&(t.type=`text`),t.children?.forEach(e)};return e}var JW=/^(https?:|mailto:)/i,YW=e=>JW.test(e.trim())?e:``,XW={a:({href:e,children:t})=>e?(0,K.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,K.jsx)(`span`,{className:`md-deadlink`,children:t}),img:({src:e,alt:t})=>typeof e==`string`&&e?(0,K.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:[`🖼 `,t||e]}):(0,K.jsxs)(`span`,{children:[`🖼 `,t]}),table:({children:e})=>(0,K.jsx)(`div`,{className:`md-table`,children:(0,K.jsx)(`table`,{children:e})})},ZW=[KW,qW,XV];function QW({text:e,className:t}){return(0,K.jsx)(`div`,{className:t?`md ${t}`:`md`,children:(0,K.jsx)(RV,{remarkPlugins:ZW,components:XW,urlTransform:YW,children:e})})}function $W({value:e,onChange:t,className:n,onKeyDown:r,...i}){let a=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[e]),(0,K.jsx)(`textarea`,{...i,ref:a,rows:1,enterKeyHint:`send`,className:`msg-box ${n??``}`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{if(r?.(e),e.defaultPrevented||e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||e.keyCode===229)return;e.preventDefault();let t=e.currentTarget.form,n=t?.querySelector(`button:not([type="button"])`);t&&!n?.disabled&&t.requestSubmit()}})}function eG({width:e,height:t,frame:n,onPointer:r,label:i}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(n),c=(0,v.useRef)(r);(0,v.useEffect)(()=>{s.current=n,c.current=r}),(0,v.useEffect)(()=>{let n=a.current,r=o.current;if(!n||!r)return;let i=1,c=()=>{let a=getComputedStyle(n),o=n.clientWidth-parseFloat(a.paddingLeft)-parseFloat(a.paddingRight),s=n.clientHeight-parseFloat(a.paddingTop)-parseFloat(a.paddingBottom),c=Math.max(.4,Math.min(o/e,s/t,1.5)),l=Math.min(2,window.devicePixelRatio||1);r.style.width=`${Math.floor(e*c)}px`,r.style.height=`${Math.floor(t*c)}px`,r.width=Math.round(e*c*l),r.height=Math.round(t*c*l),i=r.width/e};c();let l=new ResizeObserver(c);l.observe(n);let u=0,d=performance.now(),f=n=>{let a=Math.min(.1,Math.max(0,(n-d)/1e3));d=n;let o=r.getContext(`2d`);o&&(o.setTransform(i,0,0,i,0,0),o.clearRect(0,0,e,t),s.current(o,a,n)),u=requestAnimationFrame(f)};return u=requestAnimationFrame(f),()=>{cancelAnimationFrame(u),l.disconnect()}},[e,t]);let l=(n,r)=>{let i=n.currentTarget.getBoundingClientRect();c.current?.(r,(n.clientX-i.left)/i.width*e,(n.clientY-i.top)/i.height*t)};return(0,K.jsx)(`div`,{ref:a,className:`game-canvas-wrap`,children:(0,K.jsx)(`canvas`,{ref:o,className:`game-canvas`,role:`img`,"aria-label":i,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),l(e,`down`)},onPointerMove:e=>e.buttons&&l(e,`move`),onPointerUp:e=>l(e,`up`)})})}function tG(e){let t=(0,v.useRef)(e);(0,v.useEffect)(()=>{t.current=e}),(0,v.useEffect)(()=>{let e=e=>{e.ctrlKey||e.metaKey||e.altKey||vT()||e.code===`Escape`||e.code===`KeyP`||e.target?.closest?.(`input, textarea, select, [contenteditable="true"]`)||t.current(e)&&(e.preventDefault(),e.stopPropagation())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[])}function nG({title:e,color:t,onBack:n,children:r}){return(0,K.jsxs)(`div`,{className:`game-head`,style:{"--game":t},children:[(0,K.jsx)(`button`,{type:`button`,className:`game-back`,onClick:n,title:`Back to the games (Backspace)`,children:`‹ Games`}),(0,K.jsx)(`b`,{className:`game-title`,children:e}),(0,K.jsx)(`span`,{className:`game-head-right`,children:r})]})}function rG(e){switch(e){case`ArrowUp`:case`KeyW`:return`up`;case`ArrowDown`:case`KeyS`:return`down`;case`ArrowLeft`:case`KeyA`:return`left`;case`ArrowRight`:case`KeyD`:return`right`}return null}var iG=e=>e===`Space`||e===`Enter`||e===`NumpadEnter`;function aG(e){let t=(0,v.useRef)(e);(0,v.useEffect)(()=>{t.current=e}),(0,v.useEffect)(()=>{let e=()=>t.current(),n=()=>document.hidden&&e();return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,n)}},[])}function oG({onPress:e,repeat:t,label:n,className:r,children:i}){let a=(0,v.useRef)(null),o=(0,v.useRef)(e);(0,v.useEffect)(()=>{o.current=e});let s=()=>{a.current&&clearTimeout(a.current),a.current=null};return(0,v.useEffect)(()=>s,[]),(0,K.jsx)(`button`,{type:`button`,tabIndex:-1,className:`game-pad ${r??``}`,"aria-label":n,title:n,onPointerDown:e=>{if(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),o.current(),!t)return;s();let n=e=>{a.current=setTimeout(()=>{o.current(),n(70)},e)};n(190)},onPointerUp:s,onPointerCancel:s,onLostPointerCapture:s,children:i})}var sG=`#1f1d2b`,cG=`#fffdf6`,lG=`#6c7086`,uG=[`#ff8a5b`,`#4fb3e8`,`#8fd14f`,`#c77dff`,`#ffc93c`,`#ff6fb5`,`#2ec4b6`,`#f25f5c`];function dG(e,t,n,r,i,a,o=Math.min(r,i)*.24,s=2){pS(e,t+s/2,n+s/2,r-s,i-s,o),e.fillStyle=a,e.fill(),e.save(),e.clip(),e.fillStyle=`rgba(255,255,255,0.38)`,e.fillRect(t,n,r,i*.26),e.fillStyle=`rgba(0,0,0,0.13)`,e.fillRect(t,n+i*.74,r,i*.26),e.restore(),e.lineWidth=s,e.strokeStyle=sG,e.stroke()}function fG(e,t,n,r,i,a=`#ffffff`,o=10){pS(e,t,n+3,r,i,o),e.fillStyle=sG,e.fill(),pS(e,t,n,r,i,o),e.fillStyle=a,e.fill(),e.lineWidth=2.5,e.strokeStyle=sG,e.stroke()}function pG(e,t,n,r,i,a=sG,o=700,s=`center`){e.font=`${o} ${i}px ${fS}`,e.fillStyle=a,e.textAlign=s,e.textBaseline=`middle`,e.fillText(t,n,r)}function mG(e,t,n,r,i,a){e.font=`700 ${i}px ${fS}`,e.textAlign=`center`,e.textBaseline=`middle`,e.lineJoin=`round`,e.lineWidth=Math.max(3,i/5),e.strokeStyle=sG,e.strokeText(t,n,r),e.fillStyle=a,e.fillText(t,n,r)}function hG(e,t,n,r,i,a=0,o=0,s=!1){for(let c of[-1,1]){let l=t+c*r/2;if(s){e.beginPath(),e.moveTo(l-i,n),e.quadraticCurveTo(l,n+i*.6,l+i,n),e.lineWidth=Math.max(1.5,i*.35),e.lineCap=`round`,e.strokeStyle=sG,e.stroke();continue}e.beginPath(),e.ellipse(l,n,i,i*1.15,0,0,Math.PI*2),e.fillStyle=`#ffffff`,e.fill(),e.lineWidth=Math.max(1.2,i*.28),e.strokeStyle=sG,e.stroke(),e.beginPath(),e.arc(l+a*i*.35,n+o*i*.35,i*.52,0,Math.PI*2),e.fillStyle=sG,e.fill(),e.beginPath(),e.arc(l+a*i*.35-i*.18,n+o*i*.35-i*.2,i*.16,0,Math.PI*2),e.fillStyle=`#ffffff`,e.fill()}}function gG(e,t){let n=parseInt(e.slice(1),16),[r,i,a]=[n>>16&255,n>>8&255,n&255].map(e=>Math.round(t>=0?e+(255-e)*t:e*(1+t)));return`#${(1<<24|r<<16|i<<8|a).toString(16).slice(1)}`}function _G(e,t,n,r,i=12,a=120){for(let o=0;o<i;o++){let i=Math.random()*Math.PI*2,s=a*(.4+Math.random()*.8);e.push({x:t,y:n,vx:Math.cos(i)*s,vy:Math.sin(i)*s-a*.4,life:.6+Math.random()*.4,color:r[o%r.length],size:3+Math.random()*3})}}function vG(e,t,n,r,i,a=18){e.push({x:t,y:n,vx:0,vy:-40,life:1.1,color:i,size:a,text:r})}function yG(e,t,n){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.life-=n,i.life<=0){t.splice(r,1);continue}i.x+=i.vx*n,i.y+=i.vy*n,i.text||(i.vy+=320*n),e.globalAlpha=Math.min(1,i.life*2),i.text?mG(e,i.text,i.x,i.y,i.size,i.color):(e.fillStyle=i.color,e.fillRect(i.x-i.size/2,i.y-i.size/2,i.size,i.size),e.lineWidth=1,e.strokeStyle=sG,e.strokeRect(i.x-i.size/2,i.y-i.size/2,i.size,i.size)),e.globalAlpha=1}}function bG(e,t,n,r,i,a){e.fillStyle=`rgba(31,29,43,0.45)`,e.fillRect(0,0,t,n);let o=Math.min(t-36,250),s=70+i.length*22,c=(t-o)/2,l=(n-s)/2;fG(e,c,l,o,s,cG,16),e.save(),e.clip(),e.fillStyle=a,e.fillRect(c,l,o,10),e.restore(),e.stroke(),mG(e,r,t/2,l+36,24,a),i.forEach((n,r)=>pG(e,n,t/2,l+68+r*22,r===i.length-1?13:15,r===i.length-1?lG:sG,r===i.length-1?600:700))}var xG=36e5,SG=720*xG,CG={awake:{food:-12,fun:-10,energy:-7},asleep:{food:-5,fun:-3,energy:35}},wG=[`Cubey`,`Pixel`,`Widget`,`Sprocket`,`Nugget`,`Mochi`,`Byte`,`Tofu`],TG=[`#ff8a5b`,`#4fb3e8`,`#8fd14f`,`#c77dff`,`#ffc93c`,`#ff6fb5`,`#2ec4b6`],EG=[{xp:0,title:`Intern`},{xp:12,title:`Junior`},{xp:40,title:`Senior`},{xp:90,title:`Tech Lead`}],DG=e=>Math.max(0,Math.min(100,e));function OG(e){let t=0;for(;t+1<EG.length&&e>=EG[t+1].xp;)t++;return t}function kG(e,t,n){let r=wG[Math.floor(t*wG.length)%wG.length];return{v:1,name:r,color:TG[Math.floor(n*TG.length)%TG.length],born:e,at:e,food:80,fun:80,energy:80,asleep:!1,xp:0,coffeeAt:0,pettedAt:0,say:{text:`Hi! I'm ${r}, your new desk pet. Keep me fed, busy and rested!`,at:e}}}function AG(e,t){let n=Math.min(Math.max(0,t-e.at),SG)/xG,{food:r,fun:i,energy:a,asleep:o}=e;for(let e=0;n>0&&e<1e3;e++){let e=o?CG.asleep:CG.awake,t=o?(100-a)/e.energy:a/-e.energy,s=Math.min(n,t);r=DG(r+e.food*s),i=DG(i+e.fun*s),a=DG(a+e.energy*s),n-=s,s===t&&(o=!o)}return{...e,at:Math.max(t,e.at),food:r,fun:i,energy:a,asleep:o}}function jG(e){return e.asleep?`asleep`:[e.food,e.fun,e.energy].filter(e=>e<25).length>=2||Math.min(e.food,e.fun,e.energy)<=0?`grumpy`:e.food<25?`hungry`:e.energy<25?`tired`:e.fun<25?`bored`:e.food+e.fun+e.energy>=210?`happy`:`content`}var MG={asleep:`Zzz… 💤`,happy:`Best. Job. Ever. ✨`,content:`Just vibing at my desk.`,hungry:`I'm hungry… got a donut? 🍩`,bored:`I'm bored. Play with me? 🎾`,tired:`So… sleepy… 🥱`,grumpy:`Hmph. Nobody looks after me. 😤`},NG=(e,t)=>e[Math.floor(t/1e3)%e.length];function PG(e,t,n){let r=AG(e,n),i=FG(r,t,n);return i===r?r:OG(i.xp)>OG(r.xp)?{...i,fun:DG(i.fun+10),say:{text:`Promoted to ${EG[OG(i.xp)].title}! 🎉`,at:n}}:i}function FG(e,t,n){let r=e=>({text:e,at:n}),i=(t,n)=>({...e,food:DG(e.food+(t.food??0)),fun:DG(e.fun+(t.fun??0)),energy:DG(e.energy+(t.energy??0)),xp:e.xp+(t.xp??0),say:r(n)});if(t===`nap`)return e.asleep?e.energy<40?{...i({fun:-4},`Five more minutes… 😒`),asleep:!1}:{...i({},`Good morning! ☀️`),asleep:!1}:e.energy>=90?i({},`I'm not sleepy!`):{...i({xp:+(e.energy<50)},`Nap time… 💤`),asleep:!0};if(e.asleep)return t===`pet`?e:i({},`Zzz… (shh, still asleep) 💤`);switch(t){case`snack`:return e.food>=90?i({fun:-2},`I'm stuffed! No more donuts.`):i({food:30,fun:3,xp:1},NG([`Nom nom nom! 🍩`,`Sprinkles! My favourite.`,`Donut-driven development!`],n));case`coffee`:return n-e.coffeeAt<6e5?i({energy:5,fun:-6},`Too… much… coffee! 😵💫`):{...i({energy:25,food:3,xp:1},NG([`☕ Ready to ship!`,`Caffeine: loaded.`,`Brb, refactoring everything.`],n)),coffeeAt:n};case`play`:return e.energy<15?i({},`Too tired to play… 🥱`):i({fun:25,energy:-10,food:-6,xp:1},NG([`Wheee! 🎾`,`Again! Again!`,`Best. Break. Ever.`],n));case`pet`:return n-e.pettedAt<3e3?e:{...i({fun:3},NG([`Hehe ❤️`,`*happy wiggle*`,`You're the best manager!`],n)),pettedAt:n}}return e}function IG(e,t,n){let r=AG(e,n);return{...r,fun:DG(r.fun+8),xp:r.xp+1,say:{text:t,at:n}}}function LG(e){if(!e||typeof e!=`object`)return null;let t=e,n=[t.born,t.at,t.food,t.fun,t.energy,t.xp,t.coffeeAt,t.pettedAt];if(t.v!==1||typeof t.name!=`string`||typeof t.color!=`string`||typeof t.asleep!=`boolean`||!n.every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let r=t.say&&typeof t.say.text==`string`&&typeof t.say.at==`number`?{text:t.say.text,at:t.say.at}:null;return{...t,food:DG(t.food),fun:DG(t.fun),energy:DG(t.energy),say:r}}function RG(e){try{return JSON.parse(localStorage.getItem(e)??`null`)}catch{return null}}function zG(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var BG=`cubefarm:games:best`;function VG(e){let t=RG(BG),n=Number(t?.[e]);return Number.isFinite(n)&&n>0?n:0}function HG(e,t){if(t<=VG(e))return!1;let n=RG(BG);return zG(BG,{...n&&typeof n==`object`?n:{},[e]:t}),!0}var UG=`cubefarm:games:pet`,WG=LG(RG(UG)),GG=new Set,KG=()=>GG.forEach(e=>e()),qG=()=>WG;function JG(e){WG=e,zG(UG,e),KG()}function YG(e){return GG.add(e),()=>void GG.delete(e)}function XG(e){return e.role===`qa`||e.task===`qa`?`Yay! ${e.name} finished testing${e.prNumber?` PR #${e.prNumber}`:` a PR`}! 🧪`:e.task===`fix`?`Yay! ${e.name} fixed${e.prNumber?` PR #${e.prNumber}`:` a PR`}! 🔧`:e.issueNumber?`Yay! ${e.name} finished issue #${e.issueNumber}! 🎉`:`Yay! ${e.name} finished a job! 🎉`}q.subscribe((e,t)=>{if(WG&&t.loaded&&e.agents!==t.agents)for(let n of Object.values(e.agents)){let e=t.agents[n.id];n.role!==`ceo`&&n.status===`done`&&e&&e.status!==`done`&&JG(IG(WG,XG(n),Date.now()))}}),window.addEventListener(`storage`,e=>{e.key===UG&&(WG=LG(RG(UG)),KG())});var ZG={move:()=>$y({freq:420,type:`square`,dur:.03,peak:.012}),rotate:()=>$y({freq:560,to:700,type:`triangle`,dur:.06,peak:.04}),land:()=>{tb({dur:.07,peak:.07,freq:500,q:.8}),$y({freq:180,to:120,type:`triangle`,dur:.08,peak:.05})},lines:e=>[659,784,988,1318.5].slice(0,Math.max(2,e+1)).forEach((e,t)=>$y({freq:e,type:`triangle`,at:t*.06,dur:.22,peak:.07})),levelUp:()=>[523,659,784,1046.5].forEach((e,t)=>$y({freq:e,type:`square`,at:t*.08,dur:.14,peak:.03})),over:()=>{$y({freq:392,to:370,type:`triangle`,dur:.22,peak:.1}),$y({freq:311,to:156,type:`triangle`,at:.22,dur:.6,peak:.1})},best:()=>[784,988,1175,1568].forEach((e,t)=>$y({freq:e,type:`triangle`,at:.5+t*.07,dur:.28,peak:.08})),chomp:()=>$y({freq:300,to:620,type:`square`,dur:.07,peak:.035}),slurp:()=>{tb({dur:.2,peak:.05,filter:`bandpass`,freq:400,to:2200,q:2,attack:.03}),$y({freq:523,to:1046,type:`triangle`,at:.12,dur:.16,peak:.06})},start:()=>[523,784].forEach((e,t)=>$y({freq:e,type:`triangle`,at:t*.08,dur:.14,peak:.07})),pause:()=>$y({freq:660,to:440,type:`triangle`,dur:.12,peak:.05}),happy:()=>{$y({freq:660,to:1320,type:`square`,dur:.1,peak:.03}),$y({freq:1320,to:990,type:`triangle`,at:.1,dur:.12,peak:.07})},nom:()=>[0,.12,.24].forEach(e=>$y({freq:250,to:180,type:`triangle`,at:e,dur:.08,peak:.06})),boing:()=>$y({freq:220,to:660,type:`sine`,dur:.25,peak:.1}),snore:()=>$y({freq:140,to:90,type:`sine`,dur:.6,peak:.05,attack:.2}),grumble:()=>$y({freq:160,to:120,type:`sawtooth`,dur:.25,peak:.025})},QG=`#ff6fb5`,$G=320,eK=260,tK=212,nK=[52,60,68,74],rK=1.4,iK=Date.now(),aK=[{action:`snack`,icon:`🍩`,label:`Snack`,key:`1`},{action:`coffee`,icon:`☕`,label:`Coffee`,key:`2`},{action:`play`,icon:`🎾`,label:`Play`,key:`3`},{action:`nap`,icon:`💤`,label:`Nap`,key:`4`}];function oK(e,t){let n=t.size,r=-n,i=Math.max(2,n/22),a=gG(t.color,-.3);e.lineCap=`round`,e.lineJoin=`round`,e.fillStyle=`rgba(31,29,43,0.16)`,e.beginPath(),e.ellipse(0,2,n*.46,n*.07,0,0,Math.PI*2),e.fill();for(let o of[-1,1])e.beginPath(),e.ellipse(o*n*.22,-3,n*.14,n*.08,0,0,Math.PI*2),e.fillStyle=a,e.fill(),e.lineWidth=i,e.strokeStyle=sG,e.stroke(),e.beginPath(),t.arms?e.ellipse(o*n*.52,r+n*.3,n*.09,n*.15,o*.5,0,Math.PI*2):e.ellipse(o*n*.5,r+n*.62,n*.09,n*.14,-o*.35,0,Math.PI*2),e.fillStyle=t.color,e.fill(),e.stroke();dG(e,-n/2,r,n,n-4,t.color,n*.3,i*1.3);let o=r+n*.4,s=n*.36,c=n*.1,l=t.mood===`asleep`;if(hG(e,0,o,s,c,0,t.mood===`hungry`?.5:.1,l||t.blink),t.mood===`tired`&&!t.blink)for(let n of[-1,1])e.beginPath(),e.ellipse(n*s/2,o,c*1.12,c*1.3,0,Math.PI,Math.PI*2),e.fillStyle=gG(t.color,-.08),e.fill(),e.lineWidth=i*.8,e.strokeStyle=sG,e.beginPath(),e.moveTo(n*s/2-c*1.1,o),e.lineTo(n*s/2+c*1.1,o),e.stroke();if(t.mood===`grumpy`){e.lineWidth=i*1.1,e.strokeStyle=sG;for(let t of[-1,1])e.beginPath(),e.moveTo(t*(s/2+c*1.2),o-c*2),e.lineTo(t*(s/2-c*.9),o-c*1.3),e.stroke()}if(t.stage>=2){e.lineWidth=i*.9,e.strokeStyle=sG;for(let t of[-1,1])e.beginPath(),e.roundRect(t*s/2-c*1.6,o-c*1.5,c*3.2,c*3,c*.6),e.stroke();e.beginPath(),e.moveTo(-s/2+c*1.6,o-c*.4),e.lineTo(s/2-c*1.6,o-c*.4),e.stroke()}e.fillStyle=`rgba(255,111,181,0.45)`;for(let t of[-1,1])e.beginPath(),e.ellipse(t*n*.3,r+n*.58,n*.075,n*.045,0,0,Math.PI*2),e.fill();let u=r+n*.62,d=n*.12;e.lineWidth=i,e.strokeStyle=sG,e.fillStyle=sG,e.beginPath(),t.open||t.mood===`hungry`?(e.ellipse(0,u+1,d*.55,d*.65,0,0,Math.PI*2),e.fill()):t.mood===`happy`?(e.arc(0,u-1,d,0,Math.PI),e.closePath(),e.fill(),e.beginPath(),e.ellipse(0,u+d*.55,d*.5,d*.3,0,0,Math.PI*2),e.fillStyle=`#ff8fa3`,e.fill()):t.mood===`content`?(e.arc(0,u-d*.6,d,Math.PI*.15,Math.PI*.85),e.stroke()):t.mood===`grumpy`?(e.arc(0,u+d*.9,d,Math.PI*1.2,Math.PI*1.8),e.stroke()):t.mood===`asleep`?(e.ellipse(0,u+1,d*.3,d*.35,0,0,Math.PI*2),e.fill()):t.mood===`tired`?(e.moveTo(-d,u+1),e.quadraticCurveTo(-d/2,u-2,0,u+1),e.quadraticCurveTo(d/2,u+4,d,u+1),e.stroke()):(e.moveTo(-d*.8,u+1),e.lineTo(d*.8,u+1),e.stroke());let f=r+n*.76;if(t.stage===0?(e.strokeStyle=`#4fb3e8`,e.lineWidth=i*.9,e.beginPath(),e.moveTo(-n*.2,r+n*.7),e.lineTo(0,f+n*.02),e.lineTo(n*.2,r+n*.7),e.stroke(),dG(e,-n*.09,f,n*.18,n*.14,`#ffffff`,n*.03,i*.8),e.fillStyle=`#4fb3e8`,e.fillRect(-n*.06,f+n*.04,n*.12,n*.025)):(e.beginPath(),e.moveTo(-n*.05,f-n*.04),e.lineTo(n*.05,f-n*.04),e.lineTo(n*.035,f+n*.02),e.lineTo(n*.065,f+n*.15),e.lineTo(0,f+n*.2),e.lineTo(-n*.065,f+n*.15),e.lineTo(-n*.035,f+n*.02),e.closePath(),e.fillStyle=t.color===`#f25f5c`||t.color===`#ff6fb5`?`#2b2d42`:`#f25f5c`,e.fill(),e.lineWidth=i*.8,e.strokeStyle=sG,e.stroke()),t.stage>=3){e.lineWidth=i*1.4,e.strokeStyle=sG,e.beginPath(),e.arc(0,r+n*.4,n*.53,Math.PI*1.12,Math.PI*1.88),e.stroke();for(let t of[-1,1])dG(e,t*n*.52-n*.08,r+n*.28,n*.16,n*.24,`#2b2d42`,n*.05,i*.8);e.lineWidth=i,e.beginPath(),e.moveTo(-n*.52,r+n*.5),e.quadraticCurveTo(-n*.4,u+n*.08,-d*1.6,u+2),e.stroke(),e.beginPath(),e.arc(-d*1.6,u+2,i*1.2,0,Math.PI*2),e.fillStyle=sG,e.fill()}}function sK(e,t,n,r,i){e.beginPath();for(let i=0;i<10;i++){let a=-Math.PI/2+i*Math.PI/5,o=i%2?r*.45:r;e.lineTo(t+Math.cos(a)*o,n+Math.sin(a)*o)}e.closePath(),e.fillStyle=i,e.fill(),e.lineWidth=2,e.strokeStyle=sG,e.stroke()}function cK(e,t,n,r,i=0){e.save(),e.translate(t,n),e.beginPath(),e.arc(0,0,r,i*Math.PI*1.5,Math.PI*2),e.arc(0,0,r*.38,Math.PI*2,i*Math.PI*1.5,!0),e.closePath(),e.fillStyle=`#e0ac69`,e.fill(),e.lineWidth=2,e.strokeStyle=sG,e.stroke(),e.beginPath(),e.arc(0,0,r*.78,i*Math.PI*1.5,Math.PI*2),e.arc(0,0,r*.45,Math.PI*2,i*Math.PI*1.5,!0),e.fillStyle=`#ff8fc7`,e.fill(),[`#4fb3e8`,`#ffc93c`,`#8fd14f`,`#ffffff`].forEach((t,n)=>{let a=n*1.7+.4;a/(Math.PI*2)<i*.75||(e.fillStyle=t,e.fillRect(Math.cos(a)*r*.62-1.5,Math.sin(a)*r*.62-1,3,2))}),e.restore()}function lK(e,t,n,r){e.lineWidth=2,e.strokeStyle=sG,e.beginPath(),e.arc(t+9,n+8,5,-Math.PI/2,Math.PI/2),e.stroke(),dG(e,t-9,n,18,18,`#ffffff`,4,2),e.beginPath(),e.ellipse(t,n+3,6.5,2,0,0,Math.PI*2),e.fillStyle=`#8d5524`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.45)`,e.lineWidth=1.5;for(let i of[-3,3]){let a=(r/600+i/7)%1;e.globalAlpha=1-a,e.beginPath(),e.moveTo(t+i,n-3-a*10),e.quadraticCurveTo(t+i+3,n-6-a*10,t+i,n-9-a*10),e.stroke()}e.globalAlpha=1}function uK(e,t,n){e.fillStyle=`#d6e2ef`,e.fillRect(0,0,$G,tK),e.fillStyle=`rgba(255,255,255,0.28)`;for(let t=6;t<$G;t+=12)e.fillRect(t,12,1.5,200);e.fillStyle=`#b9c9dc`,e.fillRect(0,0,$G,12),e.fillStyle=sG,e.fillRect(0,12,$G,2),dG(e,16,58,76,52,`#d9a066`,6,2);for(let[t,n,r,i]of[[24,66,`#fff3b0`,-.08],[56,70,`#ffd6e8`,.1]]){e.save(),e.translate(t+13,n+13),e.rotate(i),e.fillStyle=r,e.fillRect(-13,-13,26,26),e.strokeStyle=sG,e.lineWidth=1.5,e.strokeRect(-13,-13,26,26),e.strokeStyle=`rgba(31,29,43,0.4)`,e.lineWidth=1.2;for(let t=0;t<3;t++)e.beginPath(),e.moveTo(-8,-6+t*6),e.lineTo(8-t*4,-6+t*6),e.stroke();e.beginPath(),e.arc(0,-11,2.5,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.restore()}dG(e,232,54,66,60,`#ffffff`,5,2),pG(e,`EMPLOYEE`,265,64,7.5,sG,700),pG(e,`OF THE MONTH`,265,73,7,sG,700),sK(e,265,93,13,n?`#ffc93c`:`#e3e7ee`);let r=new Date;e.beginPath(),e.arc(160,42,17,0,Math.PI*2),e.fillStyle=`#ffffff`,e.fill(),e.lineWidth=3,e.strokeStyle=sG,e.stroke(),e.lineCap=`round`;for(let[t,n,i]of[[(r.getHours()%12+r.getMinutes()/60)/12,8,3],[(r.getMinutes()+r.getSeconds()/60)/60,12,2]]){let r=t*Math.PI*2-Math.PI/2;e.beginPath(),e.moveTo(160,42),e.lineTo(160+Math.cos(r)*n,42+Math.sin(r)*n),e.lineWidth=i,e.stroke()}e.beginPath(),e.arc(160,42,2.5,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.fillStyle=`#d9b48a`,e.fillRect(0,224,$G,36),e.fillStyle=sG,e.fillRect(0,224,$G,2),dG(e,-6,tK,332,14,`#f1d19b`,5,2.5),dG(e,48,200,18,12,`#3d4152`,2,2),dG(e,18,146,78,54,`#2b2d42`,7,2.5),e.fillStyle=`#1b1b29`,e.fillRect(25,153,64,40);let i=Math.floor(t/700);for(let t=0;t<5;t++){let n=i+t;e.fillStyle=uG[n*3%uG.length],e.fillRect(29+n%3*5,157+t*7,14+n*17%30,3)}e.lineWidth=2;for(let[t,n,r]of[[262,176,13],[276,168,11],[252,164,10]])e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fillStyle=`#52b788`,e.fill(),e.strokeStyle=sG,e.stroke();dG(e,248,186,32,26,`#e07a5f`,5,2)}function dK(e,t=1){e.save(),e.scale(t,t),dG(e,-38,-56,76,56,`#d9a066`,6,2.5),e.fillStyle=`rgba(241,209,155,0.9)`,e.fillRect(-7,-55,14,54),dG(e,-30,-34,38,16,`#ffffff`,3,1.5),pG(e,`NEW HIRE`,-11,-26,7.5,sG,700),e.restore()}function fK(e,t,n,r){e.lineWidth=2,e.strokeStyle=sG,e.fillStyle=`#ffffff`;for(let[r,i,a]of[[-16,22,3],[-10,14,5]])e.beginPath(),e.arc(t+r,n+i,a,0,Math.PI*2),e.fill(),e.stroke();e.beginPath(),e.ellipse(t+8,n-4,20,15,0,0,Math.PI*2),e.fill(),e.stroke(),e.save(),e.translate(t+8,n-4),r(),e.restore()}function pK({onBack:e}){let t=(0,v.useSyncExternalStore)(YG,qG),[n,r]=(0,v.useState)(Date.now()),i=(0,v.useRef)(null),a=(0,v.useRef)([]),o=(0,v.useRef)(0),s=(0,v.useRef)(t?.say?.at??0),[c]=(0,v.useState)(()=>Date.now()),[l]=(0,v.useState)(()=>t?.say&&t.say.at>iK&&c-t.say.at>5e3?t.say:null);(0,v.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>{clearInterval(e),iK=Date.now()}},[]);let u=t?.say?.at??0;(0,v.useEffect)(()=>{u!==s.current&&(s.current=u,u!==o.current&&Date.now()-u<3e3&&(i.current={kind:`cheer`,t:0},_G(a.current,$G/2,152,uG,16,140),ZG.happy()))},[u]);let d=()=>{if(qG())return;let e=kG(Date.now(),Math.random(),Math.random());o.current=e.say?.at??0,i.current={kind:`hatch`,t:0},_G(a.current,$G/2,182,[`#d9a066`,`#f1d19b`,...uG],22,170),ZG.levelUp(),JG(e)},f=e=>{let t=qG();if(!t)return;let n=Date.now(),s=PG(t,e,n);s.say?.at===n&&(o.current=n),JG(s),r(n);let c=s.xp>t.xp,l=nK[OG(s.xp)];if(s.say?.text.startsWith(`Promoted`)){ZG.levelUp(),_G(a.current,$G/2,tK-l,uG,22,160),i.current={kind:`cheer`,t:0};return}switch(e){case`snack`:case`play`:c?(i.current={kind:e,t:0},(e===`snack`?ZG.nom:ZG.boing)()):s.asleep||ZG.grumble();break;case`coffee`:c?(i.current={kind:`coffee`,t:0},ZG.slurp()):s.asleep||(i.current={kind:`jitter`,t:0},ZG.grumble());break;case`nap`:s.asleep?ZG.snore():t.asleep&&(i.current={kind:`wake`,t:0},ZG.happy());break;case`pet`:if(s.pettedAt===n){i.current={kind:`pet`,t:0};for(let e=0;e<3;e++)a.current.push({x:$G/2+(e-1)*16,y:tK-l-6,vx:(e-1)*14,vy:-50-e*8,life:1.1,color:`#ff6fb5`,size:16+e*2,text:`♥`});ZG.happy()}}};tG(e=>{if(e.repeat)return!1;let t=aK.find(t=>e.code===`Digit${t.key}`||e.code===`Numpad${t.key}`);return t?(f(t.action),!0):iG(e.code)?(qG()?f(`pet`):d(),!0):!1});let p=(e,t,n)=>{let r=qG(),o=r?AG(r,Date.now()):null,s=o?jG(o):`content`,c=o?OG(o.xp):0;uK(e,n,c>=2||s===`happy`);let l=i.current;if(l&&(l.t+=t,l.t>rK&&(i.current=null)),o){let t=nK[c],r=$G/2,i=0,a=1,u=1,d=Math.sin(n/(s===`asleep`?900:450));u+=d*(s===`asleep`?.04:.025),a-=d*.015;let f=l?l.t/rK:0;if((l?.kind===`play`||l?.kind===`cheer`||l?.kind===`wake`)&&(i=Math.abs(Math.sin(f*Math.PI*(l.kind===`wake`?1:4)))*(l.kind===`wake`?10:16)*(1-f*.5)),(l?.kind===`coffee`||l?.kind===`jitter`)&&(r+=Math.sin(l.t*70)*(l.kind===`jitter`?2.5:1.2)),l?.kind===`pet`){let e=Math.sin(Math.min(1,f*3)*Math.PI)*.1;u-=e,a+=e}if(l?.kind===`hatch`){let e=Math.min(1,f*3);a*=.3+e*.7,u*=.3+e*.7}e.save(),e.translate(r,214-i),e.scale(a,u);let p=l?.kind===`snack`&&f>.3&&Math.floor(l.t*8)%2==0;oK(e,{size:t,color:o.color,mood:l?.kind===`jitter`?`grumpy`:l?.kind===`cheer`||l?.kind===`play`?`happy`:s,stage:c,blink:Math.floor(n/160)%24==0,open:p,arms:l?.kind===`cheer`||l?.kind===`play`}),e.restore();let m=tK-t-i;if(l?.kind===`snack`){let n=Math.min(1,f/.3);cK(e,r+t*.2+60*(1-n),202+(12-t*.38)*n-Math.sin(n*Math.PI)*24,10*(1-Math.max(0,f-.3)*.6),Math.max(0,(f-.3)/.7))}if(l?.kind===`coffee`&&lK(e,r+t/2+16,194,n),l?.kind===`play`){let t=$G/2+Math.cos(f*Math.PI*2)*70,n=196-Math.abs(Math.sin(f*Math.PI*5))*60;e.beginPath(),e.arc(t,n,8,0,Math.PI*2),e.fillStyle=`#d4f25c`,e.fill(),e.lineWidth=2,e.strokeStyle=sG,e.stroke(),e.beginPath(),e.arc(t-8,n,7,-.9,.9),e.strokeStyle=`#ffffff`,e.stroke()}if(!l){let i=Math.sin(n/400)*2;if(s===`asleep`){for(let i=0;i<3;i++){let a=(n/1400+i/3)%1;e.globalAlpha=Math.min(1,(1-a)*2),mG(e,`z`,r+t*.35+a*26,m-a*34,12+a*10,`#ffffff`)}e.globalAlpha=1}else if(s===`hungry`)fK(e,r+t*.55+18,m-8+i,()=>cK(e,0,0,9));else if(s===`bored`)fK(e,r+t*.55+18,m-8+i,()=>pG(e,`…`,0,-2,20,sG,700));else if(s===`tired`)fK(e,r+t*.55+18,m-8+i,()=>pG(e,`💤`,0,0,14,sG,400));else if(s===`grumpy`){let t=r,a=m-22+i;e.fillStyle=`#8e93a8`,e.strokeStyle=sG,e.lineWidth=2,e.beginPath(),e.arc(t-12,a,9,0,Math.PI*2),e.arc(t,a-5,11,0,Math.PI*2),e.arc(t+12,a,9,0,Math.PI*2),e.fill(),e.stroke(),e.fill(),Math.floor(n/250)%6==0&&(e.beginPath(),e.moveTo(t+2,a+8),e.lineTo(t-3,a+16),e.lineTo(t+2,a+16),e.lineTo(t-2,a+24),e.strokeStyle=`#ffc93c`,e.lineWidth=2.5,e.stroke())}else if(s===`happy`&&Math.floor(n/900)%3==0){let i=n%900/900;e.globalAlpha=Math.sin(i*Math.PI),mG(e,`✦`,r-t*.6,m+10-i*8,14,`#ffc93c`),mG(e,`✦`,r+t*.62,m+22-i*6,11,`#ffffff`),e.globalAlpha=1}}s===`asleep`&&(e.fillStyle=`rgba(28,36,82,0.32)`,e.fillRect(0,0,$G,eK))}else{let t=n%2600<450?Math.sin(n/45)*.06:0;e.save(),e.translate($G/2,213),e.rotate(t),dK(e),e.restore(),mG(e,`?`,194,142+Math.sin(n/300)*3,20,`#ffc93c`)}yG(e,a.current,t)},m=(e,t,n)=>{if(e!==`down`)return;let r=qG();if(!r){Math.abs(t-$G/2)<50&&n>142&&d();return}let i=nK[OG(r.xp)];Math.abs(t-$G/2)<i/2+8&&n>tK-i-12&&n<218&&f(`pet`)},h=t?AG(t,n):null,g=h?jG(h):null,_=h?.say&&n-h.say.at<2e4?h.say.text:null,y=h?_??(l&&n-c<1e4?`While you were away: ${l.text}`:MG[g]):`A delivery just arrived at your desk…`,b=h?EG[OG(h.xp)].title:``,x=h?Math.floor((n-h.born)/864e5)+1:0,S=h?[[`🍩`,`Food`,h.food,`#ffc93c`],[`🎾`,`Fun`,h.fun,`#ff6fb5`],[`⚡`,`Energy`,h.energy,`#4fb3e8`]]:[];return(0,K.jsxs)(`div`,{className:`game pet`,children:[(0,K.jsx)(nG,{title:`Desk Pet`,color:QG,onBack:e,children:h&&(0,K.jsxs)(`span`,{className:`game-chip`,title:`${h.xp} care points`,children:[h.name,` · `,b]})}),(0,K.jsx)(`div`,{className:`pet-say`,"aria-live":`polite`,children:y}),(0,K.jsx)(eG,{width:$G,height:eK,frame:p,label:h?`${h.name}, your desk pet, is ${g}`:`A delivery box`,onPointer:m}),h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`pet-bars`,children:S.map(([e,t,n,r])=>(0,K.jsxs)(`div`,{className:`pet-bar ${n<25?`pet-bar-low`:``}`,title:`${t}: ${Math.round(n)}%`,children:[(0,K.jsxs)(`span`,{className:`pet-bar-label`,children:[e,` `,t]}),(0,K.jsx)(`span`,{className:`pet-meter`,children:(0,K.jsx)(`i`,{style:{width:`${Math.max(2,n)}%`,background:r}})})]},t))}),(0,K.jsx)(`div`,{className:`pet-actions`,children:aK.map(e=>{let t=e.action===`nap`&&h.asleep;return(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-small pet-act`,tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:()=>f(e.action),disabled:h.asleep&&!t,title:`${t?`Wake up`:e.label} (${e.key})`,children:[(0,K.jsx)(`span`,{className:`pet-act-icon`,children:t?`☀️`:e.icon}),t?`Wake`:e.label]},e.action)})}),(0,K.jsxs)(`div`,{className:`game-keys`,children:[(0,K.jsx)(`kbd`,{children:`1`}),`–`,(0,K.jsx)(`kbd`,{children:`4`}),` care · click `,h.name,` (or `,(0,K.jsx)(`kbd`,{children:`Space`}),`) for a pat · day `,x]})]}):(0,K.jsx)(`div`,{className:`pet-actions`,children:(0,K.jsx)(`button`,{type:`button`,className:`btn btn-good pet-unbox`,onClick:d,children:`📦 Unbox your desk pet`})})]})}function mK(e){let t=e+1831565813|0,n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,[((n^n>>>14)>>>0)/4294967296,t]}var hK=()=>Math.floor(Math.random()*2**31),gK={up:{x:0,y:-1},down:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}},_K={up:`down`,down:`up`,left:`right`,right:`left`},vK={bug:10,coffee:50},yK={bug:1,coffee:2},bK=(e,t)=>e.x===t.x&&e.y===t.y;function xK(e,t){let n=Math.floor(e*.2),r=e-n-2,i=Math.floor(t*.2),a=t-i-1;return[n,r].flatMap(e=>[i,a].flatMap(t=>[{x:e,y:t},{x:e+1,y:t}]))}function SK(e,t,n,r){let i=new Set(n.map(t=>t.y*e+t.x)),a=[];for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.has(n*e+t)||a.push({x:t,y:n});if(!a.length)return{at:null,seed:r};let[o,s]=mK(r);return{at:a[Math.floor(o*a.length)],seed:s}}function CK(e,t=16,n=16){let r=Math.floor(n/2),i=Math.floor(t/2)-1,a=[0,1,2].map(e=>({x:i-e,y:r})),o=xK(t,n),s=SK(t,n,[...a,...o],e);return{cols:t,rows:n,body:a,dir:`right`,queue:[],desks:o,food:{...s.at??{x:0,y:0},kind:`bug`},grow:0,score:0,eaten:0,seed:s.seed,over:null,ate:null}}function wK(e,t){if(e.over)return e;let n=e.queue[e.queue.length-1]??e.dir;return t===n||t===_K[n]||e.queue.length>=2?e:{...e,queue:[...e.queue,t]}}function TK(e){if(e.over)return e;let[t=e.dir,...n]=e.queue,r=gK[t],i={x:e.body[0].x+r.x,y:e.body[0].y+r.y},a=r=>({...e,dir:t,queue:n,over:r,ate:null});if(i.x<0||i.y<0||i.x>=e.cols||i.y>=e.rows)return a(`wall`);if(e.desks.some(e=>bK(e,i)))return a(`desk`);let o=e.grow>0?e.body:e.body.slice(0,-1);if(o.some(e=>bK(e,i)))return a(`self`);let s=[i,...o],c=Math.max(0,e.grow-1);if(!bK(i,e.food))return{...e,body:s,dir:t,queue:n,grow:c,ate:null};let l=e.food.kind,u=e.eaten+1;c+=yK[l];let d=SK(e.cols,e.rows,[...s,...e.desks],e.seed),f={...e,body:s,dir:t,queue:n,grow:c,eaten:u,score:e.score+vK[l],seed:d.seed,ate:l};return d.at?{...f,food:{...d.at,kind:(u+1)%5==0?`coffee`:`bug`}}:{...f,over:`won`}}var EK=e=>Math.max(70,165-e.eaten*4),DK=`#4fb3e8`,OK=20,kK=6,AK=38,jK=16,MK=16,NK=332,PK=364,FK=`#4fb3e8`,IK=null,LK=()=>IK!==null,RK={wall:`Unplugged!`,self:`Tangled up!`,desk:`Desk crash!`,won:`Office wired! 🎉`},zK={right:0,down:Math.PI/2,left:Math.PI,up:-Math.PI/2},BK={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]},VK=e=>kK+e.x*OK+OK/2,HK=e=>AK+e.y*OK+OK/2;function UK({onBack:e}){let[t,n]=(0,v.useState)(IK?`paused`:`ready`),r=(0,v.useRef)({game:IK??CK(hK(),jK,MK),status:IK?`paused`:`ready`,acc:0,best:VG(`snake`),newBest:!1,particles:[],shake:0,chomp:0,swipe:null}),i=e=>{r.current.status=e,n(e),IK=e===`over`||e===`ready`?null:r.current.game},a=e=>{let t=r.current,n=t.game;if(e!==n){if(t.game=e,t.status===`playing`&&(IK=e),e.ate){let n=e.body[0];e.ate===`coffee`?ZG.slurp():ZG.chomp(),t.chomp=.18,_G(t.particles,VK(n),HK(n),e.ate===`coffee`?[`#8d5524`,`#ffffff`,`#ffc93c`]:[`#f25f5c`,`#8fd14f`,`#ffffff`],8,90),vG(t.particles,VK(n),HK(n)-12,e.ate===`coffee`?`+50 ☕`:`+10`,e.ate===`coffee`?`#ffc93c`:`#ffffff`,15)}e.over&&!n.over&&(t.newBest=HG(`snake`,e.score),t.newBest&&(t.best=e.score),t.shake=e.over===`won`?0:.3,e.over===`won`?ZG.best():ZG.over(),t.newBest&&e.over!==`won`&&ZG.best(),i(`over`))}},o=()=>{let e=r.current;e.status!==`playing`&&(e.status===`over`&&(e.game=CK(hK(),jK,MK)),e.status!==`paused`&&(e.newBest=!1,e.particles.length=0),e.acc=0,ZG.start(),i(`playing`))},s=()=>{r.current.status===`playing`&&(ZG.pause(),i(`paused`))},c=e=>{if(r.current.status!==`playing`){if(r.current.status===`paused`)return o();o()}a(wK(r.current.game,e))};tG(e=>{let t=rG(e.code);return t?(e.repeat||c(t),!0):iG(e.code)?(e.repeat||(r.current.status===`playing`?s:o)(),!0):!1}),aG(s);let l=(e,t,n)=>{let i=r.current;if(e===`down`){i.swipe={x:t,y:n};return}if(!i.swipe)return;let a=t-i.swipe.x,s=n-i.swipe.y;e===`move`&&Math.max(Math.abs(a),Math.abs(s))>18?(c(Math.abs(a)>Math.abs(s)?a>0?`right`:`left`:s>0?`down`:`up`),i.swipe={x:t,y:n}):e===`up`&&(Math.max(Math.abs(a),Math.abs(s))<8&&i.status!==`playing`&&o(),i.swipe=null)},u=(e,t,n)=>{let i=r.current;if(i.status===`playing`){i.acc+=t*1e3;let e=EK(i.game);for(;i.acc>=e&&i.status===`playing`;)i.acc-=e,a(TK(i.game)),e=EK(i.game)}let o=i.game;fG(e,kK,4,96,26,`#ffffff`,9),pG(e,`🐛 ${o.eaten} eaten`,54,17,12,sG,700),fG(e,NK/2-50,4,100,26,`#ffffff`,9),pG(e,`SCORE ${o.score}`,NK/2,17,12,sG,700),fG(e,230,4,96,26,`#ffffff`,9),pG(e,`BEST ${Math.max(i.best,o.score)}`,278,17,12,o.score>i.best?`#e05a2b`:lG,700),e.save(),i.shake>0&&(i.shake-=t,e.translate((Math.random()-.5)*12*i.shake,(Math.random()-.5)*12*i.shake)),fG(e,3,35,326,326,`#e6ebf3`,8),e.save(),e.beginPath(),e.roundRect(kK,AK,320,320,6),e.clip(),e.fillStyle=`#dce3ee`;for(let t=0;t<MK;t++)for(let n=0;n<jK;n++)(n+t)%2&&e.fillRect(kK+n*OK,AK+t*OK,OK,OK);e.restore();for(let t=0;t+1<o.desks.length;t+=2){let n=o.desks[t],r=kK+n.x*OK,i=AK+n.y*OK;dG(e,r+1,i+2,38,17,`#f1d19b`,5),dG(e,r+OK-8,i-3,16,12,`#2b2d42`,3,1.5),e.fillStyle=uG[t/2%uG.length],e.fillRect(r+OK-5,i,10,5)}WK(e,o,n),GK(e,o,i.chomp,n),i.chomp=Math.max(0,i.chomp-t),e.restore(),yG(e,i.particles,t),i.status===`ready`?bG(e,NK,PK,`Cable Snake`,[`Eat bugs 🐛, sip coffee ☕`,`Dodge desks, walls & yourself`,`Arrows, swipe or tap to start`],DK):i.status===`paused`?bG(e,NK,PK,`Coffee break ☕`,[`Score ${o.score}`,`Space or tap to resume`],DK):i.status===`over`&&bG(e,NK,PK,RK[o.over??`self`],[`Score ${o.score} · ${o.body.length} long`,i.newBest?`🏆 New best!`:`Best ${i.best}`,`Space or tap to play again`],o.over===`won`?`#8fd14f`:`#f25f5c`)},d=(e,t,n)=>(0,K.jsx)(oG,{label:n,className:`game-pad-${e}`,onPress:()=>c(e),children:t});return(0,K.jsxs)(`div`,{className:`game`,children:[(0,K.jsx)(nG,{title:`Cable Snake`,color:DK,onBack:e,children:(0,K.jsx)(`button`,{type:`button`,className:`game-mini`,tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:()=>t===`playing`?s():o(),title:t===`playing`?`Pause (Space)`:`Play (Space)`,children:t===`playing`?`⏸`:`▶`})}),(0,K.jsx)(eG,{width:NK,height:PK,frame:u,label:`Cable Snake board`,onPointer:l}),(0,K.jsxs)(`div`,{className:`game-dpad`,children:[d(`up`,`▲`,`Up`),d(`left`,`◀`,`Left`),d(`right`,`▶`,`Right`),d(`down`,`▼`,`Down`)]}),(0,K.jsxs)(`div`,{className:`game-keys`,children:[(0,K.jsx)(`kbd`,{children:`←`}),(0,K.jsx)(`kbd`,{children:`↑`}),(0,K.jsx)(`kbd`,{children:`→`}),(0,K.jsx)(`kbd`,{children:`↓`}),` or `,(0,K.jsx)(`kbd`,{children:`WASD`}),` steer · swipe on the board · `,(0,K.jsx)(`kbd`,{children:`Space`}),` pause`]})]})}function WK(e,t,n){let r=VK(t.food),i=HK(t.food);if(e.save(),e.translate(r,i),t.food.kind===`coffee`){let t=.5+Math.sin(n/200)*.5;e.beginPath(),e.arc(0,0,10+t*2,0,Math.PI*2),e.fillStyle=`rgba(255,201,60,${.25+t*.2})`,e.fill(),e.lineWidth=2,e.strokeStyle=sG,e.beginPath(),e.arc(5,1,3.5,-Math.PI/2,Math.PI/2),e.stroke(),e.beginPath(),e.roundRect(-7,-5,12,12,2.5),e.fillStyle=`#ffffff`,e.fill(),e.stroke(),e.beginPath(),e.ellipse(-1,-4,5,1.6,0,0,Math.PI*2),e.fillStyle=`#8d5524`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.5)`,e.lineWidth=1.2;for(let t of[-3,1]){let r=(n/400+t)%1;e.globalAlpha=1-r,e.beginPath(),e.moveTo(t,-7-r*6),e.quadraticCurveTo(t+2,-9-r*6,t,-11-r*6),e.stroke()}e.globalAlpha=1}else{e.rotate(Math.sin(n/160)*.18),e.strokeStyle=sG,e.lineWidth=1.4,e.lineCap=`round`;for(let t of[-1,1])for(let r of[-3,.5,4])e.beginPath(),e.moveTo(t*3,r),e.lineTo(t*8,r+Math.sin(n/90+r)*1.5-1),e.stroke();e.beginPath(),e.moveTo(-1.5,-7),e.lineTo(-4,-10),e.moveTo(1.5,-7),e.lineTo(4,-10),e.stroke(),e.beginPath(),e.arc(0,-6,3,0,Math.PI*2),e.fillStyle=sG,e.fill(),e.beginPath(),e.ellipse(0,1,5.5,6.5,0,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.lineWidth=1.8,e.stroke(),e.beginPath(),e.moveTo(0,-5),e.lineTo(0,7),e.lineWidth=1.2,e.stroke(),e.fillStyle=sG;for(let[t,n]of[[-2.6,-.5],[2.6,-.5],[-2.4,3.5],[2.4,3.5]])e.beginPath(),e.arc(t,n,1.1,0,Math.PI*2),e.fill()}e.restore()}function GK(e,t,n,r){let i=t.body;e.lineCap=`round`,e.lineJoin=`round`,(()=>{e.beginPath(),e.moveTo(VK(i[i.length-1]),HK(i[i.length-1]));for(let t=i.length-2;t>=0;t--)e.lineTo(VK(i[t]),HK(i[t]))})(),e.strokeStyle=sG,e.lineWidth=14,e.stroke(),e.strokeStyle=FK,e.lineWidth=10,e.stroke(),e.save(),e.translate(0,-2),e.strokeStyle=`rgba(255,255,255,0.4)`,e.lineWidth=3,e.stroke(),e.restore(),e.strokeStyle=gG(FK,-.45),e.lineWidth=3;for(let t=3;t<i.length-1;t+=4){let n=i[t],r=i[t+1],a=(VK(n)+VK(r))/2,o=(HK(n)+HK(r))/2,s=n.x===r.x;e.beginPath(),e.moveTo(a-(s?5:0),o-(s?0:5)),e.lineTo(a+(s?5:0),o+(s?0:5)),e.stroke()}let a=i[0],o=t.queue[0]??t.dir,s=VK(a),c=HK(a);e.save(),e.translate(s,c),e.rotate(zK[t.dir]);let l=n>0?1.12:1;e.scale(l,l),e.beginPath(),e.roundRect(-8,-8,16,16,3.5),e.fillStyle=`#e4f4ff`,e.fill(),e.lineWidth=2,e.strokeStyle=sG,e.stroke(),e.fillStyle=`#ffc93c`;for(let t=0;t<4;t++)e.fillRect(5,-6+t*3.3,3,1.8);e.restore();let[u,d]=BK[o],f=s-BK[t.dir][0]*2,p=c-BK[t.dir][1]*2-1;if(t.over&&t.over!==`won`){e.strokeStyle=sG,e.lineWidth=2;for(let t of[-1,1]){let n=f+t*4;e.beginPath(),e.moveTo(n-2.5,p-2.5),e.lineTo(n+2.5,p+2.5),e.moveTo(n+2.5,p-2.5),e.lineTo(n-2.5,p+2.5),e.stroke()}}else hG(e,f,p,8,3.2,u,d,Math.floor(r/170)%25==0)}var KK=[`I`,`O`,`T`,`S`,`Z`,`J`,`L`],qK={I:[`....`,`XXXX`,`....`,`....`],O:[`XX`,`XX`],T:[`.X.`,`XXX`,`...`],S:[`.XX`,`XX.`,`...`],Z:[`XX.`,`.XX`,`...`],J:[`X..`,`XXX`,`...`],L:[`..X`,`XXX`,`...`]};function JK(e){let t=[];return e.forEach((e,n)=>[...e].forEach((e,r)=>e===`X`&&t.push([r,n]))),t}function YK(e){let t=e.length;return e.map((n,r)=>e.map((n,i)=>e[t-1-i][r]).join(``))}var XK=Object.fromEntries(KK.map(e=>{let t=[qK[e]];for(let e=1;e<4;e++)t.push(YK(t[e-1]));return[e,t.map(JK)]})),ZK=()=>Array.from({length:20},()=>Array(10).fill(null));function QK(e){return XK[e.type][e.rot].map(([t,n])=>[e.x+t,e.y+n])}var $K=e=>XK[e][0];function eq(e,t){return QK(t).some(([t,n])=>t<0||t>=10||n>=20||n>=0&&e[n][t]!==null)}function tq(e){let t=qK[e].length,n=Math.min(...XK[e][0].map(([,e])=>e));return{type:e,rot:0,x:Math.floor((10-t)/2),y:-n}}function nq(e,t){let n=[...e],r=t;for(;n.length<KK.length;){let e=[...KK];for(let t=e.length-1;t>0;t--){let[n,i]=mK(r);r=i;let a=Math.floor(n*(t+1));[e[t],e[a]]=[e[a],e[t]]}n.push(...e)}return{queue:n,seed:r}}function rq(e){let t=nq([],e),[n,...r]=t.queue,i=nq(r,t.seed);return{board:ZK(),piece:tq(n),queue:i.queue,seed:i.seed,score:0,lines:0,level:1,over:!1,cleared:[],locks:0}}var iq=e=>Math.max(80,Math.round(800*.85**(e-1))),aq=[0,100,300,500,800];function oq(e){let t=[],n=e.filter((e,n)=>{let r=e.every(e=>e!==null);return r&&t.push(n),!r});return t.length?{board:[...Array.from({length:t.length},()=>Array(10).fill(null)),...n],rows:t}:{board:e,rows:t}}function sq(e,t,n=0){if(e.over)return e;let r={...e.piece,x:e.piece.x+t,y:e.piece.y+n};return eq(e.board,r)?e:{...e,piece:r}}var cq=[[0,0],[-1,0],[1,0],[0,-1],[-1,-1],[1,-1]],lq=[[0,0],[-1,0],[1,0],[-2,0],[2,0],[0,-1]];function uq(e,t=1){if(e.over||e.piece.type===`O`)return e;let n=(e.piece.rot+t+4)%4;for(let[t,r]of e.piece.type===`I`?lq:cq){let i={...e.piece,rot:n,x:e.piece.x+t,y:e.piece.y+r};if(!eq(e.board,i))return{...e,piece:i}}return e}function dq(e){let t=0;for(;!eq(e.board,{...e.piece,y:e.piece.y+t+1});)t++;return t}function fq(e){if(e.over)return e;let t=QK(e.piece),n=e.board.map(e=>[...e]),r=!1;for(let[i,a]of t)a<0?r=!0:n[a][i]=e.piece.type;let{board:i,rows:a}=oq(n),o=e.lines+a.length,s=e.score+aq[a.length]*e.level,c=1+Math.floor(o/10),[l,...u]=e.queue,d=nq(u,e.seed),f=tq(l),p=r||eq(i,f);return{board:i,piece:f,queue:d.queue,seed:d.seed,score:s,lines:o,level:c,over:p,cleared:a,locks:e.locks+1}}function pq(e){if(e.over)return e;let t=sq(e,0,1);return t===e?fq(e):t}function mq(e){if(e.over)return e;let t=sq(e,0,1);return t===e?fq(e):{...t,score:t.score+1}}function hq(e){if(e.over)return e;let t=dq(e);return fq({...e,piece:{...e.piece,y:e.piece.y+t},score:e.score+t*2})}var gq=`#c77dff`,_q={I:uG[1],O:uG[4],T:uG[3],S:uG[2],Z:uG[7],J:uG[6],L:uG[0]},vq=18,yq=8,bq=8,xq=10*vq,Sq=20*vq,Cq=yq+xq+12,wq=Cq+92+6,Tq=bq+Sq+8,Eq=null,Dq=()=>Eq!==null,Oq=[``,`Shipped!`,`Double ship!`,`Triple ship!`,`CUBETRIS!`];function kq({onBack:e}){let[t,n]=(0,v.useState)(Eq?`paused`:`ready`),r=(0,v.useRef)({game:Eq??rq(hK()),status:Eq?`paused`:`ready`,acc:0,best:VG(`tetris`),newBest:!1,flash:[],particles:[],shake:0,lastDx:0}),i=e=>{r.current.status=e,n(e),Eq=e===`over`||e===`ready`?null:r.current.game},a=e=>{let t=r.current,n=t.game;if(e===n)return!1;if(t.game=e,Eq=t.status===`playing`?e:Eq,e.locks!==n.locks){let r=e.cleared.length;if(r){ZG.lines(r);let i=e.score-n.score;for(let n of e.cleared)t.flash.push({y:n,t:.35}),_G(t.particles,yq+xq/2,bq+n*vq+vq/2,uG,10,150);let a=bq+e.cleared.reduce((e,t)=>e+t,0)/r*vq;vG(t.particles,yq+xq/2,a-14,Oq[r],r===4?`#ffc93c`:`#ffffff`,r===4?26:20),vG(t.particles,yq+xq/2,a+12,`+${i}`,`#80ed99`,16),r===4&&(t.shake=.35)}else ZG.land();e.level>n.level&&(ZG.levelUp(),vG(t.particles,yq+xq/2,bq+Sq/3,`Level ${e.level}!`,`#4fb3e8`,24)),e.over&&(t.newBest=HG(`tetris`,e.score),t.newBest&&(t.best=e.score),ZG.over(),t.newBest&&ZG.best(),i(`over`))}return!0},o=()=>{let e=r.current;e.status!==`playing`&&((e.status===`over`||e.status===`ready`)&&(e.status===`over`&&(e.game=rq(hK())),e.newBest=!1,e.particles.length=0),e.acc=0,ZG.start(),i(`playing`))},s=()=>{r.current.status===`playing`&&(ZG.pause(),i(`paused`))},c=e=>{r.current.lastDx=e,a(sq(r.current.game,e))&&ZG.move()},l=e=>a(uq(r.current.game,e))&&ZG.rotate(),u=()=>{r.current.acc=0,a(mq(r.current.game))},d=()=>{r.current.acc=0,a(hq(r.current.game))},f=e=>()=>r.current.status===`playing`?e():o();return tG(e=>{let t=r.current.status===`playing`,n=rG(e.code);return iG(e.code)?(e.repeat||(t?e.code===`Space`?d():s():o()),!0):n?(t&&(n===`left`||n===`right`?c(n===`left`?-1:1):n===`down`?u():e.repeat||l(1)),!0):e.code===`KeyZ`||e.code===`KeyQ`||e.code===`KeyX`?(t&&!e.repeat&&l(e.code===`KeyX`?1:-1),!0):!1}),aG(s),(0,K.jsxs)(`div`,{className:`game`,children:[(0,K.jsx)(nG,{title:`Cubetris`,color:gq,onBack:e,children:(0,K.jsx)(`button`,{type:`button`,className:`game-mini`,tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:()=>t===`playing`?s():o(),title:t===`playing`?`Pause (Enter)`:`Play (Space)`,children:t===`playing`?`⏸`:`▶`})}),(0,K.jsx)(eG,{width:wq,height:Tq,frame:(e,t,n)=>{let i=r.current;if(i.status===`playing`){i.acc+=t*1e3;let e=iq(i.game.level);for(;i.acc>=e&&i.status===`playing`;)i.acc-=e,a(pq(i.game))}let o=i.game;e.save(),i.shake>0&&(i.shake-=t,e.translate((Math.random()-.5)*6*i.shake*3,(Math.random()-.5)*6*i.shake*3)),fG(e,5,5,xq+6,Sq+6,`#e3e9f3`,8),e.strokeStyle=`rgba(80,100,140,0.12)`,e.lineWidth=1,e.beginPath();for(let t=1;t<10;t++)e.moveTo(yq+t*vq,bq),e.lineTo(yq+t*vq,bq+Sq);for(let t=1;t<20;t++)e.moveTo(yq,bq+t*vq),e.lineTo(yq+xq,bq+t*vq);if(e.stroke(),o.board.forEach((t,n)=>t.forEach((t,r)=>t&&dG(e,yq+r*vq,bq+n*vq,vq,vq,_q[t],4.5))),!o.over){let t=dq(o);e.setLineDash([3,3]);for(let[n,r]of QK({...o.piece,y:o.piece.y+t}))r<0||(e.beginPath(),e.roundRect(yq+n*vq+2,bq+r*vq+2,14,14,4),e.fillStyle=`${_q[o.piece.type]}44`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.45)`,e.lineWidth=1.5,e.stroke());e.setLineDash([]);let r=QK(o.piece);e.save(),e.beginPath(),e.rect(6,bq,xq+4,Sq+4),e.clip();for(let[t,n]of r)dG(e,yq+t*vq,bq+n*vq,vq,vq,_q[o.piece.type],4.5);let a=r.reduce((e,[t])=>e+t,0)/r.length,s=r.reduce((e,[,t])=>e+t,0)/r.length,[c,l]=r.reduce((e,t)=>Math.hypot(t[0]-a,t[1]-s)<Math.hypot(e[0]-a,e[1]-s)?t:e);l>=0&&hG(e,yq+c*vq+vq/2,bq+l*vq+vq/2-1,8,2.7,i.lastDx,.6,Math.floor(n/180)%22==0),e.restore()}i.flash=i.flash.filter(e=>(e.t-=t)>0);for(let t of i.flash)e.fillStyle=`rgba(255,255,255,${Math.min(1,t.t*3)})`,e.fillRect(yq,bq+t.y*vq,xq,vq);e.restore(),fG(e,Cq,bq,92,110,`#ffffff`,10),pG(e,`NEXT`,Cq+46,21,11,lG,700),o.queue.slice(0,3).forEach((t,n)=>{let r=n===0?14:9,i=$K(t),a=i.map(([e])=>e),o=i.map(([,e])=>e),s=(Math.max(...a)-Math.min(...a)+1)*r,c=(Math.max(...o)-Math.min(...o)+1)*r,l=n===0?Cq+46-s/2:Cq+(n===1?24:68)-s/2,u=n===0?52-c/2:98-c/2;for(let[s,c]of i)dG(e,l+(s-Math.min(...a))*r,u+(c-Math.min(...o))*r,r,r,_q[t],r*.25,n===0?2:1.5)});let s=(t,n,r,i=sG)=>{fG(e,Cq,r,92,46,`#ffffff`,10),pG(e,t,Cq+46,r+13,10,lG,700),pG(e,n,Cq+46,r+31,17,i,700)};if(s(`SCORE`,o.score.toLocaleString(),130),s(`LINES`,String(o.lines),186),s(`LEVEL`,String(o.level),242),s(`BEST`,Math.max(i.best,o.score).toLocaleString(),298,o.score>i.best?`#e05a2b`:sG),yG(e,i.particles,t),i.status!==`playing`){let t=i.status===`ready`?`Space or tap to start`:i.status===`paused`?`Space or tap to resume`:`Space or tap to play again`;i.status===`ready`?bG(e,wq,Tq,`Cubetris`,[`Stack the blocks.`,`Fill a row to ship it!`,t],gq):i.status===`paused`?bG(e,wq,Tq,`Coffee break ☕`,[`Score ${o.score.toLocaleString()}`,t],gq):bG(e,wq,Tq,`Stack overflow!`,[`Score ${o.score.toLocaleString()}`,i.newBest?`🏆 New best!`:`Best ${i.best.toLocaleString()}`,t],`#f25f5c`)}else o.score===0&&o.locks===0&&mG(e,`Go!`,yq+xq/2,bq+Sq/2,30+Math.sin(n/120)*2,`#80ed99`)},label:`Cubetris board`,onPointer:e=>e===`down`&&f(()=>l(1))()}),(0,K.jsxs)(`div`,{className:`game-pads`,children:[(0,K.jsx)(oG,{label:`Move left`,repeat:!0,onPress:f(()=>c(-1)),children:`◀`}),(0,K.jsx)(oG,{label:`Soft drop`,repeat:!0,onPress:f(u),children:`▼`}),(0,K.jsx)(oG,{label:`Move right`,repeat:!0,onPress:f(()=>c(1)),children:`▶`}),(0,K.jsx)(`span`,{className:`game-pad-gap`}),(0,K.jsx)(oG,{label:`Rotate`,className:`game-pad-round`,onPress:f(()=>l(1)),children:`⟳`}),(0,K.jsx)(oG,{label:`Drop`,className:`game-pad-round game-pad-hot`,onPress:f(d),children:`⤓`})]}),(0,K.jsxs)(`div`,{className:`game-keys`,children:[(0,K.jsx)(`kbd`,{children:`←`}),(0,K.jsx)(`kbd`,{children:`→`}),` move · `,(0,K.jsx)(`kbd`,{children:`↑`}),` turn · `,(0,K.jsx)(`kbd`,{children:`↓`}),` down · `,(0,K.jsx)(`kbd`,{children:`Space`}),` drop · `,(0,K.jsx)(`kbd`,{children:`Enter`}),` pause`]})]})}function Aq({draw:e}){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let n=t.current,r=n?.getContext(`2d`);if(!n||!r)return;let i=Math.min(2,window.devicePixelRatio||1);n.width=56*i,n.height=56*i,r.setTransform(i,0,0,i,0,0),e(r)},[e]),(0,K.jsx)(`canvas`,{ref:t,className:`game-thumb`,style:{width:56,height:56},"aria-hidden":!0})}var jq=e=>{let t=(t,n,r)=>dG(e,2+t*13,2+n*13,13,13,r,3.5,1.8);for(let[e,n]of[[`#ffc93c`,[[0,2],[1,2],[0,3],[1,3]]],[`#ff8a5b`,[[3,1],[3,2],[3,3],[2,3]]],[`#c77dff`,[[0,0],[1,0],[2,0],[1,1]]]])for(let[r,i]of n)t(r,i,e);hG(e,21.5,8.5,7,2.4,0,.5)},Mq=e=>{e.lineCap=`round`,e.lineJoin=`round`,e.beginPath(),e.moveTo(8,48),e.lineTo(8,34),e.lineTo(28,34),e.lineTo(28,16),e.lineTo(36,16),e.strokeStyle=sG,e.lineWidth=11,e.stroke(),e.strokeStyle=`#4fb3e8`,e.lineWidth=7,e.stroke(),e.beginPath(),e.roundRect(33,9,14,14,3),e.fillStyle=`#e4f4ff`,e.fill(),e.lineWidth=2,e.strokeStyle=sG,e.stroke(),e.fillStyle=`#ffc93c`;for(let t=0;t<3;t++)e.fillRect(44,11+t*3.6,2.5,1.8);hG(e,39,15,6,2.4,1,0),e.beginPath(),e.ellipse(46,44,5,6,0,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.lineWidth=1.6,e.stroke(),e.beginPath(),e.arc(46,38,2.6,0,Math.PI*2),e.fillStyle=sG,e.fill()};function Nq({icon:e,name:t,what:n,status:r,color:i,onOpen:a}){return(0,K.jsxs)(`button`,{type:`button`,className:`game-card`,style:{"--game":i},onClick:a,children:[(0,K.jsx)(Aq,{draw:e}),(0,K.jsxs)(`span`,{className:`game-card-text`,children:[(0,K.jsx)(`b`,{children:t}),(0,K.jsx)(`span`,{className:`game-card-what`,children:n}),(0,K.jsx)(`span`,{className:`game-card-status`,children:r})]}),(0,K.jsx)(`span`,{className:`game-card-go`,children:`▶`})]})}function Pq({onGame:e}){let t=(0,v.useSyncExternalStore)(YG,qG),[n]=(0,v.useState)(Date.now),r=t?AG(t,n):null,i=e=>{e.translate(28,50),r?oK(e,{size:38,color:r.color,mood:jG(r),stage:OG(r.xp),blink:!1}):dK(e,.6)},a=e=>VG(e)?`Best ${VG(e).toLocaleString()}`:`No best score yet`;return tG(t=>{let n=[`Digit1`,`Digit2`,`Digit3`].indexOf(t.code);return n<0||t.repeat?!1:(e([`tetris`,`snake`,`pet`][n]),!0)}),(0,K.jsxs)(`div`,{className:`phone-scroll games-list`,children:[(0,K.jsx)(`h3`,{className:`phone-h`,children:`🎮 Games`}),(0,K.jsx)(`p`,{className:`muted small games-blurb`,children:`Something to do while the team works. They pause when you put the phone away.`}),(0,K.jsx)(Nq,{icon:jq,name:`Cubetris`,what:`Falling blocks (a Tetris clone)`,status:Dq()?`⏸ Game paused, tap to resume`:a(`tetris`),color:gq,onOpen:()=>e(`tetris`)}),(0,K.jsx)(Nq,{icon:Mq,name:`Cable Snake`,what:`Eat the bugs (a Snake clone)`,status:LK()?`⏸ Game paused, tap to resume`:a(`snake`),color:DK,onOpen:()=>e(`snake`)}),(0,K.jsx)(Nq,{icon:i,name:`Desk Pet`,what:`Your office pet (a Tamagotchi clone)`,status:r?`${r.name} the ${EG[OG(r.xp)].title.toLowerCase()} ${{asleep:`is napping`,happy:`is thrilled`,content:`is doing fine`,hungry:`is hungry`,bored:`is bored`,tired:`is sleepy`,grumpy:`is grumpy, needs you`}[jG(r)]}`:`📦 A delivery is waiting for you`,color:QG,onOpen:()=>e(`pet`)}),(0,K.jsxs)(`p`,{className:`muted small games-blurb`,children:[(0,K.jsx)(`kbd`,{children:`1`}),` `,(0,K.jsx)(`kbd`,{children:`2`}),` `,(0,K.jsx)(`kbd`,{children:`3`}),` open a game · `,(0,K.jsx)(`kbd`,{children:`Backspace`}),` comes back here`]})]})}function Fq({game:e,onGame:t}){tG(n=>!e||n.code!==`Backspace`?!1:(t(null),!0));let n=()=>t(null);return e===`tetris`?(0,K.jsx)(kq,{onBack:n}):e===`snake`?(0,K.jsx)(UK,{onBack:n}):e===`pet`?(0,K.jsx)(pK,{onBack:n}):(0,K.jsx)(Pq,{onGame:t})}async function Iq(e){try{return await e()}catch{return}}var Lq=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function Rq({name:e,color:t,size:n=34}){return(0,K.jsx)(`span`,{className:`avatar`,style:{background:t,width:n,height:n,fontSize:n*.45},children:e[0]})}function zq({req:e,highlight:t}){let n=q(t=>t.repos.find(t=>t.id===e.repoId)),r=q(e=>e.settings),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),f=(0,v.useRef)(null);(0,v.useEffect)(()=>{t&&f.current?.scrollIntoView({block:`center`})},[t]);let p=e.status===`pending`,m=e.kind===`hire`,h=async e=>{d(!0),await Iq(e),d(!1)};return(0,K.jsxs)(`div`,{ref:f,className:`resume ${m?``:`resume-letgo`} ${t?`resume-hot`:``} ${p?``:`resume-done`}`,children:[(0,K.jsxs)(`div`,{className:`resume-head`,children:[(0,K.jsx)(Rq,{name:e.name,color:e.color,size:42}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`div`,{className:`resume-name`,children:m?e.name:`Let ${e.name} go?`}),(0,K.jsx)(`div`,{className:`resume-title`,children:e.title})]}),!p&&(0,K.jsx)(`span`,{className:`chip ${e.status===`approved`?`chip-good`:``}`,children:e.status===`approved`?m?`✅ hired`:`👋 left`:`✋ declined`})]}),(0,K.jsxs)(`div`,{className:`resume-meta`,children:[(0,K.jsxs)(`span`,{className:`chip`,style:{background:n?.color},children:[`Floor `,n?.floor??`?`]}),(0,K.jsx)(`span`,{className:`muted small`,children:n?.fullName.split(`/`)[1]??`removed floor`}),(0,K.jsx)(`span`,{className:`chip`,children:e.role===`qa`?`🔍 QA`:`💻 Dev`}),e.specialty&&(0,K.jsxs)(`span`,{className:`chip`,children:[`🎯 `,e.specialty]})]}),e.reason&&(0,K.jsx)(QW,{className:`resume-reason`,text:e.reason}),m&&e.brief&&(0,K.jsx)(`button`,{className:`linkish small`,"aria-expanded":i,onClick:()=>a(!i),children:i?`▾ Job description`:`▸ Job description`}),i&&(0,K.jsx)(QW,{className:`resume-brief`,text:e.brief}),m&&p&&(0,K.jsxs)(`div`,{className:`muted small`,children:[WE(e.model,r.runtime===`terminal`?r.defaultCli:`claude`,r,`claude-opus-5-5`)||`default model`,` · `,e.effort||r.defaultEffort,` effort`]}),!p&&e.note&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`Your note: “`,e.note,`”`]}),p&&!o&&(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:u,onClick:()=>s(!0),children:m?`Decline`:`Keep them`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:u,onClick:()=>h(()=>Y.approveRequest(e.id)),children:m?`Hire ${e.name}`:`Let ${e.name} go`})]}),p&&o&&(0,K.jsxs)(`form`,{className:`row`,onSubmit:t=>{t.preventDefault(),h(()=>Y.rejectRequest(e.id,c))},children:[(0,K.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Why not? (optional, the CEO reads it)`,autoFocus:!0}),(0,K.jsx)(`button`,{className:`btn btn-small btn-bad`,disabled:u,children:m?`Decline`:`Keep`})]})]})}function Bq({focusId:e}){let t=q(e=>e.requests),n=Fb(t),r=t.filter(e=>e.status!==`pending`).slice(-8).reverse();return(0,K.jsxs)(`div`,{className:`phone-scroll`,children:[(0,K.jsxs)(`h3`,{className:`phone-h`,children:[`📄 Waiting on you `,n.length>0&&(0,K.jsx)(`span`,{className:`badge`,children:n.length})]}),n.length===0&&(0,K.jsx)(`p`,{className:`muted small phone-empty`,children:`Nobody's waiting. When the CEO wants to hire someone, or let someone go, their resume shows up here.`}),n.map(t=>(0,K.jsx)(zq,{req:t,highlight:t.id===e},t.id)),r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{className:`phone-h`,children:`Earlier`}),r.map(e=>(0,K.jsx)(zq,{req:e},e.id))]})]})}var Vq=[`What's everyone working on?`,`Do we need anyone new?`,`Plan the next milestone for the busiest floor.`];function Hq({m:e,ceoName:t}){let n=q(t=>e.requestId?t.requests.find(t=>t.id===e.requestId):void 0);if(e.from===`office`)return(0,K.jsx)(`div`,{className:`bubble-office`,children:e.text});let r=e.from===`manager`;return(0,K.jsx)(`div`,{className:`bubble-row ${r?`bubble-row-me`:``}`,children:(0,K.jsxs)(`div`,{className:`bubble ${r?`bubble-me`:`bubble-them`}`,children:[!r&&(0,K.jsx)(`div`,{className:`bubble-from`,children:t}),r?(0,K.jsx)(`div`,{className:`bubble-text`,children:e.text}):(0,K.jsx)(QW,{className:`bubble-md`,text:e.text}),n&&n.status===`pending`&&e.from===`ceo`&&(0,K.jsx)(zq,{req:n}),(0,K.jsx)(`div`,{className:`bubble-time`,children:Lq(e.at)})]})})}function Uq(){let e=q(e=>e.messages),t=q(e=>e.phoneReadAt),n=q(e=>e.agents.ceo),r=q(e=>e.ceo),i=q(e=>e.settings),a=q(e=>Object.values(e.agents).filter(Nb).length),[o,s]=(0,v.useState)(``),c=(0,v.useRef)(null);if((0,v.useEffect)(()=>{let n=[...e].reverse().find(e=>e.from===`ceo`);n&&n.at>t&&Iq(()=>Y.phoneRead(n.at))},[e,t]),(0,v.useLayoutEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[e.length,r.job?.kind]),!n)return(0,K.jsx)(`p`,{className:`muted phone-empty`,children:`The corner office is empty.`});let l=e=>{let t=e.trim();t&&(s(``),Iq(()=>Y.messageCeo(t)))},u=n.status===`working`&&r.job?.kind===`chat`,d=r.queue.some(e=>e.kind===`chat`),f=n.status===`working`?u?`typing…`:`busy: ${r.job?.label??`working`}`:d?i.sessionLimit&&a>=i.sessionLimit?`will reply when a session slot frees up (${a}/${i.sessionLimit} busy)`:`reading your message…`:r.queue.length?`next up: ${r.queue[0].label}`:`available`;return(0,K.jsxs)(`div`,{className:`phone-chat`,children:[(0,K.jsxs)(`div`,{className:`chat-head`,children:[(0,K.jsx)(Rq,{name:n.name,color:n.color}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`b`,{children:n.name}),` `,(0,K.jsx)(`span`,{className:`muted small`,children:`CEO`}),(0,K.jsx)(`div`,{className:`small ${n.status===`working`?`presence-busy`:`muted`}`,children:f})]})]}),(0,K.jsxs)(`div`,{className:`chat-log`,ref:c,children:[e.length===0&&(0,K.jsxs)(`p`,{className:`muted small phone-empty`,children:[`Say hi to `,n.name,`. Ask how things are going, hand over a project brief, or ask who the team should hire. Replies land here, and the phone buzzes when `,n.name,` needs you.`]}),e.map(e=>(0,K.jsx)(Hq,{m:e,ceoName:n.name},e.id)),u&&(0,K.jsx)(`div`,{className:`bubble-row`,children:(0,K.jsxs)(`div`,{className:`bubble bubble-them bubble-typing`,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})})]}),(0,K.jsx)(`div`,{className:`quick`,children:Vq.map(e=>(0,K.jsx)(`button`,{className:`quick-chip`,onClick:()=>l(e),children:e},e))}),(0,K.jsxs)(`form`,{className:`chat-input`,onSubmit:e=>{e.preventDefault(),l(o)},children:[(0,K.jsx)($W,{value:o,onChange:s,placeholder:`Message ${n.name}…`,"aria-label":`Message ${n.name}`,title:`Enter sends · Shift+Enter adds a new line`,autoFocus:!0}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!o.trim(),children:`Send`})]})]})}function Wq(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.qa),r=q(e=>e.requests),i=q(e=>e.settings),a=q(e=>e.ceo);return(0,v.useMemo)(()=>{let o=Object.values(t).filter(e=>e.role!==`ceo`),s=t.ceo,c=Object.values(t).filter(Nb).length,l=e.map(e=>{let t=o.filter(t=>t.repoId===e.id),r=e.pulls.filter(e=>e.state===`OPEN`).map(t=>n[kb(e.id,t.number)]);return{repo:e,team:t.length,working:t.filter(Nb).length,idleDevs:t.filter(e=>e.role===`dev`&&!Nb(e)).length,issues:e.issues.length,prs:e.pulls.filter(e=>e.state===`OPEN`).length,inQa:r.filter(e=>e&&e.status!==`passed`&&e.status!==`needs-human`).length,ready:r.filter(e=>e?.status===`passed`).length,stuck:r.filter(e=>e?.status===`needs-human`).length,merged:e.pulls.filter(e=>e.state===`MERGED`).length}}),u=e=>l.reduce((t,n)=>t+n[e],0),d=Fb(r).length,f=[],p=l.filter(e=>e.ready>0);p.length&&f.push({icon:`✅`,text:`${u(`ready`)} pull request${u(`ready`)===1?` passed`:`s passed`} QA and ${u(`ready`)===1?`is`:`are`} ready for you to merge (${p.map(e=>`${e.repo.fullName.split(`/`)[1]}: ${e.ready}`).join(`, `)}).`,tone:`good`}),u(`stuck`)&&f.push({icon:`⚠️`,text:`${u(`stuck`)} pull request${u(`stuck`)===1?``:`s`} failed QA three times and need${u(`stuck`)===1?`s`:``} your call.`,tone:`warn`}),d&&f.push({icon:`📄`,text:`${d} hiring decision${d===1?` is`:`s are`} waiting in Hires.`,tone:`warn`}),f.push({icon:`⚙️`,text:i.sessionLimit?c?`${c} of ${i.sessionLimit} session slots are busy right now.`:`Nobody is working at the moment (${i.sessionLimit} session slots free).`:c?`${c} session${c===1?` is`:`s are`} running right now.`:`Nobody is working at the moment.`});for(let e of l)e.issues>0&&!e.repo.autoAssign&&e.working===0&&e.idleDevs>0&&f.push({icon:`💤`,text:`${e.repo.fullName.split(`/`)[1]} has ${e.issues} open issue${e.issues===1?``:`s`} and free developers, but auto-assign is off.`});let m=[...l].sort((e,t)=>t.issues+t.prs-(e.issues+e.prs))[0];return m&&m.issues+m.prs>0&&l.length>1&&f.push({icon:`🔥`,text:`Most work in flight: ${m.repo.fullName.split(`/`)[1]} (${m.issues} issues, ${m.prs} PRs).`}),s&&f.push({icon:`🧠`,text:s.status===`working`?`${s.name} is ${(a.job?.label??`working`).replace(/^\w/,e=>e.toLowerCase())}.`:a.nextReviewAt?`${s.name} reviews the company next at ${Lq(a.nextReviewAt)}.`:`${s.name}'s periodic reviews are off.`}),l.length===0&&f.splice(0,f.length,{icon:`👋`,text:`No projects yet. Connect a repo in the manager's office (lobby, back left) and the CEO will staff it.`}),{floors:l,staff:o.length,running:c,max:i.sessionLimit,issues:u(`issues`),prs:u(`prs`),report:f}},[e,t,n,r,i,a])}function Gq(){let e=Wq(),t=q(e=>e.goToFloor),n=[[`🏢`,e.floors.length,e.floors.length===1?`project`:`projects`],[`📋`,e.issues,`open issues`],[`🔀`,e.prs,`open PRs`],[`👥`,e.staff,`on staff`],[`⚙️`,e.max?`${e.running}/${e.max}`:`${e.running}`,`working now`]];return(0,K.jsxs)(`div`,{className:`phone-scroll`,children:[(0,K.jsx)(`div`,{className:`tiles`,children:n.map(([e,t,n])=>(0,K.jsxs)(`div`,{className:`tile`,children:[(0,K.jsxs)(`div`,{className:`tile-value`,children:[e,` `,t]}),(0,K.jsx)(`div`,{className:`tile-label`,children:n})]},n))}),(0,K.jsx)(`h3`,{className:`phone-h`,children:`Today's report`}),(0,K.jsx)(`ul`,{className:`report`,children:e.report.map((e,t)=>(0,K.jsxs)(`li`,{className:e.tone?`report-${e.tone}`:``,children:[(0,K.jsx)(`span`,{children:e.icon}),(0,K.jsx)(`span`,{children:e.text})]},t))}),e.floors.length>0&&(0,K.jsx)(`h3`,{className:`phone-h`,children:`Projects`}),e.floors.map(e=>(0,K.jsxs)(`div`,{className:`proj`,style:{"--accent":e.repo.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.repo.floor}),(0,K.jsxs)(`div`,{className:`grow`,style:{minWidth:0},children:[(0,K.jsx)(`b`,{className:`proj-name`,children:e.repo.fullName.split(`/`)[1]}),(0,K.jsx)(`div`,{className:`muted small proj-sum`,children:e.repo.summary||e.repo.description||e.repo.fullName})]}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>t(e.repo.floor),children:`Go`})]}),(0,K.jsxs)(`div`,{className:`proj-stats small`,children:[(0,K.jsxs)(`span`,{children:[`👥 `,e.team,e.working?` (${e.working} busy)`:``]}),(0,K.jsxs)(`span`,{children:[`📋 `,e.issues]}),(0,K.jsxs)(`span`,{children:[`🔍 `,e.inQa]}),(0,K.jsxs)(`span`,{className:e.ready?`proj-ready`:``,children:[`✅ `,e.ready]}),(0,K.jsxs)(`span`,{children:[`🎉 `,e.merged]})]})]},e.repo.id))]})}var Kq=null,qq=()=>{let e=q.getState();return Fb(e.requests).length+Pb(e.messages,e.phoneReadAt)};function Jq({tab:e,requestId:t}){let[n,r]=(0,v.useState)(()=>Kq&&!t&&qq()<=Kq.waiting?`games`:e??(t?`hires`:`chat`)),[i,a]=(0,v.useState)(()=>n===`games`?Kq?.game??null:null),o=(0,v.useRef)({tab:n,game:i});(0,v.useEffect)(()=>{o.current={tab:n,game:i}}),(0,v.useEffect)(()=>()=>{Kq=o.current.tab===`games`?{game:o.current.game,waiting:qq()}:null},[]);let s=q(e=>e.openOverlay),c=q(e=>e.requests),l=q(e=>e.messages),u=q(e=>e.phoneReadAt),d=q(e=>e.agents.ceo?.name??`CEO`),[f,p]=(0,v.useState)(Date.now());(0,v.useEffect)(()=>{let e=setInterval(()=>p(Date.now()),2e4);return()=>clearInterval(e)},[]),(0,v.useEffect)(()=>{s({kind:`phone`,tab:n,requestId:t})},[n]),(0,v.useEffect)(()=>{let e=e=>{let t=e.target,n=!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`);(e.key===`Escape`||!n&&e.code===`KeyP`)&&(e.preventDefault(),bJ())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let m=Fb(c).length,h=Pb(l,u),g=[[`chat`,`💬`,d,n===`chat`?0:h],[`hires`,`📄`,`Hires`,m],[`company`,`📊`,`Company`,0],[`games`,`🎮`,`Games`,0]];return(0,K.jsx)(`div`,{className:`overlay phone-overlay`,onMouseDown:e=>e.target===e.currentTarget&&bJ(),children:(0,K.jsxs)(`div`,{className:`phone`,children:[(0,K.jsxs)(`div`,{className:`phone-status`,children:[(0,K.jsx)(`span`,{children:Lq(f)}),(0,K.jsx)(`span`,{className:`phone-notch`}),(0,K.jsx)(`span`,{children:`📶 🔋`})]}),(0,K.jsxs)(`div`,{className:`phone-screen`,children:[n===`chat`&&(0,K.jsx)(Uq,{}),n===`hires`&&(0,K.jsx)(Bq,{focusId:t}),n===`company`&&(0,K.jsx)(Gq,{}),n===`games`&&(0,K.jsx)(Fq,{game:i,onGame:a})]}),(0,K.jsx)(`nav`,{className:`phone-tabs`,children:g.map(([e,t,i,o])=>(0,K.jsxs)(`button`,{className:`phone-tab ${n===e?`phone-tab-on`:``}`,onClick:()=>e===`games`&&n===`games`?a(null):r(e),children:[(0,K.jsxs)(`span`,{className:`phone-tab-icon`,children:[t,o>0&&(0,K.jsx)(`span`,{className:`badge badge-dot`,children:o})]}),(0,K.jsx)(`span`,{children:i})]},e))}),(0,K.jsxs)(`div`,{className:`phone-hint`,children:[n===`chat`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`kbd`,{children:`Shift`}),`+`,(0,K.jsx)(`kbd`,{children:`Enter`}),` new line ·`,` `]}),n===`games`&&i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`kbd`,{children:`Backspace`}),` games ·`,` `]}),(0,K.jsx)(`kbd`,{children:`P`}),` or `,(0,K.jsx)(`kbd`,{children:`Esc`}),` to put it away`]})]})})}async function Yq(e){try{return await e()}catch{return}}var Xq=e=>e.includes(`\\`)?`\\`:`/`;function Zq({floor:e,onDone:t}){let n=q(e=>e.settings.projectsDir),[r,i]=(0,v.useState)(n),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(null),p=e=>{c(null),Yq(()=>Y.folders(e)).then(e=>{c(e?.folders??[]),e&&(o(e.root),i(e.root))})};(0,v.useEffect)(()=>p(),[]);let m=(0,v.useMemo)(()=>(s??[]).filter(e=>e.name.toLowerCase().includes(l.toLowerCase())),[s,l]),h=async(e,n)=>{f(e.path);let r=await Yq(n);f(null),r?t(r):p(a)},g=async t=>{await _T({icon:`🐙`,title:`Put ${t.name} on GitHub?`,body:(0,K.jsxs)(K.Fragment,{children:[`This creates a `,(0,K.jsx)(`b`,{children:`private`}),` GitHub repo called `,(0,K.jsx)(`code`,{children:t.name}),` and pushes what's already committed. Nothing uncommitted leaves your computer.`,!t.git&&` An empty folder gets a starter README first.`]}),confirm:`Create private repo`})&&h(t,()=>Y.publishFolder({path:t.path,visibility:`private`,...e}))};return(0,K.jsxs)(`div`,{className:`picker-mode`,children:[(0,K.jsxs)(`form`,{className:`row`,onSubmit:e=>{e.preventDefault(),p(r.trim()||void 0)},children:[(0,K.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`C:\\Projects`,title:`Your projects folder`}),(0,K.jsx)(`button`,{className:`btn btn-small`,children:`Look here`})]}),a&&a!==n&&(0,K.jsxs)(`div`,{className:`row small`,children:[(0,K.jsxs)(`span`,{className:`muted grow`,children:[`New projects are created in `,n,`.`]}),(0,K.jsxs)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void Yq(()=>Y.updateSettings({projectsDir:a})),children:[`Use `,a,` instead`]})]}),(0,K.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`Filter folders…`}),(0,K.jsxs)(`div`,{className:`repo-list folder-list`,children:[s===null&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`Looking through `,r||`your projects folder`,`…`]}),s&&m.length===0&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`No folders here`,l?` match`:``,`.`]}),m.map(t=>(0,K.jsxs)(`div`,{className:`repo-row`,children:[(0,K.jsxs)(`div`,{style:{minWidth:0},children:[(0,K.jsxs)(`b`,{children:[`📁 `,t.name]}),` `,t.floor==null?t.github?(0,K.jsxs)(`span`,{className:`chip`,children:[`🐙 `,t.github]}):(0,K.jsx)(`span`,{className:`chip chip-warn`,children:t.git?`not on GitHub`:`no git yet`}):(0,K.jsxs)(`span`,{className:`chip chip-good`,children:[`floor `,t.floor]})]}),t.floor==null?t.github?(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!!d,onClick:()=>h(t,()=>Y.connectFolder(t.path,e)),children:d===t.path?`Moving in…`:`Add floor`}):(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:!!d,onClick:()=>void g(t),children:d===t.path?`Publishing…`:`Publish to GitHub`}):(0,K.jsx)(`span`,{className:`muted small`,children:`in the office`})]},t.path))]}),(0,K.jsx)(`p`,{className:`muted small`,children:`The office never touches your work in progress: after a merge it only fast-forwards your folder when it's on the default branch with no local changes (and runs npm install if dependencies changed). Each agent works in its own git worktree of it, kept outside your project (so your dev server and linters never see them).`})]})}function Qq({floor:e,onDone:t}){let n=q(e=>e.repos),r=q(e=>e.settings.projectsDir),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(null),m=e=>{a(null),Yq(()=>Y.githubRepos(e)).then(e=>a(e??[]))};(0,v.useEffect)(()=>m(),[]);let h=new Set(n.map(e=>e.id.toLowerCase())),g=(i??[]).filter(e=>!h.has(e.nameWithOwner.toLowerCase())&&e.nameWithOwner.toLowerCase().includes(c.toLowerCase())).slice(0,60),_=async n=>{p(n);let r=await Yq(()=>Y.connectRepo(n,e));p(null),r&&t(r)};return(0,K.jsxs)(`div`,{className:`picker-mode`,children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Filter your repos…`}),(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Org (optional)`,style:{maxWidth:160}}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>m(o.trim()||void 0),children:`List`})]}),(0,K.jsxs)(`div`,{className:`repo-list folder-list`,children:[i===null&&(0,K.jsx)(`div`,{className:`muted small`,children:`Asking GitHub for your repos…`}),i&&g.length===0&&(0,K.jsx)(`div`,{className:`muted small`,children:`No matching repos.`}),g.map(e=>(0,K.jsxs)(`div`,{className:`repo-row`,children:[(0,K.jsxs)(`div`,{style:{minWidth:0},children:[(0,K.jsx)(`b`,{children:e.nameWithOwner}),` `,(0,K.jsx)(`span`,{className:`chip`,children:e.visibility.toLowerCase()}),e.description&&(0,K.jsx)(`div`,{className:`muted small`,children:e.description})]}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!!f,onClick:()=>_(e.nameWithOwner),children:f===e.nameWithOwner?`Moving in…`:`Add floor`})]},e.nameWithOwner))]}),(0,K.jsxs)(`form`,{className:`row`,onSubmit:e=>{e.preventDefault(),u.trim()&&_(u.trim())},children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`…or type owner/name`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:!u.trim()||!!f,children:`Add floor`})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`If it's already in `,r||`your projects folder`,`, that folder is used. Otherwise it's cloned to `,r,Xq(r),`<name>.`]})]})}function $q({floor:e,onDone:t}){let n=q(e=>e.settings.projectsDir),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(`private`),[l,u]=(0,v.useState)(!1),d=r.trim().replace(/[^A-Za-z0-9._-]+/g,`-`);return(0,K.jsxs)(`form`,{className:`picker-mode`,onSubmit:async n=>{if(n.preventDefault(),!d)return;u(!0);let r=await Yq(()=>Y.createRepo({name:d,description:a,visibility:s,...e}));u(!1),r&&t(r)},children:[(0,K.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Project name, e.g. island-bakery`,autoFocus:!0}),(0,K.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`One-line description (optional)`}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:s===`private`,onChange:()=>c(`private`)}),` Private`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:s===`public`,onChange:()=>c(`public`)}),` Public`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:l||!d,children:l?`Creating…`:`Create project`})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Creates `,(0,K.jsx)(`code`,{children:d?`${n}${Xq(n)}${d}`:`${n}${Xq(n)}…`}),` with a README and pushes it to a new `,s,` GitHub repo. Give the CEO a brief below and they'll plan the first milestone.`]})]})}function eJ({onConnected:e,initial:t=`folder`}){let[n,r]=(0,v.useState)(t),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),c={mission:i,autoAssign:o},l=t=>{a(``),e?.(t)};return(0,K.jsxs)(`div`,{className:`picker`,children:[(0,K.jsx)(`div`,{className:`picker-tabs`,children:[[`folder`,`📁 A folder on this computer`],[`github`,`🐙 A GitHub repo`],[`new`,`✨ Something new`]].map(([e,t])=>(0,K.jsx)(`button`,{className:`picker-tab ${n===e?`picker-tab-on`:``}`,onClick:()=>r(e),children:t},e))}),(0,K.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),rows:2,placeholder:n===`new`?`What should the team build? e.g. A cozy 3D browser game where you run a tiny island bakery.`:`Brief for the CEO (optional): what should the team work on next?`}),(0,K.jsxs)(`label`,{className:`toggle small`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`⚡ Start work automatically: free developers pick up issues as soon as they're filed (you can switch this off per floor)`]}),n===`folder`&&(0,K.jsx)(Zq,{floor:c,onDone:l}),n===`github`&&(0,K.jsx)(Qq,{floor:c,onDone:l}),n===`new`&&(0,K.jsx)($q,{floor:c,onDone:l})]})}var tJ={idle:`free`,preparing:`setting up`,working:`working`,done:`done`,error:`needs help`,stopped:`stopped`};function nJ({status:e}){return(0,K.jsx)(`span`,{className:`status status-${e}`,children:tJ[e]??e})}function rJ(e,t){if(!e)return``;let n=Math.max(0,Math.floor(((t??Date.now())-e)/1e3));return`${Math.floor(n/60)}m ${n%60}s`}function iJ({agentId:e}){let t=q(t=>t.agents[e]),n=q(t=>t.logs[e])??[],r=q(t=>t.screens[e]),i=q(t=>t.repos.find(n=>n.id===t.agents[e]?.repoId)),a=q(e=>e.agents),o=q(e=>e.settings),s=q(e=>e.clis),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[,m]=(0,v.useState)(0),h=(0,v.useRef)(null),g=(0,v.useRef)(!0);(0,v.useEffect)(()=>{let e=setInterval(()=>m(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,v.useLayoutEffect)(()=>{let e=h.current;e&&g.current&&(e.scrollTop=e.scrollHeight)},[n.length]);let _=q(e=>e.qa),y=(0,v.useMemo)(()=>i?Lb(i,jb(a,i.id),_):null,[i,a,_]),b=t?.role===`qa`,x=y?b?y.qa.filter(e=>!e.qa||e.qa.status===`needs-human`||e.qa.status===`queued`):y.backlog:[];if(!t||!i)return(0,K.jsx)(xJ,{title:`Terminal`,children:(0,K.jsx)(`p`,{className:`muted`,children:`That agent has left the building.`})});let S=async e=>{p(!0);try{await e()}catch{}finally{p(!1)}},C=Nb(t),w=t.role===`ceo`?`claude`:t.cli||o.defaultCli,T=s.find(e=>e.id===w)?.label??w,E=t.issueNumber?`https://github.com/${i.fullName}/issues/${t.issueNumber}`:null,D=C||!b&&!!t.branch&&t.status!==`idle`,O=t.prNumber?_[`${i.id}#${t.prNumber}`]:void 0;return(0,K.jsxs)(xJ,{wide:!0,accent:t.color,title:(0,K.jsxs)(`div`,{className:`term-title`,children:[(0,K.jsx)(`span`,{className:`avatar`,style:{background:t.color},children:t.name[0]}),(0,K.jsx)(`span`,{children:t.name}),(0,K.jsxs)(`span`,{className:`chip`,title:t.brief||void 0,children:[b?`🔍`:`💻`,` `,t.title||(b?`QA tester`:`Developer`),t.specialty?` · 🎯 ${t.specialty}`:``]}),(0,K.jsx)(nJ,{status:t.status}),C&&t.currentTool&&(0,K.jsxs)(`span`,{className:`muted small`,children:[vS(t.currentTool),`…`]})]}),children:[(0,K.jsxs)(`div`,{className:`term-meta`,children:[t.task===`qa`&&t.status!==`idle`?(0,K.jsxs)(`a`,{href:t.prUrl??`#`,target:`_blank`,rel:`noreferrer`,children:[`Testing PR #`,t.prNumber,`: `,t.issueTitle]}):t.task===`fix`&&t.status!==`idle`?(0,K.jsxs)(`a`,{href:t.prUrl??`#`,target:`_blank`,rel:`noreferrer`,children:[`Fixing PR #`,t.prNumber,` after QA: `,t.issueTitle]}):t.issueNumber&&t.status!==`idle`?(0,K.jsxs)(`a`,{href:E,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,t.issueNumber,`: `,t.issueTitle]}):(0,K.jsx)(`span`,{className:`muted`,children:b?`Nothing under test`:`No issue assigned`}),t.prUrl&&t.task===`issue`&&(0,K.jsxs)(`a`,{href:t.prUrl,target:`_blank`,rel:`noreferrer`,className:`chip chip-good`,children:[`PR #`,t.prNumber]}),O&&t.status!==`idle`&&(0,K.jsxs)(`span`,{className:`chip ${O.status===`passed`?`chip-good`:``}`,children:[`QA: `,O.status,O.round>1?` · round ${O.round}`:``]}),O?.commentUrl&&(0,K.jsx)(`a`,{href:O.commentUrl,target:`_blank`,rel:`noreferrer`,children:`QA report ↗`}),t.branch&&(0,K.jsx)(`code`,{children:t.branch}),o.runtime===`terminal`&&(0,K.jsxs)(`span`,{className:`chip`,title:`The coding agent in their terminal`,children:[`⌨️ `,T]}),(0,K.jsxs)(`span`,{className:`muted`,children:[(t.role===`ceo`?t.model:WE(t.model,o.runtime===`terminal`?w:`claude`,o,`claude-opus-5-5`))||`default model`,` ·`,` `,t.effort||o.defaultEffort,` effort`]}),t.startedAt&&(0,K.jsxs)(`span`,{className:`muted`,children:[`⏱ `,rJ(t.startedAt,C?null:t.endedAt)]}),t.turns>0&&(0,K.jsxs)(`span`,{className:`muted`,children:[t.turns,` turns`]}),t.costUsd>0&&(0,K.jsxs)(`span`,{className:`muted`,title:`API-equivalent cost reported by the coding agent; subscription usage is billed by plan`,children:[`≈$`,t.costUsd.toFixed(2)]})]}),t.lastError&&t.status!==`working`&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,t.lastError]}),t.brief&&(0,K.jsxs)(`details`,{className:`small job-brief`,children:[(0,K.jsxs)(`summary`,{children:[`Job description`,t.hiredBy===`ceo`?` (from the CEO)`:``]}),(0,K.jsx)(QW,{text:t.brief})]}),(0,K.jsxs)(`div`,{className:`term-split ${t.hasScreenshot?`term-split-2`:``}`,children:[t.terminal?(0,K.jsx)(QP,{agentId:t.id}):(0,K.jsxs)(`div`,{className:`term`,ref:h,onScroll:e=>{let t=e.currentTarget;g.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},children:[n.length===0&&(0,K.jsx)(`div`,{className:`term-line term-system`,children:`(no output yet)`}),n.map(e=>(0,K.jsx)(`div`,{className:`term-line term-${e.kind}`,children:e.text||` `},e.id)),C&&(0,K.jsxs)(`div`,{className:`term-line term-spin`,children:[`✻ `,t.status===`preparing`?`Setting up worktree`:vS(t.currentTool)||`Thinking`,`… (`,rJ(t.startedAt,null),`)`]})]}),t.hasScreenshot&&(0,K.jsxs)(`div`,{className:`browser`,children:[(0,K.jsxs)(`div`,{className:`browser-bar`,children:[`🔒 `,t.browserUrl??`about:blank`]}),(0,K.jsx)(`div`,{className:`browser-view`,children:(0,K.jsx)(`img`,{src:`/api/agents/${t.id}/screen?t=${r??t.screenshotAt}`,alt:`Latest browser screenshot from the agent`})}),(0,K.jsxs)(`div`,{className:`muted small`,children:[`Latest Playwright screenshot`,t.screenshotAt?` · ${new Date(t.screenshotAt).toLocaleTimeString()}`:``]})]})]}),(0,K.jsxs)(`form`,{className:`term-input`,onSubmit:e=>{e.preventDefault();let n=c.trim();n&&(l(``),S(()=>Y.message(t.id,n)))},children:[(0,K.jsx)($W,{value:c,onChange:l,"aria-label":`Message ${t.name}`,title:`Enter sends · Shift+Enter adds a new line`,placeholder:C?`Tell ${t.name} something while they work${t.terminal?` (typed into their terminal)`:``}…`:D?`Ask ${t.name} for a follow-up (resumes their session)…`:`Assign an issue to get ${t.name} started`,disabled:!D,autoFocus:!t.terminal}),(0,K.jsx)(`button`,{className:`btn`,disabled:f||!D||!c.trim(),children:`Send`})]}),(0,K.jsxs)(`div`,{className:`term-actions`,children:[C?(0,K.jsx)(`button`,{className:`btn btn-bad`,disabled:f,onClick:()=>S(()=>Y.stop(t.id)),children:`■ Stop`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:b?`Pick a pull request to test…`:`Pick an issue from the backlog…`}),x.map(e=>(0,K.jsxs)(`option`,{value:e.number,children:[b?`PR `:``,`#`,e.number,` `,e.title]},e.key))]}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:f||!u,onClick:()=>S(async()=>{b?await Y.sendToQa(i.id,Number(u)):await Y.assign(t.id,Number(u)),d(``)}),children:b?`🔍 Send to QA`:`▶ Start issue`}),t.status!==`idle`&&(0,K.jsx)(`button`,{className:`btn`,disabled:f,onClick:()=>S(()=>Y.reset(t.id)),children:`↺ Clear desk`})]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-ghost`,disabled:f,onClick:()=>{S(async()=>{await _T({tone:`danger`,icon:`👋`,title:`Let ${t.name} go?`,body:`Their worktree is removed. Branches they pushed stay on GitHub.`,confirm:`Let ${t.name} go`})&&(await Y.fireAgent(t.id),bJ())})},children:`Let go`})]})]})}var aJ=[`claude-opus-5-5`,`claude-opus-5`,`claude-fable-5-1`,`claude-sonnet-5`,`claude-haiku-4-5`],oJ=[`low`,`medium`,`high`,`xhigh`,`max`],sJ=(e,t)=>e.find(e=>e.id===t)?.label??t;function cJ({clis:e}){return(0,K.jsx)(K.Fragment,{children:[...e].sort((e,t)=>Number(t.installed)-Number(e.installed)).map(e=>(0,K.jsxs)(`option`,{value:e.id,disabled:!e.installed,children:[e.label,e.installed?``:` (not installed)`]},e.id))})}async function lJ(e){try{return await e()}catch{return}}var uJ=`Start the office with npm run dev or npm start so it can install updates and restart itself.`;function dJ({update:e}){let t=q(e=>e.officeCommit),n=q(e=>e.settings.autoUpdate),[r,i]=(0,v.useState)(!1),a=e=>{i(!0),lJ(()=>Y.updateOffice(e)).finally(()=>i(!1))},o=bE(e),s=e.state!==`none`,c=e.state===`failed`?`office-state-bad`:e.state===`none`?`office-state-ok`:`office-state-busy`,l=(t,n)=>e.launcher?t?n:void 0:uJ;return(0,K.jsxs)(`div`,{className:`card office-card`,children:[(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsx)(`span`,{className:`floor-badge office-badge`,"aria-hidden":!0,children:`🏢`}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`b`,{children:`Office`}),` `,(0,K.jsxs)(`span`,{className:`muted small`,children:[`running `,t?(0,K.jsx)(`code`,{children:t}):`an unknown commit`]}),(0,K.jsx)(`div`,{className:`small office-state ${c}`,role:`status`,children:vE(e)})]}),s&&(0,K.jsxs)(`div`,{className:`office-actions`,title:e.launcher?void 0:uJ,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:r||!xE(e),title:l(xE(e),`Start nothing new, let running sessions finish, then update and restart the office`),onClick:()=>a(`now`),children:`Update now`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:r||!SE(e),title:l(SE(e),`Keep working; ask again in 2 hours or when a newer commit lands`),onClick:()=>a(`later`),children:`Later`})]})]}),e.detail&&e.state!==`failed`&&(0,K.jsx)(`div`,{className:`muted small`,children:e.detail}),o&&e.running>0&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`Sessions still running at `,new Date(o).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),` are stopped, and their work goes back to the queue.`]}),!e.launcher&&s&&(0,K.jsx)(`div`,{className:`muted small`,children:uJ}),typeof n==`boolean`&&(0,K.jsxs)(`label`,{className:`toggle`,title:`When an update is ready, start nothing new, let running sessions finish, then update and restart the office`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>void lJ(()=>Y.updateSettings({autoUpdate:e.target.checked}))}),` Update automatically`]})]})}function fJ({repo:e,all:t}){let n=q(e=>e.agents),r=q(e=>e.goToFloor),i=q(e=>e.openOverlay),a=q(e=>!!e.officeUpdate)&&!!e.folderSync?.startsWith(`update ready`),o=jb(n,e.id),s=t.filter(t=>t.id!==e.id),c=t=>void lJ(()=>Y.updateRepo(e.id,t));return(0,K.jsxs)(`div`,{className:`card floor-card`,style:{"--accent":e.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.floor}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:(0,K.jsx)(`b`,{children:e.fullName})}),e.summary&&(0,K.jsxs)(`div`,{className:`small`,children:[`🧠 `,e.summary]}),(0,K.jsxs)(`div`,{className:`muted small`,children:[o.length,` agents · `,e.issues.length,` open issues · `,e.pulls.filter(e=>e.state===`OPEN`).length,` open PRs · default branch `,(0,K.jsx)(`code`,{children:e.defaultBranch}),e.cloneStatus!==`ready`&&` · checkout: ${e.cloneStatus}`]}),(0,K.jsxs)(`div`,{className:`muted small`,title:e.localPath?`Your own project folder`:`A clone the office manages`,children:[`📁 `,(0,K.jsx)(`code`,{children:e.checkoutPath}),a?` · the office's own folder, updated from the Office row`:e.folderSync&&` · ${e.folderSync}`,` `,(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,title:`Fast-forward it to GitHub's default branch, when that's safe`,onClick:()=>void lJ(()=>Y.syncFolder(e.id)),children:`⟳ Sync now`})]}),e.cloneError&&(0,K.jsxs)(`div`,{className:`term-error small`,children:[`clone failed: `,e.cloneError]}),e.syncError&&(0,K.jsxs)(`div`,{className:`term-error small`,children:[`sync failed: `,e.syncError]})]}),(0,K.jsx)(`input`,{type:`color`,value:e.color,onChange:e=>c({color:e.target.value}),title:`Floor colour`}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>r(e.floor),children:`Visit`})]}),(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.autoAssign,onChange:e=>c({autoAssign:e.target.checked})}),` ⚡ Auto-assign issues`]}),(0,K.jsxs)(`label`,{className:`toggle`,title:`Merge a PR as soon as QA has signed off on its latest commit and GitHub's checks are green`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.autoMerge,onChange:e=>c({autoMerge:e.target.checked})}),` 🔀 Auto-merge`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.browserTesting,onChange:e=>c({browserTesting:e.target.checked})}),` 🌐 Browser testing (Playwright MCP)`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>{_T({tone:`danger`,title:`Disconnect ${e.fullName}?`,body:`Everyone on this floor is let go. Nothing is deleted on GitHub, and ${e.localPath?`your folder stays exactly as it is`:`the local clone stays on disk`}.`,confirm:`Disconnect`}).then(t=>t&&lJ(()=>Y.disconnectRepo(e.id)))},children:`Disconnect`})]}),s.length>0&&(0,K.jsxs)(`div`,{className:`row wrap links`,children:[(0,K.jsx)(`span`,{className:`muted small`,children:`🔗 Agents here may read:`}),s.map(t=>(0,K.jsxs)(`label`,{className:`toggle small`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.links.includes(t.id),onChange:n=>c({links:n.target.checked?[...e.links,t.id]:e.links.filter(e=>e!==t.id)})}),t.fullName]},t.id))]}),(0,K.jsxs)(`details`,{className:`small preview-details`,children:[(0,K.jsxs)(`summary`,{children:[`🖥️ App preview · `,(0,K.jsx)(NE,{status:e.preview.status}),e.previewConfig.command?(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(`code`,{children:e.previewConfig.command})]}):` auto-detected command`]}),(0,K.jsx)(IE,{repo:e}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`app`,repoId:e.id}),children:`Open the app viewer`})]})]})}function pJ(){let e=q(e=>e.repos),t=q(e=>e.officeUpdate);return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{children:[t&&(0,K.jsx)(dJ,{update:t}),(0,K.jsx)(`h3`,{className:`section`,children:`🏢 Floors`}),e.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No floors yet. Add a project →`}),[...e].sort((e,t)=>e.floor-t.floor).map(t=>(0,K.jsx)(fJ,{repo:t,all:e},t.id))]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`➕ Add a project`}),(0,K.jsx)(eJ,{})]})]})}function mJ({repo:e}){let[t,n]=(0,v.useState)(e.mission);return(0,v.useEffect)(()=>n(e.mission),[e.mission]),(0,K.jsxs)(`div`,{className:`card floor-card`,style:{"--accent":e.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.floor}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`b`,{children:e.fullName}),(0,K.jsx)(`div`,{className:`muted small`,children:e.summary?`🧠 ${e.summary}`:`The CEO has not studied this floor yet.`})]}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void lJ(()=>Y.onboardFloor(e.id)),title:`Study the repo again and rethink the team`,children:`Re-study`})]}),(0,K.jsx)(`textarea`,{value:t,onChange:e=>n(e.target.value),rows:2,placeholder:`Brief: what should this floor build next? The CEO turns it into issues and a team.`}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:t===e.mission,onClick:()=>void lJ(()=>Y.updateRepo(e.id,{mission:t})),children:`Save brief`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!t.trim(),onClick:()=>void lJ(()=>Y.planFloor(e.id,t)),children:`🧠 Ask the CEO to plan it`})]}),(0,K.jsxs)(`details`,{className:`small`,children:[(0,K.jsxs)(`summary`,{children:[`QA brief`,e.qaBrief?``:` (none yet)`]}),(0,K.jsx)(`textarea`,{rows:4,defaultValue:e.qaBrief,placeholder:`What QA testers must check on every PR for this project.`,onBlur:t=>t.target.value!==e.qaBrief&&void lJ(()=>Y.updateRepo(e.id,{qaBrief:t.target.value}))},e.qaBrief)]})]})}function hJ(){let e=q(e=>e.agents.ceo),t=q(e=>e.logs.ceo)??[],n=q(e=>e.ceo),r=q(e=>e.repos),i=q(e=>e.requests),a=q(e=>e.openOverlay),[o,s]=(0,v.useState)(``),c=(0,v.useRef)(null);if((0,v.useLayoutEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[t.length]),!e)return(0,K.jsx)(`p`,{className:`muted`,children:`The corner office is empty.`});let l=e.status===`working`,u=Fb(i),d=i.filter(e=>e.status!==`pending`).slice(-6).reverse();return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`avatar`,style:{background:e.color},children:e.name[0]}),(0,K.jsx)(`input`,{className:`inline`,defaultValue:e.name,style:{maxWidth:140,fontWeight:700},onBlur:t=>t.target.value.trim()&&t.target.value!==e.name&&void lJ(()=>Y.updateAgent(e.id,{name:t.target.value}))}),(0,K.jsx)(`span`,{className:`muted small`,children:`CEO`}),(0,K.jsx)(nJ,{status:e.status}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`input`,{className:`inline`,list:`models-ceo`,defaultValue:e.model,title:`The CEO's model`,style:{maxWidth:150},onBlur:t=>t.target.value!==e.model&&void lJ(()=>Y.updateAgent(e.id,{model:t.target.value}))}),(0,K.jsx)(`datalist`,{id:`models-ceo`,children:aJ.map(e=>(0,K.jsx)(`option`,{value:e},e))}),(0,K.jsx)(`select`,{value:e.effort,title:`The CEO's effort`,onChange:t=>void lJ(()=>Y.updateAgent(e.id,{effort:t.target.value})),style:{width:`auto`},children:oJ.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`small`,children:[(0,K.jsx)(`b`,{children:`Now:`}),` `,l?n.job?.label:`free`,n.queue.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`· `,(0,K.jsx)(`b`,{children:`Up next:`}),` `,n.queue.map(e=>e.label).join(` → `)]})]}),(0,K.jsx)(`div`,{className:`muted small`,children:n.nextReviewAt?`Next company review around ${new Date(n.nextReviewAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} (skipped if nothing changed).`:`Periodic reviews are off (Settings).`}),e.terminal?(0,K.jsx)(QP,{agentId:e.id,className:`ceo-term`}):(0,K.jsxs)(`div`,{className:`term ceo-term`,ref:c,children:[t.length===0&&(0,K.jsx)(`div`,{className:`term-line term-system`,children:`(nothing yet)`}),t.map(e=>(0,K.jsx)(`div`,{className:`term-line term-${e.kind}`,children:e.text||` `},e.id))]}),(0,K.jsxs)(`form`,{className:`row`,onSubmit:e=>{if(e.preventDefault(),!o.trim())return;let t=o;s(``),lJ(()=>Y.messageCeo(t))},children:[(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Message ${e.name} (or press P anywhere for your phone)…`}),(0,K.jsx)(`button`,{className:`btn`,disabled:!o.trim(),children:`Send`})]}),(0,K.jsxs)(`div`,{className:`row`,children:[l&&(0,K.jsx)(`button`,{className:`btn btn-small btn-bad`,onClick:()=>void lJ(()=>Y.stop(e.id)),children:`■ Stop`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:r.length===0,onClick:()=>void lJ(()=>Y.ceoReview()),children:`🔎 Review the company now`}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>a({kind:`phone`,tab:`chat`}),children:`📱 Open the phone`})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`section`,children:[`📄 Hiring `,u.length>0&&(0,K.jsx)(`span`,{className:`badge`,children:u.length})]}),u.length===0&&(0,K.jsx)(`p`,{className:`muted small`,children:`No proposals waiting. The CEO proposes hires when they study a floor or notice the team can't cover the work.`}),u.map(e=>(0,K.jsx)(zq,{req:e},e.id)),d.length>0&&(0,K.jsxs)(`details`,{className:`small`,style:{marginBottom:12},children:[(0,K.jsx)(`summary`,{children:`Recent decisions`}),d.map(e=>(0,K.jsx)(zq,{req:e},e.id))]}),(0,K.jsx)(`h3`,{className:`section`,children:`🗺️ Project briefs`}),r.length===0&&(0,K.jsx)(`p`,{className:`muted small`,children:`Connect a repo first.`}),[...r].sort((e,t)=>e.floor-t.floor).map(e=>(0,K.jsx)(mJ,{repo:e},e.id))]})]})}function gJ(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.settings),r=q(e=>e.clis),i=q(e=>e.openOverlay),a=n.runtime===`terminal`,o=e=>a?e.cli||n.defaultCli:`claude`,[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(null);return e.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`Connect a repo first; agents need a floor to sit on.`}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`datalist`,{id:`models`,children:aJ.map(e=>(0,K.jsx)(`option`,{value:e},e))}),[...e].sort((e,t)=>e.floor-t.floor).map(e=>{let d=jb(t,e.id);return(0,K.jsxs)(`div`,{className:`card floor-card`,style:{"--accent":e.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.floor}),(0,K.jsx)(`b`,{className:`grow`,children:e.fullName}),(0,K.jsx)(`input`,{value:s[e.id]??``,onChange:t=>c({...s,[e.id]:t.target.value}),placeholder:`Name (optional)`,style:{maxWidth:160}}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:d.filter(e=>e.role===`dev`).length>=12,onClick:()=>void lJ(()=>Y.hireAgent(e.id,{name:s[e.id]||void 0,role:`dev`})).then(()=>c({...s,[e.id]:``})),children:`+ Developer`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:d.filter(e=>e.role===`qa`).length>=3,onClick:()=>void lJ(()=>Y.hireAgent(e.id,{name:s[e.id]||void 0,role:`qa`})).then(()=>c({...s,[e.id]:``})),children:`+ QA tester`})]}),d.length===0&&(0,K.jsx)(`div`,{className:`muted small`,children:`No one works here yet.`}),(0,K.jsx)(`table`,{className:`team`,children:(0,K.jsx)(`tbody`,{children:d.map(e=>(0,K.jsxs)(v.Fragment,{children:[(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{children:(0,K.jsx)(`span`,{className:`dot`,style:{background:e.color}})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,defaultValue:e.name,onBlur:t=>t.target.value.trim()&&t.target.value!==e.name&&void lJ(()=>Y.updateAgent(e.id,{name:t.target.value}))})}),(0,K.jsx)(`td`,{className:`nowrap`,children:(0,K.jsxs)(`span`,{className:`chip`,title:e.hiredBy===`ceo`?`Hired on the CEO's proposal`:void 0,children:[e.role===`qa`?`🔍 QA`:`💻 Dev`,e.hiredBy===`ceo`?` · 🧠`:``]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,defaultValue:e.title,placeholder:e.role===`qa`?`QA tester`:`Developer`,title:`Job title`,onBlur:t=>t.target.value!==e.title&&void lJ(()=>Y.updateAgent(e.id,{title:t.target.value}))},`t-${e.title}`)}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,style:{width:96},defaultValue:e.specialty,placeholder:`specialty`,title:`Issues labelled swarm:<specialty> go to this agent first`,onBlur:t=>t.target.value!==e.specialty&&void lJ(()=>Y.updateAgent(e.id,{specialty:t.target.value}))},`s-${e.specialty}`)}),(0,K.jsx)(`td`,{children:(0,K.jsxs)(`button`,{className:`btn btn-small btn-ghost`,title:`Job description and look`,onClick:()=>u(l===e.id?null:e.id),children:[`📝`,e.brief?``:` +`]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(nJ,{status:e.status})}),(0,K.jsx)(`td`,{className:`small`,children:e.status===`idle`?(0,K.jsx)(`span`,{className:`muted`,children:`—`}):e.task===`qa`?`testing PR #${e.prNumber}`:e.task===`fix`?`fixing PR #${e.prNumber}`:`#${e.issueNumber??``} ${e.issueTitle??``}`.slice(0,40)}),a&&(0,K.jsx)(`td`,{children:(0,K.jsxs)(`select`,{value:e.cli,title:`Their coding agent`,style:{width:112},onChange:t=>void lJ(()=>Y.updateAgent(e.id,{cli:t.target.value})),children:[(0,K.jsxs)(`option`,{value:``,children:[sJ(r,n.defaultCli),` (default)`]}),(0,K.jsx)(cJ,{clis:r})]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,style:{minWidth:110},list:o(e)===`claude`?`models`:void 0,defaultValue:e.model,placeholder:WE(``,o(e),n,aJ[0])||`agent default`,title:`Their model ('' = the default for their coding agent)`,onBlur:t=>t.target.value!==e.model&&void lJ(()=>Y.updateAgent(e.id,{model:t.target.value}))},`m-${e.model}-${o(e)}`)}),(0,K.jsx)(`td`,{children:(0,K.jsxs)(`select`,{value:e.effort,title:`Their effort`,style:{width:124},onChange:t=>void lJ(()=>Y.updateAgent(e.id,{effort:t.target.value})),children:[(0,K.jsxs)(`option`,{value:``,children:[`default (`,n.defaultEffort,`)`]}),oJ.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})}),(0,K.jsxs)(`td`,{className:`nowrap`,children:[(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`terminal`,agentId:e.id}),children:`Terminal`}),` `,(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void _T({tone:`danger`,icon:`👋`,title:`Let ${e.name} go?`,body:`Their worktree is removed. Branches they pushed stay on GitHub.`,confirm:`Let ${e.name} go`}).then(t=>t&&lJ(()=>Y.fireAgent(e.id))),children:`Let go`})]})]}),l===e.id&&(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{}),(0,K.jsxs)(`td`,{colSpan:a?11:10,children:[(0,K.jsxs)(`label`,{className:`row small`,children:[(0,K.jsx)(`span`,{children:`Drawn as`}),(0,K.jsxs)(`select`,{value:e.look,title:`Character look`,style:{width:`auto`},onChange:t=>void lJ(()=>Y.updateAgent(e.id,{look:t.target.value})),children:[(0,K.jsx)(`option`,{value:`feminine`,children:`👩 She`}),(0,K.jsx)(`option`,{value:`masculine`,children:`👨 He`})]})]}),(0,K.jsx)(`textarea`,{rows:3,defaultValue:e.brief,placeholder:`What ${e.name} owns on this project and how they should work. It's added to their instructions.`,onBlur:t=>t.target.value!==e.brief&&void lJ(()=>Y.updateAgent(e.id,{brief:t.target.value}))},`b-${e.brief}`)]})]})]},e.id))})})]},e.id)})]})}function _J({initialRepo:e}){let t=q(e=>e.repos),n=q(e=>e.agents),[r,i]=(0,v.useState)(e??t[0]?.id??``),a=t.find(e=>e.id===r),o=(0,v.useMemo)(()=>jb(n,r),[n,r]);return t.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`Connect a repo first.`}):(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`📝 File a new issue`}),(0,K.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:t.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[`Floor `,e.floor,` · `,e.fullName]},e.id))}),a&&(0,K.jsx)(BE,{repoId:a.id,agents:o},a.id)]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsxs)(`h3`,{children:[`Open issues on `,a?.fullName]}),(0,K.jsxs)(`div`,{className:`repo-list tall`,children:[a?.issues.length===0&&(0,K.jsx)(`div`,{className:`muted small`,children:`None. Nice.`}),a?.issues.map(e=>{let t=o.find(t=>t.role===`dev`&&t.issueNumber===e.number&&t.status!==`idle`);return(0,K.jsxs)(`div`,{className:`repo-row`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title,e.labels.length>0&&(0,K.jsx)(`div`,{className:`muted small`,children:e.labels.join(`, `)})]}),t?(0,K.jsxs)(`span`,{className:`agent-chip`,children:[(0,K.jsx)(`span`,{className:`dot`,style:{background:t.color}}),t.name]}):(0,K.jsxs)(`select`,{value:``,onChange:t=>t.target.value&&void lJ(()=>Y.assign(t.target.value,e.number)),children:[(0,K.jsx)(`option`,{value:``,children:`Assign…`}),o.filter(e=>e.role===`dev`&&e.status!==`working`&&e.status!==`preparing`).map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]},e.number)})]})]})]})}function vJ(){let e=q(e=>e.settings),t=q(e=>e.clis),n=q(e=>e.user),r=q(e=>e.workspaceRoot),i=q(e=>e.demo),a=e=>void lJ(()=>Y.updateSettings(e)),o=e.runtime===`terminal`,s=o?e.defaultCli:`claude`;return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`🧠 Agents`}),o&&(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Default coding agent`}),(0,K.jsx)(`select`,{value:e.defaultCli,onChange:e=>a({defaultCli:e.target.value}),children:(0,K.jsx)(cJ,{clis:t})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsxs)(`span`,{children:[`Default model`,o?` for ${sJ(t,e.defaultCli)}`:``]}),(0,K.jsx)(`input`,{list:s===`claude`?`models-s`:void 0,defaultValue:e.defaultModel,placeholder:`the agent's own default`,onBlur:t=>t.target.value!==e.defaultModel&&a({defaultModel:t.target.value})},`${e.defaultCli}:${e.defaultModel}`),(0,K.jsx)(`datalist`,{id:`models-s`,children:aJ.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Default effort`}),(0,K.jsx)(`select`,{value:e.defaultEffort,onChange:e=>a({defaultEffort:e.target.value}),children:oJ.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsx)(`p`,{className:`muted small`,children:o?`Each worker can use their own coding agent, model and effort (Team tab); the CEO always runs Claude Code. Claude Code reports every step; Codex and OpenCode are experimental: the office sees their task rather than each step.`:`The Agent SDK runs Claude Code. Each worker can use their own model and effort (Team tab).`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Session limit`}),(0,K.jsx)(`input`,{type:`number`,min:0,placeholder:`No limit`,defaultValue:e.sessionLimit||``,onBlur:e=>a({sessionLimit:Number(e.target.value)||0})})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`Leave empty so every agent with work runs at once. Agents on the same coding agent share its subscription's usage limits, and each one is its own process on this PC, so set a limit if you hit either.`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Sessions while pacing`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:32,defaultValue:e.pacingSessions,onBlur:t=>Number(t.target.value)!==e.pacingSessions&&a({pacingSessions:Number(t.target.value)||3})},e.pacingSessions)]}),(0,K.jsx)(`p`,{className:`muted small`,children:`When Claude warns that usage is getting high, new issues only start while fewer sessions than this are running. QA, fixes and the CEO carry on.`}),(0,K.jsx)(`h3`,{children:`🧠 The CEO`}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.hiring===`approve`,onChange:()=>a({hiring:`approve`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`I approve every hire`}),` (recommended): the CEO's proposals wait on your phone.`]})]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.hiring===`auto`,onChange:()=>a({hiring:`auto`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Auto-approve`}),` while a floor has fewer people than the team cap. Anything beyond the cap still waits for you.`]})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Team cap per floor`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:15,defaultValue:e.teamCap,onBlur:e=>a({teamCap:Number(e.target.value)})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Company review every (minutes, 0 = off)`}),(0,K.jsx)(`input`,{type:`number`,min:0,max:1440,defaultValue:e.ceoHeartbeatMin,onBlur:e=>a({ceoHeartbeatMin:Number(e.target.value)})})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`A review is skipped when nothing changed since the last one. The CEO's own model and effort are on the CEO tab.`})]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`⌨️ How agents run`}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.runtime===`terminal`,onChange:()=>a({runtime:`terminal`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Real terminals`}),` (recommended): every agent is its actual coding agent running in its own terminal. Open a desk to watch it live or type into it.`]})]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.runtime===`sdk`,onChange:()=>a({runtime:`sdk`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Agent SDK`}),`: Claude Code through the Claude Agent SDK, shown as a log of its steps. Claude Code only.`]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`Agents work like your own coding agents in a terminal, with your skills, MCP servers and settings, and don't stop to ask. The office's workflow (branches, pull requests, QA reporting back) is in their instructions.`}),(0,K.jsx)(`h3`,{children:`🏢 Company`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Your name`}),(0,K.jsx)(`input`,{defaultValue:e.managerName,placeholder:n??`Boss`,onBlur:t=>t.target.value!==e.managerName&&a({managerName:t.target.value})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Company name`}),(0,K.jsx)(`input`,{defaultValue:e.companyName,placeholder:`cubefarm`,onBlur:t=>t.target.value!==e.companyName&&a({companyName:t.target.value})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Projects folder (new projects are created here)`}),(0,K.jsx)(`input`,{defaultValue:e.projectsDir,onBlur:t=>t.target.value.trim()&&t.target.value!==e.projectsDir&&a({projectsDir:t.target.value})},e.projectsDir)]}),(0,K.jsx)(`div`,{className:`row`,children:(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>a({tutorialStep:0}),children:`🧭 Replay the tour`})}),(0,K.jsx)(`h3`,{children:`ℹ️ Environment`}),(0,K.jsxs)(`div`,{className:`small`,children:[`GitHub: `,(0,K.jsx)(`b`,{children:n??`not signed in`}),i&&` (demo)`,(0,K.jsx)(`br`,{}),`Agent desks: `,(0,K.jsx)(`code`,{children:r})]})]})]})}function yJ({initialTab:e,initialRepo:t}){let[n,r]=(0,v.useState)(e??`floors`),i=q(e=>Fb(e.requests).length),a=[[`floors`,`🏢 Floors & repos`],[`ceo`,`🧠 CEO & hiring${i?` (${i})`:``}`],[`team`,`👩💻 Team`],[`issues`,`📝 Issues`],[`settings`,`⚙️ Settings`]];return(0,K.jsxs)(xJ,{wide:!0,title:`🧑💼 Manager's console`,children:[(0,K.jsx)(`div`,{className:`tabs`,children:a.map(([e,t])=>(0,K.jsx)(`button`,{className:`tab ${n===e?`tab-on`:``}`,onClick:()=>r(e),children:t},e))}),(0,K.jsxs)(`div`,{className:`tab-body`,children:[n===`floors`&&(0,K.jsx)(pJ,{}),n===`ceo`&&(0,K.jsx)(hJ,{}),n===`team`&&(0,K.jsx)(gJ,{}),n===`issues`&&(0,K.jsx)(_J,{initialRepo:t}),n===`settings`&&(0,K.jsx)(vJ,{})]})]})}function bJ(){q.getState().openOverlay(null)}function xJ({title:e,children:t,wide:n,accent:r,className:i,onClose:a}){return(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),a?a():bJ())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,K.jsx)(`div`,{className:`overlay`,onMouseDown:e=>e.target===e.currentTarget&&bJ(),children:(0,K.jsxs)(`div`,{className:`panel ${n?`panel-wide`:``} ${i??``}`,style:{"--accent":r??`#ff8a5b`},children:[(0,K.jsxs)(`div`,{className:`panel-head`,children:[(0,K.jsx)(`div`,{className:`panel-title`,children:e}),(0,K.jsx)(`button`,{className:`panel-x`,onClick:()=>a?a():bJ(),"aria-label":`Close`,children:`✕`})]}),(0,K.jsx)(`div`,{className:`panel-body`,children:t})]})})}function SJ(){let{volume:e,muted:t}=(0,v.useSyncExternalStore)(Xy,Yy);return(0,K.jsxs)(`div`,{className:`row wrap sound`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!t,onChange:e=>Zy({muted:!e.target.checked})}),` `,t?`🔇`:`🔊`,` Sound`]}),(0,K.jsxs)(`label`,{className:`sound-volume`,children:[(0,K.jsx)(`span`,{className:`muted small`,children:`Volume`}),(0,K.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e,disabled:t,"aria-label":`Volume`,onChange:e=>Zy({volume:Number(e.target.value)})}),(0,K.jsxs)(`span`,{className:`small sound-pct`,children:[e,`%`]})]})]})}function CJ(){let{sensitivity:e,invertY:t,grabOnClose:n,set:r}=hT();return(0,K.jsxs)(`div`,{className:`mouse-settings`,children:[(0,K.jsxs)(`label`,{className:`mouse-sens`,children:[(0,K.jsx)(`span`,{children:`Mouse sensitivity`}),(0,K.jsx)(`input`,{type:`range`,min:uT,max:3,step:.05,value:e,onChange:e=>r({sensitivity:Number(e.target.value)})}),(0,K.jsxs)(`b`,{children:[e.toFixed(2),`×`]}),e!==1&&(0,K.jsx)(`button`,{className:`btn btn-ghost btn-small`,onClick:()=>r({sensitivity:1}),children:`Reset`})]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>r({invertY:e.target.checked})}),` Invert Y (push the mouse forward to look down)`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r({grabOnClose:e.target.checked})}),` Grab the mouse when panels close`]})]})}function wJ(){return(0,K.jsx)(xJ,{title:`How the office works`,children:(0,K.jsxs)(`div`,{className:`help`,children:[(0,K.jsx)(`h3`,{children:`Moving around`}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`kbd`,{children:`W`}),(0,K.jsx)(`kbd`,{children:`A`}),(0,K.jsx)(`kbd`,{children:`S`}),(0,K.jsx)(`kbd`,{children:`D`}),` walk · `,(0,K.jsx)(`kbd`,{children:`Shift`}),` run · mouse to look · `,(0,K.jsx)(`kbd`,{children:`E`}),` or left click interacts with whatever the crosshair is on (the first click only grabs the mouse) · `,(0,K.jsx)(`kbd`,{children:`Esc`}),` frees the mouse. Closing a panel or changing floor grabs it again.`]}),(0,K.jsx)(CJ,{}),(0,K.jsx)(`h3`,{children:`Balls`}),(0,K.jsxs)(`p`,{children:[`Walk into a ball to push it, or aim at one and press `,(0,K.jsx)(`kbd`,{children:`E`}),` (or click) to pick it up. Click or press `,(0,K.jsx)(`kbd`,{children:`F`}),` to throw: a tap lobs it, holding charges a harder throw. `,(0,K.jsx)(`kbd`,{children:`G`}),` drops it at your feet. With a ball in hand, `,(0,K.jsx)(`kbd`,{children:`E`}),` still works on desks, boards and the elevator (the ball drops when a panel opens), and `,(0,K.jsx)(`kbd`,{children:`E`}),` on another ball swaps them.`]}),(0,K.jsx)(`h3`,{children:`Foam blasters`}),(0,K.jsxs)(`p`,{children:[`Every floor has a rack of foam blasters by the south wall: aim at it and press `,(0,K.jsx)(`kbd`,{children:`E`}),` to take one. `,(0,K.jsx)(`b`,{children:`Fire`}),`: click or `,(0,K.jsx)(`kbd`,{children:`F`}),` (12 darts, up to four a second). `,(0,K.jsx)(`b`,{children:`Reload`}),`: `,(0,K.jsx)(`kbd`,{children:`R`}),`. `,(0,K.jsx)(`b`,{children:`Drop`}),`: `,(0,K.jsx)(`kbd`,{children:`G`}),`, then `,(0,K.jsx)(`kbd`,{children:`E`}),` picks it up again. Darts stick to walls, boards and screens when they hit square on and bounce off everything else. They never open anything, and the blasters go back on the rack when you change floors.`]}),(0,K.jsx)(`h3`,{children:`Sound`}),(0,K.jsxs)(`p`,{children:[`The office chimes when a PR is ready to merge, fails QA or gets merged, when someone hits an error and when a new teammate arrives. `,(0,K.jsx)(`kbd`,{children:`M`}),` mutes or unmutes anywhere.`]}),(0,K.jsx)(SJ,{}),(0,K.jsx)(`h3`,{children:`The building`}),(0,K.jsx)(`p`,{children:`The ground floor is the lobby: your office is the glass room at the back left, the CEO's corner office is at the back right, and candidates wait on the chairs by the entrance. Every connected GitHub repo gets its own floor. Walk into the elevator in the middle of the south wall to travel.`}),(0,K.jsx)(`h3`,{children:`Your phone`}),(0,K.jsxs)(`p`,{children:[`Press `,(0,K.jsx)(`kbd`,{children:`P`}),` anywhere to pull out your phone. Text the CEO, approve or decline the people they want to hire, see every project at a glance, or play Cubetris, Cable Snake or look after your Desk Pet while the team works. The red badge counts decisions and messages waiting for you. In the chat, and in an agent's terminal, `,(0,K.jsx)(`kbd`,{children:`Enter`}),` sends and `,(0,K.jsx)(`kbd`,{children:`Shift`}),`+`,(0,K.jsx)(`kbd`,{children:`Enter`}),` starts a new line.`]}),(0,K.jsx)(`h3`,{children:`Who's working`}),(0,K.jsxs)(`p`,{children:[`The list at the top right shows everyone who is working right now (on this floor, or on every floor from the lobby) with their latest thought, reply or tool call. Click someone to watch their screen. `,(0,K.jsx)(`kbd`,{children:`Tab`}),` `,`shows or hides it.`]}),(0,K.jsx)(`h3`,{children:`The CEO`}),(0,K.jsx)(`p`,{children:`The CEO studies every new floor, writes its QA brief, gives each agent a job that fits the project, turns your project briefs into issues and proposes hires. Hires wait for your approval unless you switch hiring to auto in the manager's console.`}),(0,K.jsx)(`h3`,{children:`Your team`}),(0,K.jsxs)(`p`,{children:[`Each agent is a real coding agent running in its own terminal, working in its own git worktree. Walk up behind them to read their laptop, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` (or click) on a desk to open their terminal: watch it live, type into it, send them instructions, stop them or hand them another issue. Aim at an empty desk and press `,(0,K.jsx)(`kbd`,{children:`E`}),` to hire, or click it and confirm.`]}),(0,K.jsx)(`h3`,{children:`The QA lab`}),(0,K.jsx)(`p`,{children:`The testers in lab coats along the east wall check every pull request before it can be merged. They run the tests, click through the change in a real browser, and post a report with screenshots on the PR. If a PR fails, it goes back to the developer who wrote it, who fixes it and sends it back to QA.`}),(0,K.jsx)(`h3`,{children:`The whiteboard`}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`b`,{children:`Backlog`}),`: open issues nobody has picked up. `,(0,K.jsx)(`b`,{children:`In progress`}),`: developers at work. `,(0,K.jsx)(`b`,{children:`In QA`}),`: being tested or fixed. `,(0,K.jsx)(`b`,{children:`Ready to merge`}),`: QA passed, waiting for you. Press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click the board to assign, send to QA, merge and file new issues.`]})]})})}function TJ(){let e=q(e=>e.overlay);if(!e)return null;switch(e.kind){case`terminal`:return e.agentId===`ceo`?(0,K.jsx)(yJ,{initialTab:`ceo`}):(0,K.jsx)(iJ,{agentId:e.agentId});case`phone`:return(0,K.jsx)(Jq,{tab:e.tab,requestId:e.requestId});case`kanban`:return(0,K.jsx)(HE,{repoId:e.repoId});case`app`:return(0,K.jsx)(LE,{repoId:e.repoId});case`elevator`:return(0,K.jsx)(RE,{});case`manager`:return(0,K.jsx)(yJ,{initialTab:e.tab,initialRepo:e.repoId});case`help`:return(0,K.jsx)(wJ,{})}}var EJ=[`Pixel & Pine`,`Byte Bakery`,`Night Owl Software`,`Tiny Rocket Co.`,`Moonbeam Works`,`Happy Path Inc.`,`Merge Conflict Ltd.`,`Quokka Labs`,`Blue Kettle Studio`,`Paper Plane Software`],DJ=[`Morgan`,`Avery`,`Jordan`,`Riley`,`Quinn`,`Harper`,`Rowan`,`Sasha`,`Casey`,`Jamie`,`Alex`,`Robin`],OJ=[`#e63946`,`#3a86ff`,`#06d6a0`,`#ffbe0b`,`#9b5de5`,`#fb5607`],kJ=[`Welcome`,`You`,`Your CEO`,`First project`,`Ready`],AJ=(e,t)=>{let n=e.filter(e=>e!==t);return n[Math.floor(Math.random()*n.length)]};function jJ({color:e,look:t}){return(0,K.jsxs)(`svg`,{viewBox:`0 0 120 120`,className:`ceo-portrait`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`60`,cy:`60`,r:`58`,fill:`#e6dcff`,stroke:`#1f1d2b`,strokeWidth:`3`}),t===`feminine`&&(0,K.jsx)(`ellipse`,{cx:`60`,cy:`58`,rx:`27`,ry:`32`,fill:`#2b2118`,stroke:`#1f1d2b`,strokeWidth:`2.5`}),(0,K.jsx)(`path`,{d:`M22 118 C24 88 40 80 60 80 C80 80 96 88 98 118 Z`,fill:`#2b2d42`,stroke:`#1f1d2b`,strokeWidth:`3`}),(0,K.jsx)(`path`,{d:`M50 81 L60 96 L70 81 Z`,fill:`#f8f9fa`}),(0,K.jsx)(`path`,{d:`M57 84 L63 84 L65 108 L60 113 L55 108 Z`,fill:e,stroke:`#1f1d2b`,strokeWidth:`1.5`}),(0,K.jsx)(`circle`,{cx:`60`,cy:`52`,r:`22`,fill:`#f1c27d`,stroke:`#1f1d2b`,strokeWidth:`3`}),(0,K.jsx)(`path`,{d:`M38 50 C38 30 82 30 82 50 C74 40 46 40 38 50 Z`,fill:`#2b2118`,stroke:`#1f1d2b`,strokeWidth:`2`}),(0,K.jsx)(`circle`,{cx:`52`,cy:`54`,r:`2.6`,fill:`#1f1d2b`}),(0,K.jsx)(`circle`,{cx:`68`,cy:`54`,r:`2.6`,fill:`#1f1d2b`}),(0,K.jsx)(`path`,{d:`M53 62 Q60 68 67 62`,fill:`none`,stroke:`#1f1d2b`,strokeWidth:`2.4`,strokeLinecap:`round`})]})}function MJ(){let e=q(e=>e.user),t=q(e=>e.demo),n=q(e=>e.ghReady),r=q(e=>e.ghError),i=q(e=>e.agents.ceo),a=q(e=>e.start),[o,s]=(0,v.useState)(0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(()=>EJ[Math.floor(Math.random()*EJ.length)]),[f,p]=(0,v.useState)(i?.name??`Morgan`),[m,h]=(0,v.useState)(i?.look??`masculine`),[g,_]=(0,v.useState)(i?.color??OJ[0]),[y,b]=(0,v.useState)(`approve`),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1),T=c.trim()||e||`Boss`,E=f.trim()||`Morgan`,D=u.trim()||EJ[0],O=()=>Y.setup({managerName:T,companyName:D,hiring:y,ceoName:E,ceoLook:m,ceoColor:g}),k=async()=>{w(!0);try{await O(),await Y.updateSettings({setupDone:!0,tutorialStep:0}),a(),XT()}catch{w(!1)}},A=async()=>{if(o===2){w(!0);try{await O()}catch{w(!1);return}w(!1)}s(o+1)};return(0,K.jsx)(`div`,{className:`start`,children:(0,K.jsxs)(`div`,{className:`start-card wizard`,children:[(0,K.jsx)(`div`,{className:`wizard-steps`,children:kJ.map((e,t)=>(0,K.jsx)(`span`,{className:`wizard-dot ${t===o?`wizard-dot-on`:t<o?`wizard-dot-done`:``}`,title:e},e))}),o===0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`start-logo`,children:`✻`}),(0,K.jsx)(`h1`,{children:`cubefarm`}),(0,K.jsx)(`p`,{className:`start-tag`,children:`Your own cartoon software company, staffed by AI coding agents.`}),(0,K.jsxs)(`ul`,{className:`start-list`,children:[(0,K.jsx)(`li`,{children:`🏢 Every project gets its own floor, with developers and a QA lab working through its GitHub issues.`}),(0,K.jsx)(`li`,{children:`🧠 A CEO studies each project, plans the work and proposes the specialists it needs. You approve every hire.`}),(0,K.jsx)(`li`,{children:`📱 Your phone keeps you in the loop from anywhere in the building.`})]}),!n&&r&&(0,K.jsxs)(`div`,{className:`term-error small`,children:[`⚠️ `,r]}),(0,K.jsx)(`button`,{className:`btn btn-big`,onClick:()=>s(1),children:`Let's set up your company`}),(0,K.jsxs)(`div`,{className:`start-meta`,children:[(0,K.jsx)(`button`,{className:`linkish`,onClick:k,disabled:C,children:`Skip setup and use the defaults`}),t&&(0,K.jsx)(`span`,{className:`pill pill-demo`,children:`DEMO MODE`})]})]}),o===1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`wizard-icon`,children:`🧑💼`}),(0,K.jsx)(`h2`,{children:`Who's the boss?`}),(0,K.jsx)(`p`,{className:`start-tag`,children:`That's you. You run the company; the agents do the typing.`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Your name`}),(0,K.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:e??`Boss`,autoFocus:!0})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Company name`}),(0,K.jsxs)(`div`,{className:`row`,style:{margin:0},children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:EJ[0]}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small`,title:`Suggest another name`,onClick:()=>d(AJ(EJ,u)),children:`🎲`})]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`It goes on the sign in the lobby. Change either any time in the manager's console.`})]}),o===2&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{children:`Meet your CEO`}),(0,K.jsxs)(`div`,{className:`ceo-setup`,children:[(0,K.jsx)(jJ,{color:g,look:m}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Name`}),(0,K.jsxs)(`div`,{className:`row`,style:{margin:0},children:[(0,K.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`Morgan`,autoFocus:!0}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small`,title:`Suggest another name`,onClick:()=>p(AJ(DJ,f)),children:`🎲`})]})]}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:m===`feminine`,onChange:()=>h(`feminine`)}),` 👩 She`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:m===`masculine`,onChange:()=>h(`masculine`)}),` 👨 He`]}),(0,K.jsx)(`span`,{className:`spacer`}),OJ.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`swatch ${e===g?`swatch-on`:``}`,style:{background:e},onClick:()=>_(e),title:`Tie colour`},e))]}),(0,K.jsx)(`div`,{className:`muted small`,children:`Claude Opus 5.5 at xhigh effort: the thinking-hardest person in the building.`})]})]}),(0,K.jsxs)(`p`,{className:`start-tag`,style:{margin:`12px 0 6px`},children:[E,` studies every project, writes its QA checklist, plans the work as GitHub issues and proposes who to hire.`]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:y===`approve`,onChange:()=>b(`approve`)}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Ask me before every hire`}),` (recommended). Candidates wait in the lobby and on your phone.`]})]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:y===`auto`,onChange:()=>b(`auto`)}),(0,K.jsxs)(`span`,{children:[(0,K.jsxs)(`b`,{children:[`Let `,E,` hire`]}),` on their own, up to 6 people per floor.`]})]})]}),o===3&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{children:`Your first project`}),x?(0,K.jsxs)(`div`,{className:`wizard-done`,children:[(0,K.jsx)(`div`,{className:`wizard-icon`,children:`🎉`}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`b`,{children:x.fullName}),` moved into floor `,x.floor,`.`]}),(0,K.jsxs)(`p`,{className:`muted`,children:[E,` is studying it right now and will text you when they know who the team needs. A QA tester is already in the lab.`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`start-tag`,children:`Pick one of your project folders, a GitHub repo, or start something new. Every project needs to be on GitHub: issues and pull requests are how the team works.`}),(0,K.jsx)(eJ,{onConnected:S})]})]}),o===4&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`wizard-icon`,children:`🏢`}),(0,K.jsxs)(`h2`,{children:[D,` is open for business`]}),(0,K.jsxs)(`ul`,{className:`start-list`,children:[(0,K.jsxs)(`li`,{children:[`🧠 `,E,x?` is studying ${x.fullName.split(`/`)[1]}`:` is waiting for your first project`,`.`,` `,y===`approve`?`Hires wait for your OK.`:`Hires up to 6 per floor go through on their own.`]}),(0,K.jsxs)(`li`,{children:[`📱 Press `,(0,K.jsx)(`kbd`,{children:`P`}),` anywhere for your phone: chat with `,E,`, approve hires, and see every project at a glance.`]}),(0,K.jsxs)(`li`,{children:[`🧭 A short tour starts when you walk in. Press `,(0,K.jsx)(`kbd`,{children:`H`}),` any time for help.`]})]}),(0,K.jsx)(`button`,{className:`btn btn-big`,onClick:k,disabled:C,children:C?`Opening the doors…`:`Enter the office`})]}),o>0&&o<4&&(0,K.jsxs)(`div`,{className:`wizard-nav`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>s(o-1),disabled:C,children:`← Back`}),(0,K.jsx)(`span`,{className:`spacer`}),o===3&&!x&&(0,K.jsx)(`button`,{className:`linkish`,onClick:()=>s(4),children:`I'll add one later`}),(o!==3||x)&&(0,K.jsx)(`button`,{className:`btn btn-good`,onClick:()=>void A(),disabled:C,children:`Next →`})]})]})})}function NJ(){let e=q(e=>e.started),t=q(e=>e.loaded),n=q(e=>e.connected),r=q(e=>e.demo),i=q(e=>e.repos),a=q(e=>e.agents),o=q(e=>e.settings),s=q(e=>e.start),c=Ib();if(e)return null;if(t&&!o.setupDone)return(0,K.jsx)(MJ,{});let l=()=>{s(),Jy(),XT()},u=a.ceo,d=Object.values(a).filter(e=>e.role!==`ceo`).length;return(0,K.jsx)(`div`,{className:`start`,children:(0,K.jsxs)(`div`,{className:`start-card`,children:[(0,K.jsx)(`div`,{className:`start-logo`,children:`✻`}),(0,K.jsx)(`h1`,{children:o.companyName||`cubefarm`}),(0,K.jsx)(`p`,{className:`start-tag`,children:o.managerName?`Welcome back, ${o.managerName}.`:`A cartoon office where a team of AI coding agents works through your GitHub issues.`}),(0,K.jsxs)(`ul`,{className:`start-list`,children:[(0,K.jsxs)(`li`,{children:[`🏢 `,i.length,` project`,i.length===1?``:`s`,`, `,d,` `,d===1?`person`:`people`,` on staff`,u?`, and ${u.name} in the corner office`:``,`.`]}),(0,K.jsx)(`li`,{children:c?`📱 ${c} thing${c===1?``:`s`} waiting on your phone. Press P once you're in.`:`📱 Press P anywhere for your phone.`}),(0,K.jsxs)(`li`,{children:[`💻 Walk up behind anyone to watch their screen, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` (or click) on things to use them. `,(0,K.jsx)(`kbd`,{children:`H`}),` for help.`]})]}),(0,K.jsx)(`button`,{className:`btn btn-big`,onClick:l,disabled:!t,children:t?`Enter the office`:n?`Loading…`:`Connecting to the swarm server…`}),(0,K.jsx)(`div`,{className:`start-meta`,children:r&&(0,K.jsx)(`span`,{className:`pill pill-demo`,children:`DEMO MODE: fake repos, fake agents`})})]})})}var PJ=[{title:`Look around`,body:()=>(0,K.jsxs)(K.Fragment,{children:[`Click the view to grab the mouse and look around, then walk with `,(0,K.jsx)(`kbd`,{children:`W`}),` `,(0,K.jsx)(`kbd`,{children:`A`}),` `,(0,K.jsx)(`kbd`,{children:`S`}),` `,(0,K.jsx)(`kbd`,{children:`D`}),`. Hold `,(0,K.jsx)(`kbd`,{children:`Shift`}),` to run. `,(0,K.jsx)(`kbd`,{children:`Esc`}),` gives you the mouse back.`]}),done:e=>e.locked,minMs:5e3},{title:`Pull out your phone`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`Press `,(0,K.jsx)(`kbd`,{children:`P`}),`. Your phone is how you talk to `,e.ceo,` from anywhere in the building.`]}),done:e=>e.overlay?.kind===`phone`},{title:`Your phone`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`💬 `,e.ceo,` texts you here, and you can text back. 📄 `,(0,K.jsx)(`b`,{children:`Hires`}),` shows candidates waiting for your OK. 📊 `,(0,K.jsx)(`b`,{children:`Company`}),` is every project at a glance. Put it away with `,(0,K.jsx)(`kbd`,{children:`P`}),`.`]}),done:e=>e.overlay?.kind!==`phone`,minMs:2500},{title:`Visit the CEO`,body:e=>(0,K.jsxs)(K.Fragment,{children:[e.ceo,`'s corner office is at the back right of the lobby, under the purple sign. Walk in and press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click the desk to see what `,e.ceo,` is up to.`]}),done:e=>e.overlay?.kind===`terminal`&&e.overlay.agentId===`ceo`||e.overlay?.kind===`manager`&&e.overlay.tab===`ceo`},{title:`Candidates`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`When `,e.ceo,` wants to hire someone, the candidate waits on the green chairs along the east wall. Press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click them to read their resume, then hire or decline. It all works from your phone too.`]}),done:e=>e.requests.some(e=>e.status!==`pending`&&e.decidedBy===`manager`)},{title:`Go upstairs`,body:e=>e.repo?(0,K.jsxs)(K.Fragment,{children:[e.repo,` has its own floor. Walk into the elevator in the middle of the south wall, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click the directory beside it.`]}):(0,K.jsx)(K.Fragment,{children:`Every project gets its own floor. Add one in your office (the glass room at the back left), then take the elevator in the middle of the south wall.`}),done:e=>e.floor>0},{title:`The whiteboard`,body:()=>(0,K.jsxs)(K.Fragment,{children:[`The whiteboard at the front of every floor is its Kanban board. Press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click it to hand out issues, send pull requests to QA and merge them.`]}),done:e=>e.overlay?.kind===`kanban`},{title:`Watch the team`,body:()=>(0,K.jsxs)(K.Fragment,{children:[`Walk up behind anyone to watch their screen, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click a desk for their full terminal. The testers in lab coats along the east wall check every pull request before you merge.`]}),done:e=>e.overlay?.kind===`terminal`&&e.overlay.agentId!==`ceo`},{title:`Your office`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`Your glass office in the lobby (back left) has the manager's console: projects, the team, and the CEO's settings. Press `,(0,K.jsx)(`kbd`,{children:`H`}),` any time for help. Enjoy running `,e.company,`!`]})}];function FJ(){let e=q(e=>e.settings.tutorialStep),t=q(e=>e.settings.setupDone),n=q(e=>e.started),r=q(e=>e.settings.companyName),i=q(e=>e.agents.ceo?.name??`the CEO`),a=q(e=>e.repos[0]?.fullName.split(`/`)[1]??null),[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(!1),l=(0,v.useRef)(Date.now()),u=n&&t&&e>=0&&e<PJ.length,d=e=>{c.current||(c.current=!0,Y.updateSettings({tutorialStep:e>=PJ.length?-1:e}).catch(()=>void 0).finally(()=>{c.current=!1,s(!1)}))};if((0,v.useEffect)(()=>{l.current=Date.now(),s(!1)},[e]),(0,v.useEffect)(()=>{if(!u)return;let t=PJ[e];if(!t.done)return;let n=null,r=()=>{if(n||c.current)return;let r=q.getState();if(!t.done(r))return;let i=Math.max(0,(t.minMs??0)-(Date.now()-l.current));n=setTimeout(()=>{if(!t.done(q.getState())){n=null;return}s(!0),n=setTimeout(()=>d(e+1),900)},i)};r();let i=q.subscribe(r),a=setInterval(r,1e3);return()=>{i(),clearInterval(a),n&&clearTimeout(n)}},[u,e]),!u)return null;let f=PJ[e],p=e===PJ.length-1;return(0,K.jsxs)(`div`,{className:`tour ${o?`tour-cheer`:``}`,children:[(0,K.jsxs)(`div`,{className:`tour-head`,children:[(0,K.jsxs)(`span`,{className:`tour-count`,children:[`🧭 Tour · `,e+1,`/`,PJ.length]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`linkish small`,onClick:()=>d(PJ.length),children:`Skip tour`})]}),(0,K.jsx)(`div`,{className:`tour-title`,children:o?`✅ ${f.title}`:f.title}),(0,K.jsx)(`div`,{className:`tour-body`,children:f.body({ceo:i,company:r||`the company`,repo:a})}),(0,K.jsxs)(`div`,{className:`tour-nav`,children:[e>0&&(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>d(e-1),children:`← Back`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,onClick:()=>d(e+1),children:p?`Finish the tour`:f.done?`Skip this step`:`Next →`})]})]})}function IJ(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(rE,{}),(0,K.jsx)(DE,{}),(0,K.jsx)(TJ,{}),(0,K.jsx)(FJ,{}),(0,K.jsx)(NJ,{}),(0,K.jsx)(xT,{}),zb&&(0,K.jsx)(Yb,{})]})}var LJ=0,RJ=`office-swarm:reloaded-for`;function zJ(){try{return sessionStorage.getItem(RJ)}catch{return null}}function BJ(e){if(!wE(q.getState().officeCommit,e,zJ()))return!1;try{sessionStorage.setItem(RJ,e)}catch{return!1}return location.reload(),!0}function VJ(){let e=location.protocol===`https:`?`wss`:`ws`,t=new WebSocket(`${e}://${location.host}/ws`);t.onopen=()=>{LJ=0,q.getState().setConnected(!0)},t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.type===`snapshot`&&t.data.officeCommit&&BJ(t.data.officeCommit))return;q.getState().apply(t)}catch(e){console.error(`bad server event`,e)}},t.onclose=()=>{let e=q.getState();e.setConnected(!1);let t=e.restarting||CE(e.officeUpdate);t!==e.restarting&&e.setRestarting(t),setTimeout(VJ,Math.min(t?2e3:8e3,500*2**LJ++))}}VJ(),(0,y.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(IJ,{}));export{jy as $,IS as A,Xb as B,J as C,V as Ct,eC as D,zS as E,l as Et,lS as F,tx as G,ix as H,aS as I,tb as J,Ab as K,oS as L,fS as M,OS as N,tC as O,pS as P,Fy as Q,fx as R,fw as S,xt as St,BS as T,s as Tt,Tx as U,Ex as V,_x as W,lb as X,ib as Y,pb as Z,vw as _,D as _t,NT as a,Pi as at,hw as b,ge as bt,AT as c,H as ct,Mw as d,Nt as dt,Ey as et,Aw as f,Sr as ft,nw as g,Na as gt,Cw as h,fr as ht,RT as i,Tg as it,FS as j,rC as k,Bw as l,Es as lt,Tw as m,Rn as mt,MT as n,W_ as nt,CT as o,W as ot,bw as p,vo as pt,q,LT as r,Hg as rt,ET as s,vs as st,UT as t,G_ as tt,jw as u,ao as ut,ow as v,zr as vt,_C as w,p as wt,dw as x,w as xt,yw as y,zn as yt,Qb as z};
|
|
4331
|
+
`))}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 sU(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=aW.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function hW(){return{exit:{taskListCheckValueChecked:_W,taskListCheckValueUnchecked:_W,paragraph:vW}}}function gW(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:yW}}}function _W(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function vW(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 yW(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=aW.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 bW(){return[TH(),YH(),eU(),oW(),hW()]}function xW(e){return{extensions:[EH(),XH(e),tU(),mW(e),gW()]}}var SW={tokenize:IW,partial:!0},CW={tokenize:LW,partial:!0},wW={tokenize:RW,partial:!0},TW={tokenize:zW,partial:!0},EW={tokenize:BW,partial:!0},DW={name:`wwwAutolink`,tokenize:PW,previous:VW},OW={name:`protocolAutolink`,tokenize:FW,previous:HW},kW={name:`emailAutolink`,tokenize:NW,previous:UW},AW={};function jW(){return{text:AW}}for(var MW=48;MW<123;)AW[MW]=kW,MW++,MW===58?MW=65:MW===91&&(MW=97);AW[43]=kW,AW[45]=kW,AW[46]=kW,AW[95]=kW,AW[72]=[kW,OW],AW[104]=[kW,OW],AW[87]=[kW,DW],AW[119]=[kW,DW];function NW(e,t,n){let r=this,i,a;return o;function o(t){return!WW(t)||!UW.call(r,r.previous)||GW(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return WW(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(EW,u,l)(t):t===45||t===95||vL(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&&_L(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function PW(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!VW.call(r,r.previous)||GW(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(SW,e.attempt(CW,e.attempt(wW,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function FW(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&HW.call(r,r.previous)&&!GW(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(_L(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||bL(t)||TL(t)||OL(t)||DL(t)?n(t):e.attempt(CW,e.attempt(wW,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function IW(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 LW(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(TW,c,s)(t):t===null||TL(t)||OL(t)||t!==45&&DL(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 RW(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(TW,t,a)(o):o===null||TL(o)||OL(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function zW(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||TL(o)||OL(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||TL(e)||OL(e)?t(e):r(e)}function a(e){return _L(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):_L(t)?(e.consume(t),o):n(t)}}function BW(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return vL(e)?n(e):t(e)}}function VW(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||TL(e)}function HW(e){return!_L(e)}function UW(e){return!(e===47||WW(e))}function WW(e){return e===43||e===45||e===46||e===95||vL(e)}function GW(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 KW={tokenize:eG,partial:!0};function qW(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:ZW,continuation:{tokenize:QW},exit:$W}},text:{91:{name:`gfmFootnoteCall`,tokenize:XW},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:JW,resolveTo:YW}}}}function JW(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=gL(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 YW(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 XW(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||TL(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(gL(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return TL(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 ZW(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||TL(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=gL(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return TL(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),jL(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function QW(e,t,n){return e.check(YL,t,e.attempt(KW,t,n))}function $W(e){e.exit(`gfmFootnoteDefinition`)}function eG(e,t,n){let r=this;return jL(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 tG(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&&lL(o,o.length,0,HL(s,e.slice(r+1,n),t)),lL(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),lL(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=VL(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=VL(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var nG=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){rG(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,this.index.clear()}};function rG(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function iG(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 aG(){return{flow:{null:{name:`table`,tokenize:oG,resolveAll:sG}}}}function oG(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{type:e}=r.events[t][1];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):wL(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):EL(t)?jL(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||TL(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,EL(t)?jL(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 EL(t)?jL(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||wL(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 EL(t)?jL(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||wL(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||wL(n)?(e.exit(`tableRow`),t(n)):EL(n)?jL(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||TL(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 sG(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 nG;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(lG(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=cG(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=cG(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=cG(f,t,o,i,n,d)):(o[0]=o[1],d=cG(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&lG(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=iG(t.events,n))}return e}function cG(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},uG(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=uG(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=uG(t.events,n[2]),a=uG(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({},uG(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function lG(e,t,n,r,i){let a=[],o=uG(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 uG(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var dG={name:`tasklistCheck`,tokenize:pG};function fG(){return{text:{91:dG}}}function pG(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 TL(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 wL(r)?t(r):EL(r)?e.check({tokenize:mG},t,n)(r):n(r)}}function mG(e,t,n){return jL(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function hG(e){return fL([jW(),qW(),tG(e),aG(),fG()])}var gG={};function _G(e){let t=this,n=e||gG,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(hG(n)),a.push(bW()),o.push(xW(n))}function vG(){let e=t=>{t.type===`html`&&(t.type=`text`),t.children?.forEach(e)};return e}var yG=/^(https?:|mailto:)/i,bG=e=>yG.test(e.trim())?e:``,xG={a:({href:e,children:t})=>e?(0,K.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,K.jsx)(`span`,{className:`md-deadlink`,children:t}),img:({src:e,alt:t})=>typeof e==`string`&&e?(0,K.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:[`🖼 `,t||e]}):(0,K.jsxs)(`span`,{children:[`🖼 `,t]}),table:({children:e})=>(0,K.jsx)(`div`,{className:`md-table`,children:(0,K.jsx)(`table`,{children:e})})},SG=[_G,vG,xH];function CG({text:e,className:t}){return(0,K.jsx)(`div`,{className:t?`md ${t}`:`md`,children:(0,K.jsx)(lH,{remarkPlugins:SG,components:xG,urlTransform:bG,children:e})})}function wG({value:e,onChange:t,className:n,onKeyDown:r,...i}){let a=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[e]),(0,K.jsx)(`textarea`,{...i,ref:a,rows:1,enterKeyHint:`send`,className:`msg-box ${n??``}`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{if(r?.(e),e.defaultPrevented||e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||e.keyCode===229)return;e.preventDefault();let t=e.currentTarget.form,n=t?.querySelector(`button:not([type="button"])`);t&&!n?.disabled&&t.requestSubmit()}})}function TG({width:e,height:t,frame:n,onPointer:r,label:i}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(n),c=(0,v.useRef)(r);(0,v.useEffect)(()=>{s.current=n,c.current=r}),(0,v.useEffect)(()=>{let n=a.current,r=o.current;if(!n||!r)return;let i=1,c=()=>{let a=getComputedStyle(n),o=n.clientWidth-parseFloat(a.paddingLeft)-parseFloat(a.paddingRight),s=n.clientHeight-parseFloat(a.paddingTop)-parseFloat(a.paddingBottom),c=Math.max(.4,Math.min(o/e,s/t,1.5)),l=Math.min(2,window.devicePixelRatio||1);r.style.width=`${Math.floor(e*c)}px`,r.style.height=`${Math.floor(t*c)}px`,r.width=Math.round(e*c*l),r.height=Math.round(t*c*l),i=r.width/e};c();let l=new ResizeObserver(c);l.observe(n);let u=0,d=performance.now(),f=n=>{let a=Math.min(.1,Math.max(0,(n-d)/1e3));d=n;let o=r.getContext(`2d`);o&&(o.setTransform(i,0,0,i,0,0),o.clearRect(0,0,e,t),s.current(o,a,n)),u=requestAnimationFrame(f)};return u=requestAnimationFrame(f),()=>{cancelAnimationFrame(u),l.disconnect()}},[e,t]);let l=(n,r)=>{let i=n.currentTarget.getBoundingClientRect();c.current?.(r,(n.clientX-i.left)/i.width*e,(n.clientY-i.top)/i.height*t)};return(0,K.jsx)(`div`,{ref:a,className:`game-canvas-wrap`,children:(0,K.jsx)(`canvas`,{ref:o,className:`game-canvas`,role:`img`,"aria-label":i,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),l(e,`down`)},onPointerMove:e=>e.buttons&&l(e,`move`),onPointerUp:e=>l(e,`up`)})})}function EG(e){let t=(0,v.useRef)(e);(0,v.useEffect)(()=>{t.current=e}),(0,v.useEffect)(()=>{let e=e=>{e.ctrlKey||e.metaKey||e.altKey||NT()||e.code===`Escape`||e.code===`KeyP`||e.target?.closest?.(`input, textarea, select, [contenteditable="true"]`)||t.current(e)&&(e.preventDefault(),e.stopPropagation())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[])}function DG({title:e,color:t,onBack:n,children:r}){return(0,K.jsxs)(`div`,{className:`game-head`,style:{"--game":t},children:[(0,K.jsx)(`button`,{type:`button`,className:`game-back`,onClick:n,title:`Back to the games (Backspace)`,children:`‹ Games`}),(0,K.jsx)(`b`,{className:`game-title`,children:e}),(0,K.jsx)(`span`,{className:`game-head-right`,children:r})]})}function OG(e){switch(e){case`ArrowUp`:case`KeyW`:return`up`;case`ArrowDown`:case`KeyS`:return`down`;case`ArrowLeft`:case`KeyA`:return`left`;case`ArrowRight`:case`KeyD`:return`right`}return null}var kG=e=>e===`Space`||e===`Enter`||e===`NumpadEnter`;function AG(e){let t=(0,v.useRef)(e);(0,v.useEffect)(()=>{t.current=e}),(0,v.useEffect)(()=>{let e=()=>t.current(),n=()=>document.hidden&&e();return window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,n)}},[])}function jG({onPress:e,repeat:t,label:n,className:r,children:i}){let a=(0,v.useRef)(null),o=(0,v.useRef)(e);(0,v.useEffect)(()=>{o.current=e});let s=()=>{a.current&&clearTimeout(a.current),a.current=null};return(0,v.useEffect)(()=>s,[]),(0,K.jsx)(`button`,{type:`button`,tabIndex:-1,className:`game-pad ${r??``}`,"aria-label":n,title:n,onPointerDown:e=>{if(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),o.current(),!t)return;s();let n=e=>{a.current=setTimeout(()=>{o.current(),n(70)},e)};n(190)},onPointerUp:s,onPointerCancel:s,onLostPointerCapture:s,children:i})}var MG=`#1f1d2b`,NG=`#fffdf6`,PG=`#6c7086`,FG=[`#ff8a5b`,`#4fb3e8`,`#8fd14f`,`#c77dff`,`#ffc93c`,`#ff6fb5`,`#2ec4b6`,`#f25f5c`];function IG(e,t,n,r,i,a,o=Math.min(r,i)*.24,s=2){DS(e,t+s/2,n+s/2,r-s,i-s,o),e.fillStyle=a,e.fill(),e.save(),e.clip(),e.fillStyle=`rgba(255,255,255,0.38)`,e.fillRect(t,n,r,i*.26),e.fillStyle=`rgba(0,0,0,0.13)`,e.fillRect(t,n+i*.74,r,i*.26),e.restore(),e.lineWidth=s,e.strokeStyle=MG,e.stroke()}function LG(e,t,n,r,i,a=`#ffffff`,o=10){DS(e,t,n+3,r,i,o),e.fillStyle=MG,e.fill(),DS(e,t,n,r,i,o),e.fillStyle=a,e.fill(),e.lineWidth=2.5,e.strokeStyle=MG,e.stroke()}function RG(e,t,n,r,i,a=MG,o=700,s=`center`){e.font=`${o} ${i}px ${ES}`,e.fillStyle=a,e.textAlign=s,e.textBaseline=`middle`,e.fillText(t,n,r)}function zG(e,t,n,r,i,a){e.font=`700 ${i}px ${ES}`,e.textAlign=`center`,e.textBaseline=`middle`,e.lineJoin=`round`,e.lineWidth=Math.max(3,i/5),e.strokeStyle=MG,e.strokeText(t,n,r),e.fillStyle=a,e.fillText(t,n,r)}function BG(e,t,n,r,i,a=0,o=0,s=!1){for(let c of[-1,1]){let l=t+c*r/2;if(s){e.beginPath(),e.moveTo(l-i,n),e.quadraticCurveTo(l,n+i*.6,l+i,n),e.lineWidth=Math.max(1.5,i*.35),e.lineCap=`round`,e.strokeStyle=MG,e.stroke();continue}e.beginPath(),e.ellipse(l,n,i,i*1.15,0,0,Math.PI*2),e.fillStyle=`#ffffff`,e.fill(),e.lineWidth=Math.max(1.2,i*.28),e.strokeStyle=MG,e.stroke(),e.beginPath(),e.arc(l+a*i*.35,n+o*i*.35,i*.52,0,Math.PI*2),e.fillStyle=MG,e.fill(),e.beginPath(),e.arc(l+a*i*.35-i*.18,n+o*i*.35-i*.2,i*.16,0,Math.PI*2),e.fillStyle=`#ffffff`,e.fill()}}function VG(e,t){let n=parseInt(e.slice(1),16),[r,i,a]=[n>>16&255,n>>8&255,n&255].map(e=>Math.round(t>=0?e+(255-e)*t:e*(1+t)));return`#${(1<<24|r<<16|i<<8|a).toString(16).slice(1)}`}function HG(e,t,n,r,i=12,a=120){for(let o=0;o<i;o++){let i=Math.random()*Math.PI*2,s=a*(.4+Math.random()*.8);e.push({x:t,y:n,vx:Math.cos(i)*s,vy:Math.sin(i)*s-a*.4,life:.6+Math.random()*.4,color:r[o%r.length],size:3+Math.random()*3})}}function UG(e,t,n,r,i,a=18){e.push({x:t,y:n,vx:0,vy:-40,life:1.1,color:i,size:a,text:r})}function WG(e,t,n){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.life-=n,i.life<=0){t.splice(r,1);continue}i.x+=i.vx*n,i.y+=i.vy*n,i.text||(i.vy+=320*n),e.globalAlpha=Math.min(1,i.life*2),i.text?zG(e,i.text,i.x,i.y,i.size,i.color):(e.fillStyle=i.color,e.fillRect(i.x-i.size/2,i.y-i.size/2,i.size,i.size),e.lineWidth=1,e.strokeStyle=MG,e.strokeRect(i.x-i.size/2,i.y-i.size/2,i.size,i.size)),e.globalAlpha=1}}function GG(e,t,n,r,i,a){e.fillStyle=`rgba(31,29,43,0.45)`,e.fillRect(0,0,t,n);let o=Math.min(t-36,250),s=70+i.length*22,c=(t-o)/2,l=(n-s)/2;LG(e,c,l,o,s,NG,16),e.save(),e.clip(),e.fillStyle=a,e.fillRect(c,l,o,10),e.restore(),e.stroke(),zG(e,r,t/2,l+36,24,a),i.forEach((n,r)=>RG(e,n,t/2,l+68+r*22,r===i.length-1?13:15,r===i.length-1?PG:MG,r===i.length-1?600:700))}var KG=36e5,qG=720*KG,JG={awake:{food:-12,fun:-10,energy:-7},asleep:{food:-5,fun:-3,energy:35}},YG=[`Cubey`,`Pixel`,`Widget`,`Sprocket`,`Nugget`,`Mochi`,`Byte`,`Tofu`],XG=[`#ff8a5b`,`#4fb3e8`,`#8fd14f`,`#c77dff`,`#ffc93c`,`#ff6fb5`,`#2ec4b6`],ZG=[{xp:0,title:`Intern`},{xp:12,title:`Junior`},{xp:40,title:`Senior`},{xp:90,title:`Tech Lead`}],QG=e=>Math.max(0,Math.min(100,e));function $G(e){let t=0;for(;t+1<ZG.length&&e>=ZG[t+1].xp;)t++;return t}function eK(e,t,n){let r=YG[Math.floor(t*YG.length)%YG.length];return{v:1,name:r,color:XG[Math.floor(n*XG.length)%XG.length],born:e,at:e,food:80,fun:80,energy:80,asleep:!1,xp:0,coffeeAt:0,pettedAt:0,say:{text:`Hi! I'm ${r}, your new desk pet. Keep me fed, busy and rested!`,at:e}}}function tK(e,t){let n=Math.min(Math.max(0,t-e.at),qG)/KG,{food:r,fun:i,energy:a,asleep:o}=e;for(let e=0;n>0&&e<1e3;e++){let e=o?JG.asleep:JG.awake,t=o?(100-a)/e.energy:a/-e.energy,s=Math.min(n,t);r=QG(r+e.food*s),i=QG(i+e.fun*s),a=QG(a+e.energy*s),n-=s,s===t&&(o=!o)}return{...e,at:Math.max(t,e.at),food:r,fun:i,energy:a,asleep:o}}function nK(e){return e.asleep?`asleep`:[e.food,e.fun,e.energy].filter(e=>e<25).length>=2||Math.min(e.food,e.fun,e.energy)<=0?`grumpy`:e.food<25?`hungry`:e.energy<25?`tired`:e.fun<25?`bored`:e.food+e.fun+e.energy>=210?`happy`:`content`}var rK={asleep:`Zzz… 💤`,happy:`Best. Job. Ever. ✨`,content:`Just vibing at my desk.`,hungry:`I'm hungry… got a donut? 🍩`,bored:`I'm bored. Play with me? 🎾`,tired:`So… sleepy… 🥱`,grumpy:`Hmph. Nobody looks after me. 😤`},iK=(e,t)=>e[Math.floor(t/1e3)%e.length];function aK(e,t,n){let r=tK(e,n),i=oK(r,t,n);return i===r?r:$G(i.xp)>$G(r.xp)?{...i,fun:QG(i.fun+10),say:{text:`Promoted to ${ZG[$G(i.xp)].title}! 🎉`,at:n}}:i}function oK(e,t,n){let r=e=>({text:e,at:n}),i=(t,n)=>({...e,food:QG(e.food+(t.food??0)),fun:QG(e.fun+(t.fun??0)),energy:QG(e.energy+(t.energy??0)),xp:e.xp+(t.xp??0),say:r(n)});if(t===`nap`)return e.asleep?e.energy<40?{...i({fun:-4},`Five more minutes… 😒`),asleep:!1}:{...i({},`Good morning! ☀️`),asleep:!1}:e.energy>=90?i({},`I'm not sleepy!`):{...i({xp:+(e.energy<50)},`Nap time… 💤`),asleep:!0};if(e.asleep)return t===`pet`?e:i({},`Zzz… (shh, still asleep) 💤`);switch(t){case`snack`:return e.food>=90?i({fun:-2},`I'm stuffed! No more donuts.`):i({food:30,fun:3,xp:1},iK([`Nom nom nom! 🍩`,`Sprinkles! My favourite.`,`Donut-driven development!`],n));case`coffee`:return n-e.coffeeAt<6e5?i({energy:5,fun:-6},`Too… much… coffee! 😵💫`):{...i({energy:25,food:3,xp:1},iK([`☕ Ready to ship!`,`Caffeine: loaded.`,`Brb, refactoring everything.`],n)),coffeeAt:n};case`play`:return e.energy<15?i({},`Too tired to play… 🥱`):i({fun:25,energy:-10,food:-6,xp:1},iK([`Wheee! 🎾`,`Again! Again!`,`Best. Break. Ever.`],n));case`pet`:return n-e.pettedAt<3e3?e:{...i({fun:3},iK([`Hehe ❤️`,`*happy wiggle*`,`You're the best manager!`],n)),pettedAt:n}}return e}function sK(e,t,n){let r=tK(e,n);return{...r,fun:QG(r.fun+8),xp:r.xp+1,say:{text:t,at:n}}}function cK(e){if(!e||typeof e!=`object`)return null;let t=e,n=[t.born,t.at,t.food,t.fun,t.energy,t.xp,t.coffeeAt,t.pettedAt];if(t.v!==1||typeof t.name!=`string`||typeof t.color!=`string`||typeof t.asleep!=`boolean`||!n.every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let r=t.say&&typeof t.say.text==`string`&&typeof t.say.at==`number`?{text:t.say.text,at:t.say.at}:null;return{...t,food:QG(t.food),fun:QG(t.fun),energy:QG(t.energy),say:r}}function lK(e){try{return JSON.parse(localStorage.getItem(e)??`null`)}catch{return null}}function uK(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var dK=`cubefarm:games:best`;function fK(e){let t=lK(dK),n=Number(t?.[e]);return Number.isFinite(n)&&n>0?n:0}function pK(e,t){if(t<=fK(e))return!1;let n=lK(dK);return uK(dK,{...n&&typeof n==`object`?n:{},[e]:t}),!0}var mK=`cubefarm:games:pet`,hK=cK(lK(mK)),gK=new Set,_K=()=>gK.forEach(e=>e()),vK=()=>hK;function yK(e){hK=e,uK(mK,e),_K()}function bK(e){return gK.add(e),()=>void gK.delete(e)}function xK(e){return e.role===`qa`||e.task===`qa`?`Yay! ${e.name} finished testing${e.prNumber?` PR #${e.prNumber}`:` a PR`}! 🧪`:e.task===`fix`?`Yay! ${e.name} fixed${e.prNumber?` PR #${e.prNumber}`:` a PR`}! 🔧`:e.issueNumber?`Yay! ${e.name} finished issue #${e.issueNumber}! 🎉`:`Yay! ${e.name} finished a job! 🎉`}q.subscribe((e,t)=>{if(hK&&t.loaded&&e.agents!==t.agents)for(let n of Object.values(e.agents)){let e=t.agents[n.id];n.role!==`ceo`&&n.status===`done`&&e&&e.status!==`done`&&yK(sK(hK,xK(n),Date.now()))}}),window.addEventListener(`storage`,e=>{e.key===mK&&(hK=cK(lK(mK)),_K())});var SK={move:()=>ub({freq:420,type:`square`,dur:.03,peak:.012}),rotate:()=>ub({freq:560,to:700,type:`triangle`,dur:.06,peak:.04}),land:()=>{fb({dur:.07,peak:.07,freq:500,q:.8}),ub({freq:180,to:120,type:`triangle`,dur:.08,peak:.05})},lines:e=>[659,784,988,1318.5].slice(0,Math.max(2,e+1)).forEach((e,t)=>ub({freq:e,type:`triangle`,at:t*.06,dur:.22,peak:.07})),levelUp:()=>[523,659,784,1046.5].forEach((e,t)=>ub({freq:e,type:`square`,at:t*.08,dur:.14,peak:.03})),over:()=>{ub({freq:392,to:370,type:`triangle`,dur:.22,peak:.1}),ub({freq:311,to:156,type:`triangle`,at:.22,dur:.6,peak:.1})},best:()=>[784,988,1175,1568].forEach((e,t)=>ub({freq:e,type:`triangle`,at:.5+t*.07,dur:.28,peak:.08})),chomp:()=>ub({freq:300,to:620,type:`square`,dur:.07,peak:.035}),slurp:()=>{fb({dur:.2,peak:.05,filter:`bandpass`,freq:400,to:2200,q:2,attack:.03}),ub({freq:523,to:1046,type:`triangle`,at:.12,dur:.16,peak:.06})},start:()=>[523,784].forEach((e,t)=>ub({freq:e,type:`triangle`,at:t*.08,dur:.14,peak:.07})),pause:()=>ub({freq:660,to:440,type:`triangle`,dur:.12,peak:.05}),happy:()=>{ub({freq:660,to:1320,type:`square`,dur:.1,peak:.03}),ub({freq:1320,to:990,type:`triangle`,at:.1,dur:.12,peak:.07})},nom:()=>[0,.12,.24].forEach(e=>ub({freq:250,to:180,type:`triangle`,at:e,dur:.08,peak:.06})),boing:()=>ub({freq:220,to:660,type:`sine`,dur:.25,peak:.1}),snore:()=>ub({freq:140,to:90,type:`sine`,dur:.6,peak:.05,attack:.2}),grumble:()=>ub({freq:160,to:120,type:`sawtooth`,dur:.25,peak:.025})},CK=`#ff6fb5`,wK=320,TK=260,EK=212,DK=[52,60,68,74],OK=1.4,kK=Date.now(),AK=[{action:`snack`,icon:`🍩`,label:`Snack`,key:`1`},{action:`coffee`,icon:`☕`,label:`Coffee`,key:`2`},{action:`play`,icon:`🎾`,label:`Play`,key:`3`},{action:`nap`,icon:`💤`,label:`Nap`,key:`4`}];function jK(e,t){let n=t.size,r=-n,i=Math.max(2,n/22),a=VG(t.color,-.3);e.lineCap=`round`,e.lineJoin=`round`,e.fillStyle=`rgba(31,29,43,0.16)`,e.beginPath(),e.ellipse(0,2,n*.46,n*.07,0,0,Math.PI*2),e.fill();for(let o of[-1,1])e.beginPath(),e.ellipse(o*n*.22,-3,n*.14,n*.08,0,0,Math.PI*2),e.fillStyle=a,e.fill(),e.lineWidth=i,e.strokeStyle=MG,e.stroke(),e.beginPath(),t.arms?e.ellipse(o*n*.52,r+n*.3,n*.09,n*.15,o*.5,0,Math.PI*2):e.ellipse(o*n*.5,r+n*.62,n*.09,n*.14,-o*.35,0,Math.PI*2),e.fillStyle=t.color,e.fill(),e.stroke();IG(e,-n/2,r,n,n-4,t.color,n*.3,i*1.3);let o=r+n*.4,s=n*.36,c=n*.1,l=t.mood===`asleep`;if(BG(e,0,o,s,c,0,t.mood===`hungry`?.5:.1,l||t.blink),t.mood===`tired`&&!t.blink)for(let n of[-1,1])e.beginPath(),e.ellipse(n*s/2,o,c*1.12,c*1.3,0,Math.PI,Math.PI*2),e.fillStyle=VG(t.color,-.08),e.fill(),e.lineWidth=i*.8,e.strokeStyle=MG,e.beginPath(),e.moveTo(n*s/2-c*1.1,o),e.lineTo(n*s/2+c*1.1,o),e.stroke();if(t.mood===`grumpy`){e.lineWidth=i*1.1,e.strokeStyle=MG;for(let t of[-1,1])e.beginPath(),e.moveTo(t*(s/2+c*1.2),o-c*2),e.lineTo(t*(s/2-c*.9),o-c*1.3),e.stroke()}if(t.stage>=2){e.lineWidth=i*.9,e.strokeStyle=MG;for(let t of[-1,1])e.beginPath(),e.roundRect(t*s/2-c*1.6,o-c*1.5,c*3.2,c*3,c*.6),e.stroke();e.beginPath(),e.moveTo(-s/2+c*1.6,o-c*.4),e.lineTo(s/2-c*1.6,o-c*.4),e.stroke()}e.fillStyle=`rgba(255,111,181,0.45)`;for(let t of[-1,1])e.beginPath(),e.ellipse(t*n*.3,r+n*.58,n*.075,n*.045,0,0,Math.PI*2),e.fill();let u=r+n*.62,d=n*.12;e.lineWidth=i,e.strokeStyle=MG,e.fillStyle=MG,e.beginPath(),t.open||t.mood===`hungry`?(e.ellipse(0,u+1,d*.55,d*.65,0,0,Math.PI*2),e.fill()):t.mood===`happy`?(e.arc(0,u-1,d,0,Math.PI),e.closePath(),e.fill(),e.beginPath(),e.ellipse(0,u+d*.55,d*.5,d*.3,0,0,Math.PI*2),e.fillStyle=`#ff8fa3`,e.fill()):t.mood===`content`?(e.arc(0,u-d*.6,d,Math.PI*.15,Math.PI*.85),e.stroke()):t.mood===`grumpy`?(e.arc(0,u+d*.9,d,Math.PI*1.2,Math.PI*1.8),e.stroke()):t.mood===`asleep`?(e.ellipse(0,u+1,d*.3,d*.35,0,0,Math.PI*2),e.fill()):t.mood===`tired`?(e.moveTo(-d,u+1),e.quadraticCurveTo(-d/2,u-2,0,u+1),e.quadraticCurveTo(d/2,u+4,d,u+1),e.stroke()):(e.moveTo(-d*.8,u+1),e.lineTo(d*.8,u+1),e.stroke());let f=r+n*.76;if(t.stage===0?(e.strokeStyle=`#4fb3e8`,e.lineWidth=i*.9,e.beginPath(),e.moveTo(-n*.2,r+n*.7),e.lineTo(0,f+n*.02),e.lineTo(n*.2,r+n*.7),e.stroke(),IG(e,-n*.09,f,n*.18,n*.14,`#ffffff`,n*.03,i*.8),e.fillStyle=`#4fb3e8`,e.fillRect(-n*.06,f+n*.04,n*.12,n*.025)):(e.beginPath(),e.moveTo(-n*.05,f-n*.04),e.lineTo(n*.05,f-n*.04),e.lineTo(n*.035,f+n*.02),e.lineTo(n*.065,f+n*.15),e.lineTo(0,f+n*.2),e.lineTo(-n*.065,f+n*.15),e.lineTo(-n*.035,f+n*.02),e.closePath(),e.fillStyle=t.color===`#f25f5c`||t.color===`#ff6fb5`?`#2b2d42`:`#f25f5c`,e.fill(),e.lineWidth=i*.8,e.strokeStyle=MG,e.stroke()),t.stage>=3){e.lineWidth=i*1.4,e.strokeStyle=MG,e.beginPath(),e.arc(0,r+n*.4,n*.53,Math.PI*1.12,Math.PI*1.88),e.stroke();for(let t of[-1,1])IG(e,t*n*.52-n*.08,r+n*.28,n*.16,n*.24,`#2b2d42`,n*.05,i*.8);e.lineWidth=i,e.beginPath(),e.moveTo(-n*.52,r+n*.5),e.quadraticCurveTo(-n*.4,u+n*.08,-d*1.6,u+2),e.stroke(),e.beginPath(),e.arc(-d*1.6,u+2,i*1.2,0,Math.PI*2),e.fillStyle=MG,e.fill()}}function MK(e,t,n,r,i){e.beginPath();for(let i=0;i<10;i++){let a=-Math.PI/2+i*Math.PI/5,o=i%2?r*.45:r;e.lineTo(t+Math.cos(a)*o,n+Math.sin(a)*o)}e.closePath(),e.fillStyle=i,e.fill(),e.lineWidth=2,e.strokeStyle=MG,e.stroke()}function NK(e,t,n,r,i=0){e.save(),e.translate(t,n),e.beginPath(),e.arc(0,0,r,i*Math.PI*1.5,Math.PI*2),e.arc(0,0,r*.38,Math.PI*2,i*Math.PI*1.5,!0),e.closePath(),e.fillStyle=`#e0ac69`,e.fill(),e.lineWidth=2,e.strokeStyle=MG,e.stroke(),e.beginPath(),e.arc(0,0,r*.78,i*Math.PI*1.5,Math.PI*2),e.arc(0,0,r*.45,Math.PI*2,i*Math.PI*1.5,!0),e.fillStyle=`#ff8fc7`,e.fill(),[`#4fb3e8`,`#ffc93c`,`#8fd14f`,`#ffffff`].forEach((t,n)=>{let a=n*1.7+.4;a/(Math.PI*2)<i*.75||(e.fillStyle=t,e.fillRect(Math.cos(a)*r*.62-1.5,Math.sin(a)*r*.62-1,3,2))}),e.restore()}function PK(e,t,n,r){e.lineWidth=2,e.strokeStyle=MG,e.beginPath(),e.arc(t+9,n+8,5,-Math.PI/2,Math.PI/2),e.stroke(),IG(e,t-9,n,18,18,`#ffffff`,4,2),e.beginPath(),e.ellipse(t,n+3,6.5,2,0,0,Math.PI*2),e.fillStyle=`#8d5524`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.45)`,e.lineWidth=1.5;for(let i of[-3,3]){let a=(r/600+i/7)%1;e.globalAlpha=1-a,e.beginPath(),e.moveTo(t+i,n-3-a*10),e.quadraticCurveTo(t+i+3,n-6-a*10,t+i,n-9-a*10),e.stroke()}e.globalAlpha=1}function FK(e,t,n){e.fillStyle=`#d6e2ef`,e.fillRect(0,0,wK,EK),e.fillStyle=`rgba(255,255,255,0.28)`;for(let t=6;t<wK;t+=12)e.fillRect(t,12,1.5,200);e.fillStyle=`#b9c9dc`,e.fillRect(0,0,wK,12),e.fillStyle=MG,e.fillRect(0,12,wK,2),IG(e,16,58,76,52,`#d9a066`,6,2);for(let[t,n,r,i]of[[24,66,`#fff3b0`,-.08],[56,70,`#ffd6e8`,.1]]){e.save(),e.translate(t+13,n+13),e.rotate(i),e.fillStyle=r,e.fillRect(-13,-13,26,26),e.strokeStyle=MG,e.lineWidth=1.5,e.strokeRect(-13,-13,26,26),e.strokeStyle=`rgba(31,29,43,0.4)`,e.lineWidth=1.2;for(let t=0;t<3;t++)e.beginPath(),e.moveTo(-8,-6+t*6),e.lineTo(8-t*4,-6+t*6),e.stroke();e.beginPath(),e.arc(0,-11,2.5,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.restore()}IG(e,232,54,66,60,`#ffffff`,5,2),RG(e,`EMPLOYEE`,265,64,7.5,MG,700),RG(e,`OF THE MONTH`,265,73,7,MG,700),MK(e,265,93,13,n?`#ffc93c`:`#e3e7ee`);let r=new Date;e.beginPath(),e.arc(160,42,17,0,Math.PI*2),e.fillStyle=`#ffffff`,e.fill(),e.lineWidth=3,e.strokeStyle=MG,e.stroke(),e.lineCap=`round`;for(let[t,n,i]of[[(r.getHours()%12+r.getMinutes()/60)/12,8,3],[(r.getMinutes()+r.getSeconds()/60)/60,12,2]]){let r=t*Math.PI*2-Math.PI/2;e.beginPath(),e.moveTo(160,42),e.lineTo(160+Math.cos(r)*n,42+Math.sin(r)*n),e.lineWidth=i,e.stroke()}e.beginPath(),e.arc(160,42,2.5,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.fillStyle=`#d9b48a`,e.fillRect(0,224,wK,36),e.fillStyle=MG,e.fillRect(0,224,wK,2),IG(e,-6,EK,332,14,`#f1d19b`,5,2.5),IG(e,48,200,18,12,`#3d4152`,2,2),IG(e,18,146,78,54,`#2b2d42`,7,2.5),e.fillStyle=`#1b1b29`,e.fillRect(25,153,64,40);let i=Math.floor(t/700);for(let t=0;t<5;t++){let n=i+t;e.fillStyle=FG[n*3%FG.length],e.fillRect(29+n%3*5,157+t*7,14+n*17%30,3)}e.lineWidth=2;for(let[t,n,r]of[[262,176,13],[276,168,11],[252,164,10]])e.beginPath(),e.arc(t,n,r,0,Math.PI*2),e.fillStyle=`#52b788`,e.fill(),e.strokeStyle=MG,e.stroke();IG(e,248,186,32,26,`#e07a5f`,5,2)}function IK(e,t=1){e.save(),e.scale(t,t),IG(e,-38,-56,76,56,`#d9a066`,6,2.5),e.fillStyle=`rgba(241,209,155,0.9)`,e.fillRect(-7,-55,14,54),IG(e,-30,-34,38,16,`#ffffff`,3,1.5),RG(e,`NEW HIRE`,-11,-26,7.5,MG,700),e.restore()}function LK(e,t,n,r){e.lineWidth=2,e.strokeStyle=MG,e.fillStyle=`#ffffff`;for(let[r,i,a]of[[-16,22,3],[-10,14,5]])e.beginPath(),e.arc(t+r,n+i,a,0,Math.PI*2),e.fill(),e.stroke();e.beginPath(),e.ellipse(t+8,n-4,20,15,0,0,Math.PI*2),e.fill(),e.stroke(),e.save(),e.translate(t+8,n-4),r(),e.restore()}function RK({onBack:e}){let t=(0,v.useSyncExternalStore)(bK,vK),[n,r]=(0,v.useState)(Date.now()),i=(0,v.useRef)(null),a=(0,v.useRef)([]),o=(0,v.useRef)(0),s=(0,v.useRef)(t?.say?.at??0),[c]=(0,v.useState)(()=>Date.now()),[l]=(0,v.useState)(()=>t?.say&&t.say.at>kK&&c-t.say.at>5e3?t.say:null);(0,v.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>{clearInterval(e),kK=Date.now()}},[]);let u=t?.say?.at??0;(0,v.useEffect)(()=>{u!==s.current&&(s.current=u,u!==o.current&&Date.now()-u<3e3&&(i.current={kind:`cheer`,t:0},HG(a.current,wK/2,152,FG,16,140),SK.happy()))},[u]);let d=()=>{if(vK())return;let e=eK(Date.now(),Math.random(),Math.random());o.current=e.say?.at??0,i.current={kind:`hatch`,t:0},HG(a.current,wK/2,182,[`#d9a066`,`#f1d19b`,...FG],22,170),SK.levelUp(),yK(e)},f=e=>{let t=vK();if(!t)return;let n=Date.now(),s=aK(t,e,n);s.say?.at===n&&(o.current=n),yK(s),r(n);let c=s.xp>t.xp,l=DK[$G(s.xp)];if(s.say?.text.startsWith(`Promoted`)){SK.levelUp(),HG(a.current,wK/2,EK-l,FG,22,160),i.current={kind:`cheer`,t:0};return}switch(e){case`snack`:case`play`:c?(i.current={kind:e,t:0},(e===`snack`?SK.nom:SK.boing)()):s.asleep||SK.grumble();break;case`coffee`:c?(i.current={kind:`coffee`,t:0},SK.slurp()):s.asleep||(i.current={kind:`jitter`,t:0},SK.grumble());break;case`nap`:s.asleep?SK.snore():t.asleep&&(i.current={kind:`wake`,t:0},SK.happy());break;case`pet`:if(s.pettedAt===n){i.current={kind:`pet`,t:0};for(let e=0;e<3;e++)a.current.push({x:wK/2+(e-1)*16,y:EK-l-6,vx:(e-1)*14,vy:-50-e*8,life:1.1,color:`#ff6fb5`,size:16+e*2,text:`♥`});SK.happy()}}};EG(e=>{if(e.repeat)return!1;let t=AK.find(t=>e.code===`Digit${t.key}`||e.code===`Numpad${t.key}`);return t?(f(t.action),!0):kG(e.code)?(vK()?f(`pet`):d(),!0):!1});let p=(e,t,n)=>{let r=vK(),o=r?tK(r,Date.now()):null,s=o?nK(o):`content`,c=o?$G(o.xp):0;FK(e,n,c>=2||s===`happy`);let l=i.current;if(l&&(l.t+=t,l.t>OK&&(i.current=null)),o){let t=DK[c],r=wK/2,i=0,a=1,u=1,d=Math.sin(n/(s===`asleep`?900:450));u+=d*(s===`asleep`?.04:.025),a-=d*.015;let f=l?l.t/OK:0;if((l?.kind===`play`||l?.kind===`cheer`||l?.kind===`wake`)&&(i=Math.abs(Math.sin(f*Math.PI*(l.kind===`wake`?1:4)))*(l.kind===`wake`?10:16)*(1-f*.5)),(l?.kind===`coffee`||l?.kind===`jitter`)&&(r+=Math.sin(l.t*70)*(l.kind===`jitter`?2.5:1.2)),l?.kind===`pet`){let e=Math.sin(Math.min(1,f*3)*Math.PI)*.1;u-=e,a+=e}if(l?.kind===`hatch`){let e=Math.min(1,f*3);a*=.3+e*.7,u*=.3+e*.7}e.save(),e.translate(r,214-i),e.scale(a,u);let p=l?.kind===`snack`&&f>.3&&Math.floor(l.t*8)%2==0;jK(e,{size:t,color:o.color,mood:l?.kind===`jitter`?`grumpy`:l?.kind===`cheer`||l?.kind===`play`?`happy`:s,stage:c,blink:Math.floor(n/160)%24==0,open:p,arms:l?.kind===`cheer`||l?.kind===`play`}),e.restore();let m=EK-t-i;if(l?.kind===`snack`){let n=Math.min(1,f/.3);NK(e,r+t*.2+60*(1-n),202+(12-t*.38)*n-Math.sin(n*Math.PI)*24,10*(1-Math.max(0,f-.3)*.6),Math.max(0,(f-.3)/.7))}if(l?.kind===`coffee`&&PK(e,r+t/2+16,194,n),l?.kind===`play`){let t=wK/2+Math.cos(f*Math.PI*2)*70,n=196-Math.abs(Math.sin(f*Math.PI*5))*60;e.beginPath(),e.arc(t,n,8,0,Math.PI*2),e.fillStyle=`#d4f25c`,e.fill(),e.lineWidth=2,e.strokeStyle=MG,e.stroke(),e.beginPath(),e.arc(t-8,n,7,-.9,.9),e.strokeStyle=`#ffffff`,e.stroke()}if(!l){let i=Math.sin(n/400)*2;if(s===`asleep`){for(let i=0;i<3;i++){let a=(n/1400+i/3)%1;e.globalAlpha=Math.min(1,(1-a)*2),zG(e,`z`,r+t*.35+a*26,m-a*34,12+a*10,`#ffffff`)}e.globalAlpha=1}else if(s===`hungry`)LK(e,r+t*.55+18,m-8+i,()=>NK(e,0,0,9));else if(s===`bored`)LK(e,r+t*.55+18,m-8+i,()=>RG(e,`…`,0,-2,20,MG,700));else if(s===`tired`)LK(e,r+t*.55+18,m-8+i,()=>RG(e,`💤`,0,0,14,MG,400));else if(s===`grumpy`){let t=r,a=m-22+i;e.fillStyle=`#8e93a8`,e.strokeStyle=MG,e.lineWidth=2,e.beginPath(),e.arc(t-12,a,9,0,Math.PI*2),e.arc(t,a-5,11,0,Math.PI*2),e.arc(t+12,a,9,0,Math.PI*2),e.fill(),e.stroke(),e.fill(),Math.floor(n/250)%6==0&&(e.beginPath(),e.moveTo(t+2,a+8),e.lineTo(t-3,a+16),e.lineTo(t+2,a+16),e.lineTo(t-2,a+24),e.strokeStyle=`#ffc93c`,e.lineWidth=2.5,e.stroke())}else if(s===`happy`&&Math.floor(n/900)%3==0){let i=n%900/900;e.globalAlpha=Math.sin(i*Math.PI),zG(e,`✦`,r-t*.6,m+10-i*8,14,`#ffc93c`),zG(e,`✦`,r+t*.62,m+22-i*6,11,`#ffffff`),e.globalAlpha=1}}s===`asleep`&&(e.fillStyle=`rgba(28,36,82,0.32)`,e.fillRect(0,0,wK,TK))}else{let t=n%2600<450?Math.sin(n/45)*.06:0;e.save(),e.translate(wK/2,213),e.rotate(t),IK(e),e.restore(),zG(e,`?`,194,142+Math.sin(n/300)*3,20,`#ffc93c`)}WG(e,a.current,t)},m=(e,t,n)=>{if(e!==`down`)return;let r=vK();if(!r){Math.abs(t-wK/2)<50&&n>142&&d();return}let i=DK[$G(r.xp)];Math.abs(t-wK/2)<i/2+8&&n>EK-i-12&&n<218&&f(`pet`)},h=t?tK(t,n):null,g=h?nK(h):null,_=h?.say&&n-h.say.at<2e4?h.say.text:null,y=h?_??(l&&n-c<1e4?`While you were away: ${l.text}`:rK[g]):`A delivery just arrived at your desk…`,b=h?ZG[$G(h.xp)].title:``,x=h?Math.floor((n-h.born)/864e5)+1:0,S=h?[[`🍩`,`Food`,h.food,`#ffc93c`],[`🎾`,`Fun`,h.fun,`#ff6fb5`],[`⚡`,`Energy`,h.energy,`#4fb3e8`]]:[];return(0,K.jsxs)(`div`,{className:`game pet`,children:[(0,K.jsx)(DG,{title:`Desk Pet`,color:CK,onBack:e,children:h&&(0,K.jsxs)(`span`,{className:`game-chip`,title:`${h.xp} care points`,children:[h.name,` · `,b]})}),(0,K.jsx)(`div`,{className:`pet-say`,"aria-live":`polite`,children:y}),(0,K.jsx)(TG,{width:wK,height:TK,frame:p,label:h?`${h.name}, your desk pet, is ${g}`:`A delivery box`,onPointer:m}),h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`pet-bars`,children:S.map(([e,t,n,r])=>(0,K.jsxs)(`div`,{className:`pet-bar ${n<25?`pet-bar-low`:``}`,title:`${t}: ${Math.round(n)}%`,children:[(0,K.jsxs)(`span`,{className:`pet-bar-label`,children:[e,` `,t]}),(0,K.jsx)(`span`,{className:`pet-meter`,children:(0,K.jsx)(`i`,{style:{width:`${Math.max(2,n)}%`,background:r}})})]},t))}),(0,K.jsx)(`div`,{className:`pet-actions`,children:AK.map(e=>{let t=e.action===`nap`&&h.asleep;return(0,K.jsxs)(`button`,{type:`button`,className:`btn btn-small pet-act`,tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:()=>f(e.action),disabled:h.asleep&&!t,title:`${t?`Wake up`:e.label} (${e.key})`,children:[(0,K.jsx)(`span`,{className:`pet-act-icon`,children:t?`☀️`:e.icon}),t?`Wake`:e.label]},e.action)})}),(0,K.jsxs)(`div`,{className:`game-keys`,children:[(0,K.jsx)(`kbd`,{children:`1`}),`–`,(0,K.jsx)(`kbd`,{children:`4`}),` care · click `,h.name,` (or `,(0,K.jsx)(`kbd`,{children:`Space`}),`) for a pat · day `,x]})]}):(0,K.jsx)(`div`,{className:`pet-actions`,children:(0,K.jsx)(`button`,{type:`button`,className:`btn btn-good pet-unbox`,onClick:d,children:`📦 Unbox your desk pet`})})]})}function zK(e){let t=e+1831565813|0,n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,[((n^n>>>14)>>>0)/4294967296,t]}var BK=()=>Math.floor(Math.random()*2**31),VK={up:{x:0,y:-1},down:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}},HK={up:`down`,down:`up`,left:`right`,right:`left`},UK={bug:10,coffee:50},WK={bug:1,coffee:2},GK=(e,t)=>e.x===t.x&&e.y===t.y;function KK(e,t){let n=Math.floor(e*.2),r=e-n-2,i=Math.floor(t*.2),a=t-i-1;return[n,r].flatMap(e=>[i,a].flatMap(t=>[{x:e,y:t},{x:e+1,y:t}]))}function qK(e,t,n,r){let i=new Set(n.map(t=>t.y*e+t.x)),a=[];for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.has(n*e+t)||a.push({x:t,y:n});if(!a.length)return{at:null,seed:r};let[o,s]=zK(r);return{at:a[Math.floor(o*a.length)],seed:s}}function JK(e,t=16,n=16){let r=Math.floor(n/2),i=Math.floor(t/2)-1,a=[0,1,2].map(e=>({x:i-e,y:r})),o=KK(t,n),s=qK(t,n,[...a,...o],e);return{cols:t,rows:n,body:a,dir:`right`,queue:[],desks:o,food:{...s.at??{x:0,y:0},kind:`bug`},grow:0,score:0,eaten:0,seed:s.seed,over:null,ate:null}}function YK(e,t){if(e.over)return e;let n=e.queue[e.queue.length-1]??e.dir;return t===n||t===HK[n]||e.queue.length>=2?e:{...e,queue:[...e.queue,t]}}function XK(e){if(e.over)return e;let[t=e.dir,...n]=e.queue,r=VK[t],i={x:e.body[0].x+r.x,y:e.body[0].y+r.y},a=r=>({...e,dir:t,queue:n,over:r,ate:null});if(i.x<0||i.y<0||i.x>=e.cols||i.y>=e.rows)return a(`wall`);if(e.desks.some(e=>GK(e,i)))return a(`desk`);let o=e.grow>0?e.body:e.body.slice(0,-1);if(o.some(e=>GK(e,i)))return a(`self`);let s=[i,...o],c=Math.max(0,e.grow-1);if(!GK(i,e.food))return{...e,body:s,dir:t,queue:n,grow:c,ate:null};let l=e.food.kind,u=e.eaten+1;c+=WK[l];let d=qK(e.cols,e.rows,[...s,...e.desks],e.seed),f={...e,body:s,dir:t,queue:n,grow:c,eaten:u,score:e.score+UK[l],seed:d.seed,ate:l};return d.at?{...f,food:{...d.at,kind:(u+1)%5==0?`coffee`:`bug`}}:{...f,over:`won`}}var ZK=e=>Math.max(70,165-e.eaten*4),QK=`#4fb3e8`,$K=20,eq=6,tq=38,nq=16,rq=16,iq=332,aq=364,oq=`#4fb3e8`,sq=null,cq=()=>sq!==null,lq={wall:`Unplugged!`,self:`Tangled up!`,desk:`Desk crash!`,won:`Office wired! 🎉`},uq={right:0,down:Math.PI/2,left:Math.PI,up:-Math.PI/2},dq={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]},fq=e=>eq+e.x*$K+$K/2,pq=e=>tq+e.y*$K+$K/2;function mq({onBack:e}){let[t,n]=(0,v.useState)(sq?`paused`:`ready`),r=(0,v.useRef)({game:sq??JK(BK(),nq,rq),status:sq?`paused`:`ready`,acc:0,best:fK(`snake`),newBest:!1,particles:[],shake:0,chomp:0,swipe:null}),i=e=>{r.current.status=e,n(e),sq=e===`over`||e===`ready`?null:r.current.game},a=e=>{let t=r.current,n=t.game;if(e!==n){if(t.game=e,t.status===`playing`&&(sq=e),e.ate){let n=e.body[0];e.ate===`coffee`?SK.slurp():SK.chomp(),t.chomp=.18,HG(t.particles,fq(n),pq(n),e.ate===`coffee`?[`#8d5524`,`#ffffff`,`#ffc93c`]:[`#f25f5c`,`#8fd14f`,`#ffffff`],8,90),UG(t.particles,fq(n),pq(n)-12,e.ate===`coffee`?`+50 ☕`:`+10`,e.ate===`coffee`?`#ffc93c`:`#ffffff`,15)}e.over&&!n.over&&(t.newBest=pK(`snake`,e.score),t.newBest&&(t.best=e.score),t.shake=e.over===`won`?0:.3,e.over===`won`?SK.best():SK.over(),t.newBest&&e.over!==`won`&&SK.best(),i(`over`))}},o=()=>{let e=r.current;e.status!==`playing`&&(e.status===`over`&&(e.game=JK(BK(),nq,rq)),e.status!==`paused`&&(e.newBest=!1,e.particles.length=0),e.acc=0,SK.start(),i(`playing`))},s=()=>{r.current.status===`playing`&&(SK.pause(),i(`paused`))},c=e=>{if(r.current.status!==`playing`){if(r.current.status===`paused`)return o();o()}a(YK(r.current.game,e))};EG(e=>{let t=OG(e.code);return t?(e.repeat||c(t),!0):kG(e.code)?(e.repeat||(r.current.status===`playing`?s:o)(),!0):!1}),AG(s);let l=(e,t,n)=>{let i=r.current;if(e===`down`){i.swipe={x:t,y:n};return}if(!i.swipe)return;let a=t-i.swipe.x,s=n-i.swipe.y;e===`move`&&Math.max(Math.abs(a),Math.abs(s))>18?(c(Math.abs(a)>Math.abs(s)?a>0?`right`:`left`:s>0?`down`:`up`),i.swipe={x:t,y:n}):e===`up`&&(Math.max(Math.abs(a),Math.abs(s))<8&&i.status!==`playing`&&o(),i.swipe=null)},u=(e,t,n)=>{let i=r.current;if(i.status===`playing`){i.acc+=t*1e3;let e=ZK(i.game);for(;i.acc>=e&&i.status===`playing`;)i.acc-=e,a(XK(i.game)),e=ZK(i.game)}let o=i.game;LG(e,eq,4,96,26,`#ffffff`,9),RG(e,`🐛 ${o.eaten} eaten`,54,17,12,MG,700),LG(e,iq/2-50,4,100,26,`#ffffff`,9),RG(e,`SCORE ${o.score}`,iq/2,17,12,MG,700),LG(e,230,4,96,26,`#ffffff`,9),RG(e,`BEST ${Math.max(i.best,o.score)}`,278,17,12,o.score>i.best?`#e05a2b`:PG,700),e.save(),i.shake>0&&(i.shake-=t,e.translate((Math.random()-.5)*12*i.shake,(Math.random()-.5)*12*i.shake)),LG(e,3,35,326,326,`#e6ebf3`,8),e.save(),e.beginPath(),e.roundRect(eq,tq,320,320,6),e.clip(),e.fillStyle=`#dce3ee`;for(let t=0;t<rq;t++)for(let n=0;n<nq;n++)(n+t)%2&&e.fillRect(eq+n*$K,tq+t*$K,$K,$K);e.restore();for(let t=0;t+1<o.desks.length;t+=2){let n=o.desks[t],r=eq+n.x*$K,i=tq+n.y*$K;IG(e,r+1,i+2,38,17,`#f1d19b`,5),IG(e,r+$K-8,i-3,16,12,`#2b2d42`,3,1.5),e.fillStyle=FG[t/2%FG.length],e.fillRect(r+$K-5,i,10,5)}hq(e,o,n),gq(e,o,i.chomp,n),i.chomp=Math.max(0,i.chomp-t),e.restore(),WG(e,i.particles,t),i.status===`ready`?GG(e,iq,aq,`Cable Snake`,[`Eat bugs 🐛, sip coffee ☕`,`Dodge desks, walls & yourself`,`Arrows, swipe or tap to start`],QK):i.status===`paused`?GG(e,iq,aq,`Coffee break ☕`,[`Score ${o.score}`,`Space or tap to resume`],QK):i.status===`over`&&GG(e,iq,aq,lq[o.over??`self`],[`Score ${o.score} · ${o.body.length} long`,i.newBest?`🏆 New best!`:`Best ${i.best}`,`Space or tap to play again`],o.over===`won`?`#8fd14f`:`#f25f5c`)},d=(e,t,n)=>(0,K.jsx)(jG,{label:n,className:`game-pad-${e}`,onPress:()=>c(e),children:t});return(0,K.jsxs)(`div`,{className:`game`,children:[(0,K.jsx)(DG,{title:`Cable Snake`,color:QK,onBack:e,children:(0,K.jsx)(`button`,{type:`button`,className:`game-mini`,tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:()=>t===`playing`?s():o(),title:t===`playing`?`Pause (Space)`:`Play (Space)`,children:t===`playing`?`⏸`:`▶`})}),(0,K.jsx)(TG,{width:iq,height:aq,frame:u,label:`Cable Snake board`,onPointer:l}),(0,K.jsxs)(`div`,{className:`game-dpad`,children:[d(`up`,`▲`,`Up`),d(`left`,`◀`,`Left`),d(`right`,`▶`,`Right`),d(`down`,`▼`,`Down`)]}),(0,K.jsxs)(`div`,{className:`game-keys`,children:[(0,K.jsx)(`kbd`,{children:`←`}),(0,K.jsx)(`kbd`,{children:`↑`}),(0,K.jsx)(`kbd`,{children:`→`}),(0,K.jsx)(`kbd`,{children:`↓`}),` or `,(0,K.jsx)(`kbd`,{children:`WASD`}),` steer · swipe on the board · `,(0,K.jsx)(`kbd`,{children:`Space`}),` pause`]})]})}function hq(e,t,n){let r=fq(t.food),i=pq(t.food);if(e.save(),e.translate(r,i),t.food.kind===`coffee`){let t=.5+Math.sin(n/200)*.5;e.beginPath(),e.arc(0,0,10+t*2,0,Math.PI*2),e.fillStyle=`rgba(255,201,60,${.25+t*.2})`,e.fill(),e.lineWidth=2,e.strokeStyle=MG,e.beginPath(),e.arc(5,1,3.5,-Math.PI/2,Math.PI/2),e.stroke(),e.beginPath(),e.roundRect(-7,-5,12,12,2.5),e.fillStyle=`#ffffff`,e.fill(),e.stroke(),e.beginPath(),e.ellipse(-1,-4,5,1.6,0,0,Math.PI*2),e.fillStyle=`#8d5524`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.5)`,e.lineWidth=1.2;for(let t of[-3,1]){let r=(n/400+t)%1;e.globalAlpha=1-r,e.beginPath(),e.moveTo(t,-7-r*6),e.quadraticCurveTo(t+2,-9-r*6,t,-11-r*6),e.stroke()}e.globalAlpha=1}else{e.rotate(Math.sin(n/160)*.18),e.strokeStyle=MG,e.lineWidth=1.4,e.lineCap=`round`;for(let t of[-1,1])for(let r of[-3,.5,4])e.beginPath(),e.moveTo(t*3,r),e.lineTo(t*8,r+Math.sin(n/90+r)*1.5-1),e.stroke();e.beginPath(),e.moveTo(-1.5,-7),e.lineTo(-4,-10),e.moveTo(1.5,-7),e.lineTo(4,-10),e.stroke(),e.beginPath(),e.arc(0,-6,3,0,Math.PI*2),e.fillStyle=MG,e.fill(),e.beginPath(),e.ellipse(0,1,5.5,6.5,0,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.lineWidth=1.8,e.stroke(),e.beginPath(),e.moveTo(0,-5),e.lineTo(0,7),e.lineWidth=1.2,e.stroke(),e.fillStyle=MG;for(let[t,n]of[[-2.6,-.5],[2.6,-.5],[-2.4,3.5],[2.4,3.5]])e.beginPath(),e.arc(t,n,1.1,0,Math.PI*2),e.fill()}e.restore()}function gq(e,t,n,r){let i=t.body;e.lineCap=`round`,e.lineJoin=`round`,(()=>{e.beginPath(),e.moveTo(fq(i[i.length-1]),pq(i[i.length-1]));for(let t=i.length-2;t>=0;t--)e.lineTo(fq(i[t]),pq(i[t]))})(),e.strokeStyle=MG,e.lineWidth=14,e.stroke(),e.strokeStyle=oq,e.lineWidth=10,e.stroke(),e.save(),e.translate(0,-2),e.strokeStyle=`rgba(255,255,255,0.4)`,e.lineWidth=3,e.stroke(),e.restore(),e.strokeStyle=VG(oq,-.45),e.lineWidth=3;for(let t=3;t<i.length-1;t+=4){let n=i[t],r=i[t+1],a=(fq(n)+fq(r))/2,o=(pq(n)+pq(r))/2,s=n.x===r.x;e.beginPath(),e.moveTo(a-(s?5:0),o-(s?0:5)),e.lineTo(a+(s?5:0),o+(s?0:5)),e.stroke()}let a=i[0],o=t.queue[0]??t.dir,s=fq(a),c=pq(a);e.save(),e.translate(s,c),e.rotate(uq[t.dir]);let l=n>0?1.12:1;e.scale(l,l),e.beginPath(),e.roundRect(-8,-8,16,16,3.5),e.fillStyle=`#e4f4ff`,e.fill(),e.lineWidth=2,e.strokeStyle=MG,e.stroke(),e.fillStyle=`#ffc93c`;for(let t=0;t<4;t++)e.fillRect(5,-6+t*3.3,3,1.8);e.restore();let[u,d]=dq[o],f=s-dq[t.dir][0]*2,p=c-dq[t.dir][1]*2-1;if(t.over&&t.over!==`won`){e.strokeStyle=MG,e.lineWidth=2;for(let t of[-1,1]){let n=f+t*4;e.beginPath(),e.moveTo(n-2.5,p-2.5),e.lineTo(n+2.5,p+2.5),e.moveTo(n+2.5,p-2.5),e.lineTo(n-2.5,p+2.5),e.stroke()}}else BG(e,f,p,8,3.2,u,d,Math.floor(r/170)%25==0)}var _q=[`I`,`O`,`T`,`S`,`Z`,`J`,`L`],vq={I:[`....`,`XXXX`,`....`,`....`],O:[`XX`,`XX`],T:[`.X.`,`XXX`,`...`],S:[`.XX`,`XX.`,`...`],Z:[`XX.`,`.XX`,`...`],J:[`X..`,`XXX`,`...`],L:[`..X`,`XXX`,`...`]};function yq(e){let t=[];return e.forEach((e,n)=>[...e].forEach((e,r)=>e===`X`&&t.push([r,n]))),t}function bq(e){let t=e.length;return e.map((n,r)=>e.map((n,i)=>e[t-1-i][r]).join(``))}var xq=Object.fromEntries(_q.map(e=>{let t=[vq[e]];for(let e=1;e<4;e++)t.push(bq(t[e-1]));return[e,t.map(yq)]})),Sq=()=>Array.from({length:20},()=>Array(10).fill(null));function Cq(e){return xq[e.type][e.rot].map(([t,n])=>[e.x+t,e.y+n])}var wq=e=>xq[e][0];function Tq(e,t){return Cq(t).some(([t,n])=>t<0||t>=10||n>=20||n>=0&&e[n][t]!==null)}function Eq(e){let t=vq[e].length,n=Math.min(...xq[e][0].map(([,e])=>e));return{type:e,rot:0,x:Math.floor((10-t)/2),y:-n}}function Dq(e,t){let n=[...e],r=t;for(;n.length<_q.length;){let e=[..._q];for(let t=e.length-1;t>0;t--){let[n,i]=zK(r);r=i;let a=Math.floor(n*(t+1));[e[t],e[a]]=[e[a],e[t]]}n.push(...e)}return{queue:n,seed:r}}function Oq(e){let t=Dq([],e),[n,...r]=t.queue,i=Dq(r,t.seed);return{board:Sq(),piece:Eq(n),queue:i.queue,seed:i.seed,score:0,lines:0,level:1,over:!1,cleared:[],locks:0}}var kq=e=>Math.max(80,Math.round(800*.85**(e-1))),Aq=[0,100,300,500,800];function jq(e){let t=[],n=e.filter((e,n)=>{let r=e.every(e=>e!==null);return r&&t.push(n),!r});return t.length?{board:[...Array.from({length:t.length},()=>Array(10).fill(null)),...n],rows:t}:{board:e,rows:t}}function Mq(e,t,n=0){if(e.over)return e;let r={...e.piece,x:e.piece.x+t,y:e.piece.y+n};return Tq(e.board,r)?e:{...e,piece:r}}var Nq=[[0,0],[-1,0],[1,0],[0,-1],[-1,-1],[1,-1]],Pq=[[0,0],[-1,0],[1,0],[-2,0],[2,0],[0,-1]];function Fq(e,t=1){if(e.over||e.piece.type===`O`)return e;let n=(e.piece.rot+t+4)%4;for(let[t,r]of e.piece.type===`I`?Pq:Nq){let i={...e.piece,rot:n,x:e.piece.x+t,y:e.piece.y+r};if(!Tq(e.board,i))return{...e,piece:i}}return e}function Iq(e){let t=0;for(;!Tq(e.board,{...e.piece,y:e.piece.y+t+1});)t++;return t}function Lq(e){if(e.over)return e;let t=Cq(e.piece),n=e.board.map(e=>[...e]),r=!1;for(let[i,a]of t)a<0?r=!0:n[a][i]=e.piece.type;let{board:i,rows:a}=jq(n),o=e.lines+a.length,s=e.score+Aq[a.length]*e.level,c=1+Math.floor(o/10),[l,...u]=e.queue,d=Dq(u,e.seed),f=Eq(l),p=r||Tq(i,f);return{board:i,piece:f,queue:d.queue,seed:d.seed,score:s,lines:o,level:c,over:p,cleared:a,locks:e.locks+1}}function Rq(e){if(e.over)return e;let t=Mq(e,0,1);return t===e?Lq(e):t}function zq(e){if(e.over)return e;let t=Mq(e,0,1);return t===e?Lq(e):{...t,score:t.score+1}}function Bq(e){if(e.over)return e;let t=Iq(e);return Lq({...e,piece:{...e.piece,y:e.piece.y+t},score:e.score+t*2})}var Vq=`#c77dff`,Hq={I:FG[1],O:FG[4],T:FG[3],S:FG[2],Z:FG[7],J:FG[6],L:FG[0]},Uq=18,Wq=8,Gq=8,Kq=10*Uq,qq=20*Uq,Jq=Wq+Kq+12,Yq=Jq+92+6,Xq=Gq+qq+8,Zq=null,Qq=()=>Zq!==null,$q=[``,`Shipped!`,`Double ship!`,`Triple ship!`,`CUBETRIS!`];function eJ({onBack:e}){let[t,n]=(0,v.useState)(Zq?`paused`:`ready`),r=(0,v.useRef)({game:Zq??Oq(BK()),status:Zq?`paused`:`ready`,acc:0,best:fK(`tetris`),newBest:!1,flash:[],particles:[],shake:0,lastDx:0}),i=e=>{r.current.status=e,n(e),Zq=e===`over`||e===`ready`?null:r.current.game},a=e=>{let t=r.current,n=t.game;if(e===n)return!1;if(t.game=e,Zq=t.status===`playing`?e:Zq,e.locks!==n.locks){let r=e.cleared.length;if(r){SK.lines(r);let i=e.score-n.score;for(let n of e.cleared)t.flash.push({y:n,t:.35}),HG(t.particles,Wq+Kq/2,Gq+n*Uq+Uq/2,FG,10,150);let a=Gq+e.cleared.reduce((e,t)=>e+t,0)/r*Uq;UG(t.particles,Wq+Kq/2,a-14,$q[r],r===4?`#ffc93c`:`#ffffff`,r===4?26:20),UG(t.particles,Wq+Kq/2,a+12,`+${i}`,`#80ed99`,16),r===4&&(t.shake=.35)}else SK.land();e.level>n.level&&(SK.levelUp(),UG(t.particles,Wq+Kq/2,Gq+qq/3,`Level ${e.level}!`,`#4fb3e8`,24)),e.over&&(t.newBest=pK(`tetris`,e.score),t.newBest&&(t.best=e.score),SK.over(),t.newBest&&SK.best(),i(`over`))}return!0},o=()=>{let e=r.current;e.status!==`playing`&&((e.status===`over`||e.status===`ready`)&&(e.status===`over`&&(e.game=Oq(BK())),e.newBest=!1,e.particles.length=0),e.acc=0,SK.start(),i(`playing`))},s=()=>{r.current.status===`playing`&&(SK.pause(),i(`paused`))},c=e=>{r.current.lastDx=e,a(Mq(r.current.game,e))&&SK.move()},l=e=>a(Fq(r.current.game,e))&&SK.rotate(),u=()=>{r.current.acc=0,a(zq(r.current.game))},d=()=>{r.current.acc=0,a(Bq(r.current.game))},f=e=>()=>r.current.status===`playing`?e():o();return EG(e=>{let t=r.current.status===`playing`,n=OG(e.code);return kG(e.code)?(e.repeat||(t?e.code===`Space`?d():s():o()),!0):n?(t&&(n===`left`||n===`right`?c(n===`left`?-1:1):n===`down`?u():e.repeat||l(1)),!0):e.code===`KeyZ`||e.code===`KeyQ`||e.code===`KeyX`?(t&&!e.repeat&&l(e.code===`KeyX`?1:-1),!0):!1}),AG(s),(0,K.jsxs)(`div`,{className:`game`,children:[(0,K.jsx)(DG,{title:`Cubetris`,color:Vq,onBack:e,children:(0,K.jsx)(`button`,{type:`button`,className:`game-mini`,tabIndex:-1,onPointerDown:e=>e.preventDefault(),onClick:()=>t===`playing`?s():o(),title:t===`playing`?`Pause (Enter)`:`Play (Space)`,children:t===`playing`?`⏸`:`▶`})}),(0,K.jsx)(TG,{width:Yq,height:Xq,frame:(e,t,n)=>{let i=r.current;if(i.status===`playing`){i.acc+=t*1e3;let e=kq(i.game.level);for(;i.acc>=e&&i.status===`playing`;)i.acc-=e,a(Rq(i.game))}let o=i.game;e.save(),i.shake>0&&(i.shake-=t,e.translate((Math.random()-.5)*6*i.shake*3,(Math.random()-.5)*6*i.shake*3)),LG(e,5,5,Kq+6,qq+6,`#e3e9f3`,8),e.strokeStyle=`rgba(80,100,140,0.12)`,e.lineWidth=1,e.beginPath();for(let t=1;t<10;t++)e.moveTo(Wq+t*Uq,Gq),e.lineTo(Wq+t*Uq,Gq+qq);for(let t=1;t<20;t++)e.moveTo(Wq,Gq+t*Uq),e.lineTo(Wq+Kq,Gq+t*Uq);if(e.stroke(),o.board.forEach((t,n)=>t.forEach((t,r)=>t&&IG(e,Wq+r*Uq,Gq+n*Uq,Uq,Uq,Hq[t],4.5))),!o.over){let t=Iq(o);e.setLineDash([3,3]);for(let[n,r]of Cq({...o.piece,y:o.piece.y+t}))r<0||(e.beginPath(),e.roundRect(Wq+n*Uq+2,Gq+r*Uq+2,14,14,4),e.fillStyle=`${Hq[o.piece.type]}44`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.45)`,e.lineWidth=1.5,e.stroke());e.setLineDash([]);let r=Cq(o.piece);e.save(),e.beginPath(),e.rect(6,Gq,Kq+4,qq+4),e.clip();for(let[t,n]of r)IG(e,Wq+t*Uq,Gq+n*Uq,Uq,Uq,Hq[o.piece.type],4.5);let a=r.reduce((e,[t])=>e+t,0)/r.length,s=r.reduce((e,[,t])=>e+t,0)/r.length,[c,l]=r.reduce((e,t)=>Math.hypot(t[0]-a,t[1]-s)<Math.hypot(e[0]-a,e[1]-s)?t:e);l>=0&&BG(e,Wq+c*Uq+Uq/2,Gq+l*Uq+Uq/2-1,8,2.7,i.lastDx,.6,Math.floor(n/180)%22==0),e.restore()}i.flash=i.flash.filter(e=>(e.t-=t)>0);for(let t of i.flash)e.fillStyle=`rgba(255,255,255,${Math.min(1,t.t*3)})`,e.fillRect(Wq,Gq+t.y*Uq,Kq,Uq);e.restore(),LG(e,Jq,Gq,92,110,`#ffffff`,10),RG(e,`NEXT`,Jq+46,21,11,PG,700),o.queue.slice(0,3).forEach((t,n)=>{let r=n===0?14:9,i=wq(t),a=i.map(([e])=>e),o=i.map(([,e])=>e),s=(Math.max(...a)-Math.min(...a)+1)*r,c=(Math.max(...o)-Math.min(...o)+1)*r,l=n===0?Jq+46-s/2:Jq+(n===1?24:68)-s/2,u=n===0?52-c/2:98-c/2;for(let[s,c]of i)IG(e,l+(s-Math.min(...a))*r,u+(c-Math.min(...o))*r,r,r,Hq[t],r*.25,n===0?2:1.5)});let s=(t,n,r,i=MG)=>{LG(e,Jq,r,92,46,`#ffffff`,10),RG(e,t,Jq+46,r+13,10,PG,700),RG(e,n,Jq+46,r+31,17,i,700)};if(s(`SCORE`,o.score.toLocaleString(),130),s(`LINES`,String(o.lines),186),s(`LEVEL`,String(o.level),242),s(`BEST`,Math.max(i.best,o.score).toLocaleString(),298,o.score>i.best?`#e05a2b`:MG),WG(e,i.particles,t),i.status!==`playing`){let t=i.status===`ready`?`Space or tap to start`:i.status===`paused`?`Space or tap to resume`:`Space or tap to play again`;i.status===`ready`?GG(e,Yq,Xq,`Cubetris`,[`Stack the blocks.`,`Fill a row to ship it!`,t],Vq):i.status===`paused`?GG(e,Yq,Xq,`Coffee break ☕`,[`Score ${o.score.toLocaleString()}`,t],Vq):GG(e,Yq,Xq,`Stack overflow!`,[`Score ${o.score.toLocaleString()}`,i.newBest?`🏆 New best!`:`Best ${i.best.toLocaleString()}`,t],`#f25f5c`)}else o.score===0&&o.locks===0&&zG(e,`Go!`,Wq+Kq/2,Gq+qq/2,30+Math.sin(n/120)*2,`#80ed99`)},label:`Cubetris board`,onPointer:e=>e===`down`&&f(()=>l(1))()}),(0,K.jsxs)(`div`,{className:`game-pads`,children:[(0,K.jsx)(jG,{label:`Move left`,repeat:!0,onPress:f(()=>c(-1)),children:`◀`}),(0,K.jsx)(jG,{label:`Soft drop`,repeat:!0,onPress:f(u),children:`▼`}),(0,K.jsx)(jG,{label:`Move right`,repeat:!0,onPress:f(()=>c(1)),children:`▶`}),(0,K.jsx)(`span`,{className:`game-pad-gap`}),(0,K.jsx)(jG,{label:`Rotate`,className:`game-pad-round`,onPress:f(()=>l(1)),children:`⟳`}),(0,K.jsx)(jG,{label:`Drop`,className:`game-pad-round game-pad-hot`,onPress:f(d),children:`⤓`})]}),(0,K.jsxs)(`div`,{className:`game-keys`,children:[(0,K.jsx)(`kbd`,{children:`←`}),(0,K.jsx)(`kbd`,{children:`→`}),` move · `,(0,K.jsx)(`kbd`,{children:`↑`}),` turn · `,(0,K.jsx)(`kbd`,{children:`↓`}),` down · `,(0,K.jsx)(`kbd`,{children:`Space`}),` drop · `,(0,K.jsx)(`kbd`,{children:`Enter`}),` pause`]})]})}function tJ({draw:e}){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let n=t.current,r=n?.getContext(`2d`);if(!n||!r)return;let i=Math.min(2,window.devicePixelRatio||1);n.width=56*i,n.height=56*i,r.setTransform(i,0,0,i,0,0),e(r)},[e]),(0,K.jsx)(`canvas`,{ref:t,className:`game-thumb`,style:{width:56,height:56},"aria-hidden":!0})}var nJ=e=>{let t=(t,n,r)=>IG(e,2+t*13,2+n*13,13,13,r,3.5,1.8);for(let[e,n]of[[`#ffc93c`,[[0,2],[1,2],[0,3],[1,3]]],[`#ff8a5b`,[[3,1],[3,2],[3,3],[2,3]]],[`#c77dff`,[[0,0],[1,0],[2,0],[1,1]]]])for(let[r,i]of n)t(r,i,e);BG(e,21.5,8.5,7,2.4,0,.5)},rJ=e=>{e.lineCap=`round`,e.lineJoin=`round`,e.beginPath(),e.moveTo(8,48),e.lineTo(8,34),e.lineTo(28,34),e.lineTo(28,16),e.lineTo(36,16),e.strokeStyle=MG,e.lineWidth=11,e.stroke(),e.strokeStyle=`#4fb3e8`,e.lineWidth=7,e.stroke(),e.beginPath(),e.roundRect(33,9,14,14,3),e.fillStyle=`#e4f4ff`,e.fill(),e.lineWidth=2,e.strokeStyle=MG,e.stroke(),e.fillStyle=`#ffc93c`;for(let t=0;t<3;t++)e.fillRect(44,11+t*3.6,2.5,1.8);BG(e,39,15,6,2.4,1,0),e.beginPath(),e.ellipse(46,44,5,6,0,0,Math.PI*2),e.fillStyle=`#f25f5c`,e.fill(),e.lineWidth=1.6,e.stroke(),e.beginPath(),e.arc(46,38,2.6,0,Math.PI*2),e.fillStyle=MG,e.fill()};function iJ({icon:e,name:t,what:n,status:r,color:i,onOpen:a}){return(0,K.jsxs)(`button`,{type:`button`,className:`game-card`,style:{"--game":i},onClick:a,children:[(0,K.jsx)(tJ,{draw:e}),(0,K.jsxs)(`span`,{className:`game-card-text`,children:[(0,K.jsx)(`b`,{children:t}),(0,K.jsx)(`span`,{className:`game-card-what`,children:n}),(0,K.jsx)(`span`,{className:`game-card-status`,children:r})]}),(0,K.jsx)(`span`,{className:`game-card-go`,children:`▶`})]})}function aJ({onGame:e}){let t=(0,v.useSyncExternalStore)(bK,vK),[n]=(0,v.useState)(Date.now),r=t?tK(t,n):null,i=e=>{e.translate(28,50),r?jK(e,{size:38,color:r.color,mood:nK(r),stage:$G(r.xp),blink:!1}):IK(e,.6)},a=e=>fK(e)?`Best ${fK(e).toLocaleString()}`:`No best score yet`;return EG(t=>{let n=[`Digit1`,`Digit2`,`Digit3`].indexOf(t.code);return n<0||t.repeat?!1:(e([`tetris`,`snake`,`pet`][n]),!0)}),(0,K.jsxs)(`div`,{className:`phone-scroll games-list`,children:[(0,K.jsx)(`h3`,{className:`phone-h`,children:`🎮 Games`}),(0,K.jsx)(`p`,{className:`muted small games-blurb`,children:`Something to do while the team works. They pause when you put the phone away.`}),(0,K.jsx)(iJ,{icon:nJ,name:`Cubetris`,what:`Falling blocks (a Tetris clone)`,status:Qq()?`⏸ Game paused, tap to resume`:a(`tetris`),color:Vq,onOpen:()=>e(`tetris`)}),(0,K.jsx)(iJ,{icon:rJ,name:`Cable Snake`,what:`Eat the bugs (a Snake clone)`,status:cq()?`⏸ Game paused, tap to resume`:a(`snake`),color:QK,onOpen:()=>e(`snake`)}),(0,K.jsx)(iJ,{icon:i,name:`Desk Pet`,what:`Your office pet (a Tamagotchi clone)`,status:r?`${r.name} the ${ZG[$G(r.xp)].title.toLowerCase()} ${{asleep:`is napping`,happy:`is thrilled`,content:`is doing fine`,hungry:`is hungry`,bored:`is bored`,tired:`is sleepy`,grumpy:`is grumpy, needs you`}[nK(r)]}`:`📦 A delivery is waiting for you`,color:CK,onOpen:()=>e(`pet`)}),(0,K.jsxs)(`p`,{className:`muted small games-blurb`,children:[(0,K.jsx)(`kbd`,{children:`1`}),` `,(0,K.jsx)(`kbd`,{children:`2`}),` `,(0,K.jsx)(`kbd`,{children:`3`}),` open a game · `,(0,K.jsx)(`kbd`,{children:`Backspace`}),` comes back here`]})]})}function oJ({game:e,onGame:t}){EG(n=>!e||n.code!==`Backspace`?!1:(t(null),!0));let n=()=>t(null);return e===`tetris`?(0,K.jsx)(eJ,{onBack:n}):e===`snake`?(0,K.jsx)(mq,{onBack:n}):e===`pet`?(0,K.jsx)(RK,{onBack:n}):(0,K.jsx)(aJ,{onGame:t})}async function sJ(e){try{return await e()}catch{return}}var cJ=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function lJ({name:e,color:t,size:n=34}){return(0,K.jsx)(`span`,{className:`avatar`,style:{background:t,width:n,height:n,fontSize:n*.45},children:e[0]})}function uJ({req:e,highlight:t}){let n=q(t=>t.repos.find(t=>t.id===e.repoId)),r=q(e=>e.settings),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),f=(0,v.useRef)(null);(0,v.useEffect)(()=>{t&&f.current?.scrollIntoView({block:`center`})},[t]);let p=e.status===`pending`,m=e.kind===`hire`,h=async e=>{d(!0),await sJ(e),d(!1)};return(0,K.jsxs)(`div`,{ref:f,className:`resume ${m?``:`resume-letgo`} ${t?`resume-hot`:``} ${p?``:`resume-done`}`,children:[(0,K.jsxs)(`div`,{className:`resume-head`,children:[(0,K.jsx)(lJ,{name:e.name,color:e.color,size:42}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`div`,{className:`resume-name`,children:m?e.name:`Let ${e.name} go?`}),(0,K.jsx)(`div`,{className:`resume-title`,children:e.title})]}),!p&&(0,K.jsx)(`span`,{className:`chip ${e.status===`approved`?`chip-good`:``}`,children:e.status===`approved`?m?`✅ hired`:`👋 left`:`✋ declined`})]}),(0,K.jsxs)(`div`,{className:`resume-meta`,children:[(0,K.jsxs)(`span`,{className:`chip`,style:{background:n?.color},children:[`Floor `,n?.floor??`?`]}),(0,K.jsx)(`span`,{className:`muted small`,children:n?.fullName.split(`/`)[1]??`removed floor`}),(0,K.jsx)(`span`,{className:`chip`,children:e.role===`qa`?`🔍 QA`:`💻 Dev`}),e.specialty&&(0,K.jsxs)(`span`,{className:`chip`,children:[`🎯 `,e.specialty]})]}),e.reason&&(0,K.jsx)(CG,{className:`resume-reason`,text:e.reason}),m&&e.brief&&(0,K.jsx)(`button`,{className:`linkish small`,"aria-expanded":i,onClick:()=>a(!i),children:i?`▾ Job description`:`▸ Job description`}),i&&(0,K.jsx)(CG,{className:`resume-brief`,text:e.brief}),m&&p&&(0,K.jsxs)(`div`,{className:`muted small`,children:[hD(e.model,r.runtime===`terminal`?r.defaultCli:`claude`,r,`claude-opus-5-5`)||`default model`,` · `,e.effort||r.defaultEffort,` effort`]}),!p&&e.note&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`Your note: “`,e.note,`”`]}),p&&!o&&(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:u,onClick:()=>s(!0),children:m?`Decline`:`Keep them`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:u,onClick:()=>h(()=>Y.approveRequest(e.id)),children:m?`Hire ${e.name}`:`Let ${e.name} go`})]}),p&&o&&(0,K.jsxs)(`form`,{className:`row`,onSubmit:t=>{t.preventDefault(),h(()=>Y.rejectRequest(e.id,c))},children:[(0,K.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Why not? (optional, the CEO reads it)`,autoFocus:!0}),(0,K.jsx)(`button`,{className:`btn btn-small btn-bad`,disabled:u,children:m?`Decline`:`Keep`})]})]})}function dJ({focusId:e}){let t=q(e=>e.requests),n=Ub(t),r=t.filter(e=>e.status!==`pending`).slice(-8).reverse();return(0,K.jsxs)(`div`,{className:`phone-scroll`,children:[(0,K.jsxs)(`h3`,{className:`phone-h`,children:[`📄 Waiting on you `,n.length>0&&(0,K.jsx)(`span`,{className:`badge`,children:n.length})]}),n.length===0&&(0,K.jsx)(`p`,{className:`muted small phone-empty`,children:`Nobody's waiting. When the CEO wants to hire someone, or let someone go, their resume shows up here.`}),n.map(t=>(0,K.jsx)(uJ,{req:t,highlight:t.id===e},t.id)),r.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{className:`phone-h`,children:`Earlier`}),r.map(e=>(0,K.jsx)(uJ,{req:e},e.id))]})]})}var fJ=[`What's everyone working on?`,`Do we need anyone new?`,`Plan the next milestone for the busiest floor.`];function pJ({m:e,ceoName:t}){let n=q(t=>e.requestId?t.requests.find(t=>t.id===e.requestId):void 0);if(e.from===`office`)return(0,K.jsx)(`div`,{className:`bubble-office`,children:e.text});let r=e.from===`manager`;return(0,K.jsx)(`div`,{className:`bubble-row ${r?`bubble-row-me`:``}`,children:(0,K.jsxs)(`div`,{className:`bubble ${r?`bubble-me`:`bubble-them`}`,children:[!r&&(0,K.jsx)(`div`,{className:`bubble-from`,children:t}),r?(0,K.jsx)(`div`,{className:`bubble-text`,children:e.text}):(0,K.jsx)(CG,{className:`bubble-md`,text:e.text}),n&&n.status===`pending`&&e.from===`ceo`&&(0,K.jsx)(uJ,{req:n}),(0,K.jsx)(`div`,{className:`bubble-time`,children:cJ(e.at)})]})})}function mJ(){let e=q(e=>e.messages),t=q(e=>e.phoneReadAt),n=q(e=>e.agents.ceo),r=q(e=>e.ceo),i=q(e=>e.settings),a=q(e=>Object.values(e.agents).filter(Vb).length),[o,s]=(0,v.useState)(``),c=(0,v.useRef)(null);if((0,v.useEffect)(()=>{let n=[...e].reverse().find(e=>e.from===`ceo`);n&&n.at>t&&sJ(()=>Y.phoneRead(n.at))},[e,t]),(0,v.useLayoutEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[e.length,r.job?.kind]),!n)return(0,K.jsx)(`p`,{className:`muted phone-empty`,children:`The corner office is empty.`});let l=e=>{let t=e.trim();t&&(s(``),sJ(()=>Y.messageCeo(t)))},u=n.status===`working`&&r.job?.kind===`chat`,d=r.queue.some(e=>e.kind===`chat`),f=n.status===`working`?u?`typing…`:`busy: ${r.job?.label??`working`}`:d?i.sessionLimit&&a>=i.sessionLimit?`will reply when a session slot frees up (${a}/${i.sessionLimit} busy)`:`reading your message…`:r.queue.length?`next up: ${r.queue[0].label}`:`available`;return(0,K.jsxs)(`div`,{className:`phone-chat`,children:[(0,K.jsxs)(`div`,{className:`chat-head`,children:[(0,K.jsx)(lJ,{name:n.name,color:n.color}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`b`,{children:n.name}),` `,(0,K.jsx)(`span`,{className:`muted small`,children:`CEO`}),(0,K.jsx)(`div`,{className:`small ${n.status===`working`?`presence-busy`:`muted`}`,children:f})]})]}),(0,K.jsxs)(`div`,{className:`chat-log`,ref:c,children:[e.length===0&&(0,K.jsxs)(`p`,{className:`muted small phone-empty`,children:[`Say hi to `,n.name,`. Ask how things are going, hand over a project brief, or ask who the team should hire. Replies land here, and the phone buzzes when `,n.name,` needs you.`]}),e.map(e=>(0,K.jsx)(pJ,{m:e,ceoName:n.name},e.id)),u&&(0,K.jsx)(`div`,{className:`bubble-row`,children:(0,K.jsxs)(`div`,{className:`bubble bubble-them bubble-typing`,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})})]}),(0,K.jsx)(`div`,{className:`quick`,children:fJ.map(e=>(0,K.jsx)(`button`,{className:`quick-chip`,onClick:()=>l(e),children:e},e))}),(0,K.jsxs)(`form`,{className:`chat-input`,onSubmit:e=>{e.preventDefault(),l(o)},children:[(0,K.jsx)(wG,{value:o,onChange:s,placeholder:`Message ${n.name}…`,"aria-label":`Message ${n.name}`,title:`Enter sends · Shift+Enter adds a new line`,autoFocus:!0}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!o.trim(),children:`Send`})]})]})}function hJ(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.qa),r=q(e=>e.requests),i=q(e=>e.settings),a=q(e=>e.ceo);return(0,v.useMemo)(()=>{let o=Object.values(t).filter(e=>e.role!==`ceo`),s=t.ceo,c=Object.values(t).filter(Vb).length,l=e.map(e=>{let t=o.filter(t=>t.repoId===e.id),r=e.pulls.filter(e=>e.state===`OPEN`).map(t=>n[Lb(e.id,t.number)]);return{repo:e,team:t.length,working:t.filter(Vb).length,idleDevs:t.filter(e=>e.role===`dev`&&!Vb(e)).length,issues:e.issues.length,prs:e.pulls.filter(e=>e.state===`OPEN`).length,inQa:r.filter(e=>e&&e.status!==`passed`&&e.status!==`needs-human`).length,ready:r.filter(e=>e?.status===`passed`).length,stuck:r.filter(e=>e?.status===`needs-human`).length,merged:e.pulls.filter(e=>e.state===`MERGED`).length}}),u=e=>l.reduce((t,n)=>t+n[e],0),d=Ub(r).length,f=[],p=l.filter(e=>e.ready>0);p.length&&f.push({icon:`✅`,text:`${u(`ready`)} pull request${u(`ready`)===1?` passed`:`s passed`} QA and ${u(`ready`)===1?`is`:`are`} ready for you to merge (${p.map(e=>`${e.repo.fullName.split(`/`)[1]}: ${e.ready}`).join(`, `)}).`,tone:`good`}),u(`stuck`)&&f.push({icon:`⚠️`,text:`${u(`stuck`)} pull request${u(`stuck`)===1?``:`s`} failed QA three times and need${u(`stuck`)===1?`s`:``} your call.`,tone:`warn`}),d&&f.push({icon:`📄`,text:`${d} hiring decision${d===1?` is`:`s are`} waiting in Hires.`,tone:`warn`}),f.push({icon:`⚙️`,text:i.sessionLimit?c?`${c} of ${i.sessionLimit} session slots are busy right now.`:`Nobody is working at the moment (${i.sessionLimit} session slots free).`:c?`${c} session${c===1?` is`:`s are`} running right now.`:`Nobody is working at the moment.`});for(let e of l)e.issues>0&&!e.repo.autoAssign&&e.working===0&&e.idleDevs>0&&f.push({icon:`💤`,text:`${e.repo.fullName.split(`/`)[1]} has ${e.issues} open issue${e.issues===1?``:`s`} and free developers, but auto-assign is off.`});let m=[...l].sort((e,t)=>t.issues+t.prs-(e.issues+e.prs))[0];return m&&m.issues+m.prs>0&&l.length>1&&f.push({icon:`🔥`,text:`Most work in flight: ${m.repo.fullName.split(`/`)[1]} (${m.issues} issues, ${m.prs} PRs).`}),s&&f.push({icon:`🧠`,text:s.status===`working`?`${s.name} is ${(a.job?.label??`working`).replace(/^\w/,e=>e.toLowerCase())}.`:a.nextReviewAt?`${s.name} reviews the company next at ${cJ(a.nextReviewAt)}.`:`${s.name}'s periodic reviews are off.`}),l.length===0&&f.splice(0,f.length,{icon:`👋`,text:`No projects yet. Connect a repo in the manager's office (lobby, back left) and the CEO will staff it.`}),{floors:l,staff:o.length,running:c,max:i.sessionLimit,issues:u(`issues`),prs:u(`prs`),report:f}},[e,t,n,r,i,a])}function gJ(){let e=hJ(),t=q(e=>e.goToFloor),n=[[`🏢`,e.floors.length,e.floors.length===1?`project`:`projects`],[`📋`,e.issues,`open issues`],[`🔀`,e.prs,`open PRs`],[`👥`,e.staff,`on staff`],[`⚙️`,e.max?`${e.running}/${e.max}`:`${e.running}`,`working now`]];return(0,K.jsxs)(`div`,{className:`phone-scroll`,children:[(0,K.jsx)(`div`,{className:`tiles`,children:n.map(([e,t,n])=>(0,K.jsxs)(`div`,{className:`tile`,children:[(0,K.jsxs)(`div`,{className:`tile-value`,children:[e,` `,t]}),(0,K.jsx)(`div`,{className:`tile-label`,children:n})]},n))}),(0,K.jsx)(`h3`,{className:`phone-h`,children:`Today's report`}),(0,K.jsx)(`ul`,{className:`report`,children:e.report.map((e,t)=>(0,K.jsxs)(`li`,{className:e.tone?`report-${e.tone}`:``,children:[(0,K.jsx)(`span`,{children:e.icon}),(0,K.jsx)(`span`,{children:e.text})]},t))}),e.floors.length>0&&(0,K.jsx)(`h3`,{className:`phone-h`,children:`Projects`}),e.floors.map(e=>(0,K.jsxs)(`div`,{className:`proj`,style:{"--accent":e.repo.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.repo.floor}),(0,K.jsxs)(`div`,{className:`grow`,style:{minWidth:0},children:[(0,K.jsx)(`b`,{className:`proj-name`,children:e.repo.fullName.split(`/`)[1]}),(0,K.jsx)(`div`,{className:`muted small proj-sum`,children:e.repo.summary||e.repo.description||e.repo.fullName})]}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>t(e.repo.floor),children:`Go`})]}),(0,K.jsxs)(`div`,{className:`proj-stats small`,children:[(0,K.jsxs)(`span`,{children:[`👥 `,e.team,e.working?` (${e.working} busy)`:``]}),(0,K.jsxs)(`span`,{children:[`📋 `,e.issues]}),(0,K.jsxs)(`span`,{children:[`🔍 `,e.inQa]}),(0,K.jsxs)(`span`,{className:e.ready?`proj-ready`:``,children:[`✅ `,e.ready]}),(0,K.jsxs)(`span`,{children:[`🎉 `,e.merged]})]})]},e.repo.id))]})}var _J=null,vJ=()=>{let e=q.getState();return Ub(e.requests).length+Hb(e.messages,e.phoneReadAt)};function yJ({tab:e,requestId:t}){let[n,r]=(0,v.useState)(()=>_J&&!t&&vJ()<=_J.waiting?`games`:e??(t?`hires`:`chat`)),[i,a]=(0,v.useState)(()=>n===`games`?_J?.game??null:null),o=(0,v.useRef)({tab:n,game:i});(0,v.useEffect)(()=>{o.current={tab:n,game:i}}),(0,v.useEffect)(()=>()=>{_J=o.current.tab===`games`?{game:o.current.game,waiting:vJ()}:null},[]);let s=q(e=>e.openOverlay),c=q(e=>e.requests),l=q(e=>e.messages),u=q(e=>e.phoneReadAt),d=q(e=>e.agents.ceo?.name??`CEO`),[f,p]=(0,v.useState)(Date.now());(0,v.useEffect)(()=>{let e=setInterval(()=>p(Date.now()),2e4);return()=>clearInterval(e)},[]),(0,v.useEffect)(()=>{s({kind:`phone`,tab:n,requestId:t})},[n]),(0,v.useEffect)(()=>{let e=e=>{let t=e.target,n=!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`);(e.key===`Escape`||!n&&e.code===`KeyP`)&&(e.preventDefault(),GJ())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let m=Ub(c).length,h=Hb(l,u),g=[[`chat`,`💬`,d,n===`chat`?0:h],[`hires`,`📄`,`Hires`,m],[`company`,`📊`,`Company`,0],[`games`,`🎮`,`Games`,0]];return(0,K.jsx)(`div`,{className:`overlay phone-overlay`,onMouseDown:e=>e.target===e.currentTarget&&GJ(),children:(0,K.jsxs)(`div`,{className:`phone`,children:[(0,K.jsxs)(`div`,{className:`phone-status`,children:[(0,K.jsx)(`span`,{children:cJ(f)}),(0,K.jsx)(`span`,{className:`phone-notch`}),(0,K.jsx)(`span`,{children:`📶 🔋`})]}),(0,K.jsxs)(`div`,{className:`phone-screen`,children:[n===`chat`&&(0,K.jsx)(mJ,{}),n===`hires`&&(0,K.jsx)(dJ,{focusId:t}),n===`company`&&(0,K.jsx)(gJ,{}),n===`games`&&(0,K.jsx)(oJ,{game:i,onGame:a})]}),(0,K.jsx)(`nav`,{className:`phone-tabs`,children:g.map(([e,t,i,o])=>(0,K.jsxs)(`button`,{className:`phone-tab ${n===e?`phone-tab-on`:``}`,onClick:()=>e===`games`&&n===`games`?a(null):r(e),children:[(0,K.jsxs)(`span`,{className:`phone-tab-icon`,children:[t,o>0&&(0,K.jsx)(`span`,{className:`badge badge-dot`,children:o})]}),(0,K.jsx)(`span`,{children:i})]},e))}),(0,K.jsxs)(`div`,{className:`phone-hint`,children:[n===`chat`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`kbd`,{children:`Shift`}),`+`,(0,K.jsx)(`kbd`,{children:`Enter`}),` new line ·`,` `]}),n===`games`&&i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`kbd`,{children:`Backspace`}),` games ·`,` `]}),(0,K.jsx)(`kbd`,{children:`P`}),` or `,(0,K.jsx)(`kbd`,{children:`Esc`}),` to put it away`]})]})})}async function bJ(e){try{return await e()}catch{return}}var xJ=e=>e.includes(`\\`)?`\\`:`/`;function SJ({floor:e,onDone:t}){let n=q(e=>e.settings.projectsDir),[r,i]=(0,v.useState)(n),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(null),p=e=>{c(null),bJ(()=>Y.folders(e)).then(e=>{c(e?.folders??[]),e&&(o(e.root),i(e.root))})};(0,v.useEffect)(()=>p(),[]);let m=(0,v.useMemo)(()=>(s??[]).filter(e=>e.name.toLowerCase().includes(l.toLowerCase())),[s,l]),h=async(e,n)=>{f(e.path);let r=await bJ(n);f(null),r?t(r):p(a)},g=async t=>{await MT({icon:`🐙`,title:`Put ${t.name} on GitHub?`,body:(0,K.jsxs)(K.Fragment,{children:[`This creates a `,(0,K.jsx)(`b`,{children:`private`}),` GitHub repo called `,(0,K.jsx)(`code`,{children:t.name}),` and pushes what's already committed. Nothing uncommitted leaves your computer.`,!t.git&&` An empty folder gets a starter README first.`]}),confirm:`Create private repo`})&&h(t,()=>Y.publishFolder({path:t.path,visibility:`private`,...e}))};return(0,K.jsxs)(`div`,{className:`picker-mode`,children:[(0,K.jsxs)(`form`,{className:`row`,onSubmit:e=>{e.preventDefault(),p(r.trim()||void 0)},children:[(0,K.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`C:\\Projects`,title:`Your projects folder`}),(0,K.jsx)(`button`,{className:`btn btn-small`,children:`Look here`})]}),a&&a!==n&&(0,K.jsxs)(`div`,{className:`row small`,children:[(0,K.jsxs)(`span`,{className:`muted grow`,children:[`New projects are created in `,n,`.`]}),(0,K.jsxs)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void bJ(()=>Y.updateSettings({projectsDir:a})),children:[`Use `,a,` instead`]})]}),(0,K.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`Filter folders…`}),(0,K.jsxs)(`div`,{className:`repo-list folder-list`,children:[s===null&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`Looking through `,r||`your projects folder`,`…`]}),s&&m.length===0&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`No folders here`,l?` match`:``,`.`]}),m.map(t=>(0,K.jsxs)(`div`,{className:`repo-row`,children:[(0,K.jsxs)(`div`,{style:{minWidth:0},children:[(0,K.jsxs)(`b`,{children:[`📁 `,t.name]}),` `,t.floor==null?t.github?(0,K.jsxs)(`span`,{className:`chip`,children:[`🐙 `,t.github]}):(0,K.jsx)(`span`,{className:`chip chip-warn`,children:t.git?`not on GitHub`:`no git yet`}):(0,K.jsxs)(`span`,{className:`chip chip-good`,children:[`floor `,t.floor]})]}),t.floor==null?t.github?(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!!d,onClick:()=>h(t,()=>Y.connectFolder(t.path,e)),children:d===t.path?`Moving in…`:`Add floor`}):(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:!!d,onClick:()=>void g(t),children:d===t.path?`Publishing…`:`Publish to GitHub`}):(0,K.jsx)(`span`,{className:`muted small`,children:`in the office`})]},t.path))]}),(0,K.jsx)(`p`,{className:`muted small`,children:`The office never touches your work in progress: after a merge it only fast-forwards your folder when it's on the default branch with no local changes (and runs npm install if dependencies changed). Each agent works in its own git worktree of it, kept outside your project (so your dev server and linters never see them).`})]})}function CJ({floor:e,onDone:t}){let n=q(e=>e.repos),r=q(e=>e.settings.projectsDir),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(null),m=e=>{a(null),bJ(()=>Y.githubRepos(e)).then(e=>a(e??[]))};(0,v.useEffect)(()=>m(),[]);let h=new Set(n.map(e=>e.id.toLowerCase())),g=(i??[]).filter(e=>!h.has(e.nameWithOwner.toLowerCase())&&e.nameWithOwner.toLowerCase().includes(c.toLowerCase())).slice(0,60),_=async n=>{p(n);let r=await bJ(()=>Y.connectRepo(n,e));p(null),r&&t(r)};return(0,K.jsxs)(`div`,{className:`picker-mode`,children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Filter your repos…`}),(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Org (optional)`,style:{maxWidth:160}}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>m(o.trim()||void 0),children:`List`})]}),(0,K.jsxs)(`div`,{className:`repo-list folder-list`,children:[i===null&&(0,K.jsx)(`div`,{className:`muted small`,children:`Asking GitHub for your repos…`}),i&&g.length===0&&(0,K.jsx)(`div`,{className:`muted small`,children:`No matching repos.`}),g.map(e=>(0,K.jsxs)(`div`,{className:`repo-row`,children:[(0,K.jsxs)(`div`,{style:{minWidth:0},children:[(0,K.jsx)(`b`,{children:e.nameWithOwner}),` `,(0,K.jsx)(`span`,{className:`chip`,children:e.visibility.toLowerCase()}),e.description&&(0,K.jsx)(`div`,{className:`muted small`,children:e.description})]}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!!f,onClick:()=>_(e.nameWithOwner),children:f===e.nameWithOwner?`Moving in…`:`Add floor`})]},e.nameWithOwner))]}),(0,K.jsxs)(`form`,{className:`row`,onSubmit:e=>{e.preventDefault(),u.trim()&&_(u.trim())},children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`…or type owner/name`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:!u.trim()||!!f,children:`Add floor`})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`If it's already in `,r||`your projects folder`,`, that folder is used. Otherwise it's cloned to `,r,xJ(r),`<name>.`]})]})}function wJ({floor:e,onDone:t}){let n=q(e=>e.settings.projectsDir),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(`private`),[l,u]=(0,v.useState)(!1),d=r.trim().replace(/[^A-Za-z0-9._-]+/g,`-`);return(0,K.jsxs)(`form`,{className:`picker-mode`,onSubmit:async n=>{if(n.preventDefault(),!d)return;u(!0);let r=await bJ(()=>Y.createRepo({name:d,description:a,visibility:s,...e}));u(!1),r&&t(r)},children:[(0,K.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Project name, e.g. island-bakery`,autoFocus:!0}),(0,K.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:`One-line description (optional)`}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:s===`private`,onChange:()=>c(`private`)}),` Private`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:s===`public`,onChange:()=>c(`public`)}),` Public`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:l||!d,children:l?`Creating…`:`Create project`})]}),(0,K.jsxs)(`p`,{className:`muted small`,children:[`Creates `,(0,K.jsx)(`code`,{children:d?`${n}${xJ(n)}${d}`:`${n}${xJ(n)}…`}),` with a README and pushes it to a new `,s,` GitHub repo. Give the CEO a brief below and they'll plan the first milestone.`]})]})}function TJ({onConnected:e,initial:t=`folder`}){let[n,r]=(0,v.useState)(t),[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(!0),c={mission:i,autoAssign:o},l=t=>{a(``),e?.(t)};return(0,K.jsxs)(`div`,{className:`picker`,children:[(0,K.jsx)(`div`,{className:`picker-tabs`,children:[[`folder`,`📁 A folder on this computer`],[`github`,`🐙 A GitHub repo`],[`new`,`✨ Something new`]].map(([e,t])=>(0,K.jsx)(`button`,{className:`picker-tab ${n===e?`picker-tab-on`:``}`,onClick:()=>r(e),children:t},e))}),(0,K.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),rows:2,placeholder:n===`new`?`What should the team build? e.g. A cozy 3D browser game where you run a tiny island bakery.`:`Brief for the CEO (optional): what should the team work on next?`}),(0,K.jsxs)(`label`,{className:`toggle small`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`⚡ Start work automatically: free developers pick up issues as soon as they're filed (you can switch this off per floor)`]}),n===`folder`&&(0,K.jsx)(SJ,{floor:c,onDone:l}),n===`github`&&(0,K.jsx)(CJ,{floor:c,onDone:l}),n===`new`&&(0,K.jsx)(wJ,{floor:c,onDone:l})]})}var EJ={idle:`free`,preparing:`setting up`,working:`working`,done:`done`,error:`needs help`,stopped:`stopped`};function DJ({status:e}){return(0,K.jsx)(`span`,{className:`status status-${e}`,children:EJ[e]??e})}function OJ(e,t){if(!e)return``;let n=Math.max(0,Math.floor(((t??Date.now())-e)/1e3));return`${Math.floor(n/60)}m ${n%60}s`}function kJ({agentId:e}){let t=q(t=>t.agents[e]),n=q(t=>t.logs[e])??[],r=q(t=>t.screens[e]),i=q(t=>t.repos.find(n=>n.id===t.agents[e]?.repoId)),a=q(e=>e.agents),o=q(e=>e.settings),s=q(e=>e.clis),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[,m]=(0,v.useState)(0),h=(0,v.useRef)(null),g=(0,v.useRef)(!0);(0,v.useEffect)(()=>{let e=setInterval(()=>m(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,v.useLayoutEffect)(()=>{let e=h.current;e&&g.current&&(e.scrollTop=e.scrollHeight)},[n.length]);let _=q(e=>e.qa),y=(0,v.useMemo)(()=>i?Gb(i,zb(a,i.id),_):null,[i,a,_]),b=t?.role===`qa`,x=y?b?y.qa.filter(e=>!e.qa||e.qa.status===`needs-human`||e.qa.status===`queued`):y.backlog:[];if(!t||!i)return(0,K.jsx)(KJ,{title:`Terminal`,children:(0,K.jsx)(`p`,{className:`muted`,children:`That agent has left the building.`})});let S=async e=>{p(!0);try{await e()}catch{}finally{p(!1)}},C=Vb(t),w=t.role===`ceo`?`claude`:t.cli||o.defaultCli,T=s.find(e=>e.id===w)?.label??w,E=t.issueNumber?`https://github.com/${i.fullName}/issues/${t.issueNumber}`:null,D=C||!b&&!!t.branch&&t.status!==`idle`,O=t.prNumber?_[`${i.id}#${t.prNumber}`]:void 0;return(0,K.jsxs)(KJ,{wide:!0,accent:t.color,title:(0,K.jsxs)(`div`,{className:`term-title`,children:[(0,K.jsx)(`span`,{className:`avatar`,style:{background:t.color},children:t.name[0]}),(0,K.jsx)(`span`,{children:t.name}),(0,K.jsxs)(`span`,{className:`chip`,title:t.brief||void 0,children:[b?`🔍`:`💻`,` `,t.title||(b?`QA tester`:`Developer`),t.specialty?` · 🎯 ${t.specialty}`:``]}),(0,K.jsx)(DJ,{status:t.status}),C&&t.currentTool&&(0,K.jsxs)(`span`,{className:`muted small`,children:[MS(t.currentTool),`…`]})]}),children:[(0,K.jsxs)(`div`,{className:`term-meta`,children:[t.task===`qa`&&t.status!==`idle`?(0,K.jsxs)(`a`,{href:t.prUrl??`#`,target:`_blank`,rel:`noreferrer`,children:[`Testing PR #`,t.prNumber,`: `,t.issueTitle]}):t.task===`fix`&&t.status!==`idle`?(0,K.jsxs)(`a`,{href:t.prUrl??`#`,target:`_blank`,rel:`noreferrer`,children:[`Fixing PR #`,t.prNumber,` after QA: `,t.issueTitle]}):t.issueNumber&&t.status!==`idle`?(0,K.jsxs)(`a`,{href:E,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,t.issueNumber,`: `,t.issueTitle]}):(0,K.jsx)(`span`,{className:`muted`,children:b?`Nothing under test`:`No issue assigned`}),t.prUrl&&t.task===`issue`&&(0,K.jsxs)(`a`,{href:t.prUrl,target:`_blank`,rel:`noreferrer`,className:`chip chip-good`,children:[`PR #`,t.prNumber]}),O&&t.status!==`idle`&&(0,K.jsxs)(`span`,{className:`chip ${O.status===`passed`?`chip-good`:``}`,children:[`QA: `,O.status,O.round>1?` · round ${O.round}`:``]}),O?.commentUrl&&(0,K.jsx)(`a`,{href:O.commentUrl,target:`_blank`,rel:`noreferrer`,children:`QA report ↗`}),t.branch&&(0,K.jsx)(`code`,{children:t.branch}),o.runtime===`terminal`&&(0,K.jsxs)(`span`,{className:`chip`,title:`The coding agent in their terminal`,children:[`⌨️ `,T]}),(0,K.jsxs)(`span`,{className:`muted`,children:[(t.role===`ceo`?t.model:hD(t.model,o.runtime===`terminal`?w:`claude`,o,`claude-opus-5-5`))||`default model`,` ·`,` `,t.effort||o.defaultEffort,` effort`]}),t.startedAt&&(0,K.jsxs)(`span`,{className:`muted`,children:[`⏱ `,OJ(t.startedAt,C?null:t.endedAt)]}),t.turns>0&&(0,K.jsxs)(`span`,{className:`muted`,children:[t.turns,` turns`]}),t.costUsd>0&&(0,K.jsxs)(`span`,{className:`muted`,title:`API-equivalent cost reported by the coding agent; subscription usage is billed by plan`,children:[`≈$`,t.costUsd.toFixed(2)]})]}),t.lastError&&t.status!==`working`&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,t.lastError]}),t.brief&&(0,K.jsxs)(`details`,{className:`small job-brief`,children:[(0,K.jsxs)(`summary`,{children:[`Job description`,t.hiredBy===`ceo`?` (from the CEO)`:``]}),(0,K.jsx)(CG,{text:t.brief})]}),(0,K.jsxs)(`div`,{className:`term-split ${t.hasScreenshot?`term-split-2`:``}`,children:[t.terminal?(0,K.jsx)(CF,{agentId:t.id}):(0,K.jsxs)(`div`,{className:`term`,ref:h,onScroll:e=>{let t=e.currentTarget;g.current=t.scrollHeight-t.scrollTop-t.clientHeight<40},children:[n.length===0&&(0,K.jsx)(`div`,{className:`term-line term-system`,children:`(no output yet)`}),n.map(e=>(0,K.jsx)(`div`,{className:`term-line term-${e.kind}`,children:e.text||` `},e.id)),C&&(0,K.jsxs)(`div`,{className:`term-line term-spin`,children:[`✻ `,t.status===`preparing`?`Setting up worktree`:MS(t.currentTool)||`Thinking`,`… (`,OJ(t.startedAt,null),`)`]})]}),t.hasScreenshot&&(0,K.jsxs)(`div`,{className:`browser`,children:[(0,K.jsxs)(`div`,{className:`browser-bar`,children:[`🔒 `,t.browserUrl??`about:blank`]}),(0,K.jsx)(`div`,{className:`browser-view`,children:(0,K.jsx)(`img`,{src:`/api/agents/${t.id}/screen?t=${r??t.screenshotAt}`,alt:`Latest browser screenshot from the agent`})}),(0,K.jsxs)(`div`,{className:`muted small`,children:[`Latest Playwright screenshot`,t.screenshotAt?` · ${new Date(t.screenshotAt).toLocaleTimeString()}`:``]})]})]}),(0,K.jsxs)(`form`,{className:`term-input`,onSubmit:e=>{e.preventDefault();let n=c.trim();n&&(l(``),S(()=>Y.message(t.id,n)))},children:[(0,K.jsx)(wG,{value:c,onChange:l,"aria-label":`Message ${t.name}`,title:`Enter sends · Shift+Enter adds a new line`,placeholder:C?`Tell ${t.name} something while they work${t.terminal?` (typed into their terminal)`:``}…`:D?`Ask ${t.name} for a follow-up (resumes their session)…`:`Assign an issue to get ${t.name} started`,disabled:!D,autoFocus:!t.terminal}),(0,K.jsx)(`button`,{className:`btn`,disabled:f||!D||!c.trim(),children:`Send`})]}),(0,K.jsxs)(`div`,{className:`term-actions`,children:[C?(0,K.jsx)(`button`,{className:`btn btn-bad`,disabled:f,onClick:()=>S(()=>Y.stop(t.id)),children:`■ Stop`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`select`,{value:u,onChange:e=>d(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:b?`Pick a pull request to test…`:`Pick an issue from the backlog…`}),x.map(e=>(0,K.jsxs)(`option`,{value:e.number,children:[b?`PR `:``,`#`,e.number,` `,e.title]},e.key))]}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:f||!u,onClick:()=>S(async()=>{b?await Y.sendToQa(i.id,Number(u)):await Y.assign(t.id,Number(u)),d(``)}),children:b?`🔍 Send to QA`:`▶ Start issue`}),t.status!==`idle`&&(0,K.jsx)(`button`,{className:`btn`,disabled:f,onClick:()=>S(()=>Y.reset(t.id)),children:`↺ Clear desk`})]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-ghost`,disabled:f,onClick:()=>{S(async()=>{await MT({tone:`danger`,icon:`👋`,title:`Let ${t.name} go?`,body:`Their worktree is removed. Branches they pushed stay on GitHub.`,confirm:`Let ${t.name} go`})&&(await Y.fireAgent(t.id),GJ())})},children:`Let go`})]})]})}var AJ=[`claude-opus-5-5`,`claude-opus-5`,`claude-fable-5-1`,`claude-sonnet-5`,`claude-haiku-4-5`],jJ=[`low`,`medium`,`high`,`xhigh`,`max`],MJ=(e,t)=>e.find(e=>e.id===t)?.label??t;function NJ({clis:e}){return(0,K.jsx)(K.Fragment,{children:[...e].sort((e,t)=>Number(t.installed)-Number(e.installed)).map(e=>(0,K.jsxs)(`option`,{value:e.id,disabled:!e.installed,children:[e.label,e.installed?``:` (not installed)`]},e.id))})}async function PJ(e){try{return await e()}catch{return}}var FJ=`Start the office with npm run dev or npm start so it can install updates and restart itself.`;function IJ({update:e}){let t=q(e=>e.officeCommit),n=q(e=>e.settings.autoUpdate),[r,i]=(0,v.useState)(!1),a=e=>{i(!0),PJ(()=>Y.updateOffice(e)).finally(()=>i(!1))},o=GE(e),s=e.state!==`none`,c=e.state===`failed`?`office-state-bad`:e.state===`none`?`office-state-ok`:`office-state-busy`,l=(t,n)=>e.launcher?t?n:void 0:FJ;return(0,K.jsxs)(`div`,{className:`card office-card`,children:[(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsx)(`span`,{className:`floor-badge office-badge`,"aria-hidden":!0,children:`🏢`}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`b`,{children:`Office`}),` `,(0,K.jsxs)(`span`,{className:`muted small`,children:[`running `,t?(0,K.jsx)(`code`,{children:t}):`an unknown commit`]}),(0,K.jsx)(`div`,{className:`small office-state ${c}`,role:`status`,children:UE(e)})]}),s&&(0,K.jsxs)(`div`,{className:`office-actions`,title:e.launcher?void 0:FJ,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:r||!KE(e),title:l(KE(e),`Start nothing new, let running sessions finish, then update and restart the office`),onClick:()=>a(`now`),children:`Update now`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,disabled:r||!qE(e),title:l(qE(e),`Keep working; ask again in 2 hours or when a newer commit lands`),onClick:()=>a(`later`),children:`Later`})]})]}),e.detail&&e.state!==`failed`&&(0,K.jsx)(`div`,{className:`muted small`,children:e.detail}),o&&e.running>0&&(0,K.jsxs)(`div`,{className:`muted small`,children:[`Sessions still running at `,new Date(o).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),` are stopped, and their work goes back to the queue.`]}),!e.launcher&&s&&(0,K.jsx)(`div`,{className:`muted small`,children:FJ}),typeof n==`boolean`&&(0,K.jsxs)(`label`,{className:`toggle`,title:`When an update is ready, start nothing new, let running sessions finish, then update and restart the office`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>void PJ(()=>Y.updateSettings({autoUpdate:e.target.checked}))}),` Update automatically`]})]})}function LJ({repo:e,all:t}){let n=q(e=>e.agents),r=q(e=>e.goToFloor),i=q(e=>e.openOverlay),a=q(e=>!!e.officeUpdate)&&!!e.folderSync?.startsWith(`update ready`),o=zb(n,e.id),s=t.filter(t=>t.id!==e.id),c=t=>void PJ(()=>Y.updateRepo(e.id,t));return(0,K.jsxs)(`div`,{className:`card floor-card`,style:{"--accent":e.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.floor}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:(0,K.jsx)(`b`,{children:e.fullName})}),e.summary&&(0,K.jsxs)(`div`,{className:`small`,children:[`🧠 `,e.summary]}),(0,K.jsxs)(`div`,{className:`muted small`,children:[o.length,` agents · `,e.issues.length,` open issues · `,e.pulls.filter(e=>e.state===`OPEN`).length,` open PRs · default branch `,(0,K.jsx)(`code`,{children:e.defaultBranch}),e.cloneStatus!==`ready`&&` · checkout: ${e.cloneStatus}`]}),(0,K.jsxs)(`div`,{className:`muted small`,title:e.localPath?`Your own project folder`:`A clone the office manages`,children:[`📁 `,(0,K.jsx)(`code`,{children:e.checkoutPath}),a?` · the office's own folder, updated from the Office row`:e.folderSync&&` · ${e.folderSync}`,` `,(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,title:`Fast-forward it to GitHub's default branch, when that's safe`,onClick:()=>void PJ(()=>Y.syncFolder(e.id)),children:`⟳ Sync now`})]}),e.cloneError&&(0,K.jsxs)(`div`,{className:`term-error small`,children:[`clone failed: `,e.cloneError]}),e.syncError&&(0,K.jsxs)(`div`,{className:`term-error small`,children:[`sync failed: `,e.syncError]})]}),(0,K.jsx)(`input`,{type:`color`,value:e.color,onChange:e=>c({color:e.target.value}),title:`Floor colour`}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>r(e.floor),children:`Visit`})]}),(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.autoAssign,onChange:e=>c({autoAssign:e.target.checked})}),` ⚡ Auto-assign issues`]}),(0,K.jsxs)(`label`,{className:`toggle`,title:`Merge a PR as soon as QA has signed off on its latest commit and GitHub's checks are green`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.autoMerge,onChange:e=>c({autoMerge:e.target.checked})}),` 🔀 Auto-merge`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.browserTesting,onChange:e=>c({browserTesting:e.target.checked})}),` 🌐 Browser testing (Playwright MCP)`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>{MT({tone:`danger`,title:`Disconnect ${e.fullName}?`,body:`Everyone on this floor is let go. Nothing is deleted on GitHub, and ${e.localPath?`your folder stays exactly as it is`:`the local clone stays on disk`}.`,confirm:`Disconnect`}).then(t=>t&&PJ(()=>Y.disconnectRepo(e.id)))},children:`Disconnect`})]}),s.length>0&&(0,K.jsxs)(`div`,{className:`row wrap links`,children:[(0,K.jsx)(`span`,{className:`muted small`,children:`🔗 Agents here may read:`}),s.map(t=>(0,K.jsxs)(`label`,{className:`toggle small`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.links.includes(t.id),onChange:n=>c({links:n.target.checked?[...e.links,t.id]:e.links.filter(e=>e!==t.id)})}),t.fullName]},t.id))]}),(0,K.jsxs)(`details`,{className:`small preview-details`,children:[(0,K.jsxs)(`summary`,{children:[`🖥️ App preview · `,(0,K.jsx)(iD,{status:e.preview.status}),e.previewConfig.command?(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(`code`,{children:e.previewConfig.command})]}):` auto-detected command`]}),(0,K.jsx)(sD,{repo:e}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`app`,repoId:e.id}),children:`Open the app viewer`})]})]})}function RJ(){let e=q(e=>e.repos),t=q(e=>e.officeUpdate);return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{children:[t&&(0,K.jsx)(IJ,{update:t}),(0,K.jsx)(`h3`,{className:`section`,children:`🏢 Floors`}),e.length===0&&(0,K.jsx)(`p`,{className:`muted`,children:`No floors yet. Add a project →`}),[...e].sort((e,t)=>e.floor-t.floor).map(t=>(0,K.jsx)(LJ,{repo:t,all:e},t.id))]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`➕ Add a project`}),(0,K.jsx)(TJ,{})]})]})}function zJ({repo:e}){let[t,n]=(0,v.useState)(e.mission);return(0,v.useEffect)(()=>n(e.mission),[e.mission]),(0,K.jsxs)(`div`,{className:`card floor-card`,style:{"--accent":e.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.floor}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsx)(`b`,{children:e.fullName}),(0,K.jsx)(`div`,{className:`muted small`,children:e.summary?`🧠 ${e.summary}`:`The CEO has not studied this floor yet.`})]}),(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void PJ(()=>Y.onboardFloor(e.id)),title:`Study the repo again and rethink the team`,children:`Re-study`})]}),(0,K.jsx)(`textarea`,{value:t,onChange:e=>n(e.target.value),rows:2,placeholder:`Brief: what should this floor build next? The CEO turns it into issues and a team.`}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:t===e.mission,onClick:()=>void PJ(()=>Y.updateRepo(e.id,{mission:t})),children:`Save brief`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:!t.trim(),onClick:()=>void PJ(()=>Y.planFloor(e.id,t)),children:`🧠 Ask the CEO to plan it`})]}),(0,K.jsxs)(`details`,{className:`small`,children:[(0,K.jsxs)(`summary`,{children:[`QA brief`,e.qaBrief?``:` (none yet)`]}),(0,K.jsx)(`textarea`,{rows:4,defaultValue:e.qaBrief,placeholder:`What QA testers must check on every PR for this project.`,onBlur:t=>t.target.value!==e.qaBrief&&void PJ(()=>Y.updateRepo(e.id,{qaBrief:t.target.value}))},e.qaBrief)]})]})}function BJ(){let e=q(e=>e.agents.ceo),t=q(e=>e.logs.ceo)??[],n=q(e=>e.ceo),r=q(e=>e.repos),i=q(e=>e.requests),a=q(e=>e.openOverlay),[o,s]=(0,v.useState)(``),c=(0,v.useRef)(null);if((0,v.useLayoutEffect)(()=>{let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[t.length]),!e)return(0,K.jsx)(`p`,{className:`muted`,children:`The corner office is empty.`});let l=e.status===`working`,u=Ub(i),d=i.filter(e=>e.status!==`pending`).slice(-6).reverse();return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`avatar`,style:{background:e.color},children:e.name[0]}),(0,K.jsx)(`input`,{className:`inline`,defaultValue:e.name,style:{maxWidth:140,fontWeight:700},onBlur:t=>t.target.value.trim()&&t.target.value!==e.name&&void PJ(()=>Y.updateAgent(e.id,{name:t.target.value}))}),(0,K.jsx)(`span`,{className:`muted small`,children:`CEO`}),(0,K.jsx)(DJ,{status:e.status}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`input`,{className:`inline`,list:`models-ceo`,defaultValue:e.model,title:`The CEO's model`,style:{maxWidth:150},onBlur:t=>t.target.value!==e.model&&void PJ(()=>Y.updateAgent(e.id,{model:t.target.value}))}),(0,K.jsx)(`datalist`,{id:`models-ceo`,children:AJ.map(e=>(0,K.jsx)(`option`,{value:e},e))}),(0,K.jsx)(`select`,{value:e.effort,title:`The CEO's effort`,onChange:t=>void PJ(()=>Y.updateAgent(e.id,{effort:t.target.value})),style:{width:`auto`},children:jJ.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`small`,children:[(0,K.jsx)(`b`,{children:`Now:`}),` `,l?n.job?.label:`free`,n.queue.length>0&&(0,K.jsxs)(K.Fragment,{children:[` `,`· `,(0,K.jsx)(`b`,{children:`Up next:`}),` `,n.queue.map(e=>e.label).join(` → `)]})]}),(0,K.jsx)(`div`,{className:`muted small`,children:n.nextReviewAt?`Next company review around ${new Date(n.nextReviewAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} (skipped if nothing changed).`:`Periodic reviews are off (Settings).`}),e.terminal?(0,K.jsx)(CF,{agentId:e.id,className:`ceo-term`}):(0,K.jsxs)(`div`,{className:`term ceo-term`,ref:c,children:[t.length===0&&(0,K.jsx)(`div`,{className:`term-line term-system`,children:`(nothing yet)`}),t.map(e=>(0,K.jsx)(`div`,{className:`term-line term-${e.kind}`,children:e.text||` `},e.id))]}),(0,K.jsxs)(`form`,{className:`row`,onSubmit:e=>{if(e.preventDefault(),!o.trim())return;let t=o;s(``),PJ(()=>Y.messageCeo(t))},children:[(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Message ${e.name} (or press P anywhere for your phone)…`}),(0,K.jsx)(`button`,{className:`btn`,disabled:!o.trim(),children:`Send`})]}),(0,K.jsxs)(`div`,{className:`row`,children:[l&&(0,K.jsx)(`button`,{className:`btn btn-small btn-bad`,onClick:()=>void PJ(()=>Y.stop(e.id)),children:`■ Stop`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:r.length===0,onClick:()=>void PJ(()=>Y.ceoReview()),children:`🔎 Review the company now`}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>a({kind:`phone`,tab:`chat`}),children:`📱 Open the phone`})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`section`,children:[`📄 Hiring `,u.length>0&&(0,K.jsx)(`span`,{className:`badge`,children:u.length})]}),u.length===0&&(0,K.jsx)(`p`,{className:`muted small`,children:`No proposals waiting. The CEO proposes hires when they study a floor or notice the team can't cover the work.`}),u.map(e=>(0,K.jsx)(uJ,{req:e},e.id)),d.length>0&&(0,K.jsxs)(`details`,{className:`small`,style:{marginBottom:12},children:[(0,K.jsx)(`summary`,{children:`Recent decisions`}),d.map(e=>(0,K.jsx)(uJ,{req:e},e.id))]}),(0,K.jsx)(`h3`,{className:`section`,children:`🗺️ Project briefs`}),r.length===0&&(0,K.jsx)(`p`,{className:`muted small`,children:`Connect a repo first.`}),[...r].sort((e,t)=>e.floor-t.floor).map(e=>(0,K.jsx)(zJ,{repo:e},e.id))]})]})}function VJ(){let e=q(e=>e.repos),t=q(e=>e.agents),n=q(e=>e.settings),r=q(e=>e.clis),i=q(e=>e.openOverlay),a=n.runtime===`terminal`,o=e=>a?e.cli||n.defaultCli:`claude`,[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(null);return e.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`Connect a repo first; agents need a floor to sit on.`}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`datalist`,{id:`models`,children:AJ.map(e=>(0,K.jsx)(`option`,{value:e},e))}),[...e].sort((e,t)=>e.floor-t.floor).map(e=>{let d=zb(t,e.id);return(0,K.jsxs)(`div`,{className:`card floor-card`,style:{"--accent":e.color},children:[(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsx)(`span`,{className:`floor-badge`,children:e.floor}),(0,K.jsx)(`b`,{className:`grow`,children:e.fullName}),(0,K.jsx)(`input`,{value:s[e.id]??``,onChange:t=>c({...s,[e.id]:t.target.value}),placeholder:`Name (optional)`,style:{maxWidth:160}}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:d.filter(e=>e.role===`dev`).length>=12,onClick:()=>void PJ(()=>Y.hireAgent(e.id,{name:s[e.id]||void 0,role:`dev`})).then(()=>c({...s,[e.id]:``})),children:`+ Developer`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:d.filter(e=>e.role===`qa`).length>=3,onClick:()=>void PJ(()=>Y.hireAgent(e.id,{name:s[e.id]||void 0,role:`qa`})).then(()=>c({...s,[e.id]:``})),children:`+ QA tester`})]}),d.length===0&&(0,K.jsx)(`div`,{className:`muted small`,children:`No one works here yet.`}),(0,K.jsx)(`table`,{className:`team`,children:(0,K.jsx)(`tbody`,{children:d.map(e=>(0,K.jsxs)(v.Fragment,{children:[(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{children:(0,K.jsx)(`span`,{className:`dot`,style:{background:e.color}})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,defaultValue:e.name,onBlur:t=>t.target.value.trim()&&t.target.value!==e.name&&void PJ(()=>Y.updateAgent(e.id,{name:t.target.value}))})}),(0,K.jsx)(`td`,{className:`nowrap`,children:(0,K.jsxs)(`span`,{className:`chip`,title:e.hiredBy===`ceo`?`Hired on the CEO's proposal`:void 0,children:[e.role===`qa`?`🔍 QA`:`💻 Dev`,e.hiredBy===`ceo`?` · 🧠`:``]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,defaultValue:e.title,placeholder:e.role===`qa`?`QA tester`:`Developer`,title:`Job title`,onBlur:t=>t.target.value!==e.title&&void PJ(()=>Y.updateAgent(e.id,{title:t.target.value}))},`t-${e.title}`)}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,style:{width:96},defaultValue:e.specialty,placeholder:`specialty`,title:`Issues labelled swarm:<specialty> go to this agent first`,onBlur:t=>t.target.value!==e.specialty&&void PJ(()=>Y.updateAgent(e.id,{specialty:t.target.value}))},`s-${e.specialty}`)}),(0,K.jsx)(`td`,{children:(0,K.jsxs)(`button`,{className:`btn btn-small btn-ghost`,title:`Job description and look`,onClick:()=>u(l===e.id?null:e.id),children:[`📝`,e.brief?``:` +`]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(DJ,{status:e.status})}),(0,K.jsx)(`td`,{className:`small`,children:e.status===`idle`?(0,K.jsx)(`span`,{className:`muted`,children:`—`}):e.task===`qa`?`testing PR #${e.prNumber}`:e.task===`fix`?`fixing PR #${e.prNumber}`:`#${e.issueNumber??``} ${e.issueTitle??``}`.slice(0,40)}),a&&(0,K.jsx)(`td`,{children:(0,K.jsxs)(`select`,{value:e.cli,title:`Their coding agent`,style:{width:112},onChange:t=>void PJ(()=>Y.updateAgent(e.id,{cli:t.target.value})),children:[(0,K.jsxs)(`option`,{value:``,children:[MJ(r,n.defaultCli),` (default)`]}),(0,K.jsx)(NJ,{clis:r})]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(`input`,{className:`inline`,style:{minWidth:110},list:o(e)===`claude`?`models`:void 0,defaultValue:e.model,placeholder:hD(``,o(e),n,AJ[0])||`agent default`,title:`Their model ('' = the default for their coding agent)`,onBlur:t=>t.target.value!==e.model&&void PJ(()=>Y.updateAgent(e.id,{model:t.target.value}))},`m-${e.model}-${o(e)}`)}),(0,K.jsx)(`td`,{children:(0,K.jsxs)(`select`,{value:e.effort,title:`Their effort`,style:{width:124},onChange:t=>void PJ(()=>Y.updateAgent(e.id,{effort:t.target.value})),children:[(0,K.jsxs)(`option`,{value:``,children:[`default (`,n.defaultEffort,`)`]}),jJ.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})}),(0,K.jsxs)(`td`,{className:`nowrap`,children:[(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`terminal`,agentId:e.id}),children:`Terminal`}),` `,(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void MT({tone:`danger`,icon:`👋`,title:`Let ${e.name} go?`,body:`Their worktree is removed. Branches they pushed stay on GitHub.`,confirm:`Let ${e.name} go`}).then(t=>t&&PJ(()=>Y.fireAgent(e.id))),children:`Let go`})]})]}),l===e.id&&(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{}),(0,K.jsxs)(`td`,{colSpan:a?11:10,children:[(0,K.jsxs)(`label`,{className:`row small`,children:[(0,K.jsx)(`span`,{children:`Drawn as`}),(0,K.jsxs)(`select`,{value:e.look,title:`Character look`,style:{width:`auto`},onChange:t=>void PJ(()=>Y.updateAgent(e.id,{look:t.target.value})),children:[(0,K.jsx)(`option`,{value:`feminine`,children:`👩 She`}),(0,K.jsx)(`option`,{value:`masculine`,children:`👨 He`})]})]}),(0,K.jsx)(`textarea`,{rows:3,defaultValue:e.brief,placeholder:`What ${e.name} owns on this project and how they should work. It's added to their instructions.`,onBlur:t=>t.target.value!==e.brief&&void PJ(()=>Y.updateAgent(e.id,{brief:t.target.value}))},`b-${e.brief}`)]})]})]},e.id))})})]},e.id)})]})}function HJ({initialRepo:e}){let t=q(e=>e.repos),n=q(e=>e.agents),[r,i]=(0,v.useState)(e??t[0]?.id??``),a=t.find(e=>e.id===r),o=(0,v.useMemo)(()=>zb(n,r),[n,r]);return t.length===0?(0,K.jsx)(`p`,{className:`muted`,children:`Connect a repo first.`}):(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`📝 File a new issue`}),(0,K.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:t.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[`Floor `,e.floor,` · `,e.fullName]},e.id))}),a&&(0,K.jsx)(dD,{repoId:a.id,agents:o},a.id)]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsxs)(`h3`,{children:[`Open issues on `,a?.fullName]}),(0,K.jsxs)(`div`,{className:`repo-list tall`,children:[a?.issues.length===0&&(0,K.jsx)(`div`,{className:`muted small`,children:`None. Nice.`}),a?.issues.map(e=>{let t=o.find(t=>t.role===`dev`&&t.issueNumber===e.number&&t.status!==`idle`);return(0,K.jsxs)(`div`,{className:`repo-row`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title,e.labels.length>0&&(0,K.jsx)(`div`,{className:`muted small`,children:e.labels.join(`, `)})]}),t?(0,K.jsxs)(`span`,{className:`agent-chip`,children:[(0,K.jsx)(`span`,{className:`dot`,style:{background:t.color}}),t.name]}):(0,K.jsxs)(`select`,{value:``,onChange:t=>t.target.value&&void PJ(()=>Y.assign(t.target.value,e.number)),children:[(0,K.jsx)(`option`,{value:``,children:`Assign…`}),o.filter(e=>e.role===`dev`&&e.status!==`working`&&e.status!==`preparing`).map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]},e.number)})]})]})]})}function UJ(){let e=q(e=>e.settings),t=q(e=>e.clis),n=q(e=>e.user),r=q(e=>e.workspaceRoot),i=q(e=>e.demo),a=e=>void PJ(()=>Y.updateSettings(e)),o=e.runtime===`terminal`,s=o?e.defaultCli:`claude`;return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`🧠 Agents`}),o&&(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Default coding agent`}),(0,K.jsx)(`select`,{value:e.defaultCli,onChange:e=>a({defaultCli:e.target.value}),children:(0,K.jsx)(NJ,{clis:t})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsxs)(`span`,{children:[`Default model`,o?` for ${MJ(t,e.defaultCli)}`:``]}),(0,K.jsx)(`input`,{list:s===`claude`?`models-s`:void 0,defaultValue:e.defaultModel,placeholder:`the agent's own default`,onBlur:t=>t.target.value!==e.defaultModel&&a({defaultModel:t.target.value})},`${e.defaultCli}:${e.defaultModel}`),(0,K.jsx)(`datalist`,{id:`models-s`,children:AJ.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Default effort`}),(0,K.jsx)(`select`,{value:e.defaultEffort,onChange:e=>a({defaultEffort:e.target.value}),children:jJ.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsx)(`p`,{className:`muted small`,children:o?`Each worker can use their own coding agent, model and effort (Team tab); the CEO always runs Claude Code. Claude Code reports every step; Codex and OpenCode are experimental: the office sees their task rather than each step.`:`The Agent SDK runs Claude Code. Each worker can use their own model and effort (Team tab).`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Session limit`}),(0,K.jsx)(`input`,{type:`number`,min:0,placeholder:`No limit`,defaultValue:e.sessionLimit||``,onBlur:e=>a({sessionLimit:Number(e.target.value)||0})})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`Leave empty so every agent with work runs at once. Agents on the same coding agent share its subscription's usage limits, and each one is its own process on this PC, so set a limit if you hit either.`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Sessions while pacing`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:32,defaultValue:e.pacingSessions,onBlur:t=>Number(t.target.value)!==e.pacingSessions&&a({pacingSessions:Number(t.target.value)||3})},e.pacingSessions)]}),(0,K.jsx)(`p`,{className:`muted small`,children:`When Claude warns that usage is getting high, new issues only start while fewer sessions than this are running. QA, fixes and the CEO carry on.`}),(0,K.jsx)(`h3`,{children:`🧠 The CEO`}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.hiring===`approve`,onChange:()=>a({hiring:`approve`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`I approve every hire`}),` (recommended): the CEO's proposals wait on your phone.`]})]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.hiring===`auto`,onChange:()=>a({hiring:`auto`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Auto-approve`}),` while a floor has fewer people than the team cap. Anything beyond the cap still waits for you.`]})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Team cap per floor`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:15,defaultValue:e.teamCap,onBlur:e=>a({teamCap:Number(e.target.value)})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Company review every (minutes, 0 = off)`}),(0,K.jsx)(`input`,{type:`number`,min:0,max:1440,defaultValue:e.ceoHeartbeatMin,onBlur:e=>a({ceoHeartbeatMin:Number(e.target.value)})})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`A review is skipped when nothing changed since the last one. The CEO's own model and effort are on the CEO tab.`})]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`⌨️ How agents run`}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.runtime===`terminal`,onChange:()=>a({runtime:`terminal`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Real terminals`}),` (recommended): every agent is its actual coding agent running in its own terminal. Open a desk to watch it live or type into it.`]})]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:e.runtime===`sdk`,onChange:()=>a({runtime:`sdk`})}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Agent SDK`}),`: Claude Code through the Claude Agent SDK, shown as a log of its steps. Claude Code only.`]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`Agents work like your own coding agents in a terminal, with your skills, MCP servers and settings, and don't stop to ask. The office's workflow (branches, pull requests, QA reporting back) is in their instructions.`}),(0,K.jsx)(`h3`,{children:`🏢 Company`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Your name`}),(0,K.jsx)(`input`,{defaultValue:e.managerName,placeholder:n??`Boss`,onBlur:t=>t.target.value!==e.managerName&&a({managerName:t.target.value})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Company name`}),(0,K.jsx)(`input`,{defaultValue:e.companyName,placeholder:`cubefarm`,onBlur:t=>t.target.value!==e.companyName&&a({companyName:t.target.value})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Projects folder (new projects are created here)`}),(0,K.jsx)(`input`,{defaultValue:e.projectsDir,onBlur:t=>t.target.value.trim()&&t.target.value!==e.projectsDir&&a({projectsDir:t.target.value})},e.projectsDir)]}),(0,K.jsx)(`div`,{className:`row`,children:(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>a({tutorialStep:0}),children:`🧭 Replay the tour`})}),(0,K.jsx)(`h3`,{children:`ℹ️ Environment`}),(0,K.jsxs)(`div`,{className:`small`,children:[`GitHub: `,(0,K.jsx)(`b`,{children:n??`not signed in`}),i&&` (demo)`,(0,K.jsx)(`br`,{}),`Agent desks: `,(0,K.jsx)(`code`,{children:r})]})]})]})}function WJ({initialTab:e,initialRepo:t}){let[n,r]=(0,v.useState)(e??`floors`),i=q(e=>Ub(e.requests).length),a=[[`floors`,`🏢 Floors & repos`],[`ceo`,`🧠 CEO & hiring${i?` (${i})`:``}`],[`team`,`👩💻 Team`],[`issues`,`📝 Issues`],[`settings`,`⚙️ Settings`]];return(0,K.jsxs)(KJ,{wide:!0,title:`🧑💼 Manager's console`,children:[(0,K.jsx)(`div`,{className:`tabs`,children:a.map(([e,t])=>(0,K.jsx)(`button`,{className:`tab ${n===e?`tab-on`:``}`,onClick:()=>r(e),children:t},e))}),(0,K.jsxs)(`div`,{className:`tab-body`,children:[n===`floors`&&(0,K.jsx)(RJ,{}),n===`ceo`&&(0,K.jsx)(BJ,{}),n===`team`&&(0,K.jsx)(VJ,{}),n===`issues`&&(0,K.jsx)(HJ,{initialRepo:t}),n===`settings`&&(0,K.jsx)(UJ,{})]})]})}function GJ(){q.getState().openOverlay(null)}function KJ({title:e,children:t,wide:n,accent:r,className:i,onClose:a}){return(0,v.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),a?a():GJ())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,K.jsx)(`div`,{className:`overlay`,onMouseDown:e=>e.target===e.currentTarget&&GJ(),children:(0,K.jsxs)(`div`,{className:`panel ${n?`panel-wide`:``} ${i??``}`,style:{"--accent":r??`#ff8a5b`},children:[(0,K.jsxs)(`div`,{className:`panel-head`,children:[(0,K.jsx)(`div`,{className:`panel-title`,children:e}),(0,K.jsx)(`button`,{className:`panel-x`,onClick:()=>a?a():GJ(),"aria-label":`Close`,children:`✕`})]}),(0,K.jsx)(`div`,{className:`panel-body`,children:t})]})})}var qJ={steps:`Footsteps`,typing:`Typing`,toys:`Toys`,alerts:`Alerts`};function JJ(){let e=(0,v.useSyncExternalStore)(ib,rb),{volume:t,muted:n}=e;return(0,K.jsxs)(`div`,{className:`sound-controls`,children:[(0,K.jsxs)(`div`,{className:`row wrap sound`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:!n,onChange:e=>sb({muted:!e.target.checked})}),` `,n?`🔇`:`🔊`,` Sound`]}),(0,K.jsxs)(`label`,{className:`sound-volume`,children:[(0,K.jsx)(`span`,{className:`muted small`,children:`Volume`}),(0,K.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:t,disabled:n,"aria-label":`Volume`,onChange:e=>sb({volume:Number(e.target.value)})}),(0,K.jsxs)(`span`,{className:`small sound-pct`,children:[t,`%`]})]})]}),(0,K.jsx)(`div`,{className:`sound-groups`,role:`group`,"aria-label":`Volume for each kind of sound`,children:zy.map(t=>(0,K.jsxs)(`label`,{className:`sound-volume`,title:t===`alerts`?`The phone, the elevator and work cues`:void 0,children:[(0,K.jsx)(`span`,{className:`muted small sound-group-name`,children:qJ[t]}),(0,K.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e[t],disabled:n,"aria-label":`${qJ[t]} volume`,"aria-valuetext":`${e[t]}%`,onChange:e=>sb({[t]:Number(e.target.value)})}),(0,K.jsxs)(`span`,{className:`small sound-pct`,children:[e[t],`%`]})]},t))})]})}function YJ(){let{sensitivity:e,invertY:t,grabOnClose:n,set:r}=AT();return(0,K.jsxs)(`div`,{className:`mouse-settings`,children:[(0,K.jsxs)(`label`,{className:`mouse-sens`,children:[(0,K.jsx)(`span`,{children:`Mouse sensitivity`}),(0,K.jsx)(`input`,{type:`range`,min:TT,max:3,step:.05,value:e,onChange:e=>r({sensitivity:Number(e.target.value)})}),(0,K.jsxs)(`b`,{children:[e.toFixed(2),`×`]}),e!==1&&(0,K.jsx)(`button`,{className:`btn btn-ghost btn-small`,onClick:()=>r({sensitivity:1}),children:`Reset`})]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>r({invertY:e.target.checked})}),` Invert Y (push the mouse forward to look down)`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r({grabOnClose:e.target.checked})}),` Grab the mouse when panels close`]})]})}function XJ(){return(0,K.jsx)(KJ,{title:`How the office works`,children:(0,K.jsxs)(`div`,{className:`help`,children:[(0,K.jsx)(`h3`,{children:`Moving around`}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`kbd`,{children:`W`}),(0,K.jsx)(`kbd`,{children:`A`}),(0,K.jsx)(`kbd`,{children:`S`}),(0,K.jsx)(`kbd`,{children:`D`}),` walk · `,(0,K.jsx)(`kbd`,{children:`Shift`}),` run · mouse to look · `,(0,K.jsx)(`kbd`,{children:`E`}),` or left click interacts with whatever the crosshair is on (the first click only grabs the mouse) · `,(0,K.jsx)(`kbd`,{children:`Esc`}),` frees the mouse. Closing a panel or changing floor grabs it again.`]}),(0,K.jsx)(YJ,{}),(0,K.jsx)(`h3`,{children:`Balls`}),(0,K.jsxs)(`p`,{children:[`Walk into a ball to push it, or aim at one and press `,(0,K.jsx)(`kbd`,{children:`E`}),` (or click) to pick it up. Click or press `,(0,K.jsx)(`kbd`,{children:`F`}),` to throw: a tap lobs it, holding charges a harder throw. `,(0,K.jsx)(`kbd`,{children:`G`}),` drops it at your feet. With a ball in hand, `,(0,K.jsx)(`kbd`,{children:`E`}),` still works on desks, boards and the elevator (the ball drops when a panel opens), and `,(0,K.jsx)(`kbd`,{children:`E`}),` on another ball swaps them.`]}),(0,K.jsx)(`h3`,{children:`Foam blasters`}),(0,K.jsxs)(`p`,{children:[`Every floor has a rack of foam blasters by the south wall: aim at it and press `,(0,K.jsx)(`kbd`,{children:`E`}),` to take one. `,(0,K.jsx)(`b`,{children:`Fire`}),`: click or `,(0,K.jsx)(`kbd`,{children:`F`}),` (12 darts, up to four a second). `,(0,K.jsx)(`b`,{children:`Reload`}),`: `,(0,K.jsx)(`kbd`,{children:`R`}),`. `,(0,K.jsx)(`b`,{children:`Drop`}),`: `,(0,K.jsx)(`kbd`,{children:`G`}),`, then `,(0,K.jsx)(`kbd`,{children:`E`}),` picks it up again. Darts stick to walls, boards and screens when they hit square on and bounce off everything else. They never open anything, and the blasters go back on the rack when you change floors.`]}),(0,K.jsx)(`h3`,{children:`Sound`}),(0,K.jsxs)(`p`,{children:[`The office chimes when a PR is ready to merge, fails QA or gets merged, when someone hits an error and when a new teammate arrives. `,(0,K.jsx)(`kbd`,{children:`M`}),` mutes or unmutes anywhere. Under the volume, turn footsteps, typing, toys and alerts (the phone, the elevator and these cues) up or down on their own.`]}),(0,K.jsx)(JJ,{}),(0,K.jsx)(`h3`,{children:`The building`}),(0,K.jsx)(`p`,{children:`The ground floor is the lobby: your office is the glass room at the back left, the CEO's corner office is at the back right, and candidates wait on the chairs by the entrance. Every connected GitHub repo gets its own floor. Walk into the elevator in the middle of the south wall to travel.`}),(0,K.jsx)(`h3`,{children:`Your phone`}),(0,K.jsxs)(`p`,{children:[`Press `,(0,K.jsx)(`kbd`,{children:`P`}),` anywhere to pull out your phone. Text the CEO, approve or decline the people they want to hire, see every project at a glance, or play Cubetris, Cable Snake or look after your Desk Pet while the team works. The red badge counts decisions and messages waiting for you. In the chat, and in an agent's terminal, `,(0,K.jsx)(`kbd`,{children:`Enter`}),` sends and `,(0,K.jsx)(`kbd`,{children:`Shift`}),`+`,(0,K.jsx)(`kbd`,{children:`Enter`}),` starts a new line.`]}),(0,K.jsx)(`h3`,{children:`Who's working`}),(0,K.jsxs)(`p`,{children:[`The list at the top right shows everyone who is working right now (on this floor, or on every floor from the lobby) with their latest thought, reply or tool call. Click someone to watch their screen. `,(0,K.jsx)(`kbd`,{children:`Tab`}),` `,`shows or hides it.`]}),(0,K.jsx)(`h3`,{children:`The CEO`}),(0,K.jsx)(`p`,{children:`The CEO studies every new floor, writes its QA brief, gives each agent a job that fits the project, turns your project briefs into issues and proposes hires. Hires wait for your approval unless you switch hiring to auto in the manager's console.`}),(0,K.jsx)(`h3`,{children:`Your team`}),(0,K.jsxs)(`p`,{children:[`Each agent is a real coding agent running in its own terminal, working in its own git worktree. Walk up behind them to read their laptop, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` (or click) on a desk to open their terminal: watch it live, type into it, send them instructions, stop them or hand them another issue. Aim at an empty desk and press `,(0,K.jsx)(`kbd`,{children:`E`}),` to hire, or click it and confirm.`]}),(0,K.jsx)(`h3`,{children:`The QA lab`}),(0,K.jsx)(`p`,{children:`The testers in lab coats along the east wall check every pull request before it can be merged. They run the tests, click through the change in a real browser, and post a report with screenshots on the PR. If a PR fails, it goes back to the developer who wrote it, who fixes it and sends it back to QA.`}),(0,K.jsx)(`h3`,{children:`The whiteboard`}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`b`,{children:`Backlog`}),`: open issues nobody has picked up. `,(0,K.jsx)(`b`,{children:`In progress`}),`: developers at work. `,(0,K.jsx)(`b`,{children:`In QA`}),`: being tested or fixed. `,(0,K.jsx)(`b`,{children:`Ready to merge`}),`: QA passed, waiting for you. Press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click the board to assign, send to QA, merge and file new issues.`]})]})})}function ZJ(){let e=q(e=>e.overlay);if(!e)return null;switch(e.kind){case`terminal`:return e.agentId===`ceo`?(0,K.jsx)(WJ,{initialTab:`ceo`}):(0,K.jsx)(kJ,{agentId:e.agentId});case`phone`:return(0,K.jsx)(yJ,{tab:e.tab,requestId:e.requestId});case`kanban`:return(0,K.jsx)(pD,{repoId:e.repoId});case`app`:return(0,K.jsx)(cD,{repoId:e.repoId});case`elevator`:return(0,K.jsx)(lD,{});case`manager`:return(0,K.jsx)(WJ,{initialTab:e.tab,initialRepo:e.repoId});case`help`:return(0,K.jsx)(XJ,{})}}var QJ=[`Pixel & Pine`,`Byte Bakery`,`Night Owl Software`,`Tiny Rocket Co.`,`Moonbeam Works`,`Happy Path Inc.`,`Merge Conflict Ltd.`,`Quokka Labs`,`Blue Kettle Studio`,`Paper Plane Software`],$J=[`Morgan`,`Avery`,`Jordan`,`Riley`,`Quinn`,`Harper`,`Rowan`,`Sasha`,`Casey`,`Jamie`,`Alex`,`Robin`],eY=[`#e63946`,`#3a86ff`,`#06d6a0`,`#ffbe0b`,`#9b5de5`,`#fb5607`],tY=[`Welcome`,`You`,`Your CEO`,`First project`,`Ready`],nY=(e,t)=>{let n=e.filter(e=>e!==t);return n[Math.floor(Math.random()*n.length)]};function rY({color:e,look:t}){return(0,K.jsxs)(`svg`,{viewBox:`0 0 120 120`,className:`ceo-portrait`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`60`,cy:`60`,r:`58`,fill:`#e6dcff`,stroke:`#1f1d2b`,strokeWidth:`3`}),t===`feminine`&&(0,K.jsx)(`ellipse`,{cx:`60`,cy:`58`,rx:`27`,ry:`32`,fill:`#2b2118`,stroke:`#1f1d2b`,strokeWidth:`2.5`}),(0,K.jsx)(`path`,{d:`M22 118 C24 88 40 80 60 80 C80 80 96 88 98 118 Z`,fill:`#2b2d42`,stroke:`#1f1d2b`,strokeWidth:`3`}),(0,K.jsx)(`path`,{d:`M50 81 L60 96 L70 81 Z`,fill:`#f8f9fa`}),(0,K.jsx)(`path`,{d:`M57 84 L63 84 L65 108 L60 113 L55 108 Z`,fill:e,stroke:`#1f1d2b`,strokeWidth:`1.5`}),(0,K.jsx)(`circle`,{cx:`60`,cy:`52`,r:`22`,fill:`#f1c27d`,stroke:`#1f1d2b`,strokeWidth:`3`}),(0,K.jsx)(`path`,{d:`M38 50 C38 30 82 30 82 50 C74 40 46 40 38 50 Z`,fill:`#2b2118`,stroke:`#1f1d2b`,strokeWidth:`2`}),(0,K.jsx)(`circle`,{cx:`52`,cy:`54`,r:`2.6`,fill:`#1f1d2b`}),(0,K.jsx)(`circle`,{cx:`68`,cy:`54`,r:`2.6`,fill:`#1f1d2b`}),(0,K.jsx)(`path`,{d:`M53 62 Q60 68 67 62`,fill:`none`,stroke:`#1f1d2b`,strokeWidth:`2.4`,strokeLinecap:`round`})]})}function iY(){let e=q(e=>e.user),t=q(e=>e.demo),n=q(e=>e.ghReady),r=q(e=>e.ghError),i=q(e=>e.agents.ceo),a=q(e=>e.start),[o,s]=(0,v.useState)(0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(()=>QJ[Math.floor(Math.random()*QJ.length)]),[f,p]=(0,v.useState)(i?.name??`Morgan`),[m,h]=(0,v.useState)(i?.look??`masculine`),[g,_]=(0,v.useState)(i?.color??eY[0]),[y,b]=(0,v.useState)(`approve`),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1),T=c.trim()||e||`Boss`,E=f.trim()||`Morgan`,D=u.trim()||QJ[0],O=()=>Y.setup({managerName:T,companyName:D,hiring:y,ceoName:E,ceoLook:m,ceoColor:g}),k=async()=>{w(!0);try{await O(),await Y.updateSettings({setupDone:!0,tutorialStep:0}),a(),xE()}catch{w(!1)}},A=async()=>{if(o===2){w(!0);try{await O()}catch{w(!1);return}w(!1)}s(o+1)};return(0,K.jsx)(`div`,{className:`start`,children:(0,K.jsxs)(`div`,{className:`start-card wizard`,children:[(0,K.jsx)(`div`,{className:`wizard-steps`,children:tY.map((e,t)=>(0,K.jsx)(`span`,{className:`wizard-dot ${t===o?`wizard-dot-on`:t<o?`wizard-dot-done`:``}`,title:e},e))}),o===0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`start-logo`,children:`✻`}),(0,K.jsx)(`h1`,{children:`cubefarm`}),(0,K.jsx)(`p`,{className:`start-tag`,children:`Your own cartoon software company, staffed by AI coding agents.`}),(0,K.jsxs)(`ul`,{className:`start-list`,children:[(0,K.jsx)(`li`,{children:`🏢 Every project gets its own floor, with developers and a QA lab working through its GitHub issues.`}),(0,K.jsx)(`li`,{children:`🧠 A CEO studies each project, plans the work and proposes the specialists it needs. You approve every hire.`}),(0,K.jsx)(`li`,{children:`📱 Your phone keeps you in the loop from anywhere in the building.`})]}),!n&&r&&(0,K.jsxs)(`div`,{className:`term-error small`,children:[`⚠️ `,r]}),(0,K.jsx)(`button`,{className:`btn btn-big`,onClick:()=>s(1),children:`Let's set up your company`}),(0,K.jsxs)(`div`,{className:`start-meta`,children:[(0,K.jsx)(`button`,{className:`linkish`,onClick:k,disabled:C,children:`Skip setup and use the defaults`}),t&&(0,K.jsx)(`span`,{className:`pill pill-demo`,children:`DEMO MODE`})]})]}),o===1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`wizard-icon`,children:`🧑💼`}),(0,K.jsx)(`h2`,{children:`Who's the boss?`}),(0,K.jsx)(`p`,{className:`start-tag`,children:`That's you. You run the company; the agents do the typing.`}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Your name`}),(0,K.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:e??`Boss`,autoFocus:!0})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Company name`}),(0,K.jsxs)(`div`,{className:`row`,style:{margin:0},children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:QJ[0]}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small`,title:`Suggest another name`,onClick:()=>d(nY(QJ,u)),children:`🎲`})]})]}),(0,K.jsx)(`p`,{className:`muted small`,children:`It goes on the sign in the lobby. Change either any time in the manager's console.`})]}),o===2&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{children:`Meet your CEO`}),(0,K.jsxs)(`div`,{className:`ceo-setup`,children:[(0,K.jsx)(rY,{color:g,look:m}),(0,K.jsxs)(`div`,{className:`grow`,children:[(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsx)(`span`,{children:`Name`}),(0,K.jsxs)(`div`,{className:`row`,style:{margin:0},children:[(0,K.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`Morgan`,autoFocus:!0}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small`,title:`Suggest another name`,onClick:()=>p(nY($J,f)),children:`🎲`})]})]}),(0,K.jsxs)(`div`,{className:`row`,children:[(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:m===`feminine`,onChange:()=>h(`feminine`)}),` 👩 She`]}),(0,K.jsxs)(`label`,{className:`toggle`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:m===`masculine`,onChange:()=>h(`masculine`)}),` 👨 He`]}),(0,K.jsx)(`span`,{className:`spacer`}),eY.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`swatch ${e===g?`swatch-on`:``}`,style:{background:e},onClick:()=>_(e),title:`Tie colour`},e))]}),(0,K.jsx)(`div`,{className:`muted small`,children:`Claude Opus 5.5 at xhigh effort: the thinking-hardest person in the building.`})]})]}),(0,K.jsxs)(`p`,{className:`start-tag`,style:{margin:`12px 0 6px`},children:[E,` studies every project, writes its QA checklist, plans the work as GitHub issues and proposes who to hire.`]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:y===`approve`,onChange:()=>b(`approve`)}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`b`,{children:`Ask me before every hire`}),` (recommended). Candidates wait in the lobby and on your phone.`]})]}),(0,K.jsxs)(`label`,{className:`toggle block`,children:[(0,K.jsx)(`input`,{type:`radio`,checked:y===`auto`,onChange:()=>b(`auto`)}),(0,K.jsxs)(`span`,{children:[(0,K.jsxs)(`b`,{children:[`Let `,E,` hire`]}),` on their own, up to 6 people per floor.`]})]})]}),o===3&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h2`,{children:`Your first project`}),x?(0,K.jsxs)(`div`,{className:`wizard-done`,children:[(0,K.jsx)(`div`,{className:`wizard-icon`,children:`🎉`}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`b`,{children:x.fullName}),` moved into floor `,x.floor,`.`]}),(0,K.jsxs)(`p`,{className:`muted`,children:[E,` is studying it right now and will text you when they know who the team needs. A QA tester is already in the lab.`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`start-tag`,children:`Pick one of your project folders, a GitHub repo, or start something new. Every project needs to be on GitHub: issues and pull requests are how the team works.`}),(0,K.jsx)(TJ,{onConnected:S})]})]}),o===4&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`wizard-icon`,children:`🏢`}),(0,K.jsxs)(`h2`,{children:[D,` is open for business`]}),(0,K.jsxs)(`ul`,{className:`start-list`,children:[(0,K.jsxs)(`li`,{children:[`🧠 `,E,x?` is studying ${x.fullName.split(`/`)[1]}`:` is waiting for your first project`,`.`,` `,y===`approve`?`Hires wait for your OK.`:`Hires up to 6 per floor go through on their own.`]}),(0,K.jsxs)(`li`,{children:[`📱 Press `,(0,K.jsx)(`kbd`,{children:`P`}),` anywhere for your phone: chat with `,E,`, approve hires, and see every project at a glance.`]}),(0,K.jsxs)(`li`,{children:[`🧭 A short tour starts when you walk in. Press `,(0,K.jsx)(`kbd`,{children:`H`}),` any time for help.`]})]}),(0,K.jsx)(`button`,{className:`btn btn-big`,onClick:k,disabled:C,children:C?`Opening the doors…`:`Enter the office`})]}),o>0&&o<4&&(0,K.jsxs)(`div`,{className:`wizard-nav`,children:[(0,K.jsx)(`button`,{className:`btn btn-ghost`,onClick:()=>s(o-1),disabled:C,children:`← Back`}),(0,K.jsx)(`span`,{className:`spacer`}),o===3&&!x&&(0,K.jsx)(`button`,{className:`linkish`,onClick:()=>s(4),children:`I'll add one later`}),(o!==3||x)&&(0,K.jsx)(`button`,{className:`btn btn-good`,onClick:()=>void A(),disabled:C,children:`Next →`})]})]})})}function aY(){let e=q(e=>e.started),t=q(e=>e.loaded),n=q(e=>e.connected),r=q(e=>e.demo),i=q(e=>e.repos),a=q(e=>e.agents),o=q(e=>e.settings),s=q(e=>e.start),c=Wb();if(e)return null;if(t&&!o.setupDone)return(0,K.jsx)(iY,{});let l=()=>{s(),nb(),xE()},u=a.ceo,d=Object.values(a).filter(e=>e.role!==`ceo`).length;return(0,K.jsx)(`div`,{className:`start`,children:(0,K.jsxs)(`div`,{className:`start-card`,children:[(0,K.jsx)(`div`,{className:`start-logo`,children:`✻`}),(0,K.jsx)(`h1`,{children:o.companyName||`cubefarm`}),(0,K.jsx)(`p`,{className:`start-tag`,children:o.managerName?`Welcome back, ${o.managerName}.`:`A cartoon office where a team of AI coding agents works through your GitHub issues.`}),(0,K.jsxs)(`ul`,{className:`start-list`,children:[(0,K.jsxs)(`li`,{children:[`🏢 `,i.length,` project`,i.length===1?``:`s`,`, `,d,` `,d===1?`person`:`people`,` on staff`,u?`, and ${u.name} in the corner office`:``,`.`]}),(0,K.jsx)(`li`,{children:c?`📱 ${c} thing${c===1?``:`s`} waiting on your phone. Press P once you're in.`:`📱 Press P anywhere for your phone.`}),(0,K.jsxs)(`li`,{children:[`💻 Walk up behind anyone to watch their screen, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` (or click) on things to use them. `,(0,K.jsx)(`kbd`,{children:`H`}),` for help.`]})]}),(0,K.jsx)(`button`,{className:`btn btn-big`,onClick:l,disabled:!t,children:t?`Enter the office`:n?`Loading…`:`Connecting to the swarm server…`}),(0,K.jsx)(`div`,{className:`start-meta`,children:r&&(0,K.jsx)(`span`,{className:`pill pill-demo`,children:`DEMO MODE: fake repos, fake agents`})})]})})}var oY=[{title:`Look around`,body:()=>(0,K.jsxs)(K.Fragment,{children:[`Click the view to grab the mouse and look around, then walk with `,(0,K.jsx)(`kbd`,{children:`W`}),` `,(0,K.jsx)(`kbd`,{children:`A`}),` `,(0,K.jsx)(`kbd`,{children:`S`}),` `,(0,K.jsx)(`kbd`,{children:`D`}),`. Hold `,(0,K.jsx)(`kbd`,{children:`Shift`}),` to run. `,(0,K.jsx)(`kbd`,{children:`Esc`}),` gives you the mouse back.`]}),done:e=>e.locked,minMs:5e3},{title:`Pull out your phone`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`Press `,(0,K.jsx)(`kbd`,{children:`P`}),`. Your phone is how you talk to `,e.ceo,` from anywhere in the building.`]}),done:e=>e.overlay?.kind===`phone`},{title:`Your phone`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`💬 `,e.ceo,` texts you here, and you can text back. 📄 `,(0,K.jsx)(`b`,{children:`Hires`}),` shows candidates waiting for your OK. 📊 `,(0,K.jsx)(`b`,{children:`Company`}),` is every project at a glance. Put it away with `,(0,K.jsx)(`kbd`,{children:`P`}),`.`]}),done:e=>e.overlay?.kind!==`phone`,minMs:2500},{title:`Visit the CEO`,body:e=>(0,K.jsxs)(K.Fragment,{children:[e.ceo,`'s corner office is at the back right of the lobby, under the purple sign. Walk in and press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click the desk to see what `,e.ceo,` is up to.`]}),done:e=>e.overlay?.kind===`terminal`&&e.overlay.agentId===`ceo`||e.overlay?.kind===`manager`&&e.overlay.tab===`ceo`},{title:`Candidates`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`When `,e.ceo,` wants to hire someone, the candidate waits on the green chairs along the east wall. Press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click them to read their resume, then hire or decline. It all works from your phone too.`]}),done:e=>e.requests.some(e=>e.status!==`pending`&&e.decidedBy===`manager`)},{title:`Go upstairs`,body:e=>e.repo?(0,K.jsxs)(K.Fragment,{children:[e.repo,` has its own floor. Walk into the elevator in the middle of the south wall, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click the directory beside it.`]}):(0,K.jsx)(K.Fragment,{children:`Every project gets its own floor. Add one in your office (the glass room at the back left), then take the elevator in the middle of the south wall.`}),done:e=>e.floor>0},{title:`The whiteboard`,body:()=>(0,K.jsxs)(K.Fragment,{children:[`The whiteboard at the front of every floor is its Kanban board. Press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click it to hand out issues, send pull requests to QA and merge them.`]}),done:e=>e.overlay?.kind===`kanban`},{title:`Watch the team`,body:()=>(0,K.jsxs)(K.Fragment,{children:[`Walk up behind anyone to watch their screen, or press `,(0,K.jsx)(`kbd`,{children:`E`}),` or click a desk for their full terminal. The testers in lab coats along the east wall check every pull request before you merge.`]}),done:e=>e.overlay?.kind===`terminal`&&e.overlay.agentId!==`ceo`},{title:`Your office`,body:e=>(0,K.jsxs)(K.Fragment,{children:[`Your glass office in the lobby (back left) has the manager's console: projects, the team, and the CEO's settings. Press `,(0,K.jsx)(`kbd`,{children:`H`}),` any time for help. Enjoy running `,e.company,`!`]})}];function sY(){let e=q(e=>e.settings.tutorialStep),t=q(e=>e.settings.setupDone),n=q(e=>e.started),r=q(e=>e.settings.companyName),i=q(e=>e.agents.ceo?.name??`the CEO`),a=q(e=>e.repos[0]?.fullName.split(`/`)[1]??null),[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(!1),l=(0,v.useRef)(Date.now()),u=n&&t&&e>=0&&e<oY.length,d=e=>{c.current||(c.current=!0,Y.updateSettings({tutorialStep:e>=oY.length?-1:e}).catch(()=>void 0).finally(()=>{c.current=!1,s(!1)}))};if((0,v.useEffect)(()=>{l.current=Date.now(),s(!1)},[e]),(0,v.useEffect)(()=>{if(!u)return;let t=oY[e];if(!t.done)return;let n=null,r=()=>{if(n||c.current)return;let r=q.getState();if(!t.done(r))return;let i=Math.max(0,(t.minMs??0)-(Date.now()-l.current));n=setTimeout(()=>{if(!t.done(q.getState())){n=null;return}s(!0),n=setTimeout(()=>d(e+1),900)},i)};r();let i=q.subscribe(r),a=setInterval(r,1e3);return()=>{i(),clearInterval(a),n&&clearTimeout(n)}},[u,e]),!u)return null;let f=oY[e],p=e===oY.length-1;return(0,K.jsxs)(`div`,{className:`tour ${o?`tour-cheer`:``}`,children:[(0,K.jsxs)(`div`,{className:`tour-head`,children:[(0,K.jsxs)(`span`,{className:`tour-count`,children:[`🧭 Tour · `,e+1,`/`,oY.length]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`linkish small`,onClick:()=>d(oY.length),children:`Skip tour`})]}),(0,K.jsx)(`div`,{className:`tour-title`,children:o?`✅ ${f.title}`:f.title}),(0,K.jsx)(`div`,{className:`tour-body`,children:f.body({ceo:i,company:r||`the company`,repo:a})}),(0,K.jsxs)(`div`,{className:`tour-nav`,children:[e>0&&(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>d(e-1),children:`← Back`}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,onClick:()=>d(e+1),children:p?`Finish the tour`:f.done?`Skip this step`:`Next →`})]})]})}function cY(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(OE,{}),(0,K.jsx)(QE,{}),(0,K.jsx)(ZJ,{}),(0,K.jsx)(sY,{}),(0,K.jsx)(aY,{}),(0,K.jsx)(IT,{}),qb&&(0,K.jsx)(rx,{})]})}var lY=0,uY=`office-swarm:reloaded-for`;function dY(){try{return sessionStorage.getItem(uY)}catch{return null}}function fY(e){if(!YE(q.getState().officeCommit,e,dY()))return!1;try{sessionStorage.setItem(uY,e)}catch{return!1}return location.reload(),!0}function pY(){let e=location.protocol===`https:`?`wss`:`ws`,t=new WebSocket(`${e}://${location.host}/ws`);t.onopen=()=>{lY=0,q.getState().setConnected(!0)},t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.type===`snapshot`&&t.data.officeCommit&&fY(t.data.officeCommit))return;q.getState().apply(t)}catch(e){console.error(`bad server event`,e)}},t.onclose=()=>{let e=q.getState();e.setConnected(!1);let t=e.restarting||JE(e.officeUpdate);t!==e.restarting&&e.setRestarting(t),setTimeout(pY,Math.min(t?2e3:8e3,500*2**lY++))}}pY(),(0,y.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(cY,{}));export{Ey as $,ZS as A,ix as B,J as C,p as Ct,hC as D,eC as E,CS as F,Rb as G,Ix as H,yS as I,hb as J,q as K,bS as L,ES as M,US as N,gC as O,DS as P,jy as Q,xx as R,Dw as S,V as St,tC as T,l as Tt,Dx as U,fx as V,lx as W,xb as X,bb as Y,Fy as Z,Nw as _,zr as _t,iE as a,W as at,Aw as b,w as bt,tE as c,Es as ct,qw as d,Sr as dt,G_ as et,Gw as f,vo as ft,_w as g,D as gt,Rw as h,Na as ht,lE as i,Pi as it,XS as j,vC as k,tT as l,ao as lt,Bw as m,fr as mt,rE as n,Hg as nt,JT as o,vs as ot,Fw as p,Rn as pt,fb as q,cE as r,Tg as rt,ZT as s,H as st,mE as t,W_ as tt,Kw as u,Nt as ut,xw as v,zn as vt,MC as w,s as wt,Ew as x,xt,Pw as y,ge as yt,ox as z};
|