cubefarm 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/ToyWorld-CCa77hRS.js +2 -0
- package/dist/assets/{index-hi9vqi9h.css → index-CIr98Zaa.css} +1 -1
- package/dist/assets/{index-D3lYbosx.js → index-g6QWWXij.js} +30 -30
- package/dist/assets/{rapier-DfUh5clU.js → rapier--PAOxOZs.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/index.js +536 -124
- package/dist-server/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/assets/ToyWorld-DQTMvcEl.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-CCa77hRS.js","assets/rapier--PAOxOZs.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=[`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
|
|
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=1.5;function Ky(e,t){return Math.hypot(e.x-t.x,e.y-t.y,e.z-t.z)}function qy(e){return Gy/(Gy+2*(Math.max(e,Gy)-Gy))}var Jy=e=>e<=16;function Yy(e,t,n,r){let i=t.y*n.z-t.z*n.y,a=t.z*n.x-t.x*n.z,o=t.x*n.y-t.y*n.x,s=r.x-e.x,c=r.y-e.y,l=r.z-e.z,u=Math.hypot(s,c,l)*Math.hypot(i,a,o);return u<1e-6?0:Math.max(-1,Math.min(1,(i*s+a*c+o*l)/u))}function Xy(e,t,n=24){if(e.length<n)return-1;let r=-1;for(let t=0;t<e.length;t++)(r<0||e[t].loud<e[r].loud)&&(r=t);return r<0||t<=e[r].loud?-2:r}var Zy=`cubefarm:audio`;function Qy(){try{return Uy(localStorage.getItem(Zy))}catch{return Uy(null)}}var $y=Qy(),eb=new Set,tb=null,nb=null,rb=!1,ib={},ab={};for(let e of zy)ab[e]=Wy($y[e]);var ob=10**(-2.81/20),sb=()=>$y.muted?0:Wy($y.volume);function cb(){if(!rb)return null;try{if(!tb){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;tb=new e,nb=tb.createGain(),nb.gain.value=sb();let t=tb.createDynamicsCompressor();t.threshold.value=-12,t.knee.value=12,t.ratio.value=4,t.attack.value=.005,t.release.value=.25;let n=tb.createGain();n.gain.value=ob,nb.connect(t).connect(n).connect(tb.destination);for(let e of zy){let t=tb.createGain();t.gain.value=ab[e],t.connect(nb),ib[e]=t}yb()}return tb.state===`suspended`&&tb.resume().catch(()=>void 0),tb.state===`running`&&nb?{ctx:tb,out:nb}:null}catch{return null}}function lb(){rb=!0,cb()}for(let e of[`pointerdown`,`keydown`])window.addEventListener(e,lb,{once:!0,capture:!0});var ub=()=>$y;function db(e){return eb.add(e),()=>void eb.delete(e)}function fb(e,t){if(tb)try{e.gain.cancelScheduledValues(tb.currentTime),e.gain.setTargetAtTime(t,tb.currentTime,.015)}catch{}}function pb(e,t){ab[e]=Math.max(0,Math.min(1,Number.isFinite(t)?t:1));let n=ib[e];n&&fb(n,ab[e])}function mb(e){let t={...$y,...e};for(let e of[`volume`,...zy])t[e]=Math.max(0,Math.min(100,Number(t[e])));$y=Hy(t);try{localStorage.setItem(Zy,JSON.stringify($y))}catch{}nb&&fb(nb,sb());for(let e of zy)pb(e,Wy($y[e]));for(let e of eb)e()}var hb=()=>mb({muted:!$y.muted}),gb={x:0,y:1.65,z:10},_b={x:0,y:0,z:-1},vb={x:0,y:1,z:0};function yb(){let e=tb?.listener;if(e)try{e.positionX?(e.positionX.value=gb.x,e.positionY.value=gb.y,e.positionZ.value=gb.z,e.forwardX.value=_b.x,e.forwardY.value=_b.y,e.forwardZ.value=_b.z,e.upX.value=vb.x,e.upY.value=vb.y,e.upZ.value=vb.z):(e.setPosition(gb.x,gb.y,gb.z),e.setOrientation(_b.x,_b.y,_b.z,vb.x,vb.y,vb.z))}catch{}}function bb(e,t,n,r,i,a,o,s,c){gb.x=e,gb.y=t,gb.z=n,_b.x=r,_b.y=i,_b.z=a,vb.x=o,vb.y=s,vb.z=c,tb?.state===`running`&&yb()}var xb=()=>gb,Sb=50,Cb=[];typeof window<`u`&&(window.__swarmSfx=Cb);function wb(e,{group:t,pos:n,pan:r=0,peak:i,played:a=!1}){let o=n?Ky(gb,n):0,s={name:e,group:t??null,at:n?{x:n.x,y:n.y,z:n.z}:null,gain:(!n||Jy(o)?i*(n?qy(o):1):0)*(t?ab[t]:1),pan:n?Yy(gb,_b,vb,n):r,played:a,t:performance.now()};return Cb.push(s),Cb.length>Sb&&Cb.splice(0,Cb.length-Sb),s}function Tb(e){let t=cb();return t?e&&ib[e]||t.out:null}function Eb(e,t){let n=e.createPanner();return n.panningModel=`equalpower`,n.distanceModel=`inverse`,n.refDistance=Gy,n.rolloffFactor=2,n.maxDistance=16,Db(n,t.x,t.y,t.z),n}function Db(e,t,n,r){e.positionX?(e.positionX.value=t,e.positionY.value=n,e.positionZ.value=r):e.setPosition(t,n,r)}var Ob=[];function kb(e,{name:t,group:n,pos:r,pan:i,into:a},o){let s=a??wb(t??e,{group:n,pos:r,pan:i,peak:o}),c=r?Ky(gb,r):0;if(r&&!Jy(c))return null;let l=o*(r?qy(c):1),u=cb();if(!u)return null;let d=u.ctx.currentTime;for(let e=Ob.length-1;e>=0;e--)Ob[e].end<=d&&Ob.splice(e,1);let f=Xy(Ob,l);if(f===-2)return null;if(f!==-1){let e=Ob[f];Ob.splice(f,1);try{e.env.gain.cancelScheduledValues(d),e.env.gain.setTargetAtTime(0,d,.01),e.src.stop(d+.06)}catch{}}let p=n&&ib[n]||u.out;try{if(r){let e=Eb(u.ctx,r);e.connect(p),p=e}else if(i&&u.ctx.createStereoPanner){let e=u.ctx.createStereoPanner();e.pan.value=i,e.connect(p),p=e}}catch{return null}return s.played=!0,{a:u,dest:p,loud:l}}function q(e){let{freq:t,to:n,type:r=`sine`,at:i=0,dur:a,peak:o,attack:s=.015}=e,c=kb(`tone`,e,o);if(!c)return;let l=c.a;try{let e=l.ctx.currentTime+i,u=l.ctx.createOscillator(),d=l.ctx.createGain();u.type=r,u.frequency.setValueAtTime(t,e),n&&u.frequency.exponentialRampToValueAtTime(n,e+a),d.gain.setValueAtTime(1e-4,e),d.gain.exponentialRampToValueAtTime(o,e+s),d.gain.exponentialRampToValueAtTime(1e-4,e+a),u.connect(d).connect(c.dest),u.start(e),u.stop(e+a+.05),Ob.push({end:e+a+.05,loud:c.loud,env:d,src:u})}catch{}}var Ab=null;function jb(e){let{at:t=0,dur:n,peak:r,filter:i=`lowpass`,freq:a,to:o,q:s=1,attack:c=.005}=e,l=kb(`noise`,e,r);if(!l)return;let u=l.a;try{if(!Ab||Ab.sampleRate!==u.ctx.sampleRate){Ab=u.ctx.createBuffer(1,u.ctx.sampleRate*2,u.ctx.sampleRate);let e=Ab.getChannelData(0);for(let t=0;t<e.length;t++)e[t]=Math.random()*2-1}let e=u.ctx.currentTime+t,d=u.ctx.createBufferSource();d.buffer=Ab;let f=u.ctx.createBiquadFilter();f.type=i,f.Q.value=s,f.frequency.setValueAtTime(a,e),o&&f.frequency.exponentialRampToValueAtTime(o,e+n);let p=u.ctx.createGain();p.gain.setValueAtTime(1e-4,e),p.gain.exponentialRampToValueAtTime(r,e+c),p.gain.exponentialRampToValueAtTime(1e-4,e+n),d.connect(f).connect(p).connect(l.dest),d.start(e,Math.random()),d.stop(e+n+.05),Ob.push({end:e+n+.05,loud:l.loud,env:p,src:d})}catch{}}typeof window<`u`&&(window.__swarmSfxPing=(e,t,n)=>q({name:`ping`,group:`alerts`,pos:{x:e,y:t,z:n},freq:880,type:`triangle`,dur:.3,peak:.12}));var Mb=-1/0;function Nb(){performance.now()-Mb<800||(Mb=performance.now(),[1046.5,1568].forEach((e,t)=>q({name:`chirp`,group:`alerts`,freq:e,type:`triangle`,at:t*.11,dur:.18,peak:.12})))}function Pb(e){let t={name:`roomba:chirp`,group:`toys`,pos:e};q({...t,freq:660,to:1320,type:`square`,dur:.12,peak:.035}),q({...t,freq:1320,to:990,type:`triangle`,at:.12,dur:.1,peak:.08}),q({...t,freq:1760,type:`triangle`,at:.24,dur:.18,peak:.07})}function Fb(){[880,1318.5].forEach((e,t)=>q({name:`ding`,group:`alerts`,freq:e,at:t*.16,dur:1.1,peak:.18,attack:.02}))}function Ib(e=.75){jb({name:`whoosh`,group:`alerts`,dur:e,peak:.1,filter:`bandpass`,freq:220,to:900,q:.8,attack:e*.45}),q({name:`whoosh`,group:`alerts`,freq:70,to:55,dur:e,peak:.05,attack:e*.4})}function Lb(e){q({name:`boop`,group:`toys`,pos:e,freq:520,to:330,dur:.16,peak:.13,attack:.008}),q({name:`boop`,group:`toys`,pos:e,freq:1040,to:660,type:`triangle`,dur:.07,peak:.025,attack:.004})}function Rb(e){let t={name:`roomba:slurp`,group:`toys`,pos:e};jb({...t,dur:.28,peak:.07,filter:`bandpass`,freq:350,to:2400,q:2.2,attack:.05}),q({...t,freq:220,to:660,type:`triangle`,dur:.24,peak:.035,attack:.03}),jb({...t,at:.24,dur:.05,peak:.05,filter:`bandpass`,freq:1800,q:1.5,attack:.002})}function zb(){jb({dur:.3,peak:.14,filter:`bandpass`,freq:5200,to:2600,q:.8,attack:.03,group:`toys`}),jb({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)=>q({freq:e,type:`triangle`,at:.2+t*.08,dur:.3,peak:.06,group:`toys`}))}var Bb=-1/0,Vb=92,Hb=[[1.52,.09,5],[2.03,.08,4.6],[2.74,.065,4],[3.43,.05,3.4],[4.18,.04,2.9],[5.4,.028,2.3],[6.79,.02,1.9]];function Ub(){if(performance.now()-Bb<1e3)return;Bb=performance.now();let e={name:`gong`,group:`alerts`};q({...e,freq:150,to:62,dur:.35,peak:.12,attack:.004}),jb({...e,dur:.14,peak:.07,filter:`lowpass`,freq:900,to:180,attack:.003}),q({...e,freq:Vb,type:`triangle`,dur:6.5,peak:.2,attack:.02}),q({...e,freq:Vb*1.008,dur:6,peak:.08,attack:.04});for(let[t,n,r]of Hb)q({...e,freq:Vb*t,dur:r,peak:n,attack:.015});q({...e,freq:Vb*8.9,type:`triangle`,at:.05,dur:4,peak:.016,attack:.9}),q({...e,freq:Vb*11.7,at:.05,dur:3.5,peak:.012,attack:1.1}),jb({...e,at:.05,dur:4.5,peak:.028,filter:`bandpass`,freq:1800,to:3200,q:1.5,attack:1.2})}var Wb={error:{rank:5,play:()=>[0,.2].forEach(e=>q({name:`cue:error`,group:`alerts`,freq:110,type:`sawtooth`,at:e,dur:.16,peak:.035,attack:.02}))},qaFailed:{rank:4,play:()=>{q({name:`cue:qaFailed`,group:`alerts`,freq:392,to:370,type:`triangle`,dur:.26,peak:.12}),q({name:`cue:qaFailed`,group:`alerts`,freq:311,to:196,type:`triangle`,at:.26,dur:.55,peak:.12})}},ready:{rank:3,play:()=>[784,988,1175,1568].forEach((e,t)=>q({name:`cue:ready`,group:`alerts`,freq:e,type:`triangle`,at:t*.07,dur:.28,peak:.09}))},merged:{rank:2,play:()=>{jb({name:`cue:merged`,group:`alerts`,dur:.07,peak:.16,filter:`bandpass`,freq:1400,q:1.2,attack:.002}),q({name:`cue:merged`,group:`alerts`,freq:523,to:1046,type:`square`,at:.04,dur:.12,peak:.04}),[1046.5,1318.5,1568].forEach(e=>q({name:`cue:merged`,group:`alerts`,freq:e,type:`triangle`,at:.14,dur:.5,peak:.05})),jb({name:`cue:merged`,group:`alerts`,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)=>q({name:`cue:welcome`,group:`alerts`,freq:e,type:`sine`,at:t*.12,dur:t===2?.5:.2,peak:.12}))}},Gb=150,Kb=1e3,qb=null,Jb=null,Yb=0,Xb=-1/0,Zb=(e,t)=>e&&Wb[e].rank>=Wb[t].rank?e:t;function Qb(e){let t=performance.now();t-Xb<Kb&&Wb[e].rank<=Yb&&!qb||(qb=Zb(qb,e),!Jb&&(Jb=setTimeout($b,Math.max(Gb,Xb+Kb-t))))}function $b(){Jb=null;let e=qb;qb=null,e&&(Xb=performance.now(),Yb=Wb[e].rank,Wb[e].play())}function ex(e,t){let n=new Set(e?.filter(e=>e.state===`OPEN`).map(e=>e.number));return t.filter(e=>e.state===`MERGED`&&n.has(e.number))}var tx=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function nx(e,t,n,r){let i=r.filter(t=>t.repoId===e&&t.role===`dev`);if(n?.devAgentId&&i.some(e=>e.id===n.devAgentId))return n.devAgentId;let a=/^swarm\/issue-\d+-(.+)$/i.exec(t.headRefName);if(!a)return null;let o=tx(a[1]);return i.find(e=>tx(e.name)===o)?.id??null}function rx(e,t,n,r,i){return e?ex(t?.pulls,n.pulls).map(e=>({repoId:n.id,prNumber:e.number,agentId:nx(n.id,e,r(e.number),i)})):[]}var ix=e=>!e.hidden&&!e.covered&&!e.reducedMotion,ax=new Map,ox=30;function sx(e,t){ax.delete(e),ax.set(e,t),ax.size>ox&&ax.delete(ax.keys().next().value)}var cx=e=>ax.get(e),lx=new Set;function ux(e){return lx.add(e),()=>void lx.delete(e)}function dx(e){for(let t of lx)t(e)}var fx=6e3,px=()=>({here:null,hitAt:-1/0,hits:0,celebrateRepo:null,celebrateUntil:-1/0});function mx(e,t,{repoId:n=e.here,celebrate:r=!1}={}){return!n||n!==e.here?`absent`:(r&&(e.celebrateRepo=n,e.celebrateUntil=t+fx),t-e.hitAt<1500?`ringing`:(e.hitAt=t,e.hits++,`boom`))}var hx=(e,t,n)=>t===e.celebrateRepo&&n<e.celebrateUntil,gx={amp:.26,hz:.85,decay:1.5,twistAmp:.07,twistHz:2.3,twistDecay:.9,settle:6},_x=e=>e<0||e>gx.settle?0:gx.amp*Math.exp(-e/gx.decay)*Math.sin(2*Math.PI*gx.hz*e),vx=e=>e<0||e>gx.settle?0:gx.twistAmp*Math.exp(-e/gx.twistDecay)*Math.sin(2*Math.PI*gx.twistHz*e),yx=e=>e<0||e>gx.settle?0:Math.min(1,Math.exp(-e/.18)+.25*Math.exp(-e/1.8)*(.5+.5*Math.sin(e*15))),bx=px();function xx(e){bx.here=e}var Sx=new Set;function Cx(e){return Sx.add(e),()=>void Sx.delete(e)}function wx(e={}){let t=mx(bx,performance.now(),e);if(t===`boom`&&Ub(),t!==`absent`&&e.celebrate&&bx.celebrateRepo)for(let e of Sx)e(bx.celebrateRepo);return t}var Tx=(e,t)=>hx(bx,e,t);typeof window<`u`&&(window.__swarmGong={hit:e=>void wx({celebrate:e?.celebrate===!0}),hits:()=>bx.hits});var Ex=1,Dx=`cubefarm:view`;function Ox(){try{let e=JSON.parse(localStorage.getItem(Dx)??`null`);return e&&[e.floor,e.x,e.z,e.yaw,e.pitch].every(Number.isFinite)?e:null}catch{return null}}function kx(e){try{localStorage.setItem(Dx,JSON.stringify(e))}catch{}}var Ax=600,J=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:Ox()?.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[jx(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=rx(r,t().repos.find(e=>e.id===n.repo.id),n.repo,e=>t().qa[jx(n.repo.id,e)]??cx(jx(n.repo.id,e)),Object.values(t().agents));i.length&&wx({repoId:n.repo.id,celebrate:!0})===`absent`&&Qb(`merged`);let a=t().repos.filter(e=>e.id!==n.repo.id);a.push(n.repo),e({repos:a.sort((e,t)=>e.floor-t.floor)});for(let e of i)dx(e);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`&&Qb(`welcome`),r&&i&&i.status!==`error`&&n.agent.status===`error`&&Qb(`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>Ax?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[jx(n.qa.repoId,n.qa.prNumber)]?.status,a=e=>e===`failed`||e===`needs-human`;r&&n.qa.status===`passed`&&i!==`passed`&&Qb(`ready`),r&&a(n.qa.status)&&!a(i)&&Qb(`qaFailed`),e({qa:{...t().qa,[jx(n.qa.repoId,n.qa.prNumber)]:n.qa}});break}case`qaRemoved`:{let{[jx(n.repoId,n.prNumber)]:r,...i}=t().qa;r&&sx(jx(n.repoId,n.prNumber),r),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`&&Qb(`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){Nb();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=Ex++;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)})})),jx=(e,t)=>`${e}#${t}`,Mx=(e,t)=>e.find(e=>e.floor===t)??null,Nx=(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),Px=e=>e?.kind===`kanban`||e?.kind===`terminal`||e?.kind===`manager`,Fx=e=>e.status===`preparing`||e.status===`working`,Ix=(e,t)=>e.filter(e=>e.from===`ceo`&&!e.requestId&&e.at>t).length,Lx=e=>e.filter(e=>e.status===`pending`);function Rx(){let e=J(e=>e.requests),t=J(e=>e.messages),n=J(e=>e.phoneReadAt);return Lx(e).length+Ix(t,n)}function zx(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[jx(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 Bx=1.75,Vx=new URLSearchParams(window.location.search).has(`stats`);function Hx(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function Ux(){return(0,v.useSyncExternalStore)(Hx,()=>document.hidden)}function Wx(){let e=J(e=>Px(e.overlay)),t=Ux();return e||t}function Gx({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 Kx(e){let t=e>130?144:e>100?120:60;return[Math.round(t*.6),Math.round(t*.9)]}function qx({onChange:e}){let t=({factor:t})=>e(Math.round((1+.75*t)*100)/100);return(0,K.jsx)(Ly,{factor:1,step:.25,bounds:Kx,onIncline:t,onDecline:t})}var Jx=null,Yx=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e);function Xx({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||!Jx)return;let{calls:a,triangles:o}=t.info.render,s=r.frames*1e3/i;Jx.textContent=`${Math.round(s)} fps · ${(i/r.frames).toFixed(1)} ms · ${a} calls · ${Yx(o)} tris · dpr ${t.getPixelRatio().toFixed(2)}`,r.start=e,r.frames=0}),null}function Zx(){let e=Wx();return(0,K.jsxs)(`div`,{className:`stats`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{ref:e=>{Jx=e},hidden:e,children:`measuring…`}),e&&(0,K.jsx)(`span`,{children:`⏸ 3D view paused`})]})}var Qx=3.6,$x=1.65,eS=.3,tS={doorHalf:1.2,cabinHalf:1.5,depth:2.6,doorHeight:2.5},nS={x:0,z:10.4,yaw:0},rS=(e,t,n,r,i)=>({minX:e-n/2,maxX:e+n/2,minZ:t-r/2,maxZ:t+r/2,h:i}),iS={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 aS(){let e=.4,{doorHalf:t,cabinHalf:n,depth:r}=tS;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 oS=()=>({minX:-tS.doorHalf,maxX:tS.doorHalf,minZ:12,maxZ:12.4}),sS=[-10.5,-3.5,3.5,10.5],cS=[-6.2,-1.6,3],lS=sS.length*cS.length,uS={w:1.9,d:.95,h:.74},dS=cS.map(e=>rS(0,e+.35,24.4,2.9));function fS(e){let t=cS.length-1-Math.floor(e/sS.length)%cS.length;return{x:sS[e%sS.length],z:cS[t]}}var pS={w:12,h:3,y:.45,z:-11.94},mS={x:-13.7,y:2.25,w:3.2,h:1.8,bezel:.09,depth:.12},hS={officeX:-10,lobbyX:-12.9,w:1.3,d:.3,h:1.85},gS=e=>rS(e,12-hS.d/2,hS.w,hS.d,hS.h),_S={x:-8.85,z:-11.3,w:2.3,d:.9,h:2.35,r:.72,y:1.3},vS=()=>({minX:_S.x-_S.w/2,maxX:_S.x+_S.w/2,minZ:-12,maxZ:_S.z+_S.d/2,h:_S.h});_S.x,_S.z+_S.d/2+.9;var yS={x:14,stations:[-5.2,-2,1.2]},bS=-Math.PI/2,xS=e=>({x:yS.x,z:yS.stations[e%yS.stations.length]}),SS=rS(yS.x-.4,-2,3.4,10.4);function CS(){let e=aS();for(let t=0;t<lS;t++){let{x:n,z:r}=fS(t);e.push(rS(n,r,uS.w+.1,uS.d+.1,iS.desk)),e.push(rS(n,r+.8,.7,.6,iS.seated))}for(let t of yS.stations)e.push(rS(yS.x,t,uS.d+.1,uS.w+.1,iS.desk)),e.push(rS(yS.x-.8,t,.6,.7,iS.seated));e.push(rS(0,-11.75,pS.w+.4,.5,iS.board));let t=mS;return e.push(rS(t.x,-12+t.depth/2,t.w+t.bezel*2,t.depth,t.y+t.h/2+t.bezel)),e.push(rS(-15.1,6.5,1.1,3.2,iS.couch)),e.push(rS(-13.4,6.5,.9,1.4,iS.coffeeTable)),e.push(gS(hS.officeX)),e.push(vS()),e.push(rS(15.55,7.4,.9,5,iS.kitchen)),e.push(rS(15.5,-9.5,.7,.7,iS.cooler)),e}var wS={minX:-16,maxX:-6.5,minZ:-12,maxZ:-3.5,doorMinX:-11,doorMaxX:-9.2},TS={x:-11.2,z:-8.6,w:2.6,d:1.1},ES={x:3,z:-3.5,w:5,d:1.2},DS={minX:6.5,maxX:16,minZ:-12,maxZ:-3.5,doorMinX:8.2,doorMaxX:10},OS={x:12,z:-7.4},kS={x:14.6,seats:[6.6,7.9,9.2,10.4]},AS=Math.PI/2,jS=rS(3,3,14,9);function MS(){let e=aS(),t=wS,n=.12;e.push({minX:t.maxX-n,maxX:t.maxX+n,minZ:t.minZ,maxZ:t.maxZ,h:iS.glass}),e.push({minX:t.minX,maxX:t.doorMinX,minZ:t.maxZ-n,maxZ:t.maxZ+n,h:iS.glass}),e.push({minX:t.doorMaxX,maxX:t.maxX,minZ:t.maxZ-n,maxZ:t.maxZ+n,h:iS.glass});let r=DS;e.push({minX:r.minX-n,maxX:r.minX+n,minZ:r.minZ,maxZ:r.maxZ,h:iS.glass}),e.push({minX:r.minX,maxX:r.doorMinX,minZ:r.maxZ-n,maxZ:r.maxZ+n,h:iS.glass}),e.push({minX:r.doorMaxX,maxX:r.maxX,minZ:r.maxZ-n,maxZ:r.maxZ+n,h:iS.glass}),e.push(rS(OS.x,OS.z,uS.w+.1,uS.d+.1,iS.desk)),e.push(rS(OS.x,OS.z+.8,.7,.6,iS.seated));for(let t of kS.seats)e.push(rS(kS.x,t,.7,.7,iS.seated));return e.push(rS(TS.x,TS.z,TS.w,TS.d,iS.desk)),e.push(rS(TS.x,TS.z-1.1,.8,.8,iS.seated)),e.push(rS(-15.6,-8,.8,5,iS.bookshelf)),e.push(gS(hS.lobbyX)),e.push(rS(ES.x,ES.z,ES.w,ES.d,iS.reception)),e.push(rS(11.5,4,3.2,1,iS.couch)),e.push(rS(11.5,6.2,1.6,.9,iS.coffeeTable)),e.push(rS(12,-11.45,4.4,1.1,iS.cabinet)),e}var NS=[...dS,SS],PS=[jS,wS,DS];function FS(e,t,n){if(n>12&&Math.abs(t)<=tS.cabinHalf)return`cabin`;for(let r of e===`lobby`?PS:NS)if(t>=r.minX&&t<=r.maxX&&n>=r.minZ&&n<=r.maxZ)return`rug`;return e===`lobby`?`lobby`:`wood`}function IS(e,t,n,r=eS){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 LS=[`#ffffff`,`#ffd166`,`#ef476f`,`#06d6a0`,`#118ab2`,`#2b2d42`],RS=[`quiff`,`afro`,`bun`,`curls`],zS={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 BS(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 VS(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 HS(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 US(e){let t=VS(BS(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=HS(n,zS[e.look]),m=f?HS(r,[[`none`,5],[`stubble`,2],[`beard`,2],[`moustache`,1]]):`none`,h=e.role===`qa`?`none`:HS(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&&!RS.includes(p)?HS(o,[[`none`,7],[`beanie`,1],[`cap`,1]]):`none`,outfit:d?HS(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*LS.length)}}var WS=.6,GS=1.1,KS=.03,qS=6,JS=4;function YS(){return{stage:`seated`,sit:1,x:0,z:0,heading:0,speed:0,phase:0,seatX:0,seatZ:0,seatHeading:0,standX:0,standZ:0,teleport:0}}function XS(e,t){let n=(t-e)%(Math.PI*2);return n>Math.PI?n-Math.PI*2:n<=-Math.PI?n+Math.PI*2:n}var ZS=(e,t,n)=>{let r=XS(e,t);return XS(0,e+Math.max(-n,Math.min(n,r)))},QS=e=>e*e*(3-2*e);function $S(e,t){let n=QS(e.sit);e.x=e.standX+(e.seatX-e.standX)*n,e.z=e.standZ+(e.seatZ-e.standZ)*n,e.heading=ZS(e.heading,e.seatHeading,qS*t),e.speed=0}function eC(e,t,n,r,i,a){let o=t-e.x,s=n-e.z,c=Math.hypot(o,s);if(c<KS)return e.speed=Math.max(0,e.speed-8*a),e.heading=ZS(e.heading,r,qS*.6*a),e.speed===0&&Math.abs(XS(e.heading,r))<.05;let l=Math.atan2(-o,-s);e.heading=ZS(e.heading,l,qS*a);let u=Math.max(0,Math.cos(XS(e.heading,l))),d=Math.min(i,c*2.5)*u;e.speed+=Math.max(-8*a,Math.min(JS*a,d-e.speed));let f=Math.min(c,e.speed*a);return e.x+=o/c*f,e.z+=s/c*f,!1}function tC(e,t,n){let r=t!=null&&t.mode!==`seated`;switch(r&&t.teleport!==e.teleport&&(e.teleport=t.teleport,e.stage=`up`,e.sit=0,e.x=t.x,e.z=t.z,e.heading=t.heading,e.speed=0),e.stage){case`seated`:e.x=e.seatX,e.z=e.seatZ,e.heading=e.seatHeading,e.speed=0,r&&(e.stage=`rising`);break;case`rising`:if(!r){e.stage=`sitting`;break}e.sit=Math.max(0,e.sit-n/WS),$S(e,n),e.sit===0&&(e.stage=`up`);break;case`sitting`:if(r){e.stage=`rising`;break}e.sit=Math.min(1,e.sit+n/WS),$S(e,n),e.sit===1&&(e.stage=`seated`,e.heading=e.seatHeading);break;case`up`:r?eC(e,t.x,t.z,t.heading,t.speed>0?t.speed:GS,n):eC(e,e.standX,e.standZ,e.seatHeading,1.1,n)&&(e.stage=`sitting`)}return e.speed>0&&(e.phase=(e.phase+n*iC(e.speed,nC).cadence*Math.PI)%(Math.PI*2)),e}var nC={stride:0,cadence:0,bob:0,lean:0},rC=.8;function iC(e,t){let n=Math.max(0,e),r=Math.min(.95,.32+.2*n);return t.cadence=n>0?n/r:0,t.stride=Math.asin(Math.min(.9,r/(2*rC))),t.bob=.018+.012*Math.min(2,n),t.lean=.04+.05*Math.min(2.5,n),t}function aC(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=oC(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=oC(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 oC(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 sC=new fr,cC=new zn,lC=new Sr;function uC(e,{at:t=[0,0,0],rot:n=[0,0,0],scale:r=[1,1,1]}={}){return cC.setFromEuler(lC.set(...n)),e.applyMatrix4(sC.compose(new V(...t),cC,new V(...r))),e}function dC(...e){e.some(e=>!e.index)&&(e=e.map(e=>e.index?e.toNonIndexed():e));let t=aC(e);if(!t)throw Error(`could not merge character geometry`);return e.forEach(e=>e.dispose()),t}var fC=(e,t=14,n=10)=>new al(e,t,n),pC=(e,t,n=6,r=12)=>new ws(e,t,n,r),mC=(e,t,n)=>new Cs(e,t,n),hC=()=>uC(new al(.215,24,16,0,Math.PI*2,0,1.75),{at:[0,.02,.01],rot:[.55,0,0]});function gC(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 _C(e){switch(e){case`crop`:return hC();case`long`:return dC(hC(),uC(fC(.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=uC(pC(.075,.24,6,10),{at:[0,-.17,.04]});return dC(hC(),uC(fC(.085,12,10),e),uC(t,e))}case`bun`:return dC(hC(),uC(fC(.1,14,10),{at:[0,.18,.12]}));case`quiff`:{let e=[-.09,-.045,0,.045,.09].map((e,t)=>uC(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(uC(fC(.1,14,10),{at:[0,.17,-.1],scale:[1.4,.7,1]})),dC(hC(),...e)}case`afro`:{let e=new V(0,.1,.06),t=gC(26,.235,e=>e.z>-.08&&e.y>-.15).map(t=>uC(fC(.075,10,8),{at:[e.x+t.x,e.y+t.y,e.z+t.z]}));return dC(uC(fC(.245,22,16),{at:[e.x,e.y,e.z]}),...t)}case`sidePart`:return dC(hC(),uC(fC(.12,16,10),{at:[.05,.16,-.1],rot:[.3,0,-.35],scale:[1.35,.5,.9]}),uC(fC(.07,12,8),{at:[-.08,.2,-.04],scale:[1,.6,1.2]}));case`buzz`:return uC(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=gC(60,.2,e=>e.y>.02&&e.y+e.z*.9>-.02).map(e=>uC(fC(.055,8,6),{at:[e.x*1.02,e.y+.03,e.z*1.02+.01]}));return dC(hC(),...e)}}}function vC(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 yC=(e,t)=>vC(new al(e,28,12,Math.PI-.15,Math.PI+.3,t,Math.PI-t),0,-.088,.07,.048),bC=()=>dC(...[-1,1].map(e=>uC(pC(.022,.05,4,8),{at:[e*.036,-.052,-.197],rot:[.25,0,e*1.2],scale:[1,1,.7]})));function xC(e){switch(e){case`none`:return null;case`stubble`:return yC(.203,2);case`moustache`:return bC();case`beard`:return dC(uC(yC(.212,1.95),{at:[0,.012,-.004],scale:[1.03,1.12,1.04]}),...[-1,1].map(e=>uC(pC(.028,.09,4,8),{at:[e*.188,-.07,-.035],rot:[0,0,e*.25]})),bC())}}function SC(e,t=-.215){if(e===`none`)return null;let n=e===`round`?[-.075,.075].map(e=>uC(new sl(.047,.01,6,20),{at:[e,.02,t]})):[-.078,.078].flatMap(e=>[uC(mC(.1,.018,.016),{at:[e,.058,t]}),uC(mC(.1,.014,.016),{at:[e,-.02,t]}),uC(mC(.014,.09,.016),{at:[e-.045,.02,t]}),uC(mC(.014,.09,.016),{at:[e+.045,.02,t]})]),r=[-1,1].map(e=>uC(mC(.012,.012,.19),{at:[e*.172,.035,-.11],rot:[0,e*.4,0]}));return dC(...n,uC(mC(.05,.012,.012),{at:[0,.03,t]}),...r)}function CC(){let e=uC(new sl(.245,.018,6,28,Math.PI),{at:[0,0,.01]}),t=[-1,1].map(e=>uC(new Es(.072,.072,.055,18),{at:[e*.235,-.01,.01],rot:[0,0,Math.PI/2]})),n=[-1,1].map(e=>uC(new Es(.052,.052,.012,18),{at:[e*.266,-.01,.01],rot:[0,0,Math.PI/2]}));return{shell:dC(e,...t),covers:dC(...n)}}function wC(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 dC(uC(new al(e,24,12,0,Math.PI*2,0,t),n),uC(uC(new sl(e*Math.sin(t),.03,8,28),{at:[0,e*Math.cos(t),0],rot:[Math.PI/2,0,0]}),n),uC(fC(.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 dC(uC(new al(e,24,12,0,Math.PI*2,0,t),n),uC(uC(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),uC(fC(.022,8,6),{at:[0,.02+e*Math.cos(.18),.015+e*Math.sin(.18)]}))}}}function TC(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:dC(uC(new sl(.12,.055,10,24),{at:[0,.5,.03],rot:[Math.PI/2-.35,0,0],scale:[1.05,1.15,1]}),uC(fC(.11,16,10),{at:[0,.5,.12],scale:[1.05,.9,.55]}),uC(mC(.22,.1,.02),{at:[0,.14,-.196]})),trim:dC(...[-1,1].flatMap(e=>[uC(pC(.01,.11,3,6),{at:[e*.045,.39,-.196],rot:[-.25,0,e*.08]}),uC(fC(.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 uC(mC(.04,.04,.012),{at:[e,.33,t],rot:[0,-Math.asin(e/.2),Math.PI/4]})});return{main:null,trim:dC(uC(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 EC(e,t){return Object.fromEntries(e.map(e=>[e,t(e)]))}var DC={legs:dC(...[-.11,.11].flatMap(e=>[uC(pC(.08,.26),{at:[e,.5,-.17],rot:[Math.PI/2,0,0]}),uC(pC(.07,.3),{at:[e,.27,-.36]})])),shoes:dC(...[-.11,.11].map(e=>uC(mC(.13,.09,.22),{at:[e,.05,-.42]}))),thigh:uC(pC(.08,.26),{at:[0,-.13,0]}),shin:uC(pC(.07,.3),{at:[0,-.23,0]}),shoe:uC(mC(.13,.09,.22),{at:[0,-.45,-.06]}),torso:pC(.2,.24,8,16),collar:new sl(.1,.03,8,20),sleeve:pC(.065,.36,6,12),hand:fC(.07,14,10),head:fC(.2,24,18),ears:dC(...[-.2,.2].map(e=>uC(fC(.05,10,8),{at:[e,-.01,0]}))),eyes:dC(...[-.07,.07].map(e=>uC(fC(.03,10,8),{at:[e,.02,-.18]}))),nose:fC(.028,10,8),mouth:new sl(.045,.011,6,16,Math.PI),lashes:dC(...[-1,1].map(e=>uC(mC(.035,.008,.008),{at:[e*.1,.045,-.172],rot:[0,0,e*-.6]}))),cheeks:dC(...[-1,1].map(e=>uC(fC(.03,10,8),{at:[e*.115,-.045,-.165],scale:[1,.6,.3]}))),hairClip:mC(.07,.035,.035),shirtFront:mC(.11,.22,.02),tie:mC(.045,.2,.012),tieKnot:mC(.06,.04,.02),coatOpening:mC(.06,.3,.02),badge:mC(.07,.05,.015),inspectorGlasses:SC(`round`,-.2),phone:mC(.075,.014,.13),phoneScreen:uC(new tl(.06,.105),{at:[0,.0075,0],rot:[-Math.PI/2,0,0]}),hair:EC([`crop`,`long`,`ponytail`,`bun`,`quiff`,`afro`,`sidePart`,`buzz`,`bald`,`curls`],_C),facialHair:EC([`none`,`stubble`,`beard`,`moustache`],xC),glasses:EC([`none`,`round`,`square`],e=>SC(e)),headphones:CC(),headwear:EC([`none`,`beanie`,`cap`],wC),outfit:EC([`tee`,`hoodie`,`stripe`,`sweater`],TC)},OC={leanBack:4.5,spin:2.6,phone:5,sip:3.4,stretch:4.2,doze:1/0,neckRoll:2.8,shoulders:2.6,scratch:2,facepalm:1.9,fistPump:1.7,wave:2.1},kC=[`leanBack`,`spin`,`phone`,`sip`,`stretch`],AC={min:5,max:14},jC={min:80,max:130},MC={min:25,max:55},NC=10,PC=.35,FC=.45;function IC(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t>>>0}function LC(e){e.rng=e.rng+1831565813|0;let t=e.rng;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}var RC=(e,t)=>t.min+(t.max-t.min)*LC(e);function zC(e,t,n=!0){let r={fidget:null,since:0,until:0,next:0,last:null,mood:`busy`,moodSince:t,sessionSince:t,dozeAfter:0,lastScratch:-1/0,rng:IC(e),hasMug:n};return r.next=t+2+LC(r)*AC.max,r.dozeAfter=RC(r,jC),r}function BC(e,t,n){e.fidget=t,e.since=n,e.until=n+OC[t]*(t===`doze`?1:.9+LC(e)*.2)}function VC(e,t,n){e.fidget=null,e.next=t+RC(e,n)}var HC=e=>kC.includes(e)||e===`doze`,UC=e=>e===`working`||e===`thinking`||e===`browsing`,WC=e=>e===`facepalm`||e===`fistPump`||e===`wave`;function GC(e,t,n){BC(e,t,n),t!==`doze`&&(e.moodSince=n)}function KC(e,t){e.fidget===`doze`&&VC(e,t,AC),e.moodSince=t}function qC(e,t,n){if(t!==e.mood){UC(t)&&!UC(e.mood)&&(e.sessionSince=n,e.next=n+RC(e,MC)),t===`idle`&&(e.next=n+RC(e,AC)*.5),e.mood=t,e.moodSince=n;let r=e.fidget;r&&!WC(r)&&(t===`idle`?!HC(r):t===`busy`||HC(r))&&VC(e,n,AC)}if(e.fidget){if(n<e.until)return e;let t=WC(e.fidget);VC(e,n,e.mood===`idle`?AC:MC),t&&(e.next=Math.max(e.next,n+AC.min))}if(t===`idle`){if(n-e.moodSince>=e.dozeAfter)BC(e,`doze`,n);else if(n>=e.next){let t=kC[Math.floor(LC(e)*kC.length)];(t===e.last||t===`sip`&&!e.hasMug)&&(t=kC[(kC.indexOf(t)+1+Math.floor(LC(e)*2))%kC.length]),t===`sip`&&!e.hasMug&&(t=`leanBack`),e.last=t,BC(e,t,n)}}else t===`thinking`?n-e.moodSince>=5&&n-e.lastScratch>=NC&&(e.lastScratch=n,BC(e,`scratch`,n)):t===`working`&&n>=e.next&&n-e.sessionSince>=60&&BC(e,LC(e)<.5?`neckRoll`:`shoulders`,n);return e}function JC(e,t){return e.fidget?e.until===1/0?t-e.since:Math.min(1,Math.max(0,(t-e.since)/(e.until-e.since))):0}function YC(e,t){if(!e.fidget)return 0;let n=Math.min(1,(t-e.since)/PC),r=e.until===1/0?1:Math.min(1,(e.until-t)/FC),i=Math.max(0,Math.min(n,r));return i*i*(3-2*i)}var XC=new ao(new Uint8Array([110,190,255]),3,1,ye);XC.minFilter=D,XC.magFilter=D,XC.generateMipmaps=!1,XC.needsUpdate=!0;var ZC=new Map;function QC(e,t={}){let n=`${e}|${t.emissive??``}|${t.emissiveIntensity??``}|${t.opacity??``}`,r=ZC.get(n);return r||(r=new Dl({color:e,gradientMap:XC,emissive:t.emissive??`#000000`,emissiveIntensity:t.emissiveIntensity??1,transparent:t.transparent??(t.opacity!==void 0&&t.opacity<1),opacity:t.opacity??1}),ZC.set(n,r)),r}function $C(e,t){let n=`map|${e}`,r=ZC.get(n);return r||(r=new Dl({map:t,gradientMap:XC}),ZC.set(n,r)),r}function ew(e){let t=`glow|${e}`,n=ZC.get(t);return n||(n=new Na({color:e,toneMapped:!1}),ZC.set(t,n)),n}var tw=new Tl({color:`#bfe8ff`,transparent:!0,opacity:.22,roughness:.05,metalness:0,depthWrite:!1,side:2});function nw(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 rw(e,t,n){return`#${new H(e).lerp(new H(t),n).getHexString()}`}var iw=new Map,aw=new Map,ow=0,sw=e=>iw.get(e);function cw(e,t){let n=iw.get(e)??{mode:`walking`,x:0,z:0,heading:0,speed:1.1,gesture:`none`,teleport:0};iw.set(e,{...n,...t})}var lw=e=>void iw.delete(e);function uw(e,t){return aw.set(e,t),()=>{aw.get(e)===t&&aw.delete(e)}}var dw=()=>aw,fw=e=>Math.round(e*100)/100;typeof window<`u`&&(window.__swarmPeople={place(e,t,n,r=0){cw(e,{mode:`standing`,x:t,z:n,heading:r}),iw.set(e,{...iw.get(e),teleport:++ow})},walkTo(e,t,n,r=GS,i){let a=aw.get(e);cw(e,{mode:`walking`,x:t,z:n,speed:r,heading:i??(a?Math.atan2(-(t-a.x),-(n-a.z)):0)})},sit:lw,gesture(e,t){cw(e,{gesture:t,...iw.has(e)?{}:{mode:`standing`,...this.where(e)}})},where(e){let t=aw.get(e);return t?{x:t.x,z:t.z,heading:t.heading}:{x:0,z:0,heading:0}},list(){return[...aw].map(([e,t])=>({id:e,stage:t.stage,x:fw(t.x),z:fw(t.z),heading:fw(t.heading),speed:fw(t.speed),target:iw.get(e)??null}))}});function pw(e,t){let n=[];for(let r in t){let i=e[r];i&&i.status!==`error`&&t[r].status===`error`&&n.push(r)}return n}function mw(e,t){let n=[];for(let r in t){let i=t[r];i.status===`passed`&&e[r]?.status!==`passed`&&i.devAgentId&&n.push(i.devAgentId)}return n}function hw(e,t){let n=[];for(let r of t){let t=e.find(e=>e.id===r.id);if(t)for(let e of r.pulls)e.state===`MERGED`&&t.pulls.some(t=>t.number===e.number&&t.state===`OPEN`)&&n.push({repoId:r.id,number:e.number,headRefName:e.headRefName})}return n}function gw(e,t,n){return t||(n.find(t=>t.repoId===e.repoId&&(t.prNumber===e.number||t.branch!=null&&t.branch===e.headRefName))?.id??null)}function _w(e,t,n=4){let r=t.get(e);if(!r)return[];let i=[];for(let[n,a]of t){if(n===e)continue;let t=Math.hypot(a.seatX-r.seatX,a.seatZ-r.seatZ);t<=7.6&&i.push({id:n,d:t})}return i.sort((e,t)=>e.d-t.d).slice(0,n).map(e=>e.id)}var vw=3e3,yw=new Map,bw=new Map,xw=[],Sw=new Map;function Cw(e,t=Date.now()){let n=yw.get(e);if(n)return yw.delete(e),t-n.at<vw?n:void 0}function ww(e,t,n=0,r=0){let i=Date.now();yw.set(e,{fidget:t,x:n,z:r,at:i}),xw.push({id:e,fidget:t,at:i}),xw.length>30&&xw.shift()}function Tw(e,t){return bw.set(e,t),()=>{bw.get(e)===t&&bw.delete(e)}}J.subscribe((e,t)=>{if(t.loaded){if(e.qa!==t.qa){for(let t in e.qa){let n=e.qa[t].devAgentId;n&&Sw.set(t,n)}for(let n of mw(t.qa,e.qa))ww(n,`fistPump`)}if(e.agents!==t.agents)for(let n of pw(t.agents,e.agents))ww(n,`facepalm`);if(e.repos!==t.repos){let n=hw(t.repos,e.repos);if(!n.length)return;let r=[...Object.values(t.agents),...Object.values(e.agents)],i=dw();for(let e of n){let t=gw(e,Sw.get(`${e.repoId}#${e.number}`),r),n=t?i.get(t):void 0;if(t&&n)for(let e of _w(t,i))ww(e,`wave`,n.seatX,n.seatZ)}}}}),typeof window<`u`&&(window.__swarmDeskLife={play(e,t,n){let r=n?dw().get(n):void 0;ww(e,t,r?.seatX??0,r?.seatZ??0)},list(){return[...bw].map(([e,t])=>({id:e,mood:t.mood,fidget:t.fidget}))},recent:()=>[...xw]});var Ew=`"JetBrains Mono", Consolas, "Cascadia Mono", monospace`,Dw=`Fredoka, "Segoe UI", system-ui, sans-serif`;function Ow(e,t,n,r,i,a){e.beginPath(),e.roundRect(t,n,r,i,a)}function kw(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 Aw={bg:`#1b1b29`,bar:`#2a2a3d`,text:`#e8e8f2`,tool:`#8be9fd`,result:`#8d8da8`,system:`#bd93f9`,error:`#ff6b6b`,manager:`#ffb86c`,done:`#50fa7b`,thinking:`#f1fa8c`},jw=[`·`,`✢`,`✳`,`✶`,`✻`,`✽`,`✻`,`✶`,`✳`,`✢`],Mw=[`Crafting`,`Pondering`,`Tinkering`,`Brewing`,`Noodling`,`Scheming`,`Assembling`,`Percolating`];function Nw(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 Pw(e,t,n,r,i,a,o,s,c){e.fillStyle=Aw.bg,e.fillRect(0,0,t,n),e.fillStyle=Aw.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 ${Ew}`,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){Fw(e,0,30,t,n-30,r,s);return}e.font=`14px ${Ew}`;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=Aw.done,e.fillText(`⏺`,10,v),e.fillStyle=Aw.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=Aw.text,e.fillText(t.text.slice(1),10+p,v)):(e.fillStyle=Aw[t.kind]??Aw.text,e.fillText(t.text,10,v)),v+=17;if(r.status===`working`||r.status===`preparing`){let t=Math.floor(s/120)%jw.length,i=r.status===`preparing`?`Setting up worktree`:Nw(r.currentTool)||Mw[Math.floor(s/6e3)%Mw.length],a=r.startedAt?Math.floor((Date.now()-r.startedAt)/1e3):0,o=Math.floor(a/60);e.fillStyle=`#ff9e64`,e.font=`600 14px ${Ew}`,e.fillText(`${jw[t]} ${i}… (${o}m ${a%60}s)`,10,n-14)}o&&Iw(e,f,30,t-f,n-30,r.browserUrl,a)}function Fw(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 ${Dw}`,e.fillText(`✻`,l,u-20),e.fillStyle=`#ffd6a5`,e.font=`600 26px ${Dw}`,e.fillText(`${a.name} is free`,l,u+34),e.fillStyle=`#b8b8dd`,e.font=`18px ${Dw}`,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 Iw(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),Ow(e,t+10,n+6,r-20,22,11),e.fillStyle=`#ffffff`,e.fill(),e.fillStyle=`#4a5160`,e.font=`13px ${Dw}`,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 ${Dw}`,e.fillText(`🌐 loading page…`,c.x+c.w/2,c.y+c.h/2),e.textAlign=`left`}var Lw=[{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`}],Rw={warn:`#ffd8a8`,bad:`#ffc9c9`,good:`#d8f9df`};Lw.map(e=>e.key);function zw(e,t){let n=(t-80)/Lw.length;return{x0:40+e*n,colW:n}}function Bw(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 ${Dw}`,e.fillText(r.fullName,40,48),e.font=`500 26px ${Dw}`,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`,Lw.forEach((r,a)=>{let{x0:o,colW:s}=zw(a,t),c=i[r.key];Ow(e,o+8,96,s-16,52,26),e.fillStyle=r.chip,e.fill(),e.fillStyle=`#1f2233`,e.font=`600 30px ${Dw}`,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)=>{Vw(e,o+16+n%2*(l+16),164+Math.floor(n/2)*116,l,104,t,t.tone?Rw[t.tone]:r.note)}),c.length>d.length){e.fillStyle=`#6c7086`,e.font=`600 26px ${Dw}`;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 ${Dw}`,e.fillText(r.key===`backlog`?`no open issues`:`nothing here yet`,o+30,206))})}function Vw(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 ${Dw}`,e.textBaseline=`top`,e.fillText(`${a.prNumber?`PR `:``}#${a.number}`,14,12),e.font=`500 19px ${Dw}`,kw(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 ${Dw}`,e.fillText(a.agent.name,36,i-14)),a.note&&(e.font=`500 16px ${Dw}`,e.fillStyle=`#5c6078`,e.textAlign=`right`,e.fillText(a.note,r-12,i-14),e.textAlign=`left`),e.restore(),e.textBaseline=`middle`}function Hw(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`?`🏛️`:`☕`;Ow(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 ${Dw}`,e.fillText(i,22,n/2+2),e.fillStyle=`#23263a`,e.font=`700 40px ${Dw}`;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 Uw(e,t,n,r,i,a,o){e.clearRect(0,0,t,n),Ow(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 ${Dw}`,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 ${Dw}`,e.fillText(s(`${r} · candidate`,t-100),80,n*.36),e.fillStyle=`#5c6078`,e.font=`600 28px ${Dw}`,e.fillText(s(`${i}${a?` · floor ${a}`:``}`,t-100),80,n*.72)}function Ww(e,t,n,r,i,a=`#ffffff`){Ow(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 ${Dw}`;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 Gw(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 Kw=[{status:`preparing`,label:`Checking out the code`},{status:`installing`,label:`Installing dependencies`},{status:`starting`,label:`Starting the app`}],qw={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 Jw(e,t,n){let r=t;for(;r.length>2&&e.measureText(r).width>n;)r=`${r.slice(0,-2)}…`;return r}function Yw(e,t,n,r){let i=r.preview;e.fillStyle=Aw.bg,e.fillRect(0,0,t,n),e.textBaseline=`middle`,e.textAlign=`left`,e.fillStyle=Aw.bar,e.fillRect(0,0,t,118),e.fillStyle=r.color,e.fillRect(0,112,t,6),e.font=`700 34px ${Dw}`;let a=`FLOOR ${r.floor}`,o=e.measureText(a).width+44;Ow(e,40,30,o,54,27),e.fillStyle=r.color,e.fill(),e.fillStyle=`#ffffff`,e.fillText(a,62,58);let s=qw[i.status];e.font=`700 38px ${Dw}`;let c=e.measureText(s.text).width+52;Ow(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 ${Dw}`;let l=40+o+26;e.fillText(Jw(e,r.name,t-40-c-26-l),l,58);let u=(n,r,i,a,o=700)=>{e.font=`${o} ${i}px ${Dw}`,e.fillStyle=a,e.textAlign=`center`,e.fillText(Jw(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 ${Dw}`,e.fillStyle=`#ffffff`,e.fillText(Jw(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,Kw.findIndex(e=>e.status===i.status));u(`Getting ${p} ready…`,198,46,`#b8b8cc`,600),u(`${Kw[n].label}…`,f-20,72,`#ffffff`);let r=(t-200-18*(Kw.length-1))/Kw.length;Kw.forEach((t,i)=>{let a=100+i*(r+18),o=f+90;Ow(e,a,o,r,34,17),e.fillStyle=i<n?Aw.done:i===n?`#f4a261`:`#3a3a52`,e.fill(),e.font=`600 28px ${Dw}`,e.fillStyle=i<=n?Aw.text:`#6c6c88`,e.textAlign=`center`,e.fillText(`${i<n?`✓ `:``}${t.label}`,a+r/2,o+70),e.textAlign=`left`}),d(`Step ${n+1} of ${Kw.length} · press E to watch`)}else{let n=r.shot?t*.5:t-112;e.font=`600 34px ${Dw}`,e.fillStyle=`#b8b8cc`,e.fillText(`Serving at`,56,190),e.font=`700 50px ${Ew}`,e.fillStyle=Aw.tool,e.fillText(Jw(e,(i.url??``).replace(/^https?:\/\//,``).replace(/\/$/,``),n),56,258),e.font=`700 42px ${Dw}`;let a=e.measureText(p).width+48;if(Ow(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 ${Ew}`,e.fillStyle=Aw.thinking,e.fillText(i.commit,56+a+24,359)),i.startedAt&&(e.font=`500 32px ${Dw}`,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 ${Dw}`,e.fillStyle=`#8d8da8`,e.fillText(Jw(e,r.shotBy?`latest from ${r.shotBy}'s browser`:`latest agent screenshot`,i),o,168+a+36)}d(`Press E to open the app`,Aw.done)}}var Xw=new Map;function Zw(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 Xw.set(r,{...e,range:t}),()=>{Xw.delete(r)}},[r,t]),n}function Qw(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 $w={gapMs:2e3,ms:1500},eT={ball:2.5,dart:3};function tT(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 nT(e,t,n){return e!==null&&!n&&t>=eT[e]}var rT=(e,t,n=$w.gapMs)=>e===void 0||t-e>=n,iT=e=>e*e*(3-2*e);function aT(e){return!(e>=0)||e>=$w.ms?0:e<120?iT(e/120):e<850?1:1-iT((e-850)/($w.ms-850))}function oT(e){return!(e>=0)||e>=400?0:e<70?iT(e/70):1-iT((e-70)/330)}var sT=(e,t,n)=>Math.min(n,Math.max(t,e));function cT(e,t,n=1.1,r=.5){if(e===0&&t===0)return{head:0,twist:0};let i=Math.atan2(-e,-t),a=sT(i,-n,n);return{head:a,twist:sT(i-a,-r,r)}}var lT=[],uT=1,dT=new Set,fT=new Map,pT=new Map,mT=0;function hT(e,t){let n={id:e,obj:t,key:uT++};lT=[...lT,n];for(let e of dT)e();return()=>{lT=lT.filter(e=>e!==n);for(let e of dT)e()}}var gT=()=>lT;function _T(e){return dT.add(e),()=>void dT.delete(e)}function vT(e,t){let n=fT.get(e);return n||fT.set(e,n=new Set),n.add(t),()=>{n.delete(t),n.size||fT.delete(e)}}function yT(e,t=performance.now()){if(!rT(pT.get(e),t))return!1;pT.set(e,t),mT++;for(let t of fT.get(e)??[])t();return!0}var bT=()=>mT,xT=1.16,ST=`#1f1d2b`;function CT(e,t,n,r){let i=n-8-34;e.lineWidth=8,e.lineJoin=`round`,e.strokeStyle=ST,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 ${Dw}`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(r,t/2,(8+i)/2+4)}function wT({text:e,since:t}){let n=(0,v.useRef)(null),r=Qw(256,176,t=>CT(t,256,176,e),[e]);return G_(()=>{if(!n.current)return;let e=performance.now()-t,r=$w.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 TT(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?hT(e,n):void 0},[e,t]),(0,v.useEffect)(()=>vT(e,()=>{let e=performance.now();r.current=e;let n=t.current?.getWorldPosition(new V);Lb(n&&{x:n.x,y:n.y+xT,z:n.z}),a({text:Math.random()<.65?`hey!`:`!`,since:e})}),[e,t]),(0,v.useEffect)(()=>{if(!i)return;let e=setTimeout(()=>a(null),$w.ms);return()=>clearTimeout(e)},[i]),{pose:e=>{let i=e-r.current;o.w=aT(i),o.flinch=oT(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=cT(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-xT,Math.hypot(s.x,s.z)))),o},bubble:i&&(0,K.jsx)(wT,{text:i.text,since:i.since},i.since)}}var ET=`#1f1d2b`,DT=new tl(.16,.16),OT=null;function kT(){if(OT)return OT;let e=document.createElement(`canvas`);e.width=e.height=64;let t=e.getContext(`2d`);t.font=`700 54px ${Dw}`,t.textAlign=`center`,t.textBaseline=`middle`,t.lineWidth=9,t.lineJoin=`round`,t.strokeStyle=ET,t.fillStyle=`#ffffff`,t.strokeText(`z`,32,30),t.fillText(`z`,32,30);let n=new vs(e);return n.colorSpace=xt,OT=new Na({map:n,transparent:!0,depthWrite:!1,toneMapped:!1}),OT}function AT({on:e,position:t}){let n=(0,v.useRef)(null),r=W_(e=>e.camera),i=(0,v.useMemo)(()=>({parent:new zn,camera:new zn}),[]);return G_(()=>{let t=n.current;if(!t||(t.visible=e.current,!e.current||!t.parent))return;t.parent.getWorldQuaternion(i.parent),t.quaternion.copy(i.parent.invert().multiply(r.getWorldQuaternion(i.camera)));let a=performance.now()/1e3;for(let e=0;e<t.children.length;e++){let n=t.children[e],r=(a*.4+e/3)%1,i=r<.15?r/.15:r>.75?(1-r)/.25:1;n.position.set(r*.16+Math.sin(r*7+e)*.03,r*.38,0),n.scale.setScalar(Math.max(.001,(.45+r*.75)*i)),n.rotation.z=Math.sin(r*5+e)*.25}}),(0,K.jsx)(`group`,{ref:n,position:t,visible:!1,children:[0,1,2].map(e=>(0,K.jsx)(`mesh`,{geometry:DT,material:kT(),renderOrder:2},e))})}var jT=()=>({half:0,walked:0,wasMoving:!1,foot:1});function MT(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 NT=e=>.9+e*.2,PT={wood:({p:e,v:t,f:n,d:r,o:i})=>{q({freq:165*e,to:110*e,dur:.07*r,peak:.028*t,attack:.004,...i}),jb({dur:.06*r,peak:.026*t,freq:650*n,q:.8,attack:.003,...i}),jb({at:.05*r,dur:.04*r,peak:.012*t,filter:`bandpass`,freq:1300*n,q:1.2,attack:.003,...i})},rug:({p:e,v:t,f:n,d:r,o:i})=>{jb({dur:.11*r,peak:.03*t,freq:260*n,q:.6,attack:.012,...i}),q({freq:85*e,to:60*e,dur:.08*r,peak:.016*t,attack:.01,...i})},lobby:({p:e,v:t,f:n,d:r,o:i})=>{jb({dur:.04*r,peak:.02*t,filter:`bandpass`,freq:2400*n,q:1.3,attack:.0015,...i}),jb({dur:.05*r,peak:.016*t,freq:900*n,q:.8,attack:.002,...i}),q({freq:520*e,to:380*e,type:`triangle`,dur:.03*r,peak:.007*t,attack:.002,...i})},cabin:({p:e,v:t,f:n,d:r,o:i})=>{q({freq:196*e,to:186*e,type:`triangle`,dur:.18*r,peak:.018*t,attack:.003,...i}),q({freq:296*e,dur:.12*r,peak:.007*t,attack:.003,...i}),jb({dur:.05*r,peak:.02*t,freq:420*n,q:.7,attack:.003,...i})}},FT={wood:1,rug:.55,lobby:1.4,cabin:.85},IT={group:`steps`,pan:0},LT={p:1,v:1,f:1,d:1,o:IT};function RT(e,t){LT.p=NT(Math.random())*(t?1.03:.97)*(e?1.03:1),LT.v=NT(Math.random())*(e?1.2:1),LT.f=NT(Math.random())*(e?1.25:1),LT.d=e?.85:1}function zT(e,t=!1,n=0){RT(t,n),IT.pan=n?.12:-.12,LT.o=IT,PT[e](LT)}function BT(e){let t=FT[e]*NT(Math.random());jb({dur:.2,peak:.012*NT(Math.random()),filter:`bandpass`,freq:1100*t,to:450*t,q:.7,attack:.05,group:`steps`})}var VT=.7;function HT(e,t,n=!1,r=0){RT(n,r),LT.v*=VT,LT.o={group:`steps`,pos:t,into:wb(`step:${e}`,{group:`steps`,pos:t,peak:.028*LT.v})},PT[e](LT)}function UT(e,t){let n=FT[e]*NT(Math.random());jb({name:`step:scuff`,group:`steps`,pos:t,dur:.2,peak:.012*VT*NT(Math.random()),filter:`bandpass`,freq:1100*n,to:450*n,q:.7,attack:.05})}var WT=jT();function GT(e,t,n,r){let i=MT(WT,e,t);i===`step`?zT(r,n,WT.foot):i===`scuff`&&BT(r)}var KT=1.8,qT={min:2.5,max:6},JT={min:.6,max:2.5},YT=1.2,XT=()=>({x:0,z:0,d:1/0,walking:!1,still:!1,stage:`seated`,gesture:`none`,steps:jT(),murmurIn:-1,out:[]});function ZT(e,t){let n=0;for(let r of e)r!==t&&r.walking&&r.d<t.d&&n++;return n}function QT(e,t){for(let n of e)if(n!==t&&n.still&&Math.hypot(n.x-t.x,n.z-t.z)<=1.8)return!0;return!1}var $T=(e,{min:t,max:n})=>t+e*(n-t);function eE(e,t,n,r,i,a){let o=e.out;o.length=0;let s=t.stage===`up`;e.x=t.x,e.z=t.z,e.d=t.d,e.walking=s&&t.speed>.15,e.still=s&&!e.walking,e.stage===`seated`&&t.stage!==`seated`?o.push(`rise`):e.stage!==`sitting`&&e.stage!==`seated`&&t.stage===`sitting`?o.push(`sit`):e.stage===`sitting`&&t.stage===`seated`&&o.push(`seated`),e.stage=t.stage;let c=MT(e.steps,t.phase,e.walking);return c&&e.d<=12&&ZT(n.people,e)<3&&o.push(c),t.gesture!==e.gesture&&(e.gesture!==`none`&&o.push(`end:${e.gesture}`),t.gesture!==`none`&&o.push(`start:${t.gesture}`),e.gesture=t.gesture),!e.still||!QT(n.people,e)?e.murmurIn=-1:e.murmurIn<0?e.murmurIn=$T(a,JT):(e.murmurIn-=r)<=0&&(i-n.lastMurmur<1.2?e.murmurIn=YT*a:(e.murmurIn=$T(a,qT),e.d<=12&&(n.lastMurmur=i,o.push(`murmur`)))),o}var tE=()=>Math.random();function nE(e){let t={group:`steps`,pos:e,into:wb(`chair:roll`,{group:`steps`,pos:e,peak:.022})};jb({...t,dur:.38,peak:.022,freq:320+tE()*60,to:170,q:.7,attack:.08}),[.06,.19].forEach(e=>jb({...t,at:e+tE()*.04,dur:.025,peak:.006,filter:`bandpass`,freq:2200+tE()*600,q:3,attack:.002}))}function rE(e){let t={group:`steps`,pos:e,into:wb(`chair:creak`,{group:`steps`,pos:e,peak:.012})},n=200+tE()*70;q({...t,freq:n,to:n*1.35,type:`sawtooth`,dur:.2,peak:.006,attack:.04}),jb({...t,dur:.18,peak:.012,filter:`bandpass`,freq:1300+tE()*300,q:6,attack:.05})}function iE(e){jb({name:`sticky:peel`,group:`typing`,pos:e,dur:.16,peak:.024,filter:`bandpass`,freq:2600+tE()*500,to:5200,q:1.4,attack:.1})}function aE(e){let t=wb(`sticky:slap`,{group:`typing`,pos:e,peak:.035});jb({group:`typing`,pos:e,into:t,dur:.06,peak:.035,freq:1100+tE()*300,q:.7,attack:.001}),q({group:`typing`,pos:e,into:t,freq:240,to:150,dur:.05,peak:.01,attack:.002})}function oE(e){let t={group:`typing`,pos:e,into:wb(`sigh`,{group:`typing`,pos:e,peak:.02})};jb({...t,dur:.9,peak:.02,filter:`bandpass`,freq:950,to:480,q:1.4,attack:.25}),q({...t,freq:250+tE()*40,to:175,dur:.75,peak:.006,attack:.2})}function sE(e){let t={group:`typing`,pos:e,into:wb(`yawn`,{group:`typing`,pos:e,peak:.012})},n=240+tE()*50;q({...t,freq:n,to:n*1.45,type:`triangle`,dur:.45,peak:.01,attack:.15}),q({...t,freq:n*1.45,to:n*.8,type:`triangle`,at:.42,dur:.6,peak:.012,attack:.05}),jb({...t,dur:1,peak:.007,filter:`bandpass`,freq:750,to:450,q:1.2,attack:.3})}function cE(e){let t={group:`typing`,pos:e,into:wb(`chat:blah`,{group:`typing`,pos:e,peak:.012})},n=170+tE()*110,r=2+Math.floor(tE()*3);for(let e=0,i=0;e<r;e++,i+=.16+tE()*.08){let a=n*(.9+tE()*.25),o=.1+tE()*.07;q({...t,at:i,freq:a,to:a*(e===r-1?.82:1.04),type:`triangle`,dur:o,peak:.011,attack:.02}),q({...t,at:i,freq:a*3.1,to:a*2.6,dur:o*.8,peak:.003,attack:.02})}}var lE={reach:{start:iE,end:aE},stretch:{start:oE},doze:{start:sE}},uE=new Map,dE={people:[],lastMurmur:-1/0};function fE(e){let t=XT();return uE.set(e,t),dE.people=[...uE.values()],()=>{uE.get(e)===t&&uE.delete(e),dE.people=[...uE.values()]}}var pE=(e,t,n)=>({x:e,y:t,z:n}),mE={stage:`seated`,x:0,z:0,speed:0,phase:0,gesture:`none`,d:0};function hE(e,t,n,r,i=0){let a=uE.get(e);if(!a)return;let o=xb();mE.stage=t.stage,mE.x=t.x,mE.z=t.z,mE.speed=t.speed,mE.phase=t.phase,mE.gesture=n,mE.d=Math.hypot(o.x-t.x,o.y-i-1,o.z-t.z);let s=eE(a,mE,dE,r,performance.now()/1e3,Math.random());if(!s.length)return;let c=J.getState();if(c.travel===null&&c.overlay===null)for(let e of s)switch(e){case`step`:case`scuff`:{let n=pE(t.x,i+.05,t.z),r=FS(c.floor===0?`lobby`:`office`,t.x,t.z);e===`step`?HT(r,n,t.speed>=KT,a.steps.foot):UT(r,n);break}case`rise`:rE(pE(t.seatX,i+.45,t.seatZ)),nE(pE(t.seatX,i+.2,t.seatZ));break;case`sit`:nE(pE(t.seatX,i+.2,t.seatZ));break;case`seated`:rE(pE(t.seatX,i+.45,t.seatZ));break;case`murmur`:cE(pE(t.x,i+1.5,t.z));break;default:{let[n,r]=e.split(`:`),a=lE[r]?.[n];a&&a(pE(t.x-Math.sin(t.heading)*.4,i+1.5,t.z-Math.cos(t.heading)*.4))}}}var gE={pitch:-.34,yaw:.26},_E={typing:{l:gE,r:gE,lean:.1,headPitch:-.02,headYaw:0,type:1,mouse:0},browsing:{l:gE,r:{pitch:-.4,yaw:-.22},lean:.06,headPitch:.05,headYaw:.04,type:.25,mouse:1},thinking:{l:gE,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}},vE=e=>({...e,l:{...e.l},r:{...e.r}}),yE=Rn.lerp,bE=`#1f1d2b`,xE=[`#1f1d2b`,`#7f5539`,`#1f1d2b`,`#c1121f`,`#355070`,`#1f1d2b`],SE={x:.11,seatY:.5,seatZ:-.04,standY:.815,thigh:.32},CE={x:.62,z:-.1},wE=.18,TE=[0,1.98,-1.12],EE={pitch:-1.42,yaw:-.1},DE={none:{l:null,r:null,head:0},reach:{l:null,r:{pitch:1.05,yaw:.05},head:.15},hold:{l:{pitch:-.45,yaw:.4},r:{pitch:-.45,yaw:.4},head:-.05},sip:{l:null,r:{pitch:.7,yaw:.85},head:.25},stretch:{l:{pitch:1.55,yaw:.22},r:{pitch:1.55,yaw:.22},head:.3}},OE={l:_E.cheer.l,r:_E.cheer.r,head:_E.cheer.headPitch},kE={pitch:-.12,yaw:-.55},AE={pitch:.55,yaw:.7},jE=(e,t,n)=>QS(Math.min(1,Math.max(0,(e-t)/(n-t)))),ME=(e,t,n)=>{e.pitch=t,e.yaw=n};function NE(e,t,n,r,i){switch(i.lw=i.rw=i.leanW=i.pitchW=i.yaw=i.roll=i.twist=i.spin=0,e){case`leanBack`:ME(i.l,2.45,.75),ME(i.r,2.45,.75),i.lw=i.rw=i.leanW=i.pitchW=1,i.lean=-.2+Math.sin(n*1.4)*.025,i.pitch=.14;break;case`spin`:i.spin=Math.sin(t*Math.PI*2)*.55,i.yaw=-i.spin*.5;break;case`phone`:ME(i.l,-.3,.6),ME(i.r,-.26+(Math.sin(n*11)>.4?.04:0),.55),i.lw=i.rw=i.pitchW=i.leanW=1,i.pitch=-.42,i.lean=.05;break;case`sip`:{let e=jE(t,.3,.45)-jE(t,.62,.77);ME(i.r,kE.pitch+(AE.pitch-kE.pitch)*e,kE.yaw+(AE.yaw-kE.yaw)*e),i.rw=1,i.twist=-.32*(1-e),i.lean=.16*(1-e),i.leanW=1,i.pitch=.28*e,i.pitchW=e;break}case`doze`:i.pitch=-.6+Math.sin(t*.9)*.05+(Math.sin(t*.37)>.97?.12:0),i.pitchW=1,i.roll=.16,i.lean=.08,i.leanW=1;break;case`neckRoll`:{let e=t*Math.PI*2.4;i.pitch=Math.sin(e)*.24-.05,i.pitchW=1,i.roll=Math.cos(e)*.3;break}case`shoulders`:ME(i.l,.05,1.35),i.lw=1,i.yaw=.3,i.twist=-.12;break;case`scratch`:ME(i.r,1.42+Math.sin(n*17)*.06,.6+Math.sin(n*17+1)*.05),i.rw=1,i.roll=-.14,i.pitch=.04,i.pitchW=1;break;case`facepalm`:ME(i.r,.73,.6),i.rw=1,i.pitch=-.3,i.pitchW=1,i.yaw=Math.sin(n*5)*.12,i.lean=.12,i.leanW=1;break;case`fistPump`:ME(i.r,1.15+Math.max(0,Math.sin(t*Math.PI*6))*.45,-.15),i.rw=1,i.pitch=.18,i.pitchW=1,i.lean=-.06,i.leanW=1;break;case`wave`:ME(r>0?i.l:i.r,1.3,-.3+Math.sin(n*10)*.35),r>0?i.lw=1:i.rw=1,i.yaw=Math.max(-1.1,Math.min(1.1,r*.7)),i.twist=Math.max(-.4,Math.min(.4,r*.3)),i.pitch=.08,i.pitchW=1}return i}function PE({agent:e,chair:t,mug:n,children:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(vE(_E.relaxed)),l=(0,v.useRef)(Math.random()*100),u=(0,v.useRef)({name:null,at:0}),d=(0,v.useMemo)(()=>US(e),[e.id,e.look,e.role]),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useRef)(null),h=(0,v.useRef)(null),g=(0,v.useRef)(null),_=(0,v.useRef)(null),y=(0,v.useRef)(null),b=(0,v.useRef)(null),x=(0,v.useRef)(null),S=(0,v.useRef)(null),C=(0,v.useMemo)(()=>({s:YS(),g:{stride:0,cadence:0,bob:0,lean:0},placed:!1,gl:0,gr:0,gh:0,l:{...EE},r:{...EE}}),[]),w=(0,v.useMemo)(()=>({s:zC(e.id,performance.now()/1e3,n!=null),o:{l:{...EE},r:{...EE},lw:0,rw:0,lean:0,leanW:0,pitch:0,pitchW:0,yaw:0,roll:0,twist:0,spin:0},stretch:null,tx:0,tz:0,toward:0,browse:0,rest:null,held:!1,v:new V}),[e.id,n]),T=(0,v.useRef)(!1),E=(0,v.useRef)(null),D=(0,v.useRef)(null),O=TT(e.id,p);e.currentTool&&(u.current={name:e.currentTool,at:performance.now()}),(0,v.useEffect)(()=>uw(e.id,C.s),[e.id,C]),(0,v.useEffect)(()=>Tw(e.id,w.s),[e.id,w]),(0,v.useEffect)(()=>()=>{w.stretch&&sw(e.id)===w.stretch&&lw(e.id)},[e.id,w]),(0,v.useEffect)(()=>fE(e.id),[e.id]),G_((r,v)=>{let k=Math.min(v,.1),A=performance.now(),j=A/1e3+l.current,M=Tx(e.repoId,A),N=C.s,ee=f.current,P=sw(e.id);if(ee){C.placed||=(ee.updateWorldMatrix(!0,!1),!0);let t=ee.matrixWorld.elements;N.seatX=t[12],N.seatZ=t[14],N.seatHeading=Math.atan2(t[8],t[10]),N.standX=t[0]*CE.x+t[8]*CE.z+t[12],N.standZ=t[2]*CE.x+t[10]*CE.z+t[14],tC(N,P??null,k);let n=p.current;if(n&&N.stage===`seated`)n.position.set(0,0,0),n.rotation.y=0;else if(n){let e=N.x-t[12],r=N.z-t[14];n.position.set(t[0]*e+t[2]*r,0,t[8]*e+t[10]*r),n.rotation.y=N.heading-N.seatHeading}let r=M?OE:DE[N.stage===`up`?P?.gesture??`none`:`none`],i=1-Math.exp(-k*6);r.l&&Object.assign(C.l,r.l),r.r&&Object.assign(C.r,r.r),C.gl+=(+!!r.l-C.gl)*i,C.gr+=(+!!r.r-C.gr)*i,C.gh+=(r.head-C.gh)*i,hE(e.id,N,N.stage===`up`?P?.gesture??`none`:`none`,k,t[13])}let te=N.stage===`seated`,ne=QS(N.sit),re=1-ne,ie=iC(N.speed,C.g),ae=Math.min(1,N.speed/.5),oe=Math.sin(N.phase)*ie.stride*ae,se=-ie.bob*ae*Math.sin(N.phase)**2;t?.current&&(S.current??=t.current.position.z,t.current.position.z=S.current+wE*re);let ce=e.status===`working`||e.status===`preparing`,le=M||e.status===`done`&&e.endedAt!=null&&Date.now()-e.endedAt<7e3,ue=A-u.current.at,de=u.current.name?.startsWith(`mcp__playwright`)&&ue<4e3,fe=M?`cheer`:ce?e.status===`preparing`?`typing`:de?`browsing`:!e.currentTool&&ue>2500?`thinking`:`typing`:e.status===`error`?`slump`:le?`cheer`:`relaxed`,pe=_E[fe],me=c.current,he=1-Math.exp(-k*5);for(let e of[`l`,`r`])me[e].pitch+=(pe[e].pitch-me[e].pitch)*he,me[e].yaw+=(pe[e].yaw-me[e].yaw)*he;for(let e of[`lean`,`headPitch`,`headYaw`,`type`,`mouse`])me[e]+=(pe[e]-me[e])*he;let F=Math.sin(j*.8)+Math.sin(j*2.1)*.6>-.35?1:.15,ge=me.type*F*.1,_e=e.status===`preparing`?10:19,ve=Math.max(0,Math.sin(j*_e))*ge,ye=Math.max(0,Math.sin(j*_e+2.4))*ge*(1-me.mouse),be=Math.sin(j*3.1)*.05*me.type,xe=Math.sin(j*2.7+1)*.05*me.type,Se=Math.sin(j*1.9)*.06*me.mouse,Ce=(Math.sin(j*5.3)>.93?.04:0)*me.mouse,we=le?Math.sin(j*9)*.35:0,Te=M?we*re:0,Ee=-(d.height-1)*.55,De=O.pose(A),Oe=De.flinch*.55,ke=w.s,Ae=A/1e3,je=Cw(e.id);if(je&&(GC(ke,je.fidget,Ae),ee)){let e=ee.matrixWorld.elements,t=je.x-e[12],n=je.z-e[14];w.toward=Math.atan2(-(e[0]*t+e[2]*n),-(e[8]*t+e[10]*n))}De.w>0&&KC(ke,Ae);let Me=P!=null&&P===w.stretch;qC(ke,P&&!Me||le||e.status===`preparing`||e.status===`error`?`busy`:ce?fe===`browsing`?`browsing`:fe===`thinking`?`thinking`:`working`:`idle`,Ae);let I=JC(ke,Ae);ke.fidget===`stretch`&&I<.8?!w.stretch&&!P&&te&&I<.2&&(cw(e.id,{mode:`standing`,x:N.standX,z:N.standZ,heading:N.seatHeading,speed:GS,gesture:`stretch`}),w.stretch=sw(e.id)??null):w.stretch&&=(sw(e.id)===w.stretch&&lw(e.id),null);let Ne=YC(ke,Ae),Pe=NE(Ne>0?ke.fidget:null,I,j,w.toward,w.o),Fe=Pe.lw*Ne,L=Pe.rw*Ne;w.browse+=(+(fe===`browsing`)-w.browse)*(1-Math.exp(-k*1.2)),T.current=te&&ke.fidget===`doze`&&Ne>.5,E.current&&(E.current.visible=te&&ke.fidget===`phone`&&Ne>.35),te&&p.current&&(p.current.rotation.y=Pe.spin*Ne),t?.current&&(t.current.rotation.y=te?Pe.spin*Ne:0);let Ie=Math.sin(j*1.1)*.03*(1-ae),Le=(EE.pitch-oe*1.1+Ie)*(1-C.gl)+C.l.pitch*C.gl,Re=EE.yaw*(1-C.gl)+C.l.yaw*C.gl,ze=(EE.pitch+oe*1.1+Ie)*(1-C.gr)+C.r.pitch*C.gr,Be=EE.yaw*(1-C.gr)+C.r.yaw*C.gr;if(o.current&&s.current&&(o.current.rotation.set(yE(me.l.pitch+Ee+ve,Pe.l.pitch,Fe)*ne+Le*re+Oe,yE(-(me.l.yaw+be)+we,-Pe.l.yaw,Fe)*ne-Re*re+Te,0),s.current.rotation.set(yE(me.r.pitch+Ee+ye-Ce,Pe.r.pitch,L)*ne+ze*re+Oe,yE(me.r.yaw+xe*(1-me.mouse)+Se-we,Pe.r.yaw,L)*ne+Be*re-Te,0)),i.current){let e=Math.sin(j*1.6)*.015,t=yE(me.lean,Pe.lean,Pe.leanW*Ne)+w.browse*.1;i.current.rotation.x=(-t+e+(ce?Math.sin(j*9)*.006*F:0))*ne+(e-ie.lean*ae)*re+De.flinch*.2,i.current.rotation.y=De.twist*De.w+Math.sin(N.phase)*.1*ae*re+Pe.twist*Ne*ne,i.current.rotation.z=(Math.sin(j*.5)*.03*(1-ae)+Math.sin(N.phase)*.035*ae)*re,i.current.position.set(0,SE.seatY*ne+(SE.standY+se)*re,-(d.height-1)*.25*ne)}if(m.current&&(m.current.visible=te),h.current&&(h.current.visible=!te),!te&&g.current&&_.current&&y.current&&b.current){let e=.3+ie.stride,t=Math.sin(j*.5)*.15*(1-ae),n=-(Math.max(0,Math.cos(N.phase))*e*ae+Math.max(0,t)+.04),r=-(Math.max(0,-Math.cos(N.phase))*e*ae+Math.max(0,-t)+.04),i=SE.seatY*ne+(SE.standY+se)*re,a=SE.seatZ*ne;g.current.position.set(-SE.x,i,a),_.current.position.set(SE.x,i,a),g.current.rotation.x=Math.PI/2*ne+(oe-n*.4)*re,_.current.rotation.x=Math.PI/2*ne+(-oe-r*.4)*re,y.current.rotation.x=-Math.PI/2*ne+n*re,b.current.rotation.x=-Math.PI/2*ne+r*re}if(x.current){let[e,t,n]=TE;x.current.position.set(e*ne,t*ne+(SE.standY+d.height*.86+.26)*re,n*ne)}if(a.current){let t=ce&&Math.sin(j*.55+2)>.92?-.22:0,n=e.status===`preparing`?Math.sin(j*1.3)*.5:Math.sin(j*.4)*.08,r=yE(me.headPitch+t+(ce?Math.sin(j*4.5)*.02*F:0),Pe.pitch,Pe.pitchW*Ne)*ne+(Math.sin(j*.3)*.05+C.gh)*re,i=(n+me.headYaw+Pe.yaw*Ne)*ne+Math.sin(j*.4)*.15*(1-ae)*re;a.current.rotation.set(r+(De.headPitch-r)*De.w,i+(De.headYaw-i)*De.w,((fe===`thinking`?.12:0)+Pe.roll*Ne)*ne*(1-De.w))}let Ve=n?.current;if(Ve){let e=ke.fidget===`sip`&&te?jE(I,.2,.3)-jE(I,.78,.88):0;e>0&&D.current&&Ve.parent?(w.rest??=Ve.position.clone(),D.current.getWorldPosition(w.v),Ve.parent.worldToLocal(w.v),Ve.position.lerpVectors(w.rest,w.v,e),Ve.rotation.x=.7*(jE(I,.3,.45)-jE(I,.62,.77)),w.held=!0):w.held&&w.rest&&(Ve.position.copy(w.rest),Ve.rotation.x=0,w.held=!1)}});let k=QC(e.skin),A=e.role===`qa`,j=e.role===`ceo`,M=e.look===`feminine`,N=e.status===`working`||e.status===`preparing`,ee=QC(A?`#f8f9fa`:j?`#2b2d42`:e.color),P=QC(d.hair===`buzz`?rw(e.hair,e.skin,.35):e.hair),te=QC(bE),ne=QC(`#3d4a6b`),re=LS[d.accent],ie=e.status===`error`,ae=DC.hair[d.hair],oe=DC.facialHair[d.facialHair],se=DC.glasses[d.glasses],ce=DC.headwear[d.headwear],le=DC.outfit[d.outfit],ue=d.hair!==`buzz`&&d.hair!==`bald`,de=M&&d.headwear===`none`&&[`long`,`ponytail`,`bun`,`sidePart`,`curls`].includes(d.hair),fe=d.headphones&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{geometry:DC.headphones.shell,material:QC(`#2b2d42`),castShadow:!0}),(0,K.jsx)(`mesh`,{geometry:DC.headphones.covers,material:QC(nw(e.color,.12))})]});return(0,K.jsx)(`group`,{ref:f,children:(0,K.jsxs)(`group`,{ref:p,children:[O.bubble,(0,K.jsx)(AT,{on:T,position:[.16,1.34,-.14]}),(0,K.jsxs)(`group`,{ref:m,children:[(0,K.jsx)(`mesh`,{geometry:DC.legs,material:ne,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:bE,angle:0})}),(0,K.jsx)(`mesh`,{geometry:DC.shoes,material:te,castShadow:!0})]}),(0,K.jsx)(`group`,{ref:h,visible:!1,children:[{hip:g,knee:y,x:-SE.x},{hip:_,knee:b,x:SE.x}].map(({hip:e,knee:t,x:n})=>(0,K.jsxs)(`group`,{ref:e,position:[n,SE.seatY,SE.seatZ],rotation:[Math.PI/2,0,0],children:[(0,K.jsx)(`mesh`,{geometry:DC.thigh,material:ne,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:bE,angle:0})}),(0,K.jsxs)(`group`,{ref:t,position:[0,-SE.thigh,0],rotation:[-Math.PI/2,0,0],children:[(0,K.jsx)(`mesh`,{geometry:DC.shin,material:ne,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:bE,angle:0})}),(0,K.jsx)(`mesh`,{geometry:DC.shoe,material:te,castShadow:!0})]})]},n))}),(0,K.jsxs)(`group`,{ref:i,position:[0,.5,-(d.height-1)*.25],scale:d.height,children:[(0,K.jsxs)(`group`,{scale:[d.shoulders,1,1],children:[(0,K.jsx)(`mesh`,{position:[0,.3,0],geometry:DC.torso,material:ee,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.015,color:bE,angle:0})}),d.outfit!==`sweater`&&(0,K.jsx)(`mesh`,{position:[0,.5,-.02],rotation:[Math.PI/2,0,0],geometry:DC.collar,material:QC(j?`#f8f9fa`:nw(e.color,-.15))}),le.main&&(0,K.jsx)(`mesh`,{geometry:le.main,material:QC(nw(e.color,-.08)),castShadow:!0}),le.trim&&(0,K.jsx)(`mesh`,{geometry:le.trim,material:QC(d.outfit===`stripe`?re:d.outfit===`hoodie`?`#f8f9fa`:nw(e.color,-.14))}),j&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{position:[0,.36,-.192],geometry:DC.shirtFront,material:QC(`#f8f9fa`)}),(0,K.jsx)(`mesh`,{position:[0,.33,-.206],geometry:DC.tie,material:QC(e.color)}),(0,K.jsx)(`mesh`,{position:[0,.445,-.206],geometry:DC.tieKnot,material:QC(nw(e.color,-.2))})]}),A&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{position:[0,.27,-.196],geometry:DC.coatOpening,material:QC(e.color)}),(0,K.jsx)(`mesh`,{position:[.1,.38,-.19],rotation:[.1,0,0],geometry:DC.badge,material:QC(`#ffd166`)})]}),!N&&fe&&(0,K.jsx)(`group`,{position:[0,.49,-.09],rotation:[Math.PI/2-.5,0,0],scale:.74,children:fe})]}),[{ref:o,x:-.25},{ref:s,x:.25}].map(({ref:e,x:t})=>(0,K.jsxs)(`group`,{ref:e,position:[t*d.shoulders,.44,0],children:[(0,K.jsx)(`mesh`,{position:[0,0,-.24],rotation:[Math.PI/2,0,0],geometry:DC.sleeve,material:ee,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:bE,angle:0})}),(0,K.jsx)(`mesh`,{position:[0,0,-.5],geometry:DC.hand,material:k,castShadow:!0}),e===s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`group`,{ref:D,position:[0,.03,-.56]}),(0,K.jsxs)(`group`,{ref:E,position:[-.03,.06,-.52],rotation:[.7,-.55,0],visible:!1,children:[(0,K.jsx)(`mesh`,{geometry:DC.phone,material:te}),(0,K.jsx)(`mesh`,{geometry:DC.phoneScreen,material:QC(`#8ecae6`,{emissive:`#8ecae6`,emissiveIntensity:.5})})]})]})]},t)),(0,K.jsxs)(`group`,{ref:a,position:[0,.66,0],children:[(0,K.jsx)(`mesh`,{geometry:DC.head,material:k,castShadow:!0,children:(0,K.jsx)(jy,{thickness:.015,color:bE,angle:0})}),ae&&(0,K.jsx)(`mesh`,{geometry:ae,material:P,castShadow:ue,children:ue&&(0,K.jsx)(jy,{thickness:.012,color:bE,angle:0})}),(0,K.jsx)(`mesh`,{geometry:DC.ears,material:k}),(0,K.jsx)(`mesh`,{geometry:DC.eyes,material:te}),(0,K.jsx)(`mesh`,{position:[0,-.02,-.2],geometry:DC.nose,material:QC(nw(e.skin,-.08))}),(0,K.jsx)(`mesh`,{position:[0,ie?-.1:-.075,-.175],rotation:[.25,0,ie?0:Math.PI],geometry:DC.mouth,material:te}),oe&&(0,K.jsx)(`mesh`,{geometry:oe,material:QC(d.facialHair===`stubble`?rw(e.skin,e.hair,.3):e.hair)}),M&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`mesh`,{geometry:DC.lashes,material:te}),(0,K.jsx)(`mesh`,{geometry:DC.cheeks,material:QC(`#ff9aa2`)})]}),de&&(0,K.jsx)(`mesh`,{position:[.15,.13,-.08],rotation:[0,0,.5],geometry:DC.hairClip,material:QC(A?`#ff9f68`:nw(e.color,.15))}),A&&(0,K.jsx)(`mesh`,{geometry:DC.inspectorGlasses,material:te}),se&&(0,K.jsx)(`mesh`,{geometry:se,material:QC(xE[d.accent])}),ce&&(0,K.jsx)(`mesh`,{geometry:ce,material:QC(d.accent===0?nw(e.color,-.2):re),castShadow:!0,children:(0,K.jsx)(jy,{thickness:.012,color:bE,angle:0})}),N&&fe]})]}),r&&(0,K.jsx)(`group`,{ref:x,position:TE,children:r})]})})}var FE=`#1f1d2b`;function Y({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:QC(r),children:[(0,K.jsx)(`boxGeometry`,{args:e}),i&&(0,K.jsx)(jy,{thickness:.018,color:FE}),o]})}function IE({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:QC(a),children:[(0,K.jsx)(`cylinderGeometry`,{args:[t??e,e,n,c]}),o&&(0,K.jsx)(jy,{thickness:.018,color:FE})]})}function LE({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:QC(r),children:[(0,K.jsx)(`sphereGeometry`,{args:[e,20,14]}),i&&(0,K.jsx)(jy,{thickness:.018,color:FE})]})}var RE={w:1,h:.6,px:896,py:538},zE=`#f1d19b`;function BE(e,t){let n=W_(e=>e.camera),{canvas:r,tex:i}=(0,v.useMemo)(()=>{let e=document.createElement(`canvas`);e.width=RE.px,e.height=RE.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)(()=>J.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=J.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`&&(J.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=J.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=J.getState().settings,g=u.role!==`ceo`&&h.runtime===`terminal`?u.cli||h.defaultCli:`claude`;Pw(r.getContext(`2d`),RE.px,RE.py,u,f,s.current,!!m,e,g),i.needsUpdate=!0}),i}function VE({agent:e}){let t=Qw(512,96,t=>Hw(t,512,96,e),[e.name,e.status,e.issueNumber,e.currentTool,e.color]);return(0,K.jsx)(Oy,{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 HE={y:1.31,z:-.3,tilt:-.06},UE=`#2b2d42`,WE=`#3d4152`;function GE({accent:e,children:t}){return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(IE,{r:.17,rTop:.15,h:.025,position:[0,.782,HE.z-.04],color:WE,outline:!0}),(0,K.jsx)(Y,{size:[.07,.36,.05],position:[0,.95,HE.z-.07],color:WE,outline:!0}),(0,K.jsxs)(`group`,{position:[0,HE.y,HE.z],rotation:[HE.tilt,0,0],children:[(0,K.jsx)(Y,{size:[RE.w+.07,RE.h+.07,.05],color:UE,outline:!0}),(0,K.jsx)(Y,{size:[.6,.36,.07],position:[0,0,-.055],color:WE}),t,(0,K.jsx)(`mesh`,{position:[0,0,-.091],rotation:[0,Math.PI,0],material:ew(e),children:(0,K.jsx)(`circleGeometry`,{args:[.06,24]})}),(0,K.jsx)(`mesh`,{position:[RE.w/2-.02,-RE.h/2-.018,.026],material:ew(`#7CFFB2`),children:(0,K.jsx)(`circleGeometry`,{args:[.008,10]})})]})]})}function KE({agent:e,accent:t}){let n=(0,v.useRef)(null),r=BE(e,n);return(0,K.jsx)(GE,{accent:t,children:(0,K.jsxs)(`mesh`,{ref:n,position:[0,0,.026],children:[(0,K.jsx)(`planeGeometry`,{args:[RE.w,RE.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:r,toneMapped:!1})]})})}function qE({accent:e,qa:t}){let n=Qw(640,384,e=>{e.fillStyle=`#151621`,e.fillRect(0,0,640,384),Ww(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)(GE,{accent:e,children:(0,K.jsxs)(`mesh`,{position:[0,0,.026],children:[(0,K.jsx)(`planeGeometry`,{args:[RE.w,RE.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:n,toneMapped:!1})]})})}function JE(){let e=Qw(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)(Y,{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:QC(`#3d4152`),children:(0,K.jsx)(`planeGeometry`,{args:[.24,.2]})}),(0,K.jsx)(`mesh`,{position:[.46,.022,.02],scale:[.75,.5,1],material:QC(`#f4f4f8`),castShadow:!0,children:(0,K.jsx)(`sphereGeometry`,{args:[.05,14,10]})})]})}var YE=`#dfe7ef`,XE=`#ff9f68`;function ZE({agent:e,accent:t,repoId:n,position:r,role:i=`dev`,rotationY:a=0}){let o=i===`qa`,s=Zw(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`} · ⚙️ Setup inside`,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?nw(e.color,.1):`#ffffff`,l=o?YE:zE,u=o?XE:t,d=(0,v.useRef)(null),f=(0,v.useRef)(null);return(0,K.jsxs)(`group`,{ref:s,position:r,rotation:[0,a,0],children:[(0,K.jsx)(Y,{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)(Y,{size:[.06,.71,.06],position:[e,.355,t],color:`#5c677d`},`${e}${t}`)),(0,K.jsx)(Y,{size:[1.76,.4,.03],position:[0,.5,-.44],color:nw(l,-.08)}),e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(KE,{agent:e,accent:t}),(0,K.jsx)(JE,{}),(0,K.jsx)(`group`,{ref:f,position:[.76,.82,.02],children:(0,K.jsx)(IE,{r:.045,h:.1,color:c,outline:!0})})]}):(0,K.jsx)(qE,{accent:t,qa:o}),o?(0,K.jsxs)(`group`,{position:[-.72,.77,-.2],children:[(0,K.jsx)(Y,{size:[.3,.05,.1],position:[0,.06,0],color:`#adb5bd`,outline:!0}),[`#ff6b6b`,`#4cc9f0`,`#80ed99`].map((e,t)=>(0,K.jsx)(IE,{r:.022,h:.16,position:[-.09+t*.09,.1,0],color:e,outline:!0},e))]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(IE,{r:.06,rTop:.07,h:.09,position:[-.76,.815,-.22],color:`#e07a5f`,outline:!0}),(0,K.jsx)(LE,{r:.09,position:[-.76,.92,-.22],color:`#52b788`,outline:!0})]}),(0,K.jsxs)(`group`,{ref:d,position:[0,0,e?.8:.6],children:[(0,K.jsx)(Y,{size:[.52,.08,.5],position:[0,.44,0],color:u,outline:!0}),(0,K.jsx)(Y,{size:[.48,.42,.07],position:[0,.72,.28],color:u,outline:!0}),(0,K.jsx)(IE,{r:.035,h:.36,position:[0,.22,0],color:`#444a5c`}),(0,K.jsx)(IE,{r:.26,h:.04,position:[0,.03,0],color:`#444a5c`})]}),e&&(0,K.jsx)(`group`,{position:[0,0,.8],children:(0,K.jsx)(PE,{agent:e,chair:d,mug:f,children:(0,K.jsx)(VE,{agent:e})},e.id)})]})}var QE=`#b9c2cf`;function $E({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}=tS,u=12.15,d=Zw({id:`elevator`,label:`Use the elevator`,action:{kind:`elevator`}},3.5),f=Zw({id:`elevator-panel`,label:`Choose a floor`,action:{kind:`elevator`}},2.5),p=Qw(512,128,t=>Ww(t,512,128,[{text:e,size:56,color:`#7CFFB2`}],`#15151f`),[e]);return G_((e,t)=>{let s=J.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)(Y,{size:[.22,l+.1,.36],position:[-o-.05,(l+.1)/2,12],color:QE,outline:!0}),(0,K.jsx)(Y,{size:[.22,l+.1,.36],position:[o+.05,(l+.1)/2,12],color:QE,outline:!0}),(0,K.jsx)(Y,{size:[o*2+.32,.22,.36],position:[0,l+.08,12],color:QE,outline:!0}),(0,K.jsx)(`mesh`,{ref:r,position:[-o/2,l/2,u],material:QC(`#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:QC(`#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)(Y,{size:[.22,.4,.04],position:[0,0,0],color:QE,outline:!0}),(0,K.jsx)(`mesh`,{position:[0,.08,.025],material:ew(t),children:(0,K.jsx)(`circleGeometry`,{args:[.05,20]})}),(0,K.jsx)(`mesh`,{position:[0,-.08,.025],material:ew(`#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:QC(`#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:QC(`#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:ew(`#fff6d6`),children:(0,K.jsx)(`circleGeometry`,{args:[.45,32]})}),[-1,1].map(e=>(0,K.jsx)(`mesh`,{position:[e*(s+.05),Qx/2,(c+.05)/2],material:QC(`#c8ced8`),children:(0,K.jsx)(`boxGeometry`,{args:[.1,Qx,c-.05]})},e)),(0,K.jsx)(`mesh`,{position:[0,Qx/2,c+.05],material:QC(`#c8ced8`),children:(0,K.jsx)(`boxGeometry`,{args:[s*2+.2,Qx,.1]})}),(0,K.jsx)(Y,{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)(Y,{size:[.36,.7,.04],position:[0,0,0],color:QE,outline:!0}),[.22,.08,-.06,-.2].map((e,n)=>(0,K.jsx)(`mesh`,{position:[0,e,.025],material:ew(n===0?t:`#fdfdfd`),children:(0,K.jsx)(`circleGeometry`,{args:[.04,16]})},e))]})]})]})}var eD=[1280,720],tD=`#2b2d42`,nD=rw(`#7CFFB2`,`#fbf3e4`,.35),rD={running:`#7CFFB2`,error:`#ff6b6b`,preparing:`#ffd166`,installing:`#ffd166`,starting:`#ffd166`};function iD(e){return J(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 aD({repo:e,agents:t}){let n=e.preview,r=n.status===`running`,i=e.fullName.split(`/`)[1]??e.fullName,a=iD(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=Qw(eD[0],eD[1],t=>Yw(t,eD[0],eD[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=Zw({id:`app-${e.id}`,label:`Open the app`,action:{kind:`app`,repoId:e.id}},6),u=mS,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:ew(nD),children:(0,K.jsx)(`planeGeometry`,{args:[d+.18,f+.18]})}),(0,K.jsx)(Y,{size:[d,f,u.depth],position:[0,0,u.depth/2],color:tD,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:ew(rD[n.status]??`#6c7086`),children:(0,K.jsx)(`circleGeometry`,{args:[.022,12]})})]})}var oD=new Map;function sD(e,t){return oD.set(e,t),()=>{oD.get(e)===t&&oD.delete(e)}}function cD(e){oD.get(e)?.()}var lD=`#1f1d2b`,uD=`#a0522d`,dD=`#7f3b1d`,fD=`#e0a53a`,pD=`#b5752a`,mD=`#f7d27a`,{w:hD,d:gD,h:_D,r:vD,y:yD}=_S,bD=.14,xD=hD/2-bD/2,SD=_D-.18,CD=SD-yD,wD=new Na({color:`#fff3b0`,transparent:!0,opacity:0,blending:2,depthWrite:!1,toneMapped:!1}),TD=wD.clone(),ED=new Es(vD,vD,.07,40),DD=new Es(vD*.86,vD*.86,.09,40),OD=new sl(vD*.55,.014,6,40),kD=new al(vD*.24,20,12),AD=new Ts(vD*.9,40),jD=new nl(.88,1,48);function MD(){let e=(0,v.useRef)(null),t=(0,v.useRef)(null),n=(0,v.useRef)(null),r=(0,v.useRef)(!0);return G_(()=>{let i=e.current;if(!i||!t.current||!n.current)return;let a=(performance.now()-bx.hitAt)/1e3,o=yx(a);if(o===0){if(r.current)return;r.current=!0,i.rotation.set(0,0,0),t.current.visible=n.current.visible=!1;return}r.current=!1;let s=vx(a);i.rotation.set(_x(a),s*.6,s),t.current.visible=!0,wD.opacity=.7*o;let c=Math.min(1,a/.45);n.current.visible=c<1,n.current.scale.setScalar(vD*(.25+c*.8)),TD.opacity=.9*(1-c)}),(0,K.jsxs)(`group`,{ref:e,position:[0,SD,0],children:[[-1,1].map(e=>(0,K.jsx)(IE,{r:.018,h:CD-vD*.92,position:[e*vD*.3,-(CD-vD*.92)/2,0],color:`#e9d8a6`,shadow:!1},e)),(0,K.jsxs)(`group`,{position:[0,-CD,0],rotation:[Math.PI/2,0,0],children:[(0,K.jsx)(`mesh`,{geometry:ED,material:QC(pD),castShadow:!0,children:(0,K.jsx)(jy,{thickness:.02,color:lD})}),(0,K.jsx)(`mesh`,{geometry:DD,material:QC(fD)})]}),(0,K.jsxs)(`group`,{position:[0,-CD,.046],children:[(0,K.jsx)(`mesh`,{geometry:OD,material:QC(pD)}),(0,K.jsx)(`mesh`,{geometry:kD,material:QC(mD),scale:[1,1,.35],children:(0,K.jsx)(jy,{thickness:.012,color:lD})}),(0,K.jsx)(`mesh`,{ref:t,geometry:AD,material:wD,position:[0,0,.04],visible:!1}),(0,K.jsx)(`mesh`,{ref:n,geometry:jD,material:TD,position:[0,0,.05],visible:!1})]})]})}function ND({repoId:e}){let t=Zw({id:`gong`,label:`Bang the gong`,action:{kind:`poke`,toyId:`gong`}},3.4);return(0,v.useEffect)(()=>{xx(e);let t=sD(`gong`,()=>void wx());return()=>{t(),bx.here===e&&xx(null)}},[e]),(0,K.jsxs)(`group`,{ref:t,position:[_S.x,0,_S.z],children:[[-1,1].map(e=>(0,K.jsxs)(`group`,{position:[e*xD,0,0],children:[(0,K.jsx)(Y,{size:[bD,_D-.1,bD],position:[0,(_D-.1)/2,0],color:uD,outline:!0}),(0,K.jsx)(Y,{size:[.24,.14,gD],position:[0,.07,0],color:dD,outline:!0}),(0,K.jsx)(Y,{size:[.2,.08,.2],position:[0,.18,0],color:dD,shadow:!1})]},e)),(0,K.jsx)(Y,{size:[hD+.2,.17,.2],position:[0,_D-.085,0],color:uD,outline:!0}),[-1,1].map(e=>(0,K.jsx)(Y,{size:[.1,.21,.24],position:[e*(hD/2+.1),_D-.085,0],color:`#d62828`,outline:!0,shadow:!1},e)),(0,K.jsx)(Y,{size:[hD-bD*2,.08,.1],position:[0,.42,0],color:dD,shadow:!1}),(0,K.jsx)(MD,{}),(0,K.jsxs)(`group`,{position:[xD,1.45,.12000000000000001],children:[(0,K.jsx)(Y,{size:[.05,.05,.1],position:[0,0,-.03],color:`#495057`,shadow:!1}),(0,K.jsx)(IE,{r:.025,h:.72,position:[0,-.36,.03],color:`#f1d19b`,outline:!0}),(0,K.jsx)(LE,{r:.13,position:[0,-.78,.03],color:`#e76f51`,outline:!0}),(0,K.jsx)(IE,{r:.135,h:.05,position:[0,-.78,.03],color:`#f4a261`,shadow:!1})]})]})}function PD({repo:e,agents:t}){let n=J(e=>e.qa),r=(0,v.useMemo)(()=>zx(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*pS.h/pS.w),o=Qw(2560,a,t=>Bw(t,2560,a,e,r),[i]),s=Zw({id:`board-${e.id}`,label:`Open the Kanban board`,action:{kind:`kanban`,repoId:e.id}},7),c=pS.y+pS.h/2;return(0,K.jsxs)(`group`,{ref:s,position:[0,0,pS.z],children:[(0,K.jsx)(Y,{size:[pS.w+.24,pS.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:[pS.w,pS.h]}),(0,K.jsx)(`meshBasicMaterial`,{map:o,toneMapped:!1})]}),(0,K.jsx)(Y,{size:[3.2,.05,.16],position:[3.5,pS.y-.12,.1],color:`#aab4c3`,outline:!0}),[`#e63946`,`#1d3557`,`#2a9d8f`].map((e,t)=>(0,K.jsx)(IE,{r:.018,h:.16,position:[2.6+t*.22,pS.y-.075,.12],rotation:[0,0,Math.PI/2],color:e},e))]})}var FD=3,ID=90,LD=2.4,RD=3.2,zD=[`#ff5d8f`,`#ffd23f`,`#3bceac`,`#3a86ff`,`#ff8c42`,`#9b5de5`],BD=null;typeof window<`u`&&!Object.getOwnPropertyDescriptor(window,`__swarmConfetti`)&&Object.defineProperty(window,"__swarmConfetti",{value:{active:()=>BD?.active()??0,burst:e=>BD?.burst(e)},enumerable:!1});var VD=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;function HD({repo:e,agents:t}){let n=(0,v.useRef)(null),r=(0,v.useRef)(t);r.current=t;let i=(0,v.useMemo)(()=>({slots:Array.from({length:FD},()=>({key:null,age:0})),pos:new Float32Array(810),vel:new Float32Array(810),rot:new Float32Array(810),spin:new Float32Array(810),phase:new Float32Array(270),dummy:new zr,colors:[...zD,e.color].map(e=>new H(e)),geometry:new tl(.1,.06),material:new Na({side:2,toneMapped:!1})}),[e.color]);return(0,v.useEffect)(()=>()=>{i.geometry.dispose(),i.material.dispose()},[i]),(0,v.useLayoutEffect)(()=>{let e=n.current;if(e){i.dummy.scale.setScalar(0),i.dummy.updateMatrix();for(let t=0;t<270;t++)e.setMatrixAt(t,i.dummy.matrix),e.setColorAt(t,i.colors[t%i.colors.length]);e.instanceMatrix.needsUpdate=!0,e.instanceColor.needsUpdate=!0,e.visible=!1}},[i]),(0,v.useEffect)(()=>{let t=()=>i.slots.filter(e=>e.key).length,a=e=>{let t=e===`gong`,a=n.current;if(!a||!ix({hidden:document.hidden,covered:Px(J.getState().overlay),reducedMotion:VD()}))return;let o=e?r.current.find(t=>t.id===e&&t.role===`dev`):void 0,s=o?.id??(t?`gong`:`board`);if(i.slots.some(e=>e.key===s))return;let c=i.slots.findIndex(e=>!e.key);if(c<0)return;let l=o?{...fS(o.desk),y:1.5}:t?{x:_S.x,z:_S.z+.3,y:_S.h+.1}:{x:0,z:pS.z+1.2,y:pS.y+pS.h*.6};i.slots[c]={key:s,age:0};for(let e=0;e<ID;e++){let n=c*ID+e,r=Math.random()*Math.PI*2,o=.6+Math.random()*1.6;i.pos.set([l.x+(Math.random()-.5)*.3,l.y,l.z+(Math.random()-.5)*.3],n*3),i.vel.set([Math.cos(r)*o,2.6+Math.random()*2.2,t?Math.abs(Math.sin(r))*o+.2:Math.sin(r)*o],n*3),i.rot.set([Math.random()*6,Math.random()*6,Math.random()*6],n*3),i.spin.set([(Math.random()-.5)*14,(Math.random()-.5)*10,(Math.random()-.5)*14],n*3),i.phase[n]=Math.random()*Math.PI*2,a.setColorAt(n,i.colors[Math.floor(Math.random()*i.colors.length)])}a.instanceColor.needsUpdate=!0,a.visible=!0},o=J.subscribe(e=>{let t=n.current;if(t?.visible&&Px(e.overlay)){i.dummy.scale.setScalar(0),i.dummy.updateMatrix();for(let e=0;e<270;e++)t.setMatrixAt(e,i.dummy.matrix);t.instanceMatrix.needsUpdate=!0;for(let e of i.slots)e.key=null;t.visible=!1}}),s=ux(t=>{t.repoId===e.id&&a(t.agentId)}),c=Cx(t=>{t===e.id&&a(`gong`)});return BD={active:t,burst:a},()=>{s(),c(),o(),BD?.burst===a&&(BD=null)}},[i,e.id]),G_((e,t)=>{let r=n.current;if(!r||!r.visible)return;let a=Math.min(t,.05),{slots:o,pos:s,vel:c,rot:l,spin:u,phase:d,dummy:f}=i,p=0;for(let e=0;e<FD;e++){let t=o[e];if(!t.key)continue;t.age+=a;let n=t.age>=LD,i=n?0:Math.min(1,(LD-t.age)/(LD*.4));for(let o=0;o<ID;o++){let p=e*ID+o,m=p*3;if(!n){let e=Math.exp(-1.6*a);c[m]*=e,c[m+2]*=e,c[m+1]=Math.max(c[m+1]*e-RD*a,-.9);let n=Math.sin(t.age*7+d[p])*.5;s[m]+=(c[m]+n)*a,s[m+1]+=c[m+1]*a,s[m+2]+=(c[m+2]+n*.6)*a,l[m]+=u[m]*a,l[m+1]+=u[m+1]*a,l[m+2]+=u[m+2]*a}f.position.set(s[m],s[m+1],s[m+2]),f.rotation.set(l[m],l[m+1],l[m+2]),f.scale.setScalar(i),f.updateMatrix(),r.setMatrixAt(p,f.matrix)}n?t.key=null:p++}r.instanceMatrix.needsUpdate=!0,p||(r.visible=!1)}),(0,K.jsx)(`instancedMesh`,{ref:n,args:[i.geometry,i.material,270],frustumCulled:!1})}var UD=[{id:`blaster-orange`,body:`#ff8c1a`,trim:`#3a86ff`,foam:`#3a86ff`},{id:`blaster-blue`,body:`#3a86ff`,trim:`#ff8c1a`,foam:`#ff8c1a`}],WD=e=>UD.some(t=>t.id===e),GD={mag:12,gapMs:250,reloadMs:1e3};function KD(e,t){return e.reloadAt===null||t-e.reloadAt<GD.reloadMs?e:{ammo:GD.mag,reloadAt:null}}function qD(e,t){let n=KD(e,t);return n.reloadAt===null?null:Math.min(1,Math.max(0,(t-n.reloadAt)/GD.reloadMs))}function JD(e,t,n){let r=KD(e,n);return r.reloadAt!==null||r.ammo<=0||n-t<GD.gapMs?null:{ammo:r.ammo-1,reloadAt:null}}function YD(e,t){let n=KD(e,t);return n.reloadAt!==null||n.ammo>=GD.mag?null:{ammo:n.ammo,reloadAt:t}}function XD(e,t){return`Darts ${KD(e,t).ammo}/${GD.mag}`}var ZD={maxAngle:28*Math.PI/180,minSpeed:6};function QD(e,t){let n=Math.hypot(e.x,e.y,e.z);return n<ZD.minSpeed?!1:-(e.x*t.x+e.y*t.y+e.z*t.z)/n>=Math.cos(ZD.maxAngle)}function $D(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 eO=.2,tO=null;function nO(e){tO=e}var rO=()=>tO?.count()??0,iO=()=>tO?.stuck()??0,aO=()=>(tO?.loose()??[]).filter(e=>e.y<eO),oO=e=>tO?.remove(e)??!1,sO={maxSips:3,cap:8},cO=`mug-dispenser`,lO=e=>e===`mug-dispenser`||e.startsWith(`mug-`);function uO(e){return typeof e!=`number`||!Number.isFinite(e)?0:Math.min(sO.maxSips,Math.max(0,Math.round(e)))}var dO=e=>uO(e)/sO.maxSips;function fO(e){let t=uO(e);return t===0?0:sO.maxSips===1?1:.3+.7*(t-1)/(sO.maxSips-1)}var pO=(e,t=sO.cap,n=1)=>$D(e,t,n),mO=1;function hO(e=0){let t={kind:`mug`,id:`mug-${mO++}`,sips:uO(e)};return J.getState().setHeld(t),t}function gO(e){let t=wO?.take(e);return t!=null&&(J.getState().setHeld({kind:`mug`,id:e,sips:uO(t)}),!0)}function _O(e){e===`mug-dispenser`?hO():gO(e)}function vO(){let e=J.getState();e.held?.kind===`mug`&&e.setHeld(null)}function yO(){let e=J.getState();if(e.held?.kind!==`mug`)return null;let t=e.held;xO=!0;try{e.setHeld(null)}finally{xO=!1}return t}var bO=[],xO=!1;J.subscribe((e,t)=>{let n=t.held;xO||n?.kind!==`mug`||e.held?.kind===`mug`&&e.held.id===n.id||bO.push({id:n.id,sips:n.sips})});function SO(){return bO.shift()??null}function CO(){bO=[]}var wO=null;function TO(e){wO=e}var EO=()=>wO?.loose()??[],DO=`#1f1d2b`,OO=`#6f4518`,kO={r:.055,rBase:.05,h:.12},AO=[`#f8f9fa`,`#ef476f`,`#118ab2`,`#ffd166`,`#06d6a0`];function jO(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)>>>0;return AO[t%AO.length]}var MO=new Map;function NO(e){let t=MO.get(e);return t||(t=QC(e).clone(),t.side=2,MO.set(e,t)),t}function PO({color:e,sips:t,shadow:n=!0,steam:r=t>0}){let{r:i,rBase:a,h:o}=kO,s=dO(t),c=-o/2+.008,l=c+.004+s*(o-.026),u=a+(i-a)*((l+o/2)/o)-.003;return(0,K.jsxs)(`group`,{children:[(0,K.jsxs)(`mesh`,{castShadow:n,receiveShadow:!0,material:NO(e),children:[(0,K.jsx)(`cylinderGeometry`,{args:[i,a,o,20,1,!0]}),(0,K.jsx)(jy,{thickness:.006,color:DO})]}),(0,K.jsx)(`mesh`,{position:[0,c,0],rotation:[-Math.PI/2,0,0],material:QC(nw(e,-.18)),children:(0,K.jsx)(`circleGeometry`,{args:[a-.002,20]})}),(0,K.jsx)(`mesh`,{position:[0,-o/2+.002,0],rotation:[Math.PI/2,0,0],material:QC(e),children:(0,K.jsx)(`circleGeometry`,{args:[a,20]})}),s>0&&(0,K.jsx)(`mesh`,{position:[0,l,0],rotation:[-Math.PI/2,0,0],material:QC(OO),children:(0,K.jsx)(`circleGeometry`,{args:[u,20]})}),(0,K.jsxs)(`mesh`,{position:[i-.003,.004,0],rotation:[0,0,-Math.PI/2],castShadow:n,material:QC(e),children:[(0,K.jsx)(`torusGeometry`,{args:[.032,.01,6,14,Math.PI]}),(0,K.jsx)(jy,{thickness:.006,color:DO})]}),r&&s>0&&(0,K.jsx)(IO,{y:o/2,sips:t})]})}var FO=[0,1,2];function IO({y:e,sips:t}){let n=(0,v.useRef)(null),r=fO(t);return G_(()=>{let e=n.current;if(!e)return;let t=performance.now()/1e3;for(let n=0;n<e.children.length;n++){let i=e.children[n],a=(t*.45+n/3)%1;i.position.set(Math.sin(t*1.3+n*2.1)*.012,a*.14*(.5+.5*r),0),i.scale.setScalar((.6+a*1.2)*(.6+.4*r)),i.material.opacity=.45*(1-a)*r}}),(0,K.jsx)(`group`,{ref:n,position:[0,e,0],children:FO.map(e=>(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`sphereGeometry`,{args:[.016,8,6]}),(0,K.jsx)(`meshBasicMaterial`,{color:`#ffffff`,transparent:!0,opacity:.4,depthWrite:!1})]},e))})}var LO=[0,1,2];function RO({position:e}){let t=Zw({id:`toy:${cO}`,label:`Take a mug`,action:{kind:`pickup`,toyId:cO}},2.8),{h:n}=kO;return(0,K.jsxs)(`group`,{ref:t,position:e,children:[(0,K.jsx)(IE,{r:.1,h:.03,position:[0,.015,0],color:`#adb5bd`,outline:!0}),(0,K.jsx)(IE,{r:.012,h:.42,position:[0,.24,0],color:`#6c757d`}),LO.map(e=>(0,K.jsx)(`group`,{position:[0,.03+n/2+e*(n+.002),0],rotation:[Math.PI,e*2.4%(Math.PI*2),0],children:(0,K.jsx)(PO,{color:AO[e+1],sips:0})},e)),(0,K.jsx)(Y,{size:[.04,.05,.05],position:[0,.47,0],color:`#6c757d`,shadow:!1})]})}var zO={ms:4500,grind:.22,pourEnd:.92},BO={kind:`empty`},VO=(e,t)=>e.kind===`empty`&&t<3;function HO(e,t){return VO(e,t.sips)?{kind:`mugPlaced`,mug:{id:t.id,sips:Math.max(0,t.sips)}}:e}function UO(e,t){return e.kind===`empty`?{state:e,result:`noMug`}:e.kind===`brewing`?{state:e,result:`busy`}:e.kind===`ready`?{state:e,result:`full`}:{state:{kind:`brewing`,mug:e.mug,start:t},result:`started`}}function WO(e,t){return e.kind===`ready`?1:e.kind===`brewing`?Math.min(1,Math.max(0,(t-e.start)/zO.ms)):0}var GO=e=>Math.min(1,Math.max(0,(e-zO.grind)/(zO.pourEnd-zO.grind))),KO=e=>e>zO.grind&&e<zO.pourEnd;function qO(e,t){return e.kind===`empty`?0:e.kind===`ready`?3:e.kind===`mugPlaced`?e.mug.sips:e.mug.sips+(3-e.mug.sips)*GO(WO(e,t))}function JO(e,t){return e.kind===`brewing`&&t-e.start>=zO.ms?{kind:`ready`,mug:e.mug}:e}function YO(e,t){if(e.kind===`empty`)return null;let n=Math.min(3,Math.max(0,Math.round(qO(JO(e,t),t))));return{state:BO,mug:{id:e.mug.id,sips:n}}}var XO=[{at:0,name:`grind`},{at:zO.grind,name:`hiss`},{at:.4,name:`gurgle`},{at:.58,name:`gurgle`},{at:.76,name:`gurgle`}];function ZO(e,t){let n=e;for(;n<XO.length&&XO[n].at<=t;)n++;return n}var QO=BO,$O=0,ek=0,tk=new Set;function nk(e){if(e!==QO){QO=e;for(let e of tk)e()}}var rk={x:0,y:0,z:0},ik={group:`toys`,pos:rk},ak={button:()=>q({...ik,name:`coffee-button`,freq:1800,to:1200,type:`square`,dur:.05,peak:.04}),nope:()=>{q({...ik,name:`coffee-nope`,freq:240,to:170,type:`square`,dur:.12,peak:.05}),q({...ik,name:`coffee-nope`,freq:200,to:140,type:`square`,at:.14,dur:.14,peak:.05})},clink:()=>q({...ik,name:`coffee-mug`,freq:2400,type:`triangle`,dur:.08,peak:.04,attack:.003}),grind:()=>{jb({...ik,name:`coffee-grind`,dur:1,peak:.05,filter:`bandpass`,freq:2400,to:1500,q:2.5,attack:.04}),q({...ik,name:`coffee-grind`,freq:118,to:96,type:`sawtooth`,dur:1,peak:.025,attack:.04})},hiss:()=>jb({...ik,name:`coffee-hiss`,dur:1.1,peak:.03,filter:`highpass`,freq:3200,q:.7,attack:.15}),gurgle:()=>{for(let e=0;e<3;e++)q({...ik,name:`coffee-gurgle`,freq:210-e*25,to:95,type:`sine`,at:e*.13+Math.random()*.04,dur:.11,peak:.05});jb({...ik,name:`coffee-hiss`,dur:.7,peak:.02,filter:`highpass`,freq:3e3,attack:.1})},done:()=>{q({...ik,name:`coffee-done`,freq:1318.5,type:`triangle`,dur:.12,peak:.07}),q({...ik,name:`coffee-done`,freq:1760,type:`triangle`,at:.14,dur:.2,peak:.07})}};function ok(e){let t=J.getState(),n=performance.now();if(nk(JO(QO,n)),e===`place`){let e=t.held;if(e?.kind!==`mug`||!VO(QO,e.sips))return;let n=yO();if(!n)return;nk(HO(QO,{id:n.id,sips:n.sips})),ak.clink()}else if(e===`brew`){let e=UO(QO,n);if(e.result===`busy`)return;if(e.result!==`started`){ak.nope(),t.pushToast(`info`,e.result===`noMug`?`☕ Put a mug under the machine first`:`☕ Your coffee is ready: take the mug`);return}nk(e.state),ek=0,$O++,ak.button()}else{let e=YO(QO,n);if(!e)return;nk(e.state),t.setHeld({kind:`mug`,id:e.mug.id,sips:e.mug.sips}),ak.clink()}}typeof window<`u`&&!Object.getOwnPropertyDescriptor(window,`__swarmCoffee`)&&(Object.defineProperty(window,"__swarmCoffee",{get:()=>{let e=performance.now(),t=JO(QO,e),n=qO(t,e);return{state:t.kind,mug:t.kind===`empty`?null:{id:t.mug.id,sips:Math.round(n)},progress:WO(t,e),level:n,brews:$O}},enumerable:!1,configurable:!1}),Object.defineProperty(window,"__swarmCoffeeDo",{value:e=>ok(e),enumerable:!1,configurable:!1}));var sk=`#6f4518`,ck={x:-.25,tray:.02},lk=.21,uk=[0,1,2,3],dk=[0,-Math.PI/2,0],fk=QC(`#ced4da`),pk=ew(`#ffb703`),mk=ew(`#80ed99`);function hk({position:e}){let[t,n]=(0,v.useState)(QO),r=J(e=>e.held?.kind===`mug`?e.held.sips:null),i=(0,v.useRef)(null),a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)(!1);(0,v.useEffect)(()=>{QO=BO,$O=0,ek=0,n(QO);let e=()=>n(QO);return tk.add(e),()=>{tk.delete(e),QO=BO}},[]);let u=Zw(t.kind===`empty`?r!==null&&VO(t,r)?{id:`coffee:slot`,label:`Put mug under the machine`,action:{kind:`coffee`,op:`place`}}:null:{id:`coffee:slot`,label:t.kind===`ready`?`Take coffee`:`Take mug`,action:{kind:`coffee`,op:`take`}},2.8),d=Zw({id:`coffee:button`,label:`Brew coffee`,action:{kind:`coffee`,op:`brew`}},2.8);return G_(()=>{let e=i.current;if(!e)return;let t=performance.now();if(!l.current){l.current=!0,e.updateWorldMatrix(!0,!1);let t=e.matrixWorld.elements;rk.x=t[12]+ck.x,rk.y=t[13]+lk,rk.z=t[14]}if(QO.kind===`brewing`){let e=QO.start+zO.ms,n=JO(QO,t);nk(n),n.kind===`ready`&&t-e<1500&&ak.done()}let n=QO.kind===`brewing`,r=WO(QO,t);if(n){let e=ZO(ek,r);for(;ek<e;ek++)r-XO[ek].at<.3&&ak[XO[ek].name]()}let u=t/1e3;if(a.current){let e=n?r<zO.grind?.003:.0012:0;a.current.position.set(Math.sin(u*97)*e,Math.abs(Math.sin(u*61))*e*.5,Math.cos(u*83)*e)}let d=qO(QO,t),{r:f,rBase:p,h:m}=kO,h=ck.tray+.008+.004+d/3*(m-.026);if(c.current&&(c.current.visible=d>.02,c.current.position.y=h,c.current.scale.setScalar(p+(f-p)*((h-ck.tray)/m)-.003)),s.current){let e=n&&KO(r);if(s.current.visible=e,e){let e=lk-h;s.current.scale.y=e,s.current.position.y=h+e/2,s.current.scale.x=s.current.scale.z=1+Math.sin(u*40)*.25}}if(o.current&&(o.current.visible=n&&r>zO.grind,o.current.visible)){let e=o.current.children;for(let t=0;t<e.length;t++){let n=e[t],r=(u*.9+t/e.length)%1;n.position.set(Math.sin(u*2+t*1.7)*.02,r*.35,Math.cos(u*1.6+t)*.02),n.scale.setScalar(.6+r*1.4),n.material.opacity=.5*(1-r)}}}),(0,K.jsxs)(`group`,{ref:i,position:e,children:[(0,K.jsxs)(`group`,{ref:a,children:[(0,K.jsx)(Y,{size:[.45,.55,.4],position:[.05,.28,0],color:`#343a40`,outline:!0}),(0,K.jsx)(Y,{size:[.22,.1,.28],position:[ck.x+.01,.28,0],color:`#495057`,outline:!0}),(0,K.jsx)(IE,{r:.018,h:.03,position:[ck.x,.215,0],color:`#adb5bd`}),(0,K.jsx)(`mesh`,{position:[-.2,.39,.13],rotation:[0,-Math.PI/2,0],material:ew(`#ff6b6b`),children:(0,K.jsx)(`circleGeometry`,{args:[.02,12]})}),(0,K.jsxs)(`group`,{ref:d,position:[-.18,.42,-.06],children:[(0,K.jsx)(IE,{r:.045,h:.02,rotation:[0,0,Math.PI/2],color:`#212529`}),(0,K.jsx)(`mesh`,{position:[-.012,0,0],rotation:[0,0,Math.PI/2],material:t.kind===`brewing`?pk:t.kind===`ready`?mk:fk,children:(0,K.jsx)(`cylinderGeometry`,{args:[.032,.034,.018,18]})}),(0,K.jsx)(`mesh`,{visible:!1,children:(0,K.jsx)(`boxGeometry`,{args:[.08,.13,.13]})})]}),(0,K.jsx)(`group`,{ref:o,position:[.05,.56,-.08],visible:!1,children:uk.map(e=>(0,K.jsxs)(`mesh`,{children:[(0,K.jsx)(`sphereGeometry`,{args:[.035,8,6]}),(0,K.jsx)(`meshBasicMaterial`,{color:`#ffffff`,transparent:!0,opacity:.4,depthWrite:!1})]},e))})]}),(0,K.jsxs)(`group`,{ref:u,children:[(0,K.jsx)(Y,{size:[.2,ck.tray,.26],position:[ck.x,ck.tray/2,0],color:`#6c757d`,outline:!0}),t.kind!==`empty`&&(0,K.jsxs)(`group`,{position:[ck.x,ck.tray+kO.h/2,0],rotation:dk,children:[(0,K.jsx)(PO,{color:jO(t.mug.id),sips:0,steam:!1}),t.kind===`ready`&&(0,K.jsx)(IO,{y:kO.h/2,sips:sO.maxSips})]}),(0,K.jsx)(`mesh`,{visible:!1,position:[ck.x,.09,0],children:(0,K.jsx)(`boxGeometry`,{args:[.22,.18,.28]})})]}),(0,K.jsx)(`mesh`,{ref:c,position:[ck.x,ck.tray,0],rotation:[-Math.PI/2,0,0],visible:!1,material:QC(sk),children:(0,K.jsx)(`circleGeometry`,{args:[1,20]})}),(0,K.jsx)(`mesh`,{ref:s,position:[ck.x,.1,0],visible:!1,material:QC(sk),children:(0,K.jsx)(`cylinderGeometry`,{args:[.006,.006,1,6]})})]})}function gk({position:e,scale:t=1,pot:n=`#e07a5f`}){return(0,K.jsxs)(`group`,{position:e,scale:t,children:[(0,K.jsx)(IE,{r:.22,rTop:.28,h:.5,position:[0,.25,0],color:n,outline:!0}),(0,K.jsx)(LE,{r:.36,position:[0,.8,0],color:`#52b788`,outline:!0}),(0,K.jsx)(LE,{r:.28,position:[.2,1.05,.08],color:`#40916c`,outline:!0}),(0,K.jsx)(LE,{r:.25,position:[-.18,1.12,-.05],color:`#74c69d`,outline:!0}),(0,K.jsx)(LE,{r:.2,position:[.02,1.35,0],color:`#52b788`,outline:!0})]})}function _k({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(Y,{size:[.45,1,.45],position:[0,.5,0],color:`#f1f3f5`,outline:!0}),(0,K.jsx)(IE,{r:.18,h:.5,position:[0,1.25,0],color:`#8ecae6`,outline:!0}),(0,K.jsx)(Y,{size:[.08,.06,.06],position:[0,.8,-.24],color:`#457b9d`})]})}function vk({position:e,rotationY:t=0,color:n=`#6c63ff`}){let r=nw(n,-.12);return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(Y,{size:[3,.42,1],position:[0,.25,0],color:n,outline:!0}),(0,K.jsx)(Y,{size:[3,.6,.25],position:[0,.7,.38],color:r,outline:!0}),(0,K.jsx)(Y,{size:[.25,.55,1],position:[-1.5,.45,0],color:r,outline:!0}),(0,K.jsx)(Y,{size:[.25,.55,1],position:[1.5,.45,0],color:r,outline:!0}),(0,K.jsx)(Y,{size:[.5,.4,.14],position:[-.9,.62,.22],color:`#ffd166`,outline:!0}),(0,K.jsx)(Y,{size:[.5,.4,.14],position:[.9,.62,.22],color:`#ef476f`,outline:!0})]})}function yk({position:e,rotationY:t=0}){return(0,K.jsxs)(`group`,{position:e,rotation:[0,t,0],children:[(0,K.jsx)(Y,{size:[1.3,.08,.8],position:[0,.42,0],color:`#f1d19b`,outline:!0}),(0,K.jsx)(Y,{size:[1.1,.38,.6],position:[0,.2,0],color:`#c9a26b`}),(0,K.jsx)(IE,{r:.05,h:.1,position:[.3,.51,.1],color:`#ffffff`,outline:!0}),(0,K.jsx)(Y,{size:[.3,.04,.22],position:[-.25,.48,-.05],color:`#4cc9f0`,outline:!0})]})}function bk({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(Y,{size:[.8,.9,4],position:[0,.45,0],color:`#8ecae6`,outline:!0}),(0,K.jsx)(Y,{size:[.9,.06,4.1],position:[-.02,.93,0],color:`#f8f9fa`,outline:!0}),(0,K.jsx)(hk,{position:[0,.96,-1.1]}),(0,K.jsx)(RO,{position:[0,.96,-.45]}),(0,K.jsx)(IE,{r:.2,rTop:.24,h:.1,position:[0,1.01,.6],color:`#f4a261`,outline:!0}),(0,K.jsx)(LE,{r:.07,position:[.05,1.1,.55],color:`#e63946`}),(0,K.jsx)(LE,{r:.07,position:[-.06,1.1,.66],color:`#ffd166`}),(0,K.jsx)(LE,{r:.07,position:[.07,1.1,.7],color:`#80ed99`}),(0,K.jsx)(IE,{r:.1,rTop:.07,h:.25,position:[0,1.08,1.4],color:`#ced4da`,outline:!0}),(0,K.jsx)(Y,{size:[.8,2,.8],position:[0,1,2.45],color:`#f1f3f5`,outline:!0}),(0,K.jsx)(Y,{size:[.04,.5,.05],position:[-.42,1.3,2.2],color:`#adb5bd`})]})}function xk({position:e,size:t,color:n}){return(0,K.jsx)(`mesh`,{position:e,rotation:[-Math.PI/2,0,0],receiveShadow:!0,material:QC(n),children:(0,K.jsx)(`planeGeometry`,{args:t})})}function Sk({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)(IE,{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:QC(`#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:QC(`#e63946`),children:(0,K.jsx)(`boxGeometry`,{args:[.025,.28,.01]})})})]})}function Ck({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)(Y,{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)(Y,{size:[4.6,.04,.55],position:[0,e-.25,.04],color:`#9c6644`,shadow:!1}),Array.from({length:14},(r,i)=>(0,K.jsx)(Y,{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 wk({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:tw,children:(0,K.jsx)(`boxGeometry`,{args:[a,n,.04]})}),(0,K.jsx)(Y,{size:[a,.08,.1],position:[0,n,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(Y,{size:[a,.08,.1],position:[0,.04,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(Y,{size:[.08,n,.1],position:[-a/2,n/2,0],color:`#8d99ae`,shadow:!1}),(0,K.jsx)(Y,{size:[.08,n,.1],position:[a/2,n/2,0],color:`#8d99ae`,shadow:!1})]})}var Tk=`#fbf3e4`;function Ek({position:e,rotationY:t,width:n,seed:r}){let i=Qw(512,256,e=>Gw(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)(Y,{size:[n+.16,.1,.1],position:[0,a/2,.04],color:`#ffffff`,outline:!0,shadow:!1}),(0,K.jsx)(Y,{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)(Y,{size:[.08,a,.1],position:[e,0,.04],color:`#ffffff`,shadow:!1},e))]})}function Dk({position:e}){return(0,K.jsxs)(`group`,{position:e,children:[(0,K.jsx)(Y,{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:ew(`#fffbe8`),children:(0,K.jsx)(`planeGeometry`,{args:[1.25,.38]})})]})}function Ok({accent:e,floorColor:t,westWindows:n=[-8,0,8],eastWindows:r=[-8,0],seed:i=1}){let a=QC(Tk),o=.3,{doorHalf:s,doorHeight:c}=tS,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,Qx-.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=nw(t,a),n.fillRect(i,e*64,256,64),n.fillStyle=nw(t,-.1),n.fillRect(i,e*64,3,64),n.fillStyle=nw(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=nw(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,Qx,0],material:QC(`#f3efe6`),children:(0,K.jsx)(`planeGeometry`,{args:[32,24]})}),l.map(e=>(0,K.jsx)(Dk,{position:e},e.join())),(0,K.jsx)(`mesh`,{position:[0,Qx/2,-12-o/2],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[32.6,Qx,o]})}),(0,K.jsx)(`mesh`,{position:[-16-o/2,Qx/2,0],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,Qx,24]})}),(0,K.jsx)(`mesh`,{position:[16.15,Qx/2,0],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[o,Qx,24]})}),[-1,1].map(e=>(0,K.jsx)(`mesh`,{position:[e*(s+d/2),Qx/2,12.15],material:a,receiveShadow:!0,children:(0,K.jsx)(`boxGeometry`,{args:[d,Qx,o]})},e)),(0,K.jsx)(`mesh`,{position:[0,(Qx+c)/2,12.15],material:a,children:(0,K.jsx)(`boxGeometry`,{args:[s*2,Qx-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:QC(nw(e,-.2)),children:(0,K.jsx)(`boxGeometry`,{args:[r,.12,.04]})}),(0,K.jsx)(`mesh`,{position:[0,.95,0],material:QC(e),children:(0,K.jsx)(`boxGeometry`,{args:[r,.12,.03]})})]},i)),n.map((e,t)=>(0,K.jsx)(Ek,{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)(Ek,{position:[15.98,1.95,e],rotationY:-Math.PI/2,width:5.5,seed:i*5+t+7},`e${e}`))]})}function kk(){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})]})}function Ak(e,t){return e?.kind!==`mug`||t===`coffee`?`target`:(e.sips??0)>0?`sip`:t?`target`:`empty`}var jk={dur:.7,up:.22,down:.45,tilt:1.1,head:0,cues:[{at:.18,cue:`slurp`},{at:.32,cue:`drink`},{at:.46,cue:`mm`}]},Mk={dur:1.75,up:.3,down:1.15,tilt:2.3,head:.16,cues:[{at:.3,cue:`gulp`},{at:.95,cue:`drink`},{at:1.2,cue:`ahh`},{at:1.6,cue:`drop`}]};function Nk(e){return e>0?e<=1?Mk:jk:null}function Pk(e,t,n){let r=t;for(;r<e.cues.length&&e.cues[r].at<=n;)r++;return r}var Fk=e=>{let t=Math.min(1,Math.max(0,e));return t*t*(3-2*t)};function Ik(e,t){return t<=0||t>=e.dur?0:t<e.up?Fk(t/e.up):t<e.down?1:1-Fk((t-e.down)/(e.dur-e.down))}function Lk(e,t,n={lift:0,tilt:0,head:0}){let r=Ik(e,t);return n.lift=r,n.tilt=r*e.tilt,n.head=r*e.head,n}var Rk={min:.6,max:4.5,peak:.14,cooldown:160},zk=(e,t,n)=>n>0?e*t/n:0;function Bk(e,t){if(!(e>=Rk.min)||t<Rk.cooldown)return 0;let n=Math.min(1,(e-Rk.min)/(Rk.max-Rk.min));return Rk.peak*(.25+.75*n)}var Vk=null,Hk={lift:0,tilt:0,head:0},Uk={group:`toys`},Wk={slurp:()=>{jb({...Uk,name:`mug-sip`,dur:.2,peak:.05,filter:`bandpass`,freq:900,to:2600,q:3,attack:.03}),q({...Uk,name:`mug-sip`,freq:320,to:540,type:`triangle`,dur:.16,peak:.02,attack:.02})},mm:()=>{q({...Uk,name:`mug-mm`,freq:196,to:175,dur:.34,peak:.07,attack:.04}),q({...Uk,name:`mug-mm`,freq:392,to:350,type:`triangle`,dur:.3,peak:.012,attack:.04})},gulp:()=>{for(let e=0;e<3;e++)q({...Uk,name:`mug-gulp`,freq:280-e*30,to:110,at:e*.24,dur:.15,peak:.09,attack:.01});jb({...Uk,name:`mug-gulp`,dur:.7,peak:.025,filter:`lowpass`,freq:500,attack:.08})},ahh:()=>{jb({...Uk,name:`mug-ahh`,dur:.65,peak:.07,filter:`bandpass`,freq:1200,to:700,q:1.3,attack:.05}),q({...Uk,name:`mug-ahh`,freq:230,to:165,type:`triangle`,dur:.6,peak:.035,attack:.06})},drink:()=>void 0,drop:()=>void 0};function Gk(e,t){q({...Uk,pos:e,name:`mug-clunk`,freq:1150,to:880,type:`triangle`,dur:.08,peak:t*.6,attack:.002}),q({...Uk,pos:e,name:`mug-clunk`,freq:2350,dur:.12,peak:t*.2,attack:.002}),jb({...Uk,pos:e,name:`mug-clunk`,dur:.05,peak:t*.8,filter:`lowpass`,freq:650,attack:.002})}function Kk(e=performance.now()){let t=J.getState().held;if(Vk||t?.kind!==`mug`)return!1;let n=Nk(t.sips);return n?(Vk={plan:n,mugId:t.id,start:e,next:0},!0):!1}var qk=()=>Vk!==null;function Jk(e=performance.now()){if(!Vk)return;let t=J.getState();if(t.held?.kind!==`mug`||t.held.id!==Vk.mugId)return Yk();let{plan:n}=Vk,r=(e-Vk.start)/1e3,i=Pk(n,Vk.next,r);for(let e=Vk.next;e<i;e++){let r=n.cues[e].cue;Wk[r]();let i=J.getState().held;if(i?.kind!==`mug`)break;if(r===`drink`&&t.setHeld({...i,sips:Math.max(0,i.sips-1)}),r===`drop`){Yk(),vO();return}}Vk.next=i,Lk(n,r,Hk),r>=n.dur&&Yk()}function Yk(){Vk=null,Hk.lift=0,Hk.tilt=0,Hk.head=0}var Xk={reach:.1,animMs:350},Zk=e=>e!==`charging`,Qk=(e,t,n,r)=>Math.hypot(n.x-e,n.z-t)<=r;function $k(e,t,n,r,i){return Zk(e)?r.filter(e=>Qk(t,n,e,i+Xk.reach)):[]}var eA=0,tA=(e=1)=>void(eA+=e),nA=()=>eA,rA=null,iA=null,aA=null;function oA(e){rA=e}function sA(e){iA=e}function cA(e){aA=e}function lA(){try{return EO()}catch{return[]}}function uA(){let{held:e,chargeAt:t}=J.getState(),n=null;try{n=aA?aA():null}catch{}let r={held:e,charging:t!==null,hoop:iA?iA():null,roomba:n,darts:rO(),dartsStuck:iO(),reactions:bT(),vacuumed:nA(),mugs:lA(),sipping:qk()};try{if(rA)return{...rA(),...r}}catch{}return{balls:[],bodies:0,...r}}typeof window<`u`&&!Object.getOwnPropertyDescriptor(window,`__swarmToys`)&&(Object.defineProperty(window,"__swarmToys",{get:uA,enumerable:!1,configurable:!1}),Object.defineProperty(window,"__swarmGiveMug",{value:(e=0)=>hO(e),enumerable:!1,configurable:!1}));var dA=!1;function fA(e){dA||(dA=!0,console.warn(`Office toys are switched off: the physics engine failed to load.`,e))}var pA=()=>null,mA=(0,v.lazy)(async()=>{try{let[e,t]=await Promise.all([Fy(()=>import(`./ToyWorld-CCa77hRS.js`),__vite__mapDeps([0,1])),Fy(()=>import(`./rapier--PAOxOZs.js`).then(e=>e.o),[])]);return await t.init(),e}catch(e){return fA(e),{default:pA}}}),hA=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}},gA=(0,v.memo)(function({floor:e}){return dA?null:(0,K.jsx)(hA,{children:(0,K.jsx)(v.Suspense,{fallback:null,children:(0,K.jsx)(mA,{floor:e})})})});function _A({position:e,size:t,px:n,draw:r,deps:i,rotationY:a=Math.PI}){let o=Qw(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 vA({repo:e}){let t=J(e=>e.agents),n=(0,v.useMemo)(()=>Nx(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=J(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=nw(e.color,.24);return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(Ok,{accent:e.color,floorColor:`#d9b48a`,seed:e.floor}),dS.map(e=>(0,K.jsx)(xk,{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:lS},(t,n)=>{let{x:i,z:a}=fS(n);return(0,K.jsx)(ZE,{agent:r.get(n)??null,accent:e.color,repoId:e.id,position:[i,0,a]},n)}),(0,K.jsx)(xk,{position:[(SS.minX+SS.maxX)/2,.005,(SS.minZ+SS.maxZ)/2],size:[SS.maxX-SS.minX,SS.maxZ-SS.minZ],color:`#ffd8bf`}),yS.stations.map((t,n)=>{let{x:r,z:a}=xS(n);return(0,K.jsx)(ZE,{role:`qa`,rotationY:bS,agent:i.get(n)??null,accent:e.color,repoId:e.id,position:[r,0,a]},`qa${n}`)}),(0,K.jsx)(_A,{position:[15.97,3.2,-2],rotationY:-Math.PI/2,size:[3.2,.55],px:[768,132],draw:e=>Ww(e,768,132,[{text:`🔍 QA LAB · ${s} in testing`,size:56}],`#ff9f68`),deps:[s]}),(0,K.jsx)(PD,{repo:e,agents:n}),(0,K.jsx)(aD,{repo:e,agents:n}),(0,K.jsx)(HD,{repo:e,agents:n}),(0,K.jsx)(ND,{repoId:e.id}),(0,K.jsx)($E,{floorLabel:`▲ ${e.floor} · ${l}`,accent:e.color}),(0,K.jsx)(gA,{floor:`office`}),(0,K.jsx)(_A,{position:[-4.6,1.95,11.97],size:[4.2,1.3],px:[1024,317],draw:t=>Ww(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)(_A,{position:[4.6,1.95,11.97],size:[4.2,1.3],px:[1024,317],draw:t=>Ww(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)(gk,{position:[-7.1,0,-11.3]}),(0,K.jsx)(gk,{position:[7.1,0,-11.3]}),(0,K.jsx)(gk,{position:[-15.3,0,11.2],scale:1.2}),(0,K.jsx)(gk,{position:[-11,0,-11.3],scale:1.1}),(0,K.jsx)(gk,{position:[15.3,0,11.3],scale:.9,pot:`#8338ec`}),(0,K.jsx)(vk,{position:[-15.1,0,6.5],rotationY:-Math.PI/2,color:nw(e.color,-.05)}),(0,K.jsx)(yk,{position:[-13.4,0,6.5],rotationY:Math.PI/2}),(0,K.jsx)(bk,{position:[15.55,0,7]}),(0,K.jsx)(_k,{position:[15.5,0,-9.5]}),(0,K.jsx)(Sk,{position:[-10,2.75,-11.95]}),(0,K.jsx)(_A,{position:[10,2.2,-11.97],rotationY:0,size:[2.2,1.4],px:[512,326],draw:e=>Ww(e,512,326,[{text:`🚀`,size:90},{text:`SHIP IT`,size:64},{text:`small PRs, happy reviewers`,size:26,weight:500}],`#3a86ff`),deps:[]})]})}var yA=`#ff8a5b`,bA=`#9b5de5`;function xA(){let e=J(e=>e.repos),t=J(e=>e.agents),n=J(e=>e.settings),r=J(e=>e.qa),i=J(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=Lx(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 SA(){let e=xA(),t=Zw({id:`manager-console`,label:`Open the manager's console`,action:{kind:`manager`}},3.2),n=Qw(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 ${Dw}`,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;Ow(t,50,i-30,924,60,16),t.fillStyle=`rgba(255,255,255,0.07)`,t.fill(),t.fillStyle=`#c9c9ee`,t.font=`500 34px ${Dw}`,t.fillText(e,76,i),t.fillStyle=`#ffffff`,t.font=`700 38px ${Dw}`,t.textAlign=`right`,t.fillText(n,948,i),t.textAlign=`left`}),t.fillStyle=`#7CFFB2`,t.font=`600 32px ${Dw}`,t.fillText(`Press E or click to manage floors, team & issues`,50,592)},[e]);return(0,K.jsxs)(`group`,{ref:t,position:[TS.x,0,TS.z],children:[(0,K.jsx)(Y,{size:[TS.w,.08,TS.d],position:[0,.76,0],color:`#8d5a3b`,outline:!0}),(0,K.jsx)(Y,{size:[TS.w-.1,.72,.06],position:[0,.37,-TS.d/2+.05],color:`#6f4530`}),(0,K.jsx)(Y,{size:[.08,.72,TS.d-.1],position:[-TS.w/2+.08,.37,0],color:`#6f4530`}),(0,K.jsx)(Y,{size:[.08,.72,TS.d-.1],position:[TS.w/2-.08,.37,0],color:`#6f4530`}),(0,K.jsx)(Y,{size:[.1,.34,.1],position:[0,.97,-.15],color:`#adb5bd`}),(0,K.jsx)(Y,{size:[.4,.03,.26],position:[0,.815,-.15],color:`#adb5bd`,outline:!0}),(0,K.jsx)(Y,{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)(Y,{size:[.5,.025,.16],position:[0,.815,.25],color:`#f4f4f8`,outline:!0}),(0,K.jsx)(IE,{r:.05,h:.11,position:[.9,.855,.1],color:`#ffd166`,outline:!0}),(0,K.jsx)(Y,{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)(Y,{size:[.64,.12,.6],position:[0,.48,0],color:`#2b2d42`,outline:!0}),(0,K.jsx)(Y,{size:[.62,.8,.12],position:[0,.95,-.3],color:`#2b2d42`,outline:!0}),(0,K.jsx)(IE,{r:.04,h:.4,position:[0,.22,0],color:`#6c757d`}),(0,K.jsx)(IE,{r:.3,h:.04,position:[0,.03,0],color:`#6c757d`})]})]})}function CA(){let e=xA(),t=Zw({id:`directory`,label:`Floor directory — take the elevator`,action:{kind:`elevator`}},4),n=Qw(768,560,t=>{Ow(t,0,0,768,560,30),t.fillStyle=`#23263a`,t.fill(),t.fillStyle=`#ffd6a5`,t.font=`700 46px ${Dw}`,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,Ow(t,36,r-22,54,44,12),t.fill(),t.fillStyle=`#1f2233`,t.font=`700 30px ${Dw}`,t.textAlign=`center`,t.fillText(String(e.floor),63,r+1),t.textAlign=`left`,t.fillStyle=`#ffffff`,t.font=`600 28px ${Dw}`;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 ${Dw}`,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=yA,Ow(t,36,r-22,54,44,12),t.fill(),t.fillStyle=`#1f2233`,t.font=`700 30px ${Dw}`,t.textAlign=`center`,t.fillText(`G`,63,r+1),t.textAlign=`left`,t.fillStyle=`#ffffff`,t.font=`600 28px ${Dw}`,t.fillText(`Lobby & manager's office`,108,r),e.floors.length===0&&(t.fillStyle=`#a9adc6`,t.font=`500 26px ${Dw}`,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 wA(){let e=xA(),t=Qw(512,160,t=>Ww(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)(Y,{size:[4.4,2.1,1],position:[0,1.05,0],color:`#b08968`,outline:!0}),(0,K.jsx)(Y,{size:[4.1,1.2,.8],position:[0,1.2,.12],color:`#fdf6e3`,shadow:!1}),(0,K.jsx)(Y,{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)(IE,{r:.08,rTop:.16,h:.22,position:[0,.2,0],color:`#ffd43b`,outline:!0}),(0,K.jsx)(IE,{r:.03,h:.1,position:[0,.05,0],color:`#ffd43b`}),(0,K.jsx)(Y,{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 TA(){let e=J(e=>e.agents.ceo),t=J(e=>e.ceo),n=Lx(J(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)(_A,{position:[15.97,2.05,OS.z],rotationY:-Math.PI/2,size:[3.4,1.9],px:[816,456],draw:t=>Ww(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 EA(){let e=DS,t=J(e=>e.agents.ceo);return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(xk,{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)(wk,{from:[e.minX,e.minZ],to:[e.minX,e.maxZ]}),(0,K.jsx)(wk,{from:[e.minX,e.maxZ],to:[e.doorMinX,e.maxZ]}),(0,K.jsx)(wk,{from:[e.doorMaxX,e.maxZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(Y,{size:[e.doorMaxX-e.doorMinX,.5,.1],position:[(e.doorMinX+e.doorMaxX)/2,2.55,e.maxZ],color:`#8d99ae`}),(0,K.jsx)(_A,{position:[(e.doorMinX+e.doorMaxX)/2,3.1,e.maxZ+.06],rotationY:0,size:[3.4,.5],px:[816,120],draw:e=>Ww(e,816,120,[{text:`CEO${t?` · ${t.name}`:``}`,size:52}],bA),deps:[t?.name]}),t&&(0,K.jsx)(ZE,{agent:t,accent:bA,repoId:``,position:[OS.x,0,OS.z]}),(0,K.jsx)(TA,{}),(0,K.jsx)(gk,{position:[e.maxX-.7,0,e.maxZ-.7],scale:1.1,pot:bA}),(0,K.jsx)(gk,{position:[e.minX+.6,0,e.maxZ-.6],scale:.9})]})}function DA(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 OA({req:e}){let t=J(t=>t.repos.find(t=>t.id===e.repoId)?.floor??null),n=Qw(512,128,n=>Uw(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 kA({z:e,req:t}){let n=Zw(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?DA(t):null,[t]),i=`#06d6a0`;return(0,K.jsxs)(`group`,{ref:n,position:[kS.x,0,e],rotation:[0,AS,0],children:[(0,K.jsx)(Y,{size:[.52,.08,.5],position:[0,.44,0],color:i,outline:!0}),(0,K.jsx)(Y,{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)(Y,{size:[.05,.42,.05],position:[e,.2,t],color:`#444a5c`},`${e}${t}`)),r&&(0,K.jsx)(PE,{agent:r}),t&&(0,K.jsx)(OA,{req:t})]})}function AA(){let e=J(e=>e.requests),t=(0,v.useMemo)(()=>Lx(e).filter(e=>e.kind===`hire`),[e]),n=t.length;return(0,K.jsxs)(`group`,{children:[kS.seats.map((e,n)=>(0,K.jsx)(kA,{z:e,req:t[n]??null},e)),(0,K.jsx)(_A,{position:[15.97,2.5,(kS.seats[0]+kS.seats[kS.seats.length-1])/2],rotationY:-Math.PI/2,size:[3.6,.62],px:[864,150],draw:e=>Ww(e,864,150,[{text:n?`🪑 Waiting room · ${n} candidate${n===1?``:`s`}${n>kS.seats.length?` (${n-kS.seats.length} more outside)`:``}`:`🪑 Waiting room`,size:50}],`#06a77d`),deps:[n]})]})}function jA(){let e=wS,t=J(e=>e.user),n=J(e=>e.settings.managerName),r=J(e=>e.settings.companyName),i=n||t;return(0,K.jsxs)(`group`,{children:[(0,K.jsx)(Ok,{accent:yA,floorColor:`#e2c7a3`,westWindows:[1.5,8],eastWindows:[-2.5,3.6],seed:0}),(0,K.jsx)(xk,{position:[(jS.minX+jS.maxX)/2,.004,(jS.minZ+jS.maxZ)/2],size:[jS.maxX-jS.minX,jS.maxZ-jS.minZ],color:`#ffd6a5`}),(0,K.jsx)(xk,{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)(wk,{from:[e.maxX,e.minZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(wk,{from:[e.minX,e.maxZ],to:[e.doorMinX,e.maxZ]}),(0,K.jsx)(wk,{from:[e.doorMaxX,e.maxZ],to:[e.maxX,e.maxZ]}),(0,K.jsx)(Y,{size:[e.doorMaxX-e.doorMinX,.5,.1],position:[(e.doorMinX+e.doorMaxX)/2,2.55,e.maxZ],color:`#8d99ae`}),(0,K.jsx)(_A,{position:[(e.doorMinX+e.doorMaxX)/2,3.1,e.maxZ+.06],rotationY:0,size:[3.4,.5],px:[816,120],draw:e=>Ww(e,816,120,[{text:`MANAGER${i?` · ${i}`:``}`,size:52}],`#2b2d42`),deps:[i]}),(0,K.jsx)(SA,{}),(0,K.jsx)(Ck,{position:[-15.6,0,-8],rotationY:Math.PI/2}),(0,K.jsx)(gk,{position:[e.maxX-.6,0,e.minZ+.6],scale:1.1,pot:`#3a86ff`}),(0,K.jsx)(gk,{position:[e.minX+.6,0,e.maxZ-.6],scale:.9}),(0,K.jsx)(_A,{position:[TS.x,2.3,-11.97],rotationY:0,size:[2.4,1.2],px:[512,256],draw:e=>Ww(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:[ES.x,0,ES.z],children:[(0,K.jsx)(Y,{size:[ES.w,1.05,ES.d],position:[0,.525,0],color:`#ffffff`,outline:!0}),(0,K.jsx)(Y,{size:[ES.w+.1,.08,ES.d+.1],position:[0,1.09,0],color:yA,outline:!0}),(0,K.jsx)(Y,{size:[ES.w-.4,.3,.02],position:[0,.6,ES.d/2+.01],color:nw(yA,.15),shadow:!1}),(0,K.jsxs)(`group`,{position:[0,1.13,-.1],children:[(0,K.jsx)(IE,{r:.2,rTop:.16,h:.4,position:[0,.2,0],color:`#e9ecef`,outline:!0}),(0,K.jsx)(LE,{r:.22,position:[0,.58,0],color:`#f8f9fa`,outline:!0}),(0,K.jsx)(`mesh`,{position:[-.08,.6,.2],material:ew(`#4cc9f0`),children:(0,K.jsx)(`sphereGeometry`,{args:[.035,10,8]})}),(0,K.jsx)(`mesh`,{position:[.08,.6,.2],material:ew(`#4cc9f0`),children:(0,K.jsx)(`sphereGeometry`,{args:[.035,10,8]})}),(0,K.jsx)(IE,{r:.012,h:.2,position:[0,.88,0],color:`#adb5bd`}),(0,K.jsx)(`mesh`,{position:[0,.99,0],material:ew(yA),children:(0,K.jsx)(`sphereGeometry`,{args:[.045,10,8]})})]})]}),(0,K.jsx)(_A,{position:[3,2.25,-11.97],rotationY:0,size:[7,1.6],px:[1400,320],draw:e=>Ww(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}],yA),deps:[r]}),(0,K.jsx)(EA,{}),(0,K.jsx)(AA,{}),(0,K.jsx)($E,{floorLabel:`▲ G · Lobby`,accent:yA}),(0,K.jsx)(gA,{floor:`lobby`}),(0,K.jsx)(CA,{}),(0,K.jsx)(wA,{}),(0,K.jsx)(Sk,{position:[8.4,2.8,-11.95]}),(0,K.jsx)(vk,{position:[11.5,0,4],rotationY:Math.PI,color:`#4cc9f0`}),(0,K.jsx)(yk,{position:[11.5,0,6.2]}),(0,K.jsx)(gk,{position:[15.3,0,11.3],scale:1.2}),(0,K.jsx)(gk,{position:[-15.3,0,11.3],scale:1.2,pot:`#06d6a0`}),(0,K.jsx)(gk,{position:[-3,0,11.4]}),(0,K.jsx)(gk,{position:[3,0,-11.3],scale:.8})]})}async function MA(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 J.getState().pushToast(`error`,e),Error(e)}return i}var NA=e=>`/api/repos/${encodeURIComponent(e)}`,PA={githubRepos:e=>MA(`GET`,`/api/github/repos${e?`?owner=${encodeURIComponent(e)}`:``}`),connectRepo:(e,t={})=>MA(`POST`,`/api/repos`,{fullName:e,...t}),createRepo:e=>MA(`POST`,`/api/repos/new`,e),folders:e=>MA(`GET`,`/api/folders${e?`?dir=${encodeURIComponent(e)}`:``}`),connectFolder:(e,t={})=>MA(`POST`,`/api/folders/connect`,{path:e,...t}),publishFolder:e=>MA(`POST`,`/api/folders/publish`,e),setup:e=>MA(`POST`,`/api/setup`,e),updateRepo:(e,t)=>MA(`PATCH`,NA(e),t),startPreview:(e,t)=>MA(`POST`,`${NA(e)}/preview`,t?{pr:t}:{}),stopPreview:e=>MA(`DELETE`,`${NA(e)}/preview`),disconnectRepo:e=>MA(`DELETE`,NA(e)),syncRepo:e=>MA(`POST`,`${NA(e)}/sync`),syncFolder:e=>MA(`POST`,`${NA(e)}/sync-folder`),createIssue:(e,t,n,r,i)=>MA(`POST`,`${NA(e)}/issues`,{title:t,body:n,assignTo:r,specialty:i}),planFloor:(e,t)=>MA(`POST`,`${NA(e)}/plan`,{mission:t}),onboardFloor:e=>MA(`POST`,`${NA(e)}/onboard`),mergePull:(e,t,n=`squash`)=>MA(`POST`,`${NA(e)}/pulls/${t}/merge`,{method:n}),closePull:(e,t)=>MA(`POST`,`${NA(e)}/pulls/${t}/close`),sendToQa:(e,t)=>MA(`POST`,`${NA(e)}/pulls/${t}/qa`),hireAgent:(e,t={})=>MA(`POST`,`${NA(e)}/agents`,t),updateAgent:(e,t)=>MA(`PATCH`,`/api/agents/${e}`,t),fireAgent:e=>MA(`DELETE`,`/api/agents/${e}`),assign:(e,t,n)=>MA(`POST`,`/api/agents/${e}/assign`,{issueNumber:t,note:n}),stop:e=>MA(`POST`,`/api/agents/${e}/stop`),reset:e=>MA(`POST`,`/api/agents/${e}/reset`),message:(e,t)=>MA(`POST`,`/api/agents/${e}/message`,{text:t}),agentPrompt:e=>MA(`GET`,`/api/agents/${e}/prompt`),updateSettings:e=>MA(`PATCH`,`/api/settings`,e),updateOffice:async e=>{let t=await MA(`POST`,`/api/office/update`,{action:e});return J.getState().setOfficeUpdate(t),t},messageCeo:e=>MA(`POST`,`/api/ceo/message`,{text:e}),ceoReview:()=>MA(`POST`,`/api/ceo/review`),phoneRead:e=>MA(`POST`,`/api/phone/read`,{at:e}),approveRequest:(e,t={})=>MA(`POST`,`/api/requests/${e}/approve`,t),rejectRequest:(e,t)=>MA(`POST`,`/api/requests/${e}/reject`,{note:t})},FA=.0022,IA=.2;function LA(){return{skip:3,avg:0,pending:null,dropped:0,skipped:0}}function RA(e){e.skip=3,e.avg=0,e.pending=null}var zA=(e,t)=>Math.max(Math.abs(e),Math.abs(t));function BA(e,t,n){return e.avg+=(zA(t,n)-e.avg)*IA,[t,n]}function VA(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=zA(t,n);if(i>1e3)return e.dropped++,null;let a=e.pending;if(e.pending=null,a){if(r-a.t<=50&&i>=zA(a.dx,a.dy)*.25)return BA(e,a.dx,a.dy),BA(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):BA(e,t,n)}var HA=.25,UA=`cubefarm:look`,WA={sensitivity:1,invertY:!1,grabOnClose:!0},GA=e=>Math.min(3,Math.max(HA,e));function KA(){try{let e=JSON.parse(localStorage.getItem(UA)??`null`);return{sensitivity:typeof e?.sensitivity==`number`&&Number.isFinite(e.sensitivity)?GA(e.sensitivity):WA.sensitivity,invertY:e?.invertY===!0,grabOnClose:e?.grabOnClose!==!1}}catch{return{...WA}}}var qA=Ty((e,t)=>({...KA(),set:n=>{e({...n,...n.sensitivity===void 0?{}:{sensitivity:GA(n.sensitivity)}});let{sensitivity:r,invertY:i,grabOnClose:a}=t();try{localStorage.setItem(UA,JSON.stringify({sensitivity:r,invertY:i,grabOnClose:a}))}catch{}}})),JA=Ty(()=>({ask:null}));function YA(e){return new Promise(t=>{JA.getState().ask?.resolve(!1),JA.setState({ask:{...e,resolve:t}})})}var XA=()=>JA.getState().ask!==null,ZA=e=>JA.subscribe((t,n)=>e(t.ask!==null,n.ask!==null));function QA(e){let t=JA.getState().ask;t&&(JA.setState({ask:null}),t.resolve(e))}function $A(){let e=JA(e=>e.ask);if((0,v.useEffect)(()=>{if(!e)return;let t=e=>{(e.key===`Escape`||e.key===`Enter`)&&(e.preventDefault(),e.stopImmediatePropagation(),QA(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&&QA(!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:()=>QA(!1),children:e.cancel??`Cancel`}),(0,K.jsx)(`button`,{className:`btn ${t===`danger`?`btn-bad`:t===`warn`?`btn-warn`:`btn-good`}`,onClick:()=>QA(!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 ej=e=>e&&typeof e==`object`?e.toy:void 0;function tj(e){if(!e.fixed){if(e.tag&&typeof e.tag==`object`&&`seat`in e.tag)return`person`;let t=ej(e.tag);return typeof t==`string`&&t!==`dart`&&t!==`roomba`&&!t.startsWith(`blaster-`)?`ball`:`toy`}return e.normalY>.7&&e.y<.05?`floor`:e.halfHeight!==null&&e.halfHeight*2<2.5?`furniture`:`wall`}var nj=(e,t)=>Math.min(1,Math.max(.25,e/t));function rj(e,t,n){return!(n>=.6)||t===`person`?null:e===`stick`?{sound:t===`furniture`?`tock`:`thwock`,gain:nj(n,15)}:t===`floor`?{sound:`patter`,gain:nj(n,e===`land`?4:10)}:t===`ball`?{sound:`bonk`,gain:nj(n,12)}:{sound:`tick`,gain:nj(n,e===`land`?4:12)}}function ij(e,t,n){return t<=6?`person`:e??n}function aj(e,t){return!(e<-.6)||t-e<.8?null:-e}var oj={dart:3,blaster:2};function sj(e,t){let n=(Math.min(1,Math.max(0,t))-.5)*.14,r=e>0?e%2?.03:-.03:0;return{pitch:1+n+r,gain:Math.max(.7,1-Math.max(0,e)*.03)}}var cj=(e,t)=>t<450?e+1:0;function lj(e){let t=e/1e3;return{magOut:.04*t,magIn:.62*t,ready:Math.max(.62*t,t-.12)}}var uj=(e,t,n)=>q({...t,name:e,group:`toys`,pos:n}),dj=(e,t,n)=>jb({...t,name:e,group:`toys`,pos:n});function fj({pitch:e,gain:t}){dj(`blaster:thwip`,{dur:.085,peak:.1*t,filter:`bandpass`,freq:2600*e,to:900*e,q:1.4,attack:.003}),uj(`blaster:thwip`,{freq:520*e,to:190*e,type:`triangle`,dur:.075,peak:.07*t,attack:.004})}function pj(){uj(`blaster:dry`,{freq:1400,to:900,type:`square`,dur:.03,peak:.03,attack:.002})}function mj(e){dj(`blaster:take`,{dur:.04,peak:.07,filter:`bandpass`,freq:2200,q:2.5,attack:.002}),uj(`blaster:take`,{freq:300,to:220,type:`triangle`,dur:.05,peak:.04,attack:.003}),e&&(dj(`blaster:pump`,{at:.14,dur:.12,peak:.05,filter:`bandpass`,freq:700,to:1300,q:2,attack:.03}),dj(`blaster:pump`,{at:.27,dur:.035,peak:.08,filter:`bandpass`,freq:1800,q:3,attack:.002}),dj(`blaster:pump`,{at:.33,dur:.1,peak:.05,filter:`bandpass`,freq:1300,to:700,q:2,attack:.02}),dj(`blaster:pump`,{at:.44,dur:.035,peak:.09,filter:`bandpass`,freq:1500,q:3,attack:.002}))}function hj(e){let t=lj(e);dj(`blaster:mag-out`,{at:t.magOut,dur:.1,peak:.06,filter:`bandpass`,freq:1100,to:600,q:2,attack:.01}),uj(`blaster:mag-out`,{at:t.magOut,freq:240,to:160,type:`triangle`,dur:.08,peak:.03}),dj(`blaster:mag-in`,{at:t.magIn,dur:.06,peak:.05,filter:`bandpass`,freq:800,to:1400,q:2,attack:.02}),dj(`blaster:mag-in`,{at:t.magIn+.06,dur:.04,peak:.1,filter:`bandpass`,freq:1600,q:3,attack:.002}),uj(`blaster:mag-in`,{at:t.magIn+.06,freq:420,to:300,type:`triangle`,dur:.05,peak:.04,attack:.003}),dj(`blaster:ready`,{at:t.ready,dur:.03,peak:.06,filter:`bandpass`,freq:2400,q:3,attack:.002})}function gj(e,t){dj(`blaster:clatter`,{dur:.06,peak:.1*t,filter:`bandpass`,freq:1500,q:1.5,attack:.002},e),uj(`blaster:clatter`,{freq:260,to:180,type:`triangle`,dur:.08,peak:.06*t,attack:.003},e),dj(`blaster:clatter`,{at:.07,dur:.04,peak:.05*t,filter:`bandpass`,freq:2300,q:2,attack:.002},e)}function _j(e,t,n){let r=`dart:${e}`;switch(e){case`thwock`:uj(r,{freq:300,to:120,dur:.11,peak:.16*n,attack:.003},t),dj(r,{dur:.05,peak:.08*n,filter:`lowpass`,freq:900,q:1,attack:.002},t);return;case`tock`:uj(r,{freq:520,to:300,type:`triangle`,dur:.07,peak:.12*n,attack:.002},t),dj(r,{dur:.035,peak:.07*n,filter:`bandpass`,freq:1200,q:2,attack:.002},t);return;case`tick`:dj(r,{dur:.025,peak:.07*n,filter:`bandpass`,freq:3200,q:3,attack:.001},t),uj(r,{freq:1900,to:1500,type:`triangle`,dur:.03,peak:.025*n,attack:.001},t);return;case`bonk`:dj(r,{dur:.025,peak:.06*n,filter:`bandpass`,freq:2800,q:3,attack:.001},t),uj(r,{freq:180,to:260,type:`sine`,dur:.12,peak:.1*n,attack:.004},t);return;case`patter`:dj(r,{dur:.04,peak:.07*n,filter:`lowpass`,freq:1100,q:.7,attack:.002},t),dj(r,{at:.045,dur:.03,peak:.035*n,filter:`lowpass`,freq:900,q:.7,attack:.002},t);return}}var vj=()=>{let e=J.getState().held;return e?.kind===`blaster`?e:null},yj={at:-1/0},bj=new Map,xj=[],Sj=0;function Cj(){bj.clear(),xj=[]}function wj(e,t=!1){J.getState().setHeld({kind:`blaster`,id:e,ammo:bj.get(e)??GD.mag,reloadAt:null}),mj(t)}J.subscribe((e,t)=>{let n=t.held;n?.kind!==`blaster`||e.held?.kind===`blaster`&&e.held.id===n.id||bj.set(n.id,KD(n,performance.now()).ammo)});function Tj(){let e=J.getState(),t=vj();if(!t||e.travel)return;let n=performance.now(),r=JD(t,yj.at,n);if(!r){let e=KD(t,n);e.reloadAt===null&&e.ammo===0&&pj();return}Sj=cj(Sj,n-yj.at),yj.at=n,xj.length<GD.mag&&xj.push(t.id),e.setHeld({...t,...r}),fj(sj(Sj,Math.random()))}function Ej(){let e=vj();if(!e)return;let t=YD(e,performance.now());t&&(J.getState().setHeld({...e,...t}),hj(GD.reloadMs),setTimeout(()=>{let n=vj();n&&n.id===e.id&&n.reloadAt===t.reloadAt&&J.getState().setHeld({...n,...KD(n,performance.now())})},GD.reloadMs+20))}function Dj(){return xj.shift()??null}var Oj={ahead:1,drop:.5,dropPerR:.9,pitch:.55,minPitch:-.7,maxPitch:.4,follow:14,maxSpeed:18,lost:2.2,lostFor:.35,windUp:.25},kj={lob:3.2,hard:14,lift:1.6,hardLift:.9,aim:12,flightDamping:.05,walk:1},Aj={tap:150,full:1e3},jj=e=>Math.min(1,Math.max(0,(e-Aj.tap)/(Aj.full-Aj.tap)));function Mj(e,t,n,r){let i=Math.min(Oj.maxPitch,Math.max(Oj.minPitch,e.pitch*Oj.pitch)),a=Oj.ahead+t-n,o=a*Math.sin(i)-Oj.drop-t*Oj.dropPerR-n*.4,s=-a*Math.cos(i);return r.x=e.eye.x+s*Math.sin(e.yaw),r.y=e.eye.y+o,r.z=e.eye.z+s*Math.cos(e.yaw),r}function Nj(e,t,n,r,i,a){let o=Math.cos(e.pitch);a.x=e.eye.x-Math.sin(e.yaw)*o*kj.aim-t.x,a.y=e.eye.y+Math.sin(e.pitch)*kj.aim-t.y,a.z=e.eye.z-Math.cos(e.yaw)*o*kj.aim-t.z;let s=Math.hypot(a.x,a.y,a.z)||1,c=kj.lob+(r-kj.lob)*n;return a.x=a.x/s*c+i.x*kj.walk,a.y=a.y/s*c+kj.lift+(kj.hardLift-kj.lift)*n,a.z=a.z/s*c+i.z*kj.walk,a}var Pj=9.81,Fj={cone:.1,minDist:.8,maxDist:9,top:Qx-.25,sweet:.45,band:.25};function Ij(e,t,n,r,i,a){let{eye:o,pitch:s,yaw:c}=e,l=Math.cos(s),u=i.square.x-o.x,d=i.square.y-o.y,f=i.square.z-o.z;if((-Math.sin(c)*l*u+Math.sin(s)*d-Math.cos(c)*l*f)/(Math.hypot(u,d,f)||1)<Math.cos(Fj.cone))return!1;let p=i.rim.x-t.x,m=i.rim.z-t.z,h=Math.hypot(p,m),g=Math.hypot(i.rim.x-o.x,i.rim.z-o.z);if(g<Fj.minDist||g>Fj.maxDist||h<.1||t.y>=i.rim.y)return!1;let _=Fj.top,v=Math.sqrt(2*Pj*(_-t.y)),y=v/Pj+Math.sqrt(2*(_-i.rim.y)/Pj),b=1+kj.flightDamping*y/2,x=h/y*b,S=Math.hypot(x,v*b),C=(kj.lob+(r-kj.lob)*n)/S-1,w=Math.min(Math.abs(C),Fj.band),T=1+Math.sign(C)*(w*Math.min(1,Fj.sweet/h)+Math.abs(C)-w);return a.x=p/h*x*T,a.y=v*b*T,a.z=m/h*x*T,!0}var Lj={x:0,z:0},Rj=null;function zj(){let e=J.getState();if(e.held?.kind===`blaster`)return Tj();e.held?.kind!==`mug`&&e.held&&e.chargeAt===null&&e.setCharge(performance.now())}function Bj(){let e=J.getState();if(!e.held||e.chargeAt===null)return;let t=jj(performance.now()-e.chargeAt);Rj={id:e.held.id,power:t,at:performance.now()};let n=.94+Math.random()*.12;jb({name:`throw`,group:`toys`,dur:.14+t*.08,peak:.03+t*.05,filter:`bandpass`,freq:500*n,to:(1500+t*900)*n,q:.9+t*.5}),e.setHeld(null)}function Vj(){let e=J.getState();e.held&&e.setHeld(null)}function Hj(e){let t=Rj;return!t||t.id!==e||performance.now()-t.at>500?null:(Rj=null,t.power)}function Uj(e,t){return(e.overlay&&!t.overlay||e.confirm&&!t.confirm)&&!t.overlay&&!t.confirm}function Wj(e,t,n){return n.enabled&&n.started&&Uj(e,t)}function Gj(e,t){let n=(n,r)=>{Uj(n,r)&&(t(),Wj(n,r,{started:J.getState().started,enabled:qA.getState().grabOnClose})&&e())},r=J.subscribe((e,t)=>{if(e.overlay===t.overlay)return;let r=XA();n({overlay:!!t.overlay,confirm:r},{overlay:!!e.overlay,confirm:r})}),i=ZA((e,t)=>{let r=!!J.getState().overlay;e!==t&&n({overlay:r,confirm:t},{overlay:r,confirm:e})});return()=>{r(),i()}}var Kj=null,qj=400,Jj=0,Yj=[`mousedown`,`mouseup`,`click`,`dblclick`],Xj=()=>{Jj=performance.now()+qj};function Zj(){let e=J.getState();if(!Kj||e.overlay||!e.started||XA())return;let t=Kj;Qj(t,{unadjustedMovement:!0})?.catch?.(e=>{e instanceof DOMException&&e.name===`NotSupportedError`&&Qj(t)?.catch?.(()=>void 0)})}function Qj(e,t){try{return e.requestPointerLock?.(t)}catch{return}}var $j={dropped:0,skipped:0};window.__swarmLook=$j;function eM(e,t=`key`){let n=J.getState();if(Jj=performance.now()+qj,e.action.kind===`pickup`&&WD(e.action.toyId)){wj(e.action.toyId,e.id.startsWith(`toy:rack:`));return}if(e.action.kind===`pickup`&&lO(e.action.toyId)){_O(e.action.toyId);return}if(e.action.kind===`pickup`){n.setHeld({kind:`ball`,id:e.action.toyId});return}if(e.action.kind===`coffee`){ok(e.action.op);return}if(e.action.kind===`poke`){cD(e.action.toyId);return}if(e.action.kind===`hire`){let{repoId:r,role:i}=e.action,a=()=>PA.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(),YA({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 tM=e=>{let t=e.target;return!!t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`||t.isContentEditable)};function nM({colliders:e,floor:t}){let{camera:n,gl:r}=W_(),i=(0,v.useRef)(new Set),a=(0,v.useRef)({yaw:nS.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)(LA,[]),d=(0,v.useRef)(!1);(0,v.useEffect)(()=>{let e=d.current?null:Ox();if(d.current=!0,e&&e.floor===t){n.position.set(e.x,$x,e.z),a.current={yaw:e.yaw,pitch:e.pitch};return}n.position.set(nS.x,$x,nS.z),a.current={yaw:nS.yaw,pitch:-.05}},[t,n]);let f=(0,v.useRef)(0);return(0,v.useEffect)(()=>{},[n]),(0,v.useEffect)(()=>{Kj=r.domElement;let e=e=>{if(e.button!==0)return;if(document.pointerLockElement!==r.domElement)return Zj();let t=J.getState();!t.started||t.overlay||t.travel||XA()||(t.held&&t.focus?.action.kind!==`coffee`?zj():t.focus&&eM(t.focus,`click`))},t=e=>{e.button===0&&Bj()},n=e=>{performance.now()>=Jj||(e.stopPropagation(),e.preventDefault())},o=()=>{RA(u);let e=document.pointerLockElement===r.domElement;e||Vj(),J.getState().setLocked(e)},s=e=>{if(document.pointerLockElement!==r.domElement||!document.hasFocus())return;let t=VA(u,e.movementX,e.movementY,e.timeStamp);if($j.dropped=u.dropped,$j.skipped=u.skipped,!t)return;let{sensitivity:n,invertY:i}=qA.getState(),o=FA*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(tM(e))return;let t=J.getState();if(e.code===`KeyM`&&!e.repeat&&!XA()&&(hb(),t.pushToast(`info`,ub().muted?`🔇 Sound off (M to turn it back on)`:`🔊 Sound on`)),!(t.overlay||!t.started||XA())){if(i.current.add(e.code),e.code===`KeyE`&&!e.repeat){let e=Ak(t.held,t.focus?.action.kind??null);e===`sip`?Kk():e===`empty`?t.pushToast(`info`,`☕ It's empty: refill it at the machine`):t.focus&&eM(t.focus)}e.code===`KeyF`&&!e.repeat&&!t.travel&&zj(),e.code===`KeyG`&&!e.repeat&&Vj(),e.code===`KeyR`&&!e.repeat&&!t.travel&&Ej(),e.code===`KeyH`&&t.openOverlay({kind:`help`}),e.code===`KeyP`&&(e.preventDefault(),t.openOverlay({kind:`phone`,tab:Lx(t.requests).length&&!Ix(t.messages,t.phoneReadAt)?`hires`:`chat`}))}},l=e=>{i.current.delete(e.code),e.code===`KeyF`&&Bj()},d=()=>{i.current.clear(),J.getState().setCharge(null)};r.domElement.addEventListener(`mousedown`,e),window.addEventListener(`mouseup`,t);for(let e of Yj)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=Gj(Zj,Xj);return()=>{f(),r.domElement.removeEventListener(`mousedown`,e),window.removeEventListener(`mouseup`,t);for(let e of Yj)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=J.getState();(p.overlay||XA())&&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(Lj.x=0,Lj.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=IS(n.position.x+a,n.position.z+o,e);d>0&&(Lj.x=(s.x-n.position.x)/d,Lj.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=$x+(b?Math.sin(o.current)*.035:0),GT(o.current,b,_>5,FS(t===0?`lobby`:`office`,n.position.x,n.position.z)),Jk(),n.rotation.set(y+Hk.head,v,0,`YXZ`);let x=performance.now();if(p.started&&!p.travel&&x-f.current>1e3&&(f.current=x,kx({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||XA()){p.focus&&p.setFocus(null);return}s.setFromCamera(c,n),s.far=8;let S=[...Xw.keys()],C=s.intersectObjects(S,!0),w=null;for(let e of C){let t=e.object;for(;t&&!Xw.has(t);)t=t.parent;if(!t)continue;let n=Xw.get(t);e.distance<=n.range&&(w={id:n.id,label:n.label,action:n.action});break}p.setFocus(w)}),null}function rM(){return G_(({camera:e})=>{let t=e.matrixWorld.elements;bb(t[12],t[13],t[14],-t[8],-t[9],-t[10],t[4],t[5],t[6])}),null}function iM(){let e=J(e=>e.travel),t=J(e=>e.finishTravel);return(0,v.useEffect)(()=>{if(!e)return;e.phase===`closing`&&Ib(.75);let n=setTimeout(()=>{e.phase===`closing`?(t(`arrived`),Fb()):t(`done`)},e.phase===`closing`?750:650);return()=>clearTimeout(n)},[e,t]),null}function aM(){let e=J(e=>e.floor),t=J(e=>e.repos),n=e===0?null:Mx(t,e),r=!!n,i=(0,v.useMemo)(()=>r?CS():MS(),[r]),a=Wx(),[o,s]=(0,v.useState)(Bx);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)(kk,{}),(0,K.jsx)(v.Suspense,{fallback:null,children:n?(0,K.jsx)(vA,{repo:n},n.id):(0,K.jsx)(jA,{})}),(0,K.jsx)(nM,{colliders:i,floor:e}),(0,K.jsx)(iM,{}),(0,K.jsx)(rM,{}),(0,K.jsx)(Gx,{paused:a}),(0,K.jsx)(qx,{onChange:s}),Vx&&(0,K.jsx)(Xx,{paused:a})]})}function oM({held:e}){let t=(0,v.useRef)(null),n=e.reloadAt!==null;(0,v.useEffect)(()=>{if(!n)return;let r=0,i=()=>{let n=qD(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:[`🎯 `,XD(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 sM({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=jj(a);t.current&&(t.current.className=`charge ${a>Aj.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 cM(){let e=J(e=>e.held),t=J(e=>e.chargeAt);return e?e.kind===`blaster`?(0,K.jsx)(oM,{held:e}):e.kind===`mug`?(0,K.jsxs)(`div`,{className:`hud-hint hud-held`,children:[`☕ `,e.sips>0?`${e.sips} ${e.sips===1?`sip`:`sips`} left`:`Empty mug`,` · `,(0,K.jsx)(`kbd`,{children:`G`}),` drop`]}):(0,K.jsxs)(K.Fragment,{children:[t!==null&&(0,K.jsx)(sM,{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 lM=[`tool`,`text`,`thinking`,`error`,`done`,`manager`],uM=e=>e.status===`working`||e.status===`preparing`,dM=`cubefarm:workers`;function fM(e){for(let t=e.length-1;t>=Math.max(0,e.length-80);t--){let n=e[t];if(!lM.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 pM(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 mM(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 hM({a:e,now:t}){let n=J(e=>e.openOverlay),r=fM(J(t=>t.logs[e.id])??[]),i=r&&(!e.startedAt||r.t>=e.startedAt)?r:null,a=pM(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:mM(i.t,t)})]})]})]})}function gM(){try{return new Set(JSON.parse(localStorage.getItem(`${dM}:collapsed`)??`[]`))}catch{return new Set}}function _M(){let e=J(e=>e.floor),t=J(e=>e.repos),n=J(e=>e.agents),r=J(e=>e.started),[i,a]=(0,v.useState)(()=>{try{return localStorage.getItem(dM)!==`closed`}catch{return!0}}),[o,s]=(0,v.useState)(gM),[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(`${dM}:collapsed`,JSON.stringify([...n]))}catch{}return n}),d=()=>a(e=>{try{localStorage.setItem(dM,e?`closed`:`open`)}catch{}return!e});if((0,v.useEffect)(()=>{let e=e=>{e.code!==`Tab`||e.repeat||e.altKey||e.ctrlKey||e.metaKey||J.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&&uM(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:Nx(n,e.id).filter(uM)}))].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)(hM,{a:e,now:c},e.id))]},e.key)})]})]})}var vM=12e5,yM=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function bM(e){switch(e.state){case`none`:return`Up to date`;case`available`:return e.behind>0?`${yM(e.behind,`update`)} ready`:`An update is ready`;case`waiting`:case`draining`:return e.running>0?`Waiting for ${yM(e.running,`session`)} to finish`:`Updating shortly…`;case`updating`:return`Updating…`;case`failed`:return`Last update failed: ${e.detail||`unknown error`}`}}function xM(e){return e?e.state===`updating`?`⟳ Updating the office…`:e.state!==`waiting`&&e.state!==`draining`?null:e.running>0?`⟳ Updating the office after ${yM(e.running,`session`)} finish${e.running===1?`es`:``}`:`⟳ Updating the office shortly`:null}var SM=e=>e.state===`draining`&&e.drainingSince?e.drainingSince+vM:null,CM=e=>e.launcher&&e.behind>0&&(e.state===`available`||e.state===`waiting`||e.state===`failed`),wM=e=>e.launcher&&(e.state===`available`||e.state===`waiting`||e.state===`draining`),TM=e=>e?.state===`draining`||e?.state===`updating`;function EM(e,t,n){return!!e&&!!t&&e!==t&&n!==t}function DM(){let e=J(e=>e.restarting?`⟳ Office restarting…`:xM(e.officeUpdate)),t=J(e=>e.overlay),n=J(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 OM(){let e=Rx(),t=J(e=>e.started),n=J(e=>e.overlay),r=J(e=>e.openOverlay),i=J(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 kM(){let e=J(e=>e.floor),t=J(e=>e.repos),n=J(e=>e.agents),r=J(e=>e.settings),i=J(e=>e.connected),a=J(e=>e.restarting),o=J(e=>e.demo),s=J(e=>e.user),c=J(e=>e.ghReady),l=J(e=>e.ghError),u=J(e=>e.focus),d=J(e=>e.held),f=Ak(d,u?.action.kind??null)===`sip`,p=J(e=>e.overlay),m=J(e=>e.locked),h=J(e=>e.started),g=J(e=>e.travel),_=J(e=>e.toasts),y=J(e=>e.dismissToast),b=e===0?null:Mx(t,e),x=(0,v.useMemo)(()=>Object.values(n).filter(e=>e.status===`working`||e.status===`preparing`).length,[n]),S=b?Object.values(n).filter(e=>e.repoId===b.id):[],C=J(e=>e.qa),w=b?Object.values(C).filter(e=>e.repoId===b.id):[];return(0,K.jsxs)(`div`,{className:`hud`,children:[(0,K.jsxs)(`div`,{className:`hud-floor`,style:{"--accent":b?.color??`#ff8a5b`},children:[(0,K.jsx)(`div`,{className:`floor-num`,children:b?b.floor:`G`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`floor-name`,children:b?b.fullName:`${r.companyName||`cubefarm`} · Lobby`}),(0,K.jsx)(`div`,{className:`floor-sub`,children:b?`${S.length} agents · ${S.filter(e=>e.status===`working`||e.status===`preparing`).length} working · ${w.filter(e=>e.status!==`passed`).length} in QA · ${w.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?`${x}/${r.sessionLimit}`:x,` sessions`]}),s&&(0,K.jsxs)(`span`,{className:`pill`,children:[`🐙 `,s]})]}),(0,K.jsx)(_M,{}),(0,K.jsx)(DM,{}),!c&&l&&(0,K.jsxs)(`div`,{className:`hud-banner`,children:[`⚠️ `,l]}),h&&!p&&!g&&(0,K.jsx)(`div`,{className:`crosshair ${u?`crosshair-hot`:``}`}),h&&!p&&(u||f)&&(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`}),` `]}),f?`Sip coffee`:u?.label]}),h&&!p&&!g&&(0,K.jsx)(cM,{}),h&&!p&&!m&&!g&&(0,K.jsx)(`div`,{className:`hud-resume`,children:`Click to look around`}),h&&!(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 ${g?.phase===`closing`?`fade-in`:``}`,children:g&&(0,K.jsx)(`div`,{className:`fade-label`,children:g.to===0?`Lobby`:`Floor ${g.to}`})}),(0,K.jsx)(OM,{}),(0,K.jsx)(`div`,{className:`toasts`,children:_.map(e=>(0,K.jsx)(`div`,{className:`toast toast-${e.level}`,onClick:()=>y(e.id),children:e.text},e.id))})]})}var AM={unconfigured:`not set up`,stopped:`stopped`,preparing:`checking out`,installing:`installing`,starting:`starting`,running:`running`,error:`error`},jM=[`preparing`,`installing`,`starting`,`running`],MM=[{status:`preparing`,label:`Check out the code`},{status:`installing`,label:`Install dependencies`},{status:`starting`,label:`Start the app`}],NM=`desktop`,PM=12e3;function FM({status:e}){return(0,K.jsx)(`span`,{className:`status status-${e}`,children:AM[e]})}var IM=e=>Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
|
|
4285
|
+
`);function LM(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 RM({repo:e,saveLabel:t=`Save`,onSaved:n}){let r={command:e.previewConfig.command??``,env:IM(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=LM(o);if(r.error)return d(r.error);d(null),l(!0);try{await PA.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 zM({repoId:e}){let t=J(t=>t.repos.find(t=>t.id===e)),n=t?.preview,[r,i]=(0,v.useState)(n?.pr??null),[a,o]=(0,v.useState)(NM),[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&&jM.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),PM);return()=>clearTimeout(e)},[y,n?.status]),(0,v.useEffect)(()=>{_.current?.querySelector(`select, button`)?.focus()},[]),!t||!n)return(0,K.jsx)(L1,{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(()=>PA.startPreview(t.id,e??void 0)),S=()=>b(()=>PA.stopPreview(t.id)),C=e=>{NM=e,o(e)},w=jM.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)(L1,{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)(FM,{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:MM.map((e,t)=>{let r=MM.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)(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}?
|
|
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)(RM,{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)(RM,{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)(RM,{repo:t})})]})]})}function BM(){let e=J(e=>e.repos),t=J(e=>e.agents),n=J(e=>e.floor),r=J(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)(L1,{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 VM({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 HM({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 PA.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 UM({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 WM({repoId:e}){let t=J(t=>t.repos.find(t=>t.id===e)),n=J(e=>e.agents),r=J(e=>e.qa),i=J(e=>e.openOverlay),a=(0,v.useMemo)(()=>Nx(n,e),[n,e]),o=(0,v.useMemo)(()=>t?zx(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)(L1,{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 YA(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,()=>PA.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`)&&PA.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)(L1,{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 PA.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 PA.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`,()=>PA.syncRepo(t.id)),children:`⟳ Sync`})]}),t.syncError&&(0,K.jsxs)(`div`,{className:`term-error`,children:[`⚠️ `,t.syncError]}),s&&(0,K.jsx)(HM,{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,()=>PA.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)(VM,{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)(VM,{agent:e.agent}),(0,K.jsx)(`span`,{className:`muted small`,children:e.note}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(UM,{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,()=>PA.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)(VM,{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)(UM,{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 YA({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,()=>PA.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)(VM,{agent:e.agent})}),`Nothing merged yet.`)]})]})}var GM=e=>/^(claude|opus|sonnet|haiku|fable|default|best|opusplan)\b/i.test(e.trim());function KM(e,t,n,r){let i=e=>e.trim()!==``&&t===`claude`===GM(e);return i(e)?e.trim():t===n.defaultCli&&i(n.defaultModel)?n.defaultModel.trim():t===`claude`?r:``}var qM=[`claude-opus-5-5`,`claude-opus-5`,`claude-fable-5-1`,`claude-sonnet-5`,`claude-haiku-4-5`];function JM(e){return e===`claude`?qM:e===`codex`?[`gpt-5.5-codex`,`gpt-5.5`]:qM.map(e=>`anthropic/${e}`)}var YM=[`low`,`medium`,`high`,`xhigh`,`max`],XM=2500,ZM=(e,t)=>e.find(e=>e.id===t)?.label??t,QM=(e,t)=>e.role===`ceo`||t.runtime!==`terminal`?`claude`:e.cli||t.defaultCli;async function $M(e,t){try{await PA.updateAgent(e,t)}catch{}}function eN({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))})}function tN({agent:e,id:t,className:n=`inline`,style:r}){return(0,K.jsx)(`input`,{id:t,className:n,style:r,defaultValue:e.name,maxLength:24,"aria-label":t?void 0:`Name`,onBlur:t=>t.target.value.trim()&&t.target.value!==e.name&&void $M(e.id,{name:t.target.value})},`n-${e.name}`)}function nN({agent:e,id:t,style:n}){let r=J(e=>e.settings),i=J(e=>e.clis);return(0,K.jsxs)(`select`,{id:t,value:e.cli,title:`Their coding agent`,"aria-label":t?void 0:`Coding agent`,style:n,onChange:t=>void $M(e.id,{cli:t.target.value}),children:[(0,K.jsxs)(`option`,{value:``,children:[ZM(i,r.defaultCli),` (default)`]}),(0,K.jsx)(eN,{clis:i})]})}function rN({agent:e,id:t,className:n=`inline`,style:r}){let i=J(e=>e.settings),a=(0,v.useId)(),o=QM(e,i);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`input`,{id:t,className:n,style:r,list:a,defaultValue:e.model,placeholder:(e.role===`ceo`?qM[0]:KM(``,o,i,qM[0]))||`agent default`,title:e.role===`ceo`?`The CEO's model`:`Their model ('' = the default for their coding agent)`,"aria-label":t?void 0:`Model`,onBlur:t=>t.target.value!==e.model&&void $M(e.id,{model:t.target.value})},`m-${e.model}-${o}`),(0,K.jsx)(`datalist`,{id:a,children:JM(o).map(e=>(0,K.jsx)(`option`,{value:e},e))})]})}function iN({agent:e,id:t,style:n}){let r=J(e=>e.settings.defaultEffort);return(0,K.jsxs)(`select`,{id:t,value:e.effort,title:e.role===`ceo`?`The CEO's effort`:`Their effort`,"aria-label":t?void 0:`Effort`,style:n,onChange:t=>void $M(e.id,{effort:t.target.value}),children:[(e.role!==`ceo`||!e.effort)&&(0,K.jsxs)(`option`,{value:``,children:[`default (`,r,`)`]}),YM.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})}function aN({agent:e,id:t,className:n=`inline`,style:r}){return(0,K.jsx)(`input`,{id:t,className:n,style:r,defaultValue:e.title,maxLength:60,placeholder:e.role===`qa`?`QA tester`:`Developer`,title:`Job title`,"aria-label":t?void 0:`Job title`,onBlur:t=>t.target.value!==e.title&&void $M(e.id,{title:t.target.value})},`t-${e.title}`)}function oN({agent:e,id:t,className:n=`inline`,style:r}){return(0,K.jsx)(`input`,{id:t,className:n,style:r,defaultValue:e.specialty,placeholder:`specialty`,title:`Issues labelled swarm:<specialty> go to this agent first`,"aria-label":t?void 0:`Specialty`,onBlur:t=>t.target.value!==e.specialty&&void $M(e.id,{specialty:t.target.value})},`s-${e.specialty}`)}function sN({agent:e,id:t}){return(0,K.jsxs)(`select`,{id:t,value:e.look,title:`Character look`,"aria-label":t?void 0:`Drawn as`,style:{width:`auto`},onChange:t=>void $M(e.id,{look:t.target.value}),children:[(0,K.jsx)(`option`,{value:`feminine`,children:`👩 She`}),(0,K.jsx)(`option`,{value:`masculine`,children:`👨 He`})]})}function cN({agent:e,id:t,compact:n}){let[r,i]=(0,v.useState)(e.brief),[a,o]=(0,v.useState)(!1);(0,v.useEffect)(()=>i(e.brief),[e.brief]);let s=`What ${e.name} owns on this project and how they should work. It's added to their instructions.`;if(n)return(0,K.jsx)(`textarea`,{rows:3,defaultValue:e.brief,placeholder:s,onBlur:t=>t.target.value!==e.brief&&void $M(e.id,{brief:t.target.value})},`b-${e.brief}`);let c=`${t??e.id}-count`,l=r.trim()!==e.brief;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`textarea`,{id:t,rows:8,value:r,maxLength:XM,placeholder:s,"aria-describedby":c,onChange:e=>i(e.target.value)}),(0,K.jsxs)(`div`,{className:`row small`,children:[(0,K.jsxs)(`span`,{id:c,className:r.length>=2500?``:`muted`,"aria-live":`polite`,children:[r.length.toLocaleString(),` / `,XM.toLocaleString(),` · Added to their instructions on every task.`]}),(0,K.jsx)(`span`,{className:`spacer`}),l&&(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small btn-ghost`,onClick:()=>i(e.brief),children:`Undo`}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small btn-good`,disabled:!l||a,onClick:()=>{o(!0),$M(e.id,{brief:r}).finally(()=>o(!1))},children:a?`Saving…`:`Save job description`})]})]})}function lN({agent:e}){let[t,n]=(0,v.useState)(!1),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),s=J(t=>{let n=t.repos.find(t=>t.id===e.repoId),r=t.settings;return JSON.stringify(n?[n.fullName,n.defaultBranch,n.autoMerge,n.browserTesting,n.links,n.mission,n.summary,n.qaBrief]:[r.companyName,r.managerName,r.sessionLimit,r.teamCap,r.hiring])});(0,v.useEffect)(()=>{if(!t)return;let n=!0;return PA.agentPrompt(e.id).then(e=>{n&&(i(e),o(!1))},()=>n&&o(!0)),()=>{n=!1}},[t,e.id,e.name,e.role,e.title,e.brief,s]);let c=r?.parts.some(e=>e.editable);return(0,K.jsxs)(`details`,{className:`prompt-preview`,onToggle:e=>n(e.currentTarget.open),children:[(0,K.jsxs)(`summary`,{children:[`What they're told`,r&&(0,K.jsxs)(`span`,{className:`muted small`,children:[` · `,r.text.length.toLocaleString(),` characters`]})]}),a&&!r&&(0,K.jsx)(`p`,{className:`muted small`,children:`Couldn't load their prompt.`}),!r&&!a&&(0,K.jsx)(`p`,{className:`muted small`,children:`Loading…`}),r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`muted small`,children:[r.kind===`ceo`?`The CEO's instructions for every job. They're all the office's own.`:`The office builds this for every ${r.kind===`qa`?`pull request they test`:`issue they start`}; <placeholders> are filled in per task. `,r.kind!==`ceo`&&(c?(0,K.jsxs)(K.Fragment,{children:[`Only the `,(0,K.jsx)(`mark`,{children:`job description`}),` is yours to edit: the rest is the office's workflow and safety rules.`]}):`They have no job description yet: add one above and it appears here.`)]}),(0,K.jsx)(`pre`,{className:`prompt-text`,tabIndex:0,"aria-label":`${e.name}'s full prompt`,children:r.parts.map((e,t)=>e.editable?(0,K.jsx)(`mark`,{title:e.label,children:e.text},t):(0,K.jsx)(`span`,{children:e.text},t))}),(0,K.jsxs)(`p`,{className:`muted small`,children:[r.text.length.toLocaleString(),` characters, sent with every session.`]})]})]})}function uN({agent:e}){let t=J(e=>e.settings.runtime===`terminal`),n=(0,v.useId)(),r=e.role===`ceo`;return(0,K.jsxs)(`section`,{className:`card agent-setup`,"aria-label":`${e.name}'s setup`,children:[(0,K.jsxs)(`div`,{className:`row wrap`,children:[(0,K.jsx)(`h3`,{className:`grow`,children:`⚙️ Setup`}),Fx(e)&&(0,K.jsx)(`span`,{className:`chip chip-warn`,role:`status`,children:`Applies from their next task`})]}),(0,K.jsxs)(`div`,{className:`setup-grid`,children:[!r&&(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-name`,children:[(0,K.jsx)(`span`,{children:`Name`}),(0,K.jsx)(tN,{agent:e,id:`${n}-name`,className:``})]}),!r&&(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-look`,children:[(0,K.jsx)(`span`,{children:`Drawn as`}),(0,K.jsx)(sN,{agent:e,id:`${n}-look`})]}),!r&&t&&(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-cli`,children:[(0,K.jsx)(`span`,{children:`Coding agent`}),(0,K.jsx)(nN,{agent:e,id:`${n}-cli`})]}),(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-model`,children:[(0,K.jsx)(`span`,{children:`Model`}),(0,K.jsx)(rN,{agent:e,id:`${n}-model`,className:``})]}),(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-effort`,children:[(0,K.jsx)(`span`,{children:`Effort`}),(0,K.jsx)(iN,{agent:e,id:`${n}-effort`})]}),!r&&(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-title`,children:[(0,K.jsx)(`span`,{children:`Title`}),(0,K.jsx)(aN,{agent:e,id:`${n}-title`,className:``})]}),!r&&(0,K.jsxs)(`label`,{className:`field`,htmlFor:`${n}-specialty`,children:[(0,K.jsx)(`span`,{children:`Specialty`}),(0,K.jsx)(oN,{agent:e,id:`${n}-specialty`,className:``})]})]}),!r&&(0,K.jsx)(`label`,{className:`field`,htmlFor:`${n}-brief`,children:(0,K.jsx)(`span`,{children:`Job description`})}),!r&&(0,K.jsx)(cN,{agent:e,id:`${n}-brief`}),(0,K.jsx)(lN,{agent:e}),(0,K.jsx)(`p`,{className:`muted small`,children:`Name, model, effort and the other fields save when you leave them. Running sessions aren't restarted.`})]})}var dN=Object.defineProperty,fN=Object.getOwnPropertyDescriptor,pN=(e,t)=>{for(var n in t)dN(e,n,{get:t[n],enumerable:!0})},mN=(e,t,n,r)=>{for(var i=r>1?void 0:r?fN(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&&dN(t,n,i),i},X=(e,t)=>(n,r)=>t(n,r,e),hN=`Terminal input`,gN={get:()=>hN,set:e=>hN=e},_N=`Too much output to announce, navigate to rows manually to read`,vN={get:()=>_N,set:e=>_N=e};function yN(e){return e.replace(/\r?\n/g,`\r`)}function bN(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function xN(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function SN(e,t,n,r){e.stopPropagation(),e.clipboardData&&CN(e.clipboardData.getData(`text/plain`),t,n,r)}function CN(e,t,n,r){e=yN(e),e=bN(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function wN(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 TN(e,t,n,r,i){wN(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function EN(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function DN(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 ON=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}},kN=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}},AN=``,jN=` `,MN=class e{constructor(){this.fg=0,this.bg=0,this.extended=new NN}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}},NN=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}},PN=class e extends MN{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new NN,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?EN(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()]}},FN=`di$target`,IN=`di$dependencies`,LN=new Map;function RN(e){return e[IN]||[]}function zN(e){if(LN.has(e))return LN.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);BN(t,e,r)};return t._id=e,LN.set(e,t),t}function BN(e,t,n){t[FN]===t?t[IN].push({id:e,index:n}):(t[IN]=[{id:e,index:n}],t[FN]=t)}var VN=zN(`BufferService`),HN=zN(`CoreMouseService`),UN=zN(`CoreService`),WN=zN(`CharsetService`),GN=zN(`InstantiationService`),KN=zN(`LogService`),qN=zN(`OptionsService`),JN=zN(`OscLinkService`),YN=zN(`UnicodeService`),XN=zN(`DecorationService`),ZN=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 PN,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):QN(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)}};ZN=mN([X(0,VN),X(1,qN),X(2,JN)],ZN);function QN(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 $N=zN(`CharSizeService`),eP=zN(`CoreBrowserService`),tP=zN(`MouseService`),nP=zN(`RenderService`),rP=zN(`SelectionService`),iP=zN(`CharacterJoinerService`),aP=zN(`ThemeService`),oP=zN(`LinkProviderService`),sP=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?pP.isErrorNoTelemetry(e)?new pP(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 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(`
|
|
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 cP(e){uP(e)||sP.onUnexpectedError(e)}var lP=`Canceled`;function uP(e){return e instanceof dP||e instanceof Error&&e.name===lP&&e.message===lP}var dP=class extends Error{constructor(){super(lP),this.name=this.message}};function fP(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var pP=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`}},mP=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function hP(e,t=0){return e[e.length-(1+t)]}var gP;(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})(gP||={});var _P=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||gP.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};_P.empty=new _P(e=>{});function vP(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 yP;(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})(yP||={});var bP=null;function xP(e){return bP?.trackDisposable(e),e}function SP(e){bP?.markAsDisposed(e)}function CP(e,t){bP?.setParent(e,t)}function wP(e){return bP?.markAsSingleton(e),e}function TP(e){if(yP.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 EP(...e){return DP(()=>TP(e))}function DP(e){let t=xP({dispose:vP(()=>{SP(t),e()})});return t}var OP=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,xP(this)}dispose(){this._isDisposed||(SP(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{TP(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return CP(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),CP(e,null))}};OP.DISABLE_DISPOSED_WARNING=!1;var kP=OP,AP=class{constructor(){this._store=new kP,xP(this),CP(this._store,this)}dispose(){SP(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};AP.None=Object.freeze({dispose(){}});var jP=class{constructor(){this._isDisposed=!1,xP(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&CP(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,SP(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&CP(e,null),e}},MP=typeof window==`object`?window:globalThis,NP=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};NP.Undefined=new NP(void 0);var PP=NP,FP=class{constructor(){this._first=PP.Undefined,this._last=PP.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===PP.Undefined}clear(){let e=this._first;for(;e!==PP.Undefined;){let t=e.next;e.prev=PP.Undefined,e.next=PP.Undefined,e=t}this._first=PP.Undefined,this._last=PP.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new PP(e);if(this._first===PP.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!==PP.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==PP.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==PP.Undefined&&e.next!==PP.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===PP.Undefined&&e.next===PP.Undefined?(this._first=PP.Undefined,this._last=PP.Undefined):e.next===PP.Undefined?(this._last=this._last.prev,this._last.next=PP.Undefined):e.prev===PP.Undefined&&(this._first=this._first.next,this._first.prev=PP.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==PP.Undefined;)yield e.element,e=e.next}},IP=globalThis.performance&&typeof globalThis.performance.now==`function`,LP=class e{static create(t){return new e(t)}constructor(e){this._now=IP&&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}},RP;(e=>{e.None=()=>AP.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(EP(...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 kP?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=D})(RP||={});var zP=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 LP,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}}};zP.all=new Set,zP._idPool=0;var BP=zP,VP=-1,HP=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 GP(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}};HP._idPool=1;var UP=HP,WP=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
|
-
`))}},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
|
|
4296
|
+
`))}},GP=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},KP=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},qP=0,JP=class{constructor(e){this.value=e,this.id=qP++}},YP=2,Z=class{constructor(e){this._size=0,this._options=e,this._leakageMon=VP>0||this._options?.leakWarningThreshold?new UP(e?.onListenerError??cP,this._options?.leakWarningThreshold??VP):void 0,this._perfMon=this._options?._profName?new BP(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 KP(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||cP)(n),AP.None}if(this._disposed)return AP.None;t&&(e=e.bind(t));let r=new JP(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=WP.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof JP?(this._deliveryQueue??=new XP,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=DP(()=>{i?.(),this._removeListener(r)});return n instanceof kP?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*YP<=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||cP;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 JP)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}},XP=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}},ZP=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}};ZP.INSTANCE=new ZP;var QP=ZP;function $P(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}QP.INSTANCE.onDidChangeZoomLevel;function eF(e){return QP.INSTANCE.getZoomFactor(e)}QP.INSTANCE.onDidChangeFullscreen;var tF=typeof navigator==`object`?navigator.userAgent:``,nF=tF.indexOf(`Firefox`)>=0,rF=tF.indexOf(`AppleWebKit`)>=0,iF=tF.indexOf(`Chrome`)>=0,aF=!iF&&tF.indexOf(`Safari`)>=0;tF.indexOf(`Electron/`),tF.indexOf(`Android`);var oF=!1;if(typeof MP.matchMedia==`function`){let e=MP.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=MP.matchMedia(`(display-mode: fullscreen)`);oF=e.matches,$P(MP,e,({matches:e})=>{oF&&t.matches||(oF=e)})}function sF(){return oF}var cF=`en`,lF=!1,uF=!1,dF=!1,fF=!1,pF=!1,mF=cF,hF,gF=globalThis,_F;typeof gF.vscode<`u`&&typeof gF.vscode.process<`u`?_F=gF.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(_F=process);var vF=typeof _F?.versions?.electron==`string`&&_F?.type===`renderer`;if(typeof _F==`object`){lF=_F.platform===`win32`,uF=_F.platform===`darwin`,dF=_F.platform===`linux`,dF&&_F.env.SNAP&&_F.env.SNAP_REVISION,_F.env.CI||_F.env.BUILD_ARTIFACTSTAGINGDIRECTORY,mF=cF;let e=_F.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,mF=t.resolvedLanguage||cF,t.languagePack?.translationsConfigFile}catch{}fF=!0}else typeof navigator==`object`&&!vF?(hF=navigator.userAgent,lF=hF.indexOf(`Windows`)>=0,uF=hF.indexOf(`Macintosh`)>=0,(hF.indexOf(`Macintosh`)>=0||hF.indexOf(`iPad`)>=0||hF.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,dF=hF.indexOf(`Linux`)>=0,hF?.indexOf(`Mobi`),pF=!0,mF=globalThis._VSCODE_NLS_LANGUAGE||cF,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var yF=lF,bF=uF,xF=dF,SF=fF;pF&&typeof gF.importScripts==`function`&&gF.origin;var CF=hF,wF=mF,TF;(e=>{function t(){return wF}e.value=t;function n(){return wF.length===2?wF===`en`:wF.length>=3&&wF[0]===`e`&&wF[1]===`n`&&wF[2]===`-`}e.isDefaultVariant=n;function r(){return wF===`en`}e.isDefault=r})(TF||={});var EF=typeof gF.postMessage==`function`&&!gF.importScripts;(()=>{if(EF){let e=[];gF.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}),gF.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var DF=!!(CF&&CF.indexOf(`Chrome`)>=0);CF&&CF.indexOf(`Firefox`),!DF&&CF&&CF.indexOf(`Safari`),CF&&CF.indexOf(`Edg/`),CF&&CF.indexOf(`Android`);var OF=typeof navigator==`object`?navigator:{};SF||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||OF&&OF.clipboard&&OF.clipboard.writeText,SF||OF&&OF.clipboard&&OF.clipboard.readText,SF||sF()||OF.keyboard,`ontouchstart`in MP||OF.maxTouchPoints,MP.PointerEvent&&(`ontouchstart`in MP||navigator.maxTouchPoints);var kF=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}},AF=new kF,jF=new kF,MF=new kF,NF=Array(230),PF;(e=>{function t(e){return AF.keyCodeToStr(e)}e.toString=t;function n(e){return AF.strToKeyCode(e)}e.fromString=n;function r(e){return jF.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return MF.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return jF.strToKeyCode(e)||MF.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 AF.keyCodeToStr(e)}e.toElectronAccelerator=o})(PF||={});var FF=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 IF([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},IF=class{constructor(e){if(e.length===0)throw fP(`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 LF(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return PF.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(nF)switch(t){case 59:return 85;case 60:if(xF)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(bF)return 57}else if(rF&&(bF&&t===93||!bF&&t===92))return 57;return NF[t]||0}var RF=bF?256:2048,zF=512,BF=1024,VF=bF?2048:256,HF=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=LF(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|=RF),this.altKey&&(t|=zF),this.shiftKey&&(t|=BF),this.metaKey&&(t|=VF),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new FF(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},UF=new WeakMap;function WF(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 GF=class{static getSameOriginWindowChain(e){let t=UF.get(e);if(!t){t=[],UF.set(e,t);let n=e,r;do r=WF(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}}},KF=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=GF.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},qF=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(iF){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?nF&&!bF?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=aF&&yF?-(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?nF&&!bF?-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()}},JF=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),YF;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof XF?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:RP.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:JF})})(YF||={});var XF=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?JF:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ZF=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 mP(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new mP(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},QF=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 mP(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=DP(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var $F;(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})($F||={});var eI=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 RP.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())}};eI.EMPTY=eI.fromArray([]);function tI(e){return nI(e,0)}function nI(e,t){switch(typeof e){case`object`:return e===null?rI(349,t):Array.isArray(e)?oI(e,t):sI(e,t);case`string`:return aI(e,t);case`boolean`:return iI(e,t);case`number`:return rI(e,t);case`undefined`:return rI(937,t);default:return rI(617,t)}}function rI(e,t){return(t<<5)-t+e|0}function iI(e,t){return rI(e?433:863,t)}function aI(e,t){t=rI(149417,t);for(let n=0,r=e.length;n<r;n++)t=rI(e.charCodeAt(n),t);return t}function oI(e,t){return t=rI(104579,t),e.reduce((e,t)=>nI(t,e),t)}function sI(e,t){return t=rI(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=aI(n,t),nI(e[n],t)),t)}var{registerWindow:cI,getWindow:lI,getDocument:uI,getWindows:dI,getWindowsCount:fI,getWindowId:pI,getWindowById:mI,hasWindow:hI,onDidRegisterWindow:gI,onWillUnregisterWindow:_I,onDidUnregisterWindow:vI}=function(){let e=new Map,t={window:MP,disposables:new kP};e.set(MP.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 AP.None;let a=new kP,o={window:t,disposables:a.add(new kP)};return e.set(t.vscodeWindowId,o),a.add(DP(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(bI(t,kI.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:MP},getDocument(e){return lI(e).document}}}(),yI=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 bI(e,t,n,r){return new yI(e,t,n,r)}function xI(e,t){return function(n){return t(new KF(e,n))}}function SI(e){return function(t){return e(new HF(t))}}var CI=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=xI(lI(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=SI(n)),bI(e,t,i,r)},wI,TI=class extends QF{constructor(e){super(),this.defaultTarget=e&&lI(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},EI=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){cP(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(EI.sort),a.shift().execute();r.set(i,!1)};wI=(t,r,a=0)=>{let o=pI(t),s=new EI(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 DI=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}};DI.None=new DI(0,0);function OI(e){let t=e.getBoundingClientRect(),n=lI(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=tI(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(DP(()=>{--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 kI={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:rF?`webkitAnimationStart`:`animationstart`,ANIMATION_END:rF?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:rF?`webkitAnimationIteration`:`animationiteration`},AI=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=jI(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=jI(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=jI(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=jI(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=jI(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=jI(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=jI(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=jI(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=jI(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=jI(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=jI(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=jI(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=jI(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=jI(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 jI(e){return typeof e==`number`?`${e}px`:e}function MI(e){return new AI(e)}var NI=class{constructor(){this._hooks=new kP,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(DP(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=lI(e)}this._hooks.add(bI(a,kI.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(bI(a,kI.POINTER_UP,e=>this.stopMonitoring(!0)))}};function PI(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 FI;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(FI||={});var II=class e extends AP{constructor(){super(),this.dispatched=!1,this.targets=new FP,this.ignoreTargets=new FP,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(RP.runAndSubscribe(gI,({window:e,disposables:t})=>{t.add(bI(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(bI(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(bI(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:MP,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=wP(new e),DP(e.INSTANCE.targets.push(t))):AP.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=wP(new e),DP(e.INSTANCE.ignoreTargets.push(t))):AP.None}static isTouchDevice(){return`ontouchstart`in MP||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(FI.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-hP(s.rollingPageX))<30&&Math.abs(s.initialPageY-hP(s.rollingPageY))<30){let e=this.newGestureEvent(FI.Tap,s.initialTarget);e.pageX=hP(s.rollingPageX),e.pageY=hP(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-hP(s.rollingPageX))<30&&Math.abs(s.initialPageY-hP(s.rollingPageY))<30){let e=this.newGestureEvent(FI.Contextmenu,s.initialTarget);e.pageX=hP(s.rollingPageX),e.pageY=hP(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=hP(s.rollingPageX),n=hP(s.rollingPageY),i=hP(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(FI.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===FI.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===FI.Change||t.type===FI.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=wI(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(FI.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(FI.Change,i.initialTarget);a.translationX=r.pageX-hP(i.rollingPageX),a.translationY=r.pageY-hP(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)}};II.SCROLL_FRICTION=-.005,II.HOLD_DELAY=700,II.CLEAR_TAP_COUNT_TIME=400,mN([PI],II,`isTouchDevice`,1);var LI=II,RI=class extends AP{onclick(e,t){this._register(bI(e,kI.CLICK,n=>t(new KF(lI(e),n))))}onmousedown(e,t){this._register(bI(e,kI.MOUSE_DOWN,n=>t(new KF(lI(e),n))))}onmouseover(e,t){this._register(bI(e,kI.MOUSE_OVER,n=>t(new KF(lI(e),n))))}onmouseleave(e,t){this._register(bI(e,kI.MOUSE_LEAVE,n=>t(new KF(lI(e),n))))}onkeydown(e,t){this._register(bI(e,kI.KEY_DOWN,e=>t(new HF(e))))}onkeyup(e,t){this._register(bI(e,kI.KEY_UP,e=>t(new HF(e))))}oninput(e,t){this._register(bI(e,kI.INPUT,t))}onblur(e,t){this._register(bI(e,kI.BLUR,t))}onfocus(e,t){this._register(bI(e,kI.FOCUS,t))}onchange(e,t){this._register(bI(e,kI.CHANGE,t))}ignoreGesture(e){return LI.ignoreTarget(e)}},zI=11,BI=class extends RI{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=zI+`px`,this.domNode.style.height=zI+`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 NI),this._register(CI(this.bgDomNode,kI.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(CI(this.domNode,kI.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new TI),this._pointerdownScheduleRepeatTimer=this._register(new ZF)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,lI(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},VI=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}}},HI=class extends AP{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 VI(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 KI(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=KI.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)))}},UI=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function WI(e,t){let n=t-e;return function(t){return e+n*JI(t)}}function GI(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var KI=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),GI(WI(e,r),WI(i,t),.33)}return WI(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 UI(this.scrollLeft(t),this.scrollTop(t),!1):new UI(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 qI(e){return e**3}function JI(e){return 1-qI(1-e)}var YI=class extends AP{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 ZF)}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`:``)))}},XI=140,ZI=class extends RI{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 YI(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new NI),this._shouldRender=!0,this.domNode=MI(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(bI(this.domNode.domNode,kI.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new BI(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=MI(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(bI(this.slider.domNode,kI.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=OI(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(yF&&a>XI){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()}},QI=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)}},$I=class extends ZI{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new QI(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}},eL=class extends ZI{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new QI(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}},tL=500,nL=50,rL=!0,iL=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},aL=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(iF){let t=eF(lI(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 iL(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}};aL.INSTANCE=new aL;var oL=aL,sL=class extends RI{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=lL(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 eL(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new $I(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=MI(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=MI(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=MI(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 ZF),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=TP(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,bF&&(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 qF(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=TP(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(bI(this._listenOnDomNode,kI.MOUSE_WHEEL,e=>{this._onMouseWheel(new qF(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=oL.INSTANCE;rL&&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=!bF&&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=nL*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=nL*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)&&(rL&&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(),tL)}},cL=class extends sL{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 lL(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,bF&&(t.className+=` mac`),t}var uL=class extends AP{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 HI({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>wI(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new cL(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(RP.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(DP(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(DP(()=>this._styleElement.remove())),this._register(RP.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}};uL=mN([X(2,VN),X(3,eP),X(4,HN),X(5,aP),X(6,qN),X(7,nP)],uL);var dL=class extends AP{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(DP(()=>{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()}};dL=mN([X(1,VN),X(2,eP),X(3,XN),X(4,nP)],dL);var fL=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)}},pL={full:0,left:0,center:0,right:0},mL={full:0,left:0,center:0,right:0},hL={full:0,left:0,center:0,right:0},gL=class extends AP{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 fL,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(DP(()=>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);mL.full=this._canvas.width,mL.left=e,mL.center=t,mL.right=e,this._refreshDrawHeightConstants(),hL.full=1,hL.left=1,hL.center=1+mL.left,hL.right=1+mL.left+mL.center}_refreshDrawHeightConstants(){pL.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);pL.left=t,pL.center=t,pL.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pL.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pL.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pL.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*pL.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(hL[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-pL[e.position||`full`]/2),mL[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+pL[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}))}};gL=mN([X(2,VN),X(3,XN),X(4,nP),X(5,qN),X(6,aP),X(7,eP)],gL);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 _L;(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=``))(_L||={});var vL;(e=>e.ST=`${Q.ESC}\\`)(vL||={});var yL=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)}}};yL=mN([X(2,VN),X(3,qN),X(4,UN),X(5,nP)],yL);var bL=0,xL=0,SL=0,CL=0,wL={css:`#00000000`,rgba:0},TL;(e=>{function t(e,t,n,r){return r===void 0?`#${AL(e)}${AL(t)}${AL(n)}`:`#${AL(e)}${AL(t)}${AL(n)}${AL(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})(TL||={});var EL;(e=>{function t(e,t){if(CL=(t.rgba&255)/255,CL===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 bL=a+Math.round((n-a)*CL),xL=o+Math.round((r-o)*CL),SL=s+Math.round((i-s)*CL),{css:TL.toCss(bL,xL,SL),rgba:TL.toRgba(bL,xL,SL)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=kL.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return TL.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[bL,xL,SL]=kL.toChannels(t),{css:TL.toCss(bL,xL,SL),rgba:t}}e.opaque=i;function a(e,t){return CL=Math.round(t*255),[bL,xL,SL]=kL.toChannels(e.rgba),{css:TL.toCss(bL,xL,SL,CL),rgba:TL.toRgba(bL,xL,SL,CL)}}e.opacity=a;function o(e,t){return CL=e.rgba&255,a(e,CL*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(EL||={});var DL;(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 bL=parseInt(e.slice(1,2).repeat(2),16),xL=parseInt(e.slice(2,3).repeat(2),16),SL=parseInt(e.slice(3,4).repeat(2),16),TL.toColor(bL,xL,SL);case 5:return bL=parseInt(e.slice(1,2).repeat(2),16),xL=parseInt(e.slice(2,3).repeat(2),16),SL=parseInt(e.slice(3,4).repeat(2),16),CL=parseInt(e.slice(4,5).repeat(2),16),TL.toColor(bL,xL,SL,CL);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 bL=parseInt(r[1]),xL=parseInt(r[2]),SL=parseInt(r[3]),CL=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),TL.toColor(bL,xL,SL,CL);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[bL,xL,SL,CL]=t.getImageData(0,0,1,1).data,CL!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:TL.toRgba(bL,xL,SL,CL),css:e}}e.toColor=r})(DL||={});var OL;(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})(OL||={});var kL;(e=>{function t(e,t){if(CL=(t&255)/255,CL===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 bL=a+Math.round((n-a)*CL),xL=o+Math.round((r-o)*CL),SL=s+Math.round((i-s)*CL),TL.toRgba(bL,xL,SL)}e.blend=t;function n(e,t,n){let a=OL.relativeLuminance(e>>8),o=OL.relativeLuminance(t>>8);if(jL(a,o)<n){if(o<a){let o=r(e,t,n),s=jL(a,OL.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>jL(a,OL.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=jL(a,OL.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>jL(a,OL.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=jL(OL.relativeLuminance2(o,s,c),OL.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=jL(OL.relativeLuminance2(o,s,c),OL.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=jL(OL.relativeLuminance2(o,s,c),OL.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=jL(OL.relativeLuminance2(o,s,c),OL.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})(kL||={});function AL(e){let t=e.toString(16);return t.length<2?`0`+t:t}function jL(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var ML=class extends MN{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()]}},NL=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new PN}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||jN.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++)NL._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||jN.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}};NL=mN([X(0,VN)],NL);function PL(e){return 57508<=e&&e<=57558}function FL(e){return 9472<=e&&e<=9631}function IL(e){return PL(e)||FL(e)}function LL(){return{css:{canvas:RL(),cell:RL()},device:{canvas:RL(),cell:RL(),char:{width:0,height:0,left:0,top:0}}}}function RL(){return{width:0,height:0}}var zL=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 PN,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 ML(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()||jN;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()?_+=jN:_+=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()?jN:N.getChars()||jN,N.isUnderline()&&(D.push(`xterm-underline-${N.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!N.isUnderlineColorDefault())){if(N.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${MN.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=TL.toColor(oe>>16,oe>>8&255,oe&255),this._addStyle(h,`background-color:#${BL((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=EL.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=TL.toColor(ie>>16&255,ie>>8&255,ie&255);this._applyMinimumContrast(h,fe,e,N,le,ue)||this._addStyle(h,`color:#${BL(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||IL(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=EL.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]}};zL=mN([X(1,iP),X(2,qN),X(3,eP),X(4,UN),X(5,XN),X(6,aP)],zL);function BL(e,t,n){for(;e.length<n;)e=t+e;return e}var VL=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}},HL=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 UL(){return new HL}var WL=`xterm-dom-renderer-owner-`,GL=`xterm-rows`,KL=`xterm-fg-`,qL=`xterm-bg-`,JL=`xterm-focus`,YL=`xterm-selection`,XL=1,ZL=class extends AP{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=XL++,this._rowElements=[],this._selectionRenderModel=UL(),this.onRequestRedraw=this._register(new Z).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(GL),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(YL),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=LL(),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(zL,document),this._element.classList.add(WL+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(DP(()=>{this._element.classList.remove(WL+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new VL(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} .${GL} 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} .${GL} { 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} .${GL} .xterm-dim { color: ${EL.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} .${GL}.${JL} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${GL}.${JL} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${GL}.${JL} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${GL} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${GL} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${GL} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${GL} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${GL} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${YL} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${YL} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${YL} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${KL}${n} { color: ${r.css}; }${this._terminalSelector} .${KL}${n}.xterm-dim { color: ${EL.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${qL}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${KL}257 { color: ${EL.opaque(e.background).css}; }${this._terminalSelector} .${KL}257.xterm-dim { color: ${EL.multiplyOpacity(EL.opaque(e.background),.5).css}; }${this._terminalSelector} .${qL}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(JL),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(JL),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`.${WL}${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))}}};ZL=mN([X(7,GN),X(8,$N),X(9,qN),X(10,VN),X(11,UN),X(12,eP),X(13,aP)],ZL);var QL=class extends AP{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 tR(this._optionsService))}catch{this._measureStrategy=this._register(new eR(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())}};QL=mN([X(2,qN)],QL);var $L=class extends AP{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)}},eR=class extends $L{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}},tR=class extends $L{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}},nR=class extends AP{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 rR(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(RP.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(bI(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(bI(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}},rR=class extends AP{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new jP),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(DP(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=bI(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)}},iR=class extends AP{constructor(){super(),this.linkProviders=[],this._register(DP(()=>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 aR(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 oR(e,t,n,r,i,a,o,s,c){if(!a)return;let l=aR(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 sR=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return oR(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=aR(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])}}};sR=mN([X(0,nP),X(1,$N)],sR);var cR=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=[]}},lR={};pN(lR,{getSafariVersion:()=>gR,isChromeOS:()=>SR,isFirefox:()=>pR,isIpad:()=>vR,isIphone:()=>yR,isLegacyEdge:()=>mR,isLinux:()=>xR,isMac:()=>_R,isNode:()=>uR,isSafari:()=>hR,isWindows:()=>bR});var uR=typeof process<`u`&&`title`in process,dR=uR?`node`:navigator.userAgent,fR=uR?`node`:navigator.platform,pR=dR.includes(`Firefox`),mR=dR.includes(`Edge`),hR=/^((?!chrome|android).)*safari/i.test(dR);function gR(){if(!hR)return 0;let e=dR.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var _R=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(fR),vR=fR===`iPad`,yR=fR===`iPhone`,bR=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(fR),xR=fR.indexOf(`Linux`)>=0,SR=/\bCrOS\b/.test(dR),CR=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()}},wR=class extends CR{_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())}}},TR=class extends CR{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ER=!uR&&`requestIdleCallback`in window?TR:wR,DR=class{constructor(){this._queue=new ER}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},OR=class extends AP{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 jP),this._pausedResizeTask=new DR,this._observerDisposable=this._register(new jP),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 cR((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new kR(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(DP(()=>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=DP(()=>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()}};OR=mN([X(2,qN),X(3,$N),X(4,UN),X(5,XN),X(6,VN),X(7,eP),X(8,aP)],OR);var kR=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 AR(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return NR(i,a,e,t,n,r)+PR(a,t,n,r)+FR(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,HR(Math.abs(i-e),VR(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return HR(MR(a>t?e:i,n)+(s-1)*n.cols+1+jR(a>t?i:e,n),VR(o,r))}function jR(e,t){return e-1}function MR(e,t){return t.cols-e}function NR(e,t,n,r,i,a){return PR(t,r,i,a).length===0?``:HR(BR(e,t,e,t-LR(t,i),!1,i).length,VR(`D`,a))}function PR(e,t,n,r){let i=e-LR(e,n),a=t-LR(t,n);return HR(Math.abs(i-a)-IR(e,t,n),VR(zR(e,t),r))}function FR(e,t,n,r,i,a){let o;o=PR(t,r,i,a).length>0?r-LR(r,i):t;let s=r,c=RR(e,t,n,r,i,a);return HR(BR(e,o,n,s,c===`C`,i).length,VR(c,a))}function IR(e,t,n){let r=0,i=e-LR(e,n),a=t-LR(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=zR(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function LR(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 RR(e,t,n,r,i,a){let o;return o=PR(n,r,i,a).length>0?r-LR(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function zR(e,t){return e>t?`A`:`B`}function BR(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 VR(e,t){let n=t?`O`:`[`;return Q.ESC+n+e}function HR(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var UR=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 WR(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 GR=50,KR=15,qR=50,JR=500,YR=RegExp(`\xA0`,`g`),XR=class extends AP{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 PN,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 UR(this._bufferService),this._activeSelectionMode=0,this._register(DP(()=>{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(YR,` `)).join(bR?`\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()),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(
|
|
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=`
|
|
4300
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),xR&&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=WR(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=aR(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,-GR),GR),t/=GR,t/Math.abs(t)+Math.round(t*(KR-1)))}shouldForceSelection(e){return _R?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(),qR)}_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&&!(_R&&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<JR&&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=AR(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=WR(n,this._bufferService.cols)}};XR=mN([X(3,VN),X(4,UN),X(5,tP),X(6,qN),X(7,nP),X(8,eP)],XR);var ZR=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={}}},QR=class{constructor(){this._color=new ZR,this._css=new ZR}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()}},$R=Object.freeze((()=>{let e=[DL.toColor(`#2e3436`),DL.toColor(`#cc0000`),DL.toColor(`#4e9a06`),DL.toColor(`#c4a000`),DL.toColor(`#3465a4`),DL.toColor(`#75507b`),DL.toColor(`#06989a`),DL.toColor(`#d3d7cf`),DL.toColor(`#555753`),DL.toColor(`#ef2929`),DL.toColor(`#8ae234`),DL.toColor(`#fce94f`),DL.toColor(`#729fcf`),DL.toColor(`#ad7fa8`),DL.toColor(`#34e2e2`),DL.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:TL.toCss(r,i,a),rgba:TL.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:TL.toCss(n,n,n),rgba:TL.toRgba(n,n,n)})}return e})()),ez=DL.toColor(`#ffffff`),tz=DL.toColor(`#000000`),nz=DL.toColor(`#ffffff`),rz=tz,iz={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},az=ez,oz=class extends AP{constructor(e){super(),this._optionsService=e,this._contrastCache=new QR,this._halfContrastCache=new QR,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ez,background:tz,cursor:nz,cursorAccent:rz,selectionForeground:void 0,selectionBackgroundTransparent:iz,selectionBackgroundOpaque:EL.blend(tz,iz),selectionInactiveBackgroundTransparent:iz,selectionInactiveBackgroundOpaque:EL.blend(tz,iz),scrollbarSliderBackground:EL.opacity(ez,.2),scrollbarSliderHoverBackground:EL.opacity(ez,.4),scrollbarSliderActiveBackground:EL.opacity(ez,.5),overviewRulerBorder:ez,ansi:$R.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=sz(e.foreground,ez),t.background=sz(e.background,tz),t.cursor=EL.blend(t.background,sz(e.cursor,nz)),t.cursorAccent=EL.blend(t.background,sz(e.cursorAccent,rz)),t.selectionBackgroundTransparent=sz(e.selectionBackground,iz),t.selectionBackgroundOpaque=EL.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=sz(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=EL.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?sz(e.selectionForeground,wL):void 0,t.selectionForeground===wL&&(t.selectionForeground=void 0),EL.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=EL.opacity(t.selectionBackgroundTransparent,.3)),EL.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=EL.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=sz(e.scrollbarSliderBackground,EL.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=sz(e.scrollbarSliderHoverBackground,EL.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=sz(e.scrollbarSliderActiveBackground,EL.opacity(t.foreground,.5)),t.overviewRulerBorder=sz(e.overviewRulerBorder,az),t.ansi=$R.slice(),t.ansi[0]=sz(e.black,$R[0]),t.ansi[1]=sz(e.red,$R[1]),t.ansi[2]=sz(e.green,$R[2]),t.ansi[3]=sz(e.yellow,$R[3]),t.ansi[4]=sz(e.blue,$R[4]),t.ansi[5]=sz(e.magenta,$R[5]),t.ansi[6]=sz(e.cyan,$R[6]),t.ansi[7]=sz(e.white,$R[7]),t.ansi[8]=sz(e.brightBlack,$R[8]),t.ansi[9]=sz(e.brightRed,$R[9]),t.ansi[10]=sz(e.brightGreen,$R[10]),t.ansi[11]=sz(e.brightYellow,$R[11]),t.ansi[12]=sz(e.brightBlue,$R[12]),t.ansi[13]=sz(e.brightMagenta,$R[13]),t.ansi[14]=sz(e.brightCyan,$R[14]),t.ansi[15]=sz(e.brightWhite,$R[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]=sz(e.extendedAnsi[r],$R[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()}}};oz=mN([X(0,qN)],oz);function sz(e,t){if(e!==void 0)try{return DL.toColor(e)}catch{}return t}var cz=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)}},lz=class{constructor(){this._services=new cz,this._services.set(GN,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=RN(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)}},uz={trace:0,debug:1,info:2,warn:3,error:4,off:5},dz=`xterm.js: `,fz=class extends AP{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),pz=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=uz[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?``:dz)+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)}};fz=mN([X(0,qN)],fz);var pz,mz=class extends AP{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}},hz=3,gz=Object.freeze(new MN),_z=0,vz=2,yz=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*hz);let r=t||PN.fromCharData([0,AN,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*hz+0],n=t&2097151;return[this._data[e*hz+1],t&2097152?this._combined[e]:n?EN(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*hz+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*hz+0]=e|2097152|t[2]<<22):this._data[e*hz+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*hz+0]>>22}hasWidth(e){return this._data[e*hz+0]&12582912}getFg(e){return this._data[e*hz+1]}getBg(e){return this._data[e*hz+2]}hasContent(e){return this._data[e*hz+0]&4194303}getCodePoint(e){let t=this._data[e*hz+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*hz+0]&2097152}getString(e){let t=this._data[e*hz+0];return t&2097152?this._combined[e]:t&2097151?EN(t&2097151):``}isProtected(e){return this._data[e*hz+2]&536870912}loadCell(e,t){return _z=e*hz,t.content=this._data[_z+0],t.fg=this._data[_z+1],t.bg=this._data[_z+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*hz+0]=t.content,this._data[e*hz+1]=t.fg,this._data[e*hz+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*hz+0]=t|n<<22,this._data[e*hz+1]=r.fg,this._data[e*hz+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*hz+0];r&2097152?this._combined[e]+=EN(t):r&2097151?(this._combined[e]=EN(r&2097151)+EN(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*hz+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 PN;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 PN;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*vz<this._data.buffer.byteLength;let n=e*hz;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*vz<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*vz<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*hz+0]&4194303)return e+(this._data[e*hz+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*hz+0]&4194303||this._data[e*hz+2]&50331648)return e+(this._data[e*hz+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<hz;e++)this._data[(n+i)*hz+e]=a[(t+i)*hz+e];a[(t+i)*hz+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<hz;e++)this._data[(n+i)*hz+e]=a[(t+i)*hz+e];a[(t+i)*hz+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*hz+0],n=e&2097151,a=e&2097152?this._combined[t]:n?EN(n):jN;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 bz(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=wz(u,d,t),p=1,m=0;for(;p<u.length;){let e=wz(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 xz(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 Sz(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 Cz(e,t,n){let r=[],i=e.map((n,r)=>wz(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=wz(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 wz(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 Tz=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(),TP(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Tz._nextId=1;var Ez=Tz,Dz={},Oz=Dz.B;Dz[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},Dz.A={"#":`£`},Dz.B=void 0,Dz[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},Dz.C=Dz[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Dz.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},Dz.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},Dz.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},Dz.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},Dz.E=Dz[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},Dz.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},Dz.H=Dz[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Dz[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var kz=4294967295,Az=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=gz.clone(),this.savedCharset=Oz,this.markers=[],this._nullCell=PN.fromCharData([0,AN,1,0]),this._whitespaceCell=PN.fromCharData([0,jN,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ER,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new mz(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 NN),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 NN),this._whitespaceCell}getBlankLine(e,t){return new yz(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>kz?kz:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=gz);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 mz(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(gz),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 yz(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 yz(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=bz(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(gz),n);if(r.length>0){let n=xz(this.lines,r);Sz(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(gz),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new yz(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(gz),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=Cz(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(gz,!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--,_=wz(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 Ez(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)}},jz=class extends AP{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 Az(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Az(!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)}},Mz=2,Nz=1,Pz=class extends AP{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,Mz),this.rows=Math.max(e.rawOptions.rows||0,Nz),this.buffers=this._register(new jz(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))}};Pz=mN([X(0,qN)],Pz);var Fz={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:_R,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Iz=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Lz=class extends AP{constructor(e){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let t={...Fz};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(DP(()=>{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 Fz))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Fz))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||=Fz[e],!Rz(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Fz[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Iz.includes(t)?t:Fz[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 Rz(e){return e===`block`||e===`underline`||e===`bar`}function zz(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]&&zz(e[r],t-1);return n}var Bz=Object.freeze({insertMode:!1}),Vz=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Hz=class extends AP{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=zz(Bz),this.decPrivateModes=zz(Vz)}reset(){this.modes=zz(Bz),this.decPrivateModes=zz(Vz)}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))}};Hz=mN([X(0,VN),X(1,KN),X(2,qN)],Hz);var Uz={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 Wz(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 Gz=String.fromCharCode,Kz={DEFAULT:e=>{let t=[Wz(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Gz(t[0])}${Gz(t[1])}${Gz(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Wz(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Wz(e,!0)};${e.x};${e.y}${t}`}},qz=class extends AP{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(Uz))this.addProtocol(e,Uz[e]);for(let e of Object.keys(Kz))this.addEncoding(e,Kz[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}};qz=mN([X(0,VN),X(1,UN),X(2,qN)],qz);var Jz=[[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]],Yz=[[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]],Xz;function Zz(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 Qz=class{constructor(){if(this.version=`6`,!Xz){Xz=new Uint8Array(65536),Xz.fill(1),Xz[0]=0,Xz.fill(0,1,32),Xz.fill(0,127,160),Xz.fill(2,4352,4448),Xz[9001]=2,Xz[9002]=2,Xz.fill(2,11904,42192),Xz[12351]=1,Xz.fill(2,44032,55204),Xz.fill(2,63744,64256),Xz.fill(2,65040,65050),Xz.fill(2,65072,65136),Xz.fill(2,65280,65377),Xz.fill(2,65504,65511);for(let e=0;e<Jz.length;++e)Xz.fill(0,Jz[e][0],Jz[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Xz[e]:Zz(e,Yz)?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=$z.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return $z.createPropertyValue(0,n,r)}},$z=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Z,this.onChange=this._onChange.event;let e=new Qz;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)}},eB=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 tB(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 nB=2147483647,rB=256,iB=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>rB)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>nB?nB: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>nB?nB: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,nB):e}},aB=[],oB=class{constructor(){this._state=0,this._active=aB,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=aB}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=aB,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||aB,!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`,DN(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=aB,this._id=-1,this._state=0}}},sB=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+=DN(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}},cB=[],lB=class{constructor(){this._handlers=Object.create(null),this._active=cB,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=cB}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=cB,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||cB,!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`,DN(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=cB,this._ident=0}},uB=new iB;uB.addParam(0);var dB=class{constructor(e){this._handler=e,this._data=``,this._params=uB,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():uB,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=DN(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=uB,this._data=``,this._hitLimit=!1,e));return this._params=uB,this._data=``,this._hitLimit=!1,t}},fB=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}},pB=160,mB=function(){let e=new fB(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(pB,0,2,0),e.add(pB,8,5,8),e.add(pB,6,0,6),e.add(pB,11,0,11),e.add(pB,13,13,13),e}(),hB=class extends AP{constructor(e=mB){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 iB,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(DP(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new oB),this._dcsParser=this._register(new lB),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:pB)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<pB){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<pB){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<pB){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<pB){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<pB){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<pB){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}}},gB=/^([\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})$/,_B=/^[\da-f]+$/;function vB(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=gB.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),_B.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 yB(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 bB(e,t=16){let[n,r,i]=e;return`rgb:${yB(n,t)}/${yB(r,t)}/${yB(i,t)}`}var xB={"(":0,")":1,"*":2,"+":3,"-":1,".":2},SB=131072,CB=10;function wB(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 TB=5e3,EB=0,DB=class extends AP{constructor(e,t,n,r,i,a,o,s,c=new hB){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 ON,this._utf8Decoder=new kN,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=gz.clone(),this._eraseAttrDataInternal=gz.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 OB(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(_L.IND,()=>this.index()),this._parser.setExecuteHandler(_L.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(_L.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new sB(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new sB(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new sB(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new sB(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new sB(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new sB(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new sB(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new sB(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new sB(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new sB(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new sB(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new sB(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 Dz)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 dB((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`),TB))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${TB} 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>SB&&(a=this._parseStack.position+SB)}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<SB&&(this._parseBuffer=new Uint32Array(Math.min(e.length,SB))),o||this._dirtyRowTracker.clearRange(),e.length>SB)for(let t=a;t<e.length;t+=SB){let a=t+SB<e.length?t+SB: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=$z.extractWidth(t);let n=$z.extractShouldJoin(t),m=n?$z.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(EN(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 yz&&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=>!wB(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new dB(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new sB(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(gz));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=$z.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,Oz),this._charsetService.setgCharset(1,Oz),this._charsetService.setgCharset(2,Oz),this._charsetService.setgCharset(3,Oz);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|=MN.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=gz.fg,e.bg=gz.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|=gz.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=gz.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|=gz.fg&16777215,r.bg&=-67108864,r.bg|=gz.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=gz.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(!wB(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>CB&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>CB&&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(kB(n)){if(r===`?`)t.push({type:0,index:n});else{let e=vB(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=vB(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]);kB(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,Oz),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(xB[e[0]],Dz[e[1]]||Oz),!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=gz.clone(),this._eraseAttrDataInternal=gz.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 PN;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)}},OB=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&&(EB=e,e=t,t=EB),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};OB=mN([X(0,VN)],OB);function kB(e){return 0<=e&&e<256}var AB=5e7,jB=12,MB=50,NB=class extends AP{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>AB)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>=jB?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>=jB)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>MB&&(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()}},PB=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)))}};PB=mN([X(0,VN)],PB);var FB=!1,IB=class extends AP{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new jP),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 lz,this.optionsService=this._register(new Lz(e)),this._instantiationService.setService(qN,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Pz)),this._instantiationService.setService(VN,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(fz)),this._instantiationService.setService(KN,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Hz)),this._instantiationService.setService(UN,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(qz)),this._instantiationService.setService(HN,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance($z)),this._instantiationService.setService(YN,this.unicodeService),this._charsetService=this._instantiationService.createInstance(eB),this._instantiationService.setService(WN,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(PB),this._instantiationService.setService(JN,this._oscLinkService),this._inputHandler=this._register(new DB(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(RP.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(RP.forward(this._bufferService.onResize,this._onResize)),this._register(RP.forward(this.coreService.onData,this._onData)),this._register(RP.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 NB((e,t)=>this._inputHandler.parse(e,t))),this._register(RP.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&&!FB&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),FB=!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,Mz),t=Math.max(t,Nz),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(tB.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(tB(this._bufferService),!1))),this._windowsWrappingHeuristics.value=DP(()=>{for(let t of e)t.dispose()})}}},LB={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 RB(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=LB[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 zB=0,BB=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ER,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ER,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||(zB=this._search(t),zB===-1)||this._getKey(this._array[zB])!==t)return!1;do if(this._array[zB]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(zB),!0;while(++zB<this._array.length&&this._getKey(this._array[zB])===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&&(zB=this._search(e),!(zB<0||zB>=this._array.length)&&this._getKey(this._array[zB])===e))do yield this._array[zB];while(++zB<this._array.length&&this._getKey(this._array[zB])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(zB=this._search(e),!(zB<0||zB>=this._array.length)&&this._getKey(this._array[zB])===e))do t(this._array[zB]);while(++zB<this._array.length&&this._getKey(this._array[zB])===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}},VB=0,HB=0,UB=class extends AP{constructor(){super(),this._decorations=new BB(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(DP(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new WB(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=>{VB=t.options.x??0,HB=VB+(t.options.width??1),e>=VB&&e<HB&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},WB=class extends kP{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?DL.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?DL.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},GB=1e3,KB=class{constructor(e,t=GB){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)}},qB=20,JB=class extends AP{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 KB(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(bI(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(DP(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<qB+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
4302
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===qB+1&&(this._liveRegion.textContent+=vN.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})`}};JB=mN([X(1,GN),X(2,eP),X(3,nP)],JB);var YB=class extends AP{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(DP(()=>{TP(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(bI(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(bI(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(bI(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(bI(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&&XB(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,TP(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}}};YB=mN([X(1,tP),X(2,nP),X(3,VN),X(4,oP)],YB);function XB(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 ZB=class extends IB{constructor(e={}){super(e),this._linkifier=this._register(new jP),this.browser=lR,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new jP),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(UB),this._instantiationService.setService(XN,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(iR),this._instantiationService.setService(oP,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ZN)),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(RP.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(RP.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(RP.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(RP.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(DP(()=>{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=EL.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${Q.ESC}]${n};${bB(r)}${vL.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=TL.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=TL.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(JB,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(bI(this.element,`copy`,e=>{this.hasSelection()&&xN(e,this._selectionService)}));let e=e=>SN(e,this.textarea,this.coreService,this.optionsService);this._register(bI(this.textarea,`paste`,e)),this._register(bI(this.element,`paste`,e)),pR?this._register(bI(this.element,`mousedown`,e=>{e.button===2&&TN(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(bI(this.element,`contextmenu`,e=>{TN(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),xR&&this._register(bI(this.element,`auxclick`,e=>{e.button===1&&wN(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(bI(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(bI(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(bI(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(bI(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(bI(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(bI(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(bI(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(bI(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`,gN.get()),SR||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(nR,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(eP,this._coreBrowserService),this._register(bI(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(bI(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(QL,this._document,this._helperContainer),this._instantiationService.setService($N,this._charSizeService),this._themeService=this._instantiationService.createInstance(oz),this._instantiationService.setService(aP,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(NL),this._instantiationService.setService(iP,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(OR,this.rows,this.screenElement)),this._instantiationService.setService(nP,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(yL,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(sR),this._instantiationService.setService(tP,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(YB,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(uL,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(XR,this.element,this.screenElement,r)),this._instantiationService.setService(rP,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(RP.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(dL,this.screenElement)),this._register(bI(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(JB,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gL,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(gL,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ZL,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(bI(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(bI(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){CN(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=RB(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)&&(QB(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(gz));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 QB(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var $B=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)}},eV=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 PN)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},tV=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 eV(t)}getNullCell(){return new PN}},nV=class extends AP{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new tV(this._core.buffers.normal,`normal`),this._alternate=new tV(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)}},rV=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)}},iV=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}},aV=[`cols`,`rows`],oV=0,sV=class extends AP{constructor(e){super(),this._core=this._register(new ZB(e)),this._addonManager=this._register(new $B),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(aV.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 rV(this._core),this._parser}get unicode(){return this._checkProposedApi(),new iV(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 nV(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 gN.get()},set promptLabel(e){gN.set(e)},get tooMuchOutput(){return vN.get()},set tooMuchOutput(e){vN.set(e)}}}_verifyIntegers(...e){for(oV of e)if(oV===1/0||isNaN(oV)||oV%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(oV of e)if(oV&&(oV===1/0||isNaN(oV)||oV%1!=0||oV<0))throw Error(`This API only accepts positive integers`)}},cV=2,lV=1,uV=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(cV,Math.floor(u/e.css.cell.width)),rows:Math.max(lV,Math.floor(l/e.css.cell.height))}}},dV=class{constructor(e,t,n,r={}){this._terminal=e,this._regex=t,this._handler=n,this._options=r}provideLinks(e,t){let n=pV.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 fV(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 pV=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(!fV(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]}},mV=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function hV(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 gV=class{constructor(e=hV,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||mV;this._linkProvider=this._terminal.registerLinkProvider(new dV(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}},_V={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 vV({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 sV({fontFamily:`'JetBrains Mono', Consolas, monospace`,fontSize:13,cursorBlink:!0,cursorInactiveStyle:`none`,scrollback:5e3,allowProposedApi:!0,scrollOnEraseInDisplay:!0,theme:_V}),a=new uV;r.loadAddon(a),r.loadAddon(new gV((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 yV(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var bV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,SV={};function CV(e,t){return((t||SV).jsx?xV:bV).test(e)}var wV=/[ \t\n\f\r]/g;function TV(e){return typeof e==`object`?e.type===`text`&&EV(e.value):EV(e)}function EV(e){return e.replace(wV,``)===``}var DV=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};DV.prototype.normal={},DV.prototype.property={},DV.prototype.space=void 0;function OV(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new DV(n,r,t)}function kV(e){return e.toLowerCase()}var AV=class{constructor(e,t){this.attribute=t,this.property=e}};AV.prototype.attribute=``,AV.prototype.booleanish=!1,AV.prototype.boolean=!1,AV.prototype.commaOrSpaceSeparated=!1,AV.prototype.commaSeparated=!1,AV.prototype.defined=!1,AV.prototype.mustUseProperty=!1,AV.prototype.number=!1,AV.prototype.overloadedBoolean=!1,AV.prototype.property=``,AV.prototype.spaceSeparated=!1,AV.prototype.space=void 0;var jV=s({boolean:()=>NV,booleanish:()=>PV,commaOrSpaceSeparated:()=>RV,commaSeparated:()=>LV,number:()=>$,overloadedBoolean:()=>FV,spaceSeparated:()=>IV}),MV=0,NV=zV(),PV=zV(),FV=zV(),$=zV(),IV=zV(),LV=zV(),RV=zV();function zV(){return 2**++MV}var BV=Object.keys(jV),VV=class extends AV{constructor(e,t,n,r){let i=-1;if(super(e,t),HV(this,`space`,r),typeof n==`number`)for(;++i<BV.length;){let e=BV[i];HV(this,BV[i],(n&jV[e])===jV[e])}}};VV.prototype.defined=!0;function HV(e,t,n){n&&(e[t]=n)}function UV(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new VV(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[kV(r)]=r,n[kV(a.attribute)]=r}return new DV(t,n,e.space)}var WV=UV({properties:{ariaActiveDescendant:null,ariaAtomic:PV,ariaAutoComplete:null,ariaBusy:PV,ariaChecked:PV,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:IV,ariaCurrent:null,ariaDescribedBy:IV,ariaDetails:null,ariaDisabled:PV,ariaDropEffect:IV,ariaErrorMessage:null,ariaExpanded:PV,ariaFlowTo:IV,ariaGrabbed:PV,ariaHasPopup:null,ariaHidden:PV,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:IV,ariaLevel:$,ariaLive:null,ariaModal:PV,ariaMultiLine:PV,ariaMultiSelectable:PV,ariaOrientation:null,ariaOwns:IV,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:PV,ariaReadOnly:PV,ariaRelevant:null,ariaRequired:PV,ariaRoleDescription:IV,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:PV,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function GV(e,t){return t in e?e[t]:t}function KV(e,t){return GV(e,t.toLowerCase())}var qV=UV({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:LV,acceptCharset:IV,accessKey:IV,action:null,allow:null,allowFullScreen:NV,allowPaymentRequest:NV,allowUserMedia:NV,alpha:NV,alt:null,as:null,async:NV,autoCapitalize:null,autoComplete:IV,autoFocus:NV,autoPlay:NV,blocking:IV,capture:null,charSet:null,checked:NV,cite:null,className:IV,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:PV,controls:NV,controlsList:IV,coords:$|LV,crossOrigin:null,data:null,dateTime:null,decoding:null,default:NV,defer:NV,dir:null,dirName:null,disabled:NV,download:FV,draggable:PV,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:NV,formTarget:null,headers:IV,height:$,hidden:FV,high:$,href:null,hrefLang:null,htmlFor:IV,httpEquiv:IV,id:null,imageSizes:null,imageSrcSet:null,inert:NV,inputMode:null,integrity:null,is:null,isMap:NV,itemId:null,itemProp:IV,itemRef:IV,itemScope:NV,itemType:IV,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:NV,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:NV,muted:NV,name:null,nonce:null,noModule:NV,noValidate:NV,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:NV,optimum:$,pattern:null,ping:IV,placeholder:null,playsInline:NV,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:NV,referrerPolicy:null,rel:IV,required:NV,reversed:NV,rows:$,rowSpan:$,sandbox:IV,scope:null,scoped:NV,seamless:NV,selected:NV,shadowRootClonable:NV,shadowRootCustomElementRegistry:NV,shadowRootDelegatesFocus:NV,shadowRootMode:null,shadowRootSerializable:NV,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:PV,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:NV,useMap:null,value:PV,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:IV,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:NV,declare:NV,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:NV,noHref:NV,noShade:NV,noWrap:NV,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:PV,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:NV,disablePictureInPicture:NV,disableRemotePlayback:NV,exportParts:LV,part:IV,prefix:null,property:null,results:$,security:null,unselectable:null},space:`html`,transform:KV}),JV=UV({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:RV,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:IV,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:NV,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:LV,g2:LV,glyphName:LV,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:RV,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:IV,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:RV,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:RV,rev:RV,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:RV,requiredFeatures:RV,requiredFonts:RV,requiredFormats:RV,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:RV,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:RV,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:RV,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:GV}),YV=UV({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()}}),XV=UV({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:KV}),ZV=UV({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),QV={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`},$V=/[A-Z]/g,eH=/-[a-z]/g,tH=/^data[-\w.:]+$/i;function nH(e,t){let n=kV(t),r=t,i=AV;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&tH.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(eH,iH);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!eH.test(e)){let n=e.replace($V,rH);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=VV}return new i(r,t)}function rH(e){return`-`+e.toLowerCase()}function iH(e){return e.charAt(1).toUpperCase()}var aH=OV([WV,qV,YV,XV,ZV],`html`),oH=OV([WV,JV,YV,XV,ZV],`svg`);function sH(e){return e.join(` `).trim()}var cH=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})),lH=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(cH());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}})),uH=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))}})),dH=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(lH()),r=uH();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})),fH=mH(`end`),pH=mH(`start`);function mH(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 hH(e){let t=pH(e),n=fH(e);if(t&&n)return{start:t,end:n}}function gH(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?vH(e.position):`start`in e||`end`in e?vH(e):`line`in e||`column`in e?_H(e):``}function _H(e){return yH(e&&e.line)+`:`+yH(e&&e.column)}function vH(e){return _H(e&&e.start)+`-`+_H(e&&e.end)}function yH(e){return e&&typeof e==`number`?e:1}var bH=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=gH(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}};bH.prototype.file=``,bH.prototype.name=``,bH.prototype.reason=``,bH.prototype.message=``,bH.prototype.stack=``,bH.prototype.column=void 0,bH.prototype.line=void 0,bH.prototype.ancestors=void 0,bH.prototype.cause=void 0,bH.prototype.fatal=void 0,bH.prototype.place=void 0,bH.prototype.ruleId=void 0,bH.prototype.source=void 0;var xH=l(dH(),1),SH={}.hasOwnProperty,CH=new Map,wH=/[A-Z]/g,TH=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),EH=new Set([`td`,`th`]),DH=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function OH(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=zH(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=RH(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`?oH:aH,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=kH(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function kH(e,t,n){if(t.type===`element`)return AH(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return jH(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return NH(e,t,n);if(t.type===`mdxjsEsm`)return MH(e,t);if(t.type===`root`)return PH(e,t,n);if(t.type===`text`)return FH(e,t)}function AH(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=oH,e.schema=i),e.ancestors.push(t);let a=GH(e,t.tagName,!1),o=BH(e,t),s=HH(e,t);return TH.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!TV(e)})),IH(e,o,a,t),LH(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function jH(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)}KH(e,t.position)}function MH(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);KH(e,t.position)}function NH(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=oH,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:GH(e,t.name,!0),o=VH(e,t),s=HH(e,t);return IH(e,o,a,t),LH(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function PH(e,t,n){let r={};return LH(r,HH(e,t)),e.create(t,e.Fragment,r,n)}function FH(e,t){return t.value}function IH(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function LH(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function RH(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 zH(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=pH(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 BH(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&SH.call(t.properties,i)){let a=UH(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&EH.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 VH(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 KH(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 KH(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function HH(e,t){let n=[],r=-1,i=e.passKeys?new Map:CH;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=kH(e,a,o);s!==void 0&&n.push(s)}return n}function UH(e,t,n){let r=nH(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?yV(n):sH(n)),r.property===`style`){let t=typeof n==`object`?n:WH(e,String(n));return e.stylePropertyNameCase===`css`&&(t=qH(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?QV[r.property]||r.property:r.attribute,n]}}function WH(e,t){try{return(0,xH.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new bH("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=DH+`#cannot-parse-style-attribute`,r}}function GH(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=CV(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=CV(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return SH.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);KH(e)}function KH(e,t){let n=new bH("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=DH+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function qH(e){let t={},n;for(n in e)SH.call(e,n)&&(t[JH(n)]=e[n]);return t}function JH(e){let t=e.replace(wH,YH);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function YH(e){return`-`+e.toLowerCase()}var XH={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`]},ZH={};function QH(e,t){let n=t||ZH;return $H(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function $H(e,t,n){if(tU(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 eU(e.children,t,n)}return Array.isArray(e)?eU(e,t,n):``}function eU(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=$H(e[i],t,n);return r.join(``)}function tU(e){return!!(e&&typeof e==`object`)}var nU=document.createElement(`i`);function rU(e){let t=`&`+e+`;`;nU.innerHTML=t;let n=nU.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function iU(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 aU(e,t){return e.length>0?(iU(e,e.length,0,t),e):t}var oU={}.hasOwnProperty;function sU(e){let t={},n=-1;for(;++n<e.length;)cU(t,e[n]);return t}function cU(e,t){let n;for(n in t){let r=(oU.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){oU.call(r,a)||(r[a]=[]);let e=i[a];lU(r[a],Array.isArray(e)?e:e?[e]:[])}}}function lU(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);iU(e,0,0,r)}function uU(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 dU(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var fU=wU(/[A-Za-z]/),pU=wU(/[\dA-Za-z]/),mU=wU(/[#-'*+\--9=?A-Z^-~]/);function hU(e){return e!==null&&(e<32||e===127)}var gU=wU(/\d/),_U=wU(/[\dA-Fa-f]/),vU=wU(/[!-/:-@[-`{-~]/);function yU(e){return e!==null&&e<-2}function bU(e){return e!==null&&(e<0||e===32)}function xU(e){return e===-2||e===-1||e===32}var SU=wU(/\p{P}|\p{S}/u),CU=wU(/\s/);function wU(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function TU(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&pU(e.charCodeAt(n+1))&&pU(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 EU(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return xU(r)?(e.enter(n),s(r)):t(r)}function s(r){return xU(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}function DU(e,t,n,r,i,a){let o=0;return s;function s(t){return a>0&&xU(t)?(e.enter(r),c(t)):l(t)}function c(t){return xU(t)&&o<a?(e.consume(t),o++,c):(e.exit(r),l(t))}function l(e){return o>=i?t(e):n(e)}}var OU={tokenize:kU};function kU(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`),EU(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 yU(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var AU=class{constructor(){this.index=new Map,this.map=[]}add(e,t,n){jU(this,e,t,n,!1)}addBefore(e,t,n){jU(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 jU(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 MU={tokenize:PU},NU={tokenize:FU};function PU(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 AU;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(NU,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(NU,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 yU(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 AU;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 FU(e,t,n){return EU(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function IU(e){if(e===null||bU(e)||CU(e))return 1;if(SU(e))return 2}function LU(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 RU={name:`attention`,resolveAll:zU,tokenize:BU};function zU(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};VU(o,-a),VU(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=aU(r,[[`enter`,e[i][1],t],[`exit`,e[i][1],t]])),r=aU(r,[[`enter`,d,t],[`enter`,c,t],[`exit`,c,t],[`enter`,u,t]]),r=aU(r,LU(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),r=aU(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=aU(r,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])),iU(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 BU(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=IU(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=IU(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 VU(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var HU={name:`autolink`,tokenize:UU};function UU(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 fU(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||pU(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||pU(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||hU(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):mU(t)?(e.consume(t),l):n(t)}function u(e){return pU(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||pU(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var WU={partial:!0,tokenize:GU};function GU(e,t,n){return r;function r(t){return xU(t)?EU(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||yU(e)?t(e):n(e)}}var KU={continuation:{tokenize:JU},exit:YU,name:`blockQuote`,tokenize:qU};function qU(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 xU(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function JU(e,t,n){let r=this;return i;function i(t){return xU(t)?EU(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(KU,t,n)(r)}}function YU(e){e.exit(`blockQuote`)}var XU={name:`characterEscape`,tokenize:ZU};function ZU(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 vU(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var QU={name:`characterReference`,tokenize:$U};function $U(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=pU,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=_U,u):(e.enter(`characterReferenceValue`),a=7,o=gU,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===pU&&!rU(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 eW={partial:!0,tokenize:tW};function tW(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 nW={concrete:!0,name:`codeFenced`,tokenize:rW};function rW(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`),xU(t)?EU(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||yU(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(eW,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||yU(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):xU(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),EU(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||yU(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||yU(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&&xU(t)?EU(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||yU(t)?e.check(eW,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||yU(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`),xU(t)?EU(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`),xU(t)?EU(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||yU(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}var iW={name:`codeIndented`,tokenize:oW},aW={partial:!0,tokenize:sW};function oW(e,t,n){return r;function r(t){return e.enter(`codeIndented`),DU(e,i,n,`linePrefix`,4,4)(t)}function i(t){return t===null?o(t):yU(t)?e.attempt(aW,i,o)(t):(e.enter(`codeFlowValue`),a(t))}function a(t){return t===null||yU(t)?(e.exit(`codeFlowValue`),i(t)):(e.consume(t),a)}function o(n){return e.exit(`codeIndented`),t(n)}}function sW(e,t,n){let r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):yU(o)?(e.enter(`lineEnding`),e.consume(o),e.exit(`lineEnding`),i):DU(e,t,a,`linePrefix`,4,4)(o)}function a(e){return yU(e)?i(e):n(e)}}var cW={name:`codeText`,previous:uW,resolve:lW,tokenize:dW};function lW(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 uW(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function dW(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)):yU(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||yU(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 fW=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&&pW(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),pW(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),pW(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);pW(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);pW(this.left,t.reverse())}}}};function pW(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 mW(e){let t={},n=-1,r,i,a,o,s,c,l,u=new fW(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,hW(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 iU(e,0,1/0,u.slice(0)),!l}function hW(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 gW={resolve:vW,tokenize:yW},_W={partial:!0,tokenize:bW};function vW(e){return mW(e),e}function yW(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):yU(t)?e.check(_W,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 bW(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),EU(e,a,`linePrefix`)}function a(i){if(i===null||yU(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 xW(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||hU(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||yU(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||bU(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||hU(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 SW(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):yU(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||yU(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!xU(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function CW(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):yU(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),EU(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||yU(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 wW(e,t){let n;return r;function r(i){return yU(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):xU(i)?EU(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var TW={name:`definition`,tokenize:DW},EW={partial:!0,tokenize:OW};function DW(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return SW.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=dU(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 bU(t)?wW(e,l)(t):l(t)}function l(t){return xW(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(EW,d,d)(t)}function d(t){return xU(t)?EU(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||yU(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function OW(e,t,n){return r;function r(t){return bU(t)?wW(e,i)(t):n(t)}function i(t){return CW(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return xU(t)?EU(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||yU(e)?t(e):n(e)}}var kW={name:`hardBreakEscape`,tokenize:AW};function AW(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return yU(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var jW={name:`headingAtx`,resolve:MW,tokenize:NW};function MW(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`};iU(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])}return e}function NW(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||bU(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||yU(n)?(e.exit(`atxHeading`),t(n)):xU(n)?EU(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||bU(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var PW=`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(`.`),FW=[`pre`,`script`,`style`,`textarea`],IW={concrete:!0,name:`htmlFlow`,resolveTo:RW,tokenize:zW},LW={partial:!0,tokenize:BW};function RW(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 zW(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):fU(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):fU(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 fU(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||bU(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&FW.includes(l)?(i=1,r.interrupt?t(s):O(s)):PW.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||pU(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 xU(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||fU(t)?(e.consume(t),b):xU(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||pU(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):xU(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):xU(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||yU(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||bU(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||xU(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||yU(t)?O(t):xU(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):yU(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(LW,re,k)(t)):t===null||yU(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(eW,A,re)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||yU(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 FW.includes(n)?(e.consume(t),ne):O(t)}return fU(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||yU(t)?(e.exit(`htmlFlowData`),re(t)):(e.consume(t),ne)}function re(n){return e.exit(`htmlFlow`),t(n)}}function BW(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(WU,t,n)}}var VW={name:`htmlText`,tokenize:HW};function HW(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):fU(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):fU(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):yU(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):yU(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):yU(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):yU(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return fU(t)?(e.consume(t),S):n(t)}function S(t){return t===45||pU(t)?(e.consume(t),S):C(t)}function C(t){return yU(t)?(o=C,N(t)):xU(t)?(e.consume(t),C):M(t)}function w(t){return t===45||pU(t)?(e.consume(t),w):t===47||t===62||bU(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||fU(t)?(e.consume(t),E):yU(t)?(o=T,N(t)):xU(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||pU(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):yU(t)?(o=D,N(t)):xU(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):yU(t)?(o=O,N(t)):xU(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):yU(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||bU(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||bU(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 xU(t)?EU(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 UW={name:`labelEnd`,resolveAll:qW,resolveTo:JW,tokenize:YW},WW={tokenize:XW},GW={tokenize:ZW},KW={tokenize:QW};function qW(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&&iU(e,0,e.length,n),e}function JW(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=aU(o,e.slice(i+1,i+r+3)),o=aU(o,[[`enter`,l,t]]),o=aU(o,LU(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),o=aU(o,[[`exit`,l,t],e[a-2],e[a-1],[`exit`,c,t]]),o=aU(o,e.slice(a+1)),o=aU(o,[[`exit`,s,t]]),iU(e,i,e.length,o),e}function YW(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(dU(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(WW,u,o?u:d)(t):t===91?e.attempt(GW,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(KW,u,d)(t)}function u(e){return i.pop(),t(e)}function d(e){return a._balanced=!0,n(e)}}function XW(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 bU(t)?wW(e,a)(t):a(t)}function a(t){return t===41?u(t):xW(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return bU(t)?wW(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?CW(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return bU(t)?wW(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 ZW(e,t,n){let r=this;return i;function i(t){return SW.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(dU(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function QW(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 $W={name:`labelStartImage`,resolveAll:UW.resolveAll,tokenize:eG};function eG(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 tG={name:`labelStartLink`,resolveAll:UW.resolveAll,tokenize:nG};function nG(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 rG={name:`lineEnding`,tokenize:iG};function iG(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),EU(e,t,`linePrefix`)}}var aG={name:`thematicBreak`,tokenize:oG};function oG(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||yU(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),xU(t)?EU(e,s,`whitespace`)(t):s(t))}}var sG={continuation:{tokenize:dG},exit:pG,name:`list`,tokenize:uG},cG={partial:!0,tokenize:mG},lG={partial:!0,tokenize:fG};function uG(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:gU(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(aG,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 gU(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(WU,r.interrupt?n:u,e.attempt(cG,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return xU(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 dG(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(WU,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,EU(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!xU(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(lG,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,EU(e,e.attempt(sG,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function fG(e,t,n){let r=this;return EU(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 pG(e){e.exit(this.containerState.type)}function mG(e,t,n){let r=this;return EU(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!xU(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var hG={name:`setextUnderline`,resolveTo:gG,tokenize:_G};function gG(e,t){let n=new AU,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 _G(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`),xU(t)?EU(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||yU(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var vG={tokenize:yG};function yG(e){let t=this,n=e.attempt(WU,r,e.attempt(this.parser.constructs.flowInitial,i,EU(e,e.attempt(this.parser.constructs.flow,i,e.attempt(gW,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 bG={resolveAll:wG()},xG=CG(`string`),SG=CG(`text`);function CG(e){return{resolveAll:wG(e===`text`?TG: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 wG(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 TG(e,t){let n=new AU,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 EG=s({attentionMarkers:()=>PG,contentInitial:()=>OG,disable:()=>FG,document:()=>DG,flow:()=>AG,flowInitial:()=>kG,insideSpan:()=>NG,string:()=>jG,text:()=>MG}),DG={42:sG,43:sG,45:sG,48:sG,49:sG,50:sG,51:sG,52:sG,53:sG,54:sG,55:sG,56:sG,57:sG,62:KU},OG={91:TW},kG={[-2]:iW,[-1]:iW,32:iW},AG={35:jW,42:aG,45:[hG,aG],60:IW,61:hG,95:aG,96:nW,126:nW},jG={38:QU,92:XU},MG={[-5]:rG,[-4]:rG,[-3]:rG,33:$W,38:QU,42:RU,60:[HU,VW],91:tG,92:[kW,XU],93:UW,95:RU,96:cW},NG={null:[RU,bG]},PG={null:[42,95]},FG={null:[]};function IG(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=aU(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=LU(a,l.events,l),l.events):[]}function f(e,t){return RG(p(e),t)}function p(e){return LG(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){yU(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&&iU(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 LG(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 RG(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 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
|
|
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 zG(e){let t={constructs:sU([EG,...(e||{}).extensions||[]]),content:n(OU),defined:[],document:n(MU),flow:n(vG),lazy:{},string:n(xG),text:n(SG)};return t;function n(e){return n;function n(n){return IG(t,e,n)}}}function BG(e){for(;!mW(e););return e}var VG=/[\0\t\n\r]/g;function HG(){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;){VG.lastIndex=c;let n=VG.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 UG=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function WG(e){return e.replace(UG,GG)}function GG(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return uU(n.slice(t?2:1),t?16:10)}return rU(n)||e}var KG={}.hasOwnProperty;function qG(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),JG(n)(BG(zG(n).document().write(HG()(e,t,!0))))}function JG(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()}};XG(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]];KG.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]||QG).call(a,void 0,e[0])}for(r.position={start:YG(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:YG(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:YG(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]||QG).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+gH({start:e.start,end:e.end})+`): it’s not open`);n.position.end=YG(e.end)}function u(){return QH(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=dU(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:YG(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=YG(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=YG(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=WG(t),n.identifier=dU(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=dU(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=uU(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=rU(t);let i=this.stack[this.stack.length-1];i.value+=r}function ce(e){let t=this.stack.pop();t.position.end=YG(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 YG(e){return{line:e.line,column:e.column,offset:e.offset}}function XG(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?XG(e,r):ZG(e,r)}}function ZG(e,t){let n;for(n in t)if(KG.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 QG(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+gH({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+gH({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+gH({start:t.start,end:t.end})+`) is still open`)}function $G(e){let t=this;t.parser=n;function n(n){return qG(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function eK(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 tK(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
4307
|
+
`}]}function nK(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 rK(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iK(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function aK(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=TU(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 oK(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 sK(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function cK(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 lK(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return cK(e,t);let i={src:TU(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 uK(e,t){let n={src:TU(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 dK(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 fK(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return cK(e,t);let i={href:TU(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 pK(e,t){let n={href:TU(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 mK(e,t,n){let r=e.all(t),i=n?hK(n):gK(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 hK(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=gK(n[r])}return t}function gK(e){return e.spread??e.children.length>1}function _K(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 vK(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yK(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function bK(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xK(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=pH(t.children[1]),o=fH(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 SK(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 CK(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var wK=9,TK=32;function EK(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(DK(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(DK(t.slice(i),i>0,!1)),a.join(``)}function DK(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===wK||t===TK;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===wK||t===TK;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function OK(e,t){let n={type:`text`,value:EK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function kK(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var AK={blockquote:eK,break:tK,code:nK,delete:rK,emphasis:iK,footnoteReference:aK,heading:oK,html:sK,imageReference:lK,image:uK,inlineCode:dK,linkReference:fK,link:pK,listItem:mK,list:_K,paragraph:vK,root:yK,strong:bK,table:xK,tableCell:CK,tableRow:SK,text:OK,thematicBreak:kK,toml:jK,yaml:jK,definition:jK,footnoteDefinition:jK};function jK(){}var{defineProperty:MK}=Object,NK=typeof self==`object`?self:globalThis,PK=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new NK[e](t)},FK=(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__`?MK(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 NK[e]==`function`?PK(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(PK(a,o),i)};return r},IK=e=>FK(new Map,e)(0),LK=``,{toString:RK}={},{keys:zK,is:BK}=Object,VK=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=RK.call(e).slice(8,-1);switch(n){case`Array`:return[1,LK];case`Object`:return[2,LK];case`Date`:return[3,LK];case`RegExp`:return[4,LK];case`Map`:return[5,LK];case`Set`:return[6,LK];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},HK=([e,t])=>e===0&&(t===`function`||t===`symbol`),UK=(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]=VK(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&BK(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 zK(o))(e||!HK(VK(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?LK: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||!(HK(VK(n))||HK(VK(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!HK(VK(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},WK=(e,{json:t,lossy:n}={})=>{let r=[];return UK(!(t||n),!!t,new Map,r)(e),r},GK=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?IK(WK(e,t)):structuredClone(e):(e,t)=>IK(WK(e,t));function KK(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 qK(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function JK(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||KK,r=e.options.footnoteBackLabel||qK,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=TU(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:{...GK(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 YK=(function(e){if(e==null)return eq;if(typeof e==`function`)return $K(e);if(typeof e==`object`)return Array.isArray(e)?XK(e):ZK(e);if(typeof e==`string`)return QK(e);throw Error(`Expected function, string, or object as test`)});function XK(e){let t=[],n=-1;for(;++n<e.length;)t[n]=YK(e[n]);return $K(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ZK(e){let t=e;return $K(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function QK(e){return $K(t);function t(t){return t&&t.type===e}}function $K(e){return t;function t(t,n,r){return!!(tq(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function eq(){return!0}function tq(e){return typeof e==`object`&&!!e&&`type`in e}function nq(e){return e}var rq=[];function iq(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=YK(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 (`+nq(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=rq,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=aq(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 aq(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?rq:[e]}function oq(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),iq(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 sq={}.hasOwnProperty,cq={};function lq(e,t){let n=t||cq,r=new Map,i=new Map,a={all:s,applyData:dq,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...AK,...n.handlers},one:o,options:n,patch:uq,wrap:pq};return oq(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(sq.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=GK(n);return r.children=a.all(e),r}return GK(e)}return(a.options.unknownHandler||fq)(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=mq(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=mq(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function uq(e,t){e.position&&(t.position=hH(e))}function dq(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,GK(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function fq(e,t){let n=t.data||{},r=`value`in t&&!(sq.call(n,`hProperties`)||sq.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 pq(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 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?
|
|
4318
|
-
`)}function
|
|
4319
|
-
`&&!e.before&&!e.after&&
|
|
4320
|
-
`}function
|
|
4315
|
+
`}),n}function mq(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function hq(e,t){let n=lq(e,t),r=n.one(e,void 0),i=JK(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 gq(e,t){return e&&`run`in e?async function(n,r){let i=hq(n,{file:r,...t});await e.run(i,r)}:function(n,r){return hq(n,{file:r,...e||t})}}function _q(e){if(e)throw e}var vq=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 yq(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 bq(){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?xq(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 xq(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 Sq={basename:Cq,dirname:wq,extname:Tq,join:Eq,sep:`/`};function Cq(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);kq(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 wq(e){if(kq(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 Tq(e){kq(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 Eq(...e){let t=-1,n;for(;++t<e.length;)kq(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Dq(n)}function Dq(e){kq(e);let t=e.codePointAt(0)===47,n=Oq(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Oq(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 kq(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Aq={cwd:jq};function jq(){return`/`}function Mq(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function Nq(e){if(typeof e==`string`)e=new URL(e);else if(!Mq(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 Pq(e)}function Pq(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 Fq=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],Iq=class{constructor(e){let t;t=e?Mq(e)?{path:e}:typeof e==`string`||Bq(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Aq.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Fq.length;){let e=Fq[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)Fq.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?Sq.basename(this.path):void 0}set basename(e){Rq(e,`basename`),Lq(e,`basename`),this.path=Sq.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?Sq.dirname(this.path):void 0}set dirname(e){zq(this.basename,`dirname`),this.path=Sq.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?Sq.extname(this.path):void 0}set extname(e){if(Lq(e,`extname`),zq(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=Sq.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){Mq(e)&&(e=Nq(e)),Rq(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?Sq.basename(this.path,this.extname):void 0}set stem(e){Rq(e,`stem`),Lq(e,`stem`),this.path=Sq.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 bH(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 Lq(e,t){if(e&&e.includes(Sq.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+Sq.sep+"`")}function Rq(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function zq(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function Bq(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var Vq=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),Hq=l(vq(),1),Uq={}.hasOwnProperty,Wq=new class e extends Vq{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=bq()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,Hq.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(qq(`data`,this.frozen),this.namespace[e]=t,this):Uq.call(this.namespace,e)&&this.namespace[e]||void 0:e?(qq(`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=Xq(e),n=this.parser||this.Parser;return Gq(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Gq(`process`,this.parser||this.Parser),Kq(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Xq(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);Qq(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(),Gq(`processSync`,this.parser||this.Parser),Kq(`processSync`,this.compiler||this.Compiler),this.process(e,r),Yq(`processSync`,`process`,t),n;function r(e,r){t=!0,_q(e),n=r}}run(e,t,n){Jq(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=Xq(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),Yq(`runSync`,`run`,n),r;function i(e,t){_q(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Xq(t),r=this.compiler||this.Compiler;return Kq(`stringify`,r),Jq(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(qq(`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,Hq.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];yq(o)&&yq(r)&&(r=(0,Hq.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Gq(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Kq(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function qq(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 Jq(e){if(!yq(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Yq(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Xq(e){return Zq(e)?e:new Iq(e)}function Zq(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function Qq(e){return typeof e==`string`||$q(e)}function $q(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var eJ=[],tJ={allowDangerousHtml:!0},nJ=/^(https?|ircs?|mailto|xmpp)$/i,rJ=[{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 iJ(e){let t=aJ(e),n=oJ(e);return sJ(t.runSync(t.parse(n),n),e)}function aJ(e){let t=e.rehypePlugins||eJ,n=e.remarkPlugins||eJ,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...tJ}:tJ;return Wq().use($G).use(n).use(gq,r).use(t)}function oJ(e){let t=e.children||``,n=new Iq;return typeof t==`string`?n.value=t:``+t,n}function sJ(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||cJ;for(let e of rJ)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return oq(e,l),OH(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 XH)if(Object.hasOwn(XH,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=XH[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 cJ(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||nJ.test(e.slice(0,t))?e:``}function lJ(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function uJ(e,t,n){let r=YK((n||{}).ignore||[]),i=dJ(t),a=-1;for(;++a<i.length;)iq(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 dJ(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([fJ(e[0]),pJ(e[1])])}return t}function fJ(e){return typeof e==`string`?new RegExp(lJ(e),`g`):e}function pJ(e){return typeof e==`function`?e:function(){return e}}function mJ(e){uJ(e,[/\r?\n|\r/g,hJ])}function hJ(){return{type:`break`}}function gJ(){return function(e){mJ(e)}}function _J(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 vJ=`phrasing`,yJ=[`autolink`,`link`,`image`,`label`];function bJ(){return{transforms:[OJ],enter:{literalAutolink:SJ,literalAutolinkEmail:CJ,literalAutolinkHttp:CJ,literalAutolinkWww:CJ},exit:{literalAutolink:DJ,literalAutolinkEmail:EJ,literalAutolinkHttp:wJ,literalAutolinkWww:TJ}}}function xJ(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:vJ,notInConstruct:yJ},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:vJ,notInConstruct:yJ},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:vJ,notInConstruct:yJ}]}}function SJ(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function CJ(e){this.config.enter.autolinkProtocol.call(this,e)}function wJ(e){this.config.exit.autolinkProtocol.call(this,e)}function TJ(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 EJ(e){this.config.exit.autolinkEmail.call(this,e)}function DJ(e){this.exit(e)}function OJ(e){uJ(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,kJ],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,AJ]],{ignore:[`link`,`linkReference`]})}function kJ(e,t,n,r,i){let a=``;if(!NJ(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!jJ(n)))return!1;let o=MJ(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 AJ(e,t,n,r){return!NJ(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function jJ(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 MJ(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=_J(e,`(`),a=_J(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 NJ(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||CU(n)||SU(n))&&(!t||n!==47)}UJ.peek=HJ;function PJ(){this.buffer()}function FJ(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function IJ(){this.buffer()}function LJ(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function RJ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=dU(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zJ(e){this.exit(e)}function BJ(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=dU(this.sliceSerialize(e)).toLowerCase(),n.label=t}function VJ(e){this.exit(e)}function HJ(){return`[`}function UJ(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 WJ(){return{enter:{gfmFootnoteCallString:PJ,gfmFootnoteCall:FJ,gfmFootnoteDefinitionLabelString:IJ,gfmFootnoteDefinition:LJ},exit:{gfmFootnoteCallString:RJ,gfmFootnoteCall:zJ,gfmFootnoteDefinitionLabelString:BJ,gfmFootnoteDefinition:VJ}}}function GJ(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:UJ},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?qJ:KJ))),s(),o}}function KJ(e,t,n){return t===0?e:qJ(e,t,n)}function qJ(e,t,n){return(n?``:` `)+e}var JJ=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];$J.peek=eY;function YJ(){return{canContainEols:[`delete`],enter:{strikethrough:ZJ},exit:{strikethrough:QJ}}}function XJ(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:JJ}],handlers:{delete:$J}}}function ZJ(e){this.enter({type:`delete`,children:[]},e)}function QJ(e){this.exit(e)}function $J(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 eY(){return`~`}function tY(e){return e.length}function nY(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||tY,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=rY(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]=iY(r[d]);else{let e=iY(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 rY(e){return e==null?``:String(e)}function iY(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 aY=YK([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function oY(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()),sY);return i(),o}function sY(e,t,n){return`>`+(n?``:` `)+e}function cY(e,t){return lY(e,t.inConstruct,!0)&&!lY(e,t.notInConstruct,!1)}function lY(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 uY(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&&cY(n.stack,e))return/[\t ]/.test(r.before)?``:` `}return`\\
|
|
4320
|
+
`}function dY(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 fY(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 pY(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function mY(e,t,n,r){let i=pY(n),a=e.value||``;if(fY(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,hY);return e(),t}let o=n.createTracker(r),s=i.repeat(Math.max(dY(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 hY(e,t,n){return(n?``:` `)+e}function gY(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function _Y(e,t,n,r){let i=gY(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 vY(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}yY.attention=bY,yY.peek=xY;function yY(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function bY(e,t){return{construct:`emphasis`,markers:vY(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[1]}}function xY(e,t,n){return n.options.emphasis||`*`}function SY(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function CY(e,t){let n=!1;return oq(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)&&QH(e)&&(t.options.setext||n))}function wY(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(CY(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=SY(u)+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}TY.peek=EY;function TY(e){return e.value||``}function EY(){return`<`}DY.peek=OY;function DY(e,t,n,r){let i=gY(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 OY(){return`!`}kY.peek=AY;function kY(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 AY(){return`!`}jY.peek=MY;function jY(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 MY(){return"`"}function NY(e,t){let n=QH(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))}PY.peek=FY;function PY(e,t,n,r){let i=gY(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r);if(NY(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 FY(e,t,n){return NY(e,n)?`<`:`[`}IY.peek=LY;function IY(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 LY(){return`[`}function RY(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 zY(e){let t=RY(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 BY(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function VY(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 HY(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?BY(n):RY(n),s=e.ordered?o===`.`?`)`:`.`:zY(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),VY(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 UY(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 WY(e,t,n,r){let i=UY(n),a=n.bulletCurrent||RY(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 GY(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}function KY(e,t,n,r){if(!e.children.some(function(e){return aY(e)}))return n.containerFlow(e,r);let i=n.enter(`phrasing`),a=n.containerPhrasing(e,r);return i(),a}function qY(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}JY.attention=YY,JY.peek=XY;function JY(e,t,n,r){let i=n.enter(`phrasing`),a=n.containerPhrasing({type:`root`,children:[e]},r);return i(),a}function YY(e,t){return{construct:`strong`,markers:qY(t)===`*`?[`*`,`_`]:[`_`,`*`],sizes:[2]}}function XY(e,t,n){return n.options.strong||`*`}function ZY(e,t,n,r){return n.safe(e.value,r)}function QY(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 $Y(e,t,n){let r=(VY(n)+(n.options.ruleSpaces?` `:``)).repeat(QY(n));return n.options.ruleSpaces?r.slice(0,-1):r}var eX={blockquote:oY,break:uY,code:mY,definition:_Y,emphasis:yY,hardBreak:uY,heading:wY,html:TY,image:DY,imageReference:kY,inlineCode:jY,link:PY,linkReference:IY,list:HY,listItem:WY,paragraph:GY,root:KY,strong:JY,text:ZY,thematicBreak:$Y};function tX(){return{enter:{table:nX,tableData:oX,tableHeader:oX,tableRow:iX},exit:{codeText:sX,table:rX,tableData:aX,tableHeader:aX,tableRow:aX}}}function nX(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 rX(e){this.exit(e),this.data.inTable=void 0}function iX(e){this.enter({type:`tableRow`,children:[]},e)}function aX(e){this.exit(e)}function oX(e){this.enter({type:`tableCell`,children:[]},e)}function sX(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,cX));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function cX(e,t){return t===`|`?t:e}function lX(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 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};
|
|
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 nY(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=eX.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function uX(){return{exit:{taskListCheckValueChecked:fX,taskListCheckValueUnchecked:fX,paragraph:pX}}}function dX(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:mX}}}function fX(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function pX(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 mX(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=eX.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 hX(){return[bJ(),WJ(),YJ(),tX(),uX()]}function gX(e){return{extensions:[xJ(),GJ(e),XJ(),lX(e),dX()]}}var _X={tokenize:jX,partial:!0},vX={tokenize:MX,partial:!0},yX={tokenize:NX,partial:!0},bX={tokenize:PX,partial:!0},xX={tokenize:FX,partial:!0},SX={name:`wwwAutolink`,tokenize:kX,previous:IX},CX={name:`protocolAutolink`,tokenize:AX,previous:LX},wX={name:`emailAutolink`,tokenize:OX,previous:RX},TX={};function EX(){return{text:TX}}for(var DX=48;DX<123;)TX[DX]=wX,DX++,DX===58?DX=65:DX===91&&(DX=97);TX[43]=wX,TX[45]=wX,TX[46]=wX,TX[95]=wX,TX[72]=[wX,CX],TX[104]=[wX,CX],TX[87]=[wX,SX],TX[119]=[wX,SX];function OX(e,t,n){let r=this,i,a;return o;function o(t){return!zX(t)||!RX.call(r,r.previous)||BX(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return zX(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(xX,u,l)(t):t===45||t===95||pU(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&&fU(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function kX(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!IX.call(r,r.previous)||BX(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(_X,e.attempt(vX,e.attempt(yX,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function AX(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&LX.call(r,r.previous)&&!BX(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(fU(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||hU(t)||bU(t)||CU(t)||SU(t)?n(t):e.attempt(vX,e.attempt(yX,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function jX(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 MX(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(bX,c,s)(t):t===null||bU(t)||CU(t)||t!==45&&SU(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 NX(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(bX,t,a)(o):o===null||bU(o)||CU(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function PX(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||bU(o)||CU(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||bU(e)||CU(e)?t(e):r(e)}function a(e){return fU(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):fU(t)?(e.consume(t),o):n(t)}}function FX(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return pU(e)?n(e):t(e)}}function IX(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||bU(e)}function LX(e){return!fU(e)}function RX(e){return!(e===47||zX(e))}function zX(e){return e===43||e===45||e===46||e===95||pU(e)}function BX(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 VX={tokenize:YX,partial:!0};function HX(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:KX,continuation:{tokenize:qX},exit:JX}},text:{91:{name:`gfmFootnoteCall`,tokenize:GX},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:UX,resolveTo:WX}}}}function UX(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=dU(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 WX(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 GX(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||bU(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(dU(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return bU(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 KX(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||bU(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=dU(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return bU(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),EU(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function qX(e,t,n){return e.check(WU,t,e.attempt(VX,t,n))}function JX(e){e.exit(`gfmFootnoteDefinition`)}function YX(e,t,n){let r=this;return EU(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 XX(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&&iU(o,o.length,0,LU(s,e.slice(r+1,n),t)),iU(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),iU(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=IU(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=IU(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var ZX=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){QX(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function QX(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 $X(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 eZ(){return{flow:{null:{name:`table`,tokenize:tZ,resolveAll:nZ}}}}function tZ(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):yU(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):xU(t)?EU(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||bU(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,xU(t)?EU(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 xU(t)?EU(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||yU(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 xU(t)?EU(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||yU(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||yU(n)?(e.exit(`tableRow`),t(n)):xU(n)?EU(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||bU(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 nZ(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 ZX;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(iZ(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=rZ(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=rZ(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=rZ(f,t,o,i,n,d)):(o[0]=o[1],d=rZ(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&iZ(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=$X(t.events,n))}return e}function rZ(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},aZ(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=aZ(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=aZ(t.events,n[2]),a=aZ(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({},aZ(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function iZ(e,t,n,r,i){let a=[],o=aZ(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 aZ(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var oZ={name:`tasklistCheck`,tokenize:cZ};function sZ(){return{text:{91:oZ}}}function cZ(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 bU(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 yU(r)?t(r):xU(r)?e.check({tokenize:lZ},t,n)(r):n(r)}}function lZ(e,t,n){return EU(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function uZ(e){return sU([EX(),HX(),XX(e),eZ(),sZ()])}var dZ={};function fZ(e){let t=this,n=e||dZ,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(uZ(n)),a.push(hX()),o.push(gX(n))}function pZ(){let e=t=>{t.type===`html`&&(t.type=`text`),t.children?.forEach(e)};return e}var mZ=/^(https?:|mailto:)/i,hZ=e=>mZ.test(e.trim())?e:``,gZ={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})})},_Z=[fZ,pZ,gJ];function vZ({text:e,className:t}){return(0,K.jsx)(`div`,{className:t?`md ${t}`:`md`,children:(0,K.jsx)(iJ,{remarkPlugins:_Z,components:gZ,urlTransform:hZ,children:e})})}function yZ({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 bZ({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 xZ(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||XA()||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 SZ({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 CZ(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 wZ=e=>e===`Space`||e===`Enter`||e===`NumpadEnter`;function TZ(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 EZ({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 DZ=`#1f1d2b`,OZ=`#fffdf6`,kZ=`#6c7086`,AZ=[`#ff8a5b`,`#4fb3e8`,`#8fd14f`,`#c77dff`,`#ffc93c`,`#ff6fb5`,`#2ec4b6`,`#f25f5c`];function jZ(e,t,n,r,i,a,o=Math.min(r,i)*.24,s=2){Ow(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=DZ,e.stroke()}function MZ(e,t,n,r,i,a=`#ffffff`,o=10){Ow(e,t,n+3,r,i,o),e.fillStyle=DZ,e.fill(),Ow(e,t,n,r,i,o),e.fillStyle=a,e.fill(),e.lineWidth=2.5,e.strokeStyle=DZ,e.stroke()}function NZ(e,t,n,r,i,a=DZ,o=700,s=`center`){e.font=`${o} ${i}px ${Dw}`,e.fillStyle=a,e.textAlign=s,e.textBaseline=`middle`,e.fillText(t,n,r)}function PZ(e,t,n,r,i,a){e.font=`700 ${i}px ${Dw}`,e.textAlign=`center`,e.textBaseline=`middle`,e.lineJoin=`round`,e.lineWidth=Math.max(3,i/5),e.strokeStyle=DZ,e.strokeText(t,n,r),e.fillStyle=a,e.fillText(t,n,r)}function FZ(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=DZ,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=DZ,e.stroke(),e.beginPath(),e.arc(l+a*i*.35,n+o*i*.35,i*.52,0,Math.PI*2),e.fillStyle=DZ,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 IZ(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 LZ(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 RZ(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 zZ(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?PZ(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=DZ,e.strokeRect(i.x-i.size/2,i.y-i.size/2,i.size,i.size)),e.globalAlpha=1}}function BZ(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;MZ(e,c,l,o,s,OZ,16),e.save(),e.clip(),e.fillStyle=a,e.fillRect(c,l,o,10),e.restore(),e.stroke(),PZ(e,r,t/2,l+36,24,a),i.forEach((n,r)=>NZ(e,n,t/2,l+68+r*22,r===i.length-1?13:15,r===i.length-1?kZ:DZ,r===i.length-1?600:700))}var VZ=36e5,HZ=720*VZ,UZ={awake:{food:-12,fun:-10,energy:-7},asleep:{food:-5,fun:-3,energy:35}},WZ=[`Cubey`,`Pixel`,`Widget`,`Sprocket`,`Nugget`,`Mochi`,`Byte`,`Tofu`],GZ=[`#ff8a5b`,`#4fb3e8`,`#8fd14f`,`#c77dff`,`#ffc93c`,`#ff6fb5`,`#2ec4b6`],KZ=[{xp:0,title:`Intern`},{xp:12,title:`Junior`},{xp:40,title:`Senior`},{xp:90,title:`Tech Lead`}],qZ=e=>Math.max(0,Math.min(100,e));function JZ(e){let t=0;for(;t+1<KZ.length&&e>=KZ[t+1].xp;)t++;return t}function YZ(e,t,n){let r=WZ[Math.floor(t*WZ.length)%WZ.length];return{v:1,name:r,color:GZ[Math.floor(n*GZ.length)%GZ.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 XZ(e,t){let n=Math.min(Math.max(0,t-e.at),HZ)/VZ,{food:r,fun:i,energy:a,asleep:o}=e;for(let e=0;n>0&&e<1e3;e++){let e=o?UZ.asleep:UZ.awake,t=o?(100-a)/e.energy:a/-e.energy,s=Math.min(n,t);r=qZ(r+e.food*s),i=qZ(i+e.fun*s),a=qZ(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 ZZ(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 QZ={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. 😤`},$Z=(e,t)=>e[Math.floor(t/1e3)%e.length];function eQ(e,t,n){let r=XZ(e,n),i=tQ(r,t,n);return i===r?r:JZ(i.xp)>JZ(r.xp)?{...i,fun:qZ(i.fun+10),say:{text:`Promoted to ${KZ[JZ(i.xp)].title}! 🎉`,at:n}}:i}function tQ(e,t,n){let r=e=>({text:e,at:n}),i=(t,n)=>({...e,food:qZ(e.food+(t.food??0)),fun:qZ(e.fun+(t.fun??0)),energy:qZ(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},$Z([`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},$Z([`☕ 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},$Z([`Wheee! 🎾`,`Again! Again!`,`Best. Break. Ever.`],n));case`pet`:return n-e.pettedAt<3e3?e:{...i({fun:3},$Z([`Hehe ❤️`,`*happy wiggle*`,`You're the best manager!`],n)),pettedAt:n}}return e}function nQ(e,t,n){let r=XZ(e,n);return{...r,fun:qZ(r.fun+8),xp:r.xp+1,say:{text:t,at:n}}}function rQ(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:qZ(t.food),fun:qZ(t.fun),energy:qZ(t.energy),say:r}}function iQ(e){try{return JSON.parse(localStorage.getItem(e)??`null`)}catch{return null}}function aQ(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var oQ=`cubefarm:games:best`;function sQ(e){let t=iQ(oQ),n=Number(t?.[e]);return Number.isFinite(n)&&n>0?n:0}function cQ(e,t){if(t<=sQ(e))return!1;let n=iQ(oQ);return aQ(oQ,{...n&&typeof n==`object`?n:{},[e]:t}),!0}var lQ=`cubefarm:games:pet`,uQ=rQ(iQ(lQ)),dQ=new Set,fQ=()=>dQ.forEach(e=>e()),pQ=()=>uQ;function mQ(e){uQ=e,aQ(lQ,e),fQ()}function hQ(e){return dQ.add(e),()=>void dQ.delete(e)}function gQ(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! 🎉`}J.subscribe((e,t)=>{if(uQ&&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`&&mQ(nQ(uQ,gQ(n),Date.now()))}}),window.addEventListener(`storage`,e=>{e.key===lQ&&(uQ=rQ(iQ(lQ)),fQ())});var _Q={move:()=>q({freq:420,type:`square`,dur:.03,peak:.012}),rotate:()=>q({freq:560,to:700,type:`triangle`,dur:.06,peak:.04}),land:()=>{jb({dur:.07,peak:.07,freq:500,q:.8}),q({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)=>q({freq:e,type:`triangle`,at:t*.06,dur:.22,peak:.07})),levelUp:()=>[523,659,784,1046.5].forEach((e,t)=>q({freq:e,type:`square`,at:t*.08,dur:.14,peak:.03})),over:()=>{q({freq:392,to:370,type:`triangle`,dur:.22,peak:.1}),q({freq:311,to:156,type:`triangle`,at:.22,dur:.6,peak:.1})},best:()=>[784,988,1175,1568].forEach((e,t)=>q({freq:e,type:`triangle`,at:.5+t*.07,dur:.28,peak:.08})),chomp:()=>q({freq:300,to:620,type:`square`,dur:.07,peak:.035}),slurp:()=>{jb({dur:.2,peak:.05,filter:`bandpass`,freq:400,to:2200,q:2,attack:.03}),q({freq:523,to:1046,type:`triangle`,at:.12,dur:.16,peak:.06})},start:()=>[523,784].forEach((e,t)=>q({freq:e,type:`triangle`,at:t*.08,dur:.14,peak:.07})),pause:()=>q({freq:660,to:440,type:`triangle`,dur:.12,peak:.05}),happy:()=>{q({freq:660,to:1320,type:`square`,dur:.1,peak:.03}),q({freq:1320,to:990,type:`triangle`,at:.1,dur:.12,peak:.07})},nom:()=>[0,.12,.24].forEach(e=>q({freq:250,to:180,type:`triangle`,at:e,dur:.08,peak:.06})),boing:()=>q({freq:220,to:660,type:`sine`,dur:.25,peak:.1}),snore:()=>q({freq:140,to:90,type:`sine`,dur:.6,peak:.05,attack:.2}),grumble:()=>q({freq:160,to:120,type:`sawtooth`,dur:.25,peak:.025})},vQ=`#ff6fb5`,yQ=320,bQ=260,xQ=212,SQ=[52,60,68,74],CQ=1.4,wQ=Date.now(),TQ=[{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 EQ(e,t){let n=t.size,r=-n,i=Math.max(2,n/22),a=IZ(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=DZ,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();jZ(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(FZ(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=IZ(t.color,-.08),e.fill(),e.lineWidth=i*.8,e.strokeStyle=DZ,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=DZ;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=DZ;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=DZ,e.fillStyle=DZ,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(),jZ(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=DZ,e.stroke()),t.stage>=3){e.lineWidth=i*1.4,e.strokeStyle=DZ,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])jZ(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=DZ,e.fill()}}function DQ(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=DZ,e.stroke()}function OQ(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=DZ,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 kQ(e,t,n,r){e.lineWidth=2,e.strokeStyle=DZ,e.beginPath(),e.arc(t+9,n+8,5,-Math.PI/2,Math.PI/2),e.stroke(),jZ(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 AQ(e,t,n){e.fillStyle=`#d6e2ef`,e.fillRect(0,0,yQ,xQ),e.fillStyle=`rgba(255,255,255,0.28)`;for(let t=6;t<yQ;t+=12)e.fillRect(t,12,1.5,200);e.fillStyle=`#b9c9dc`,e.fillRect(0,0,yQ,12),e.fillStyle=DZ,e.fillRect(0,12,yQ,2),jZ(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=DZ,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()}jZ(e,232,54,66,60,`#ffffff`,5,2),NZ(e,`EMPLOYEE`,265,64,7.5,DZ,700),NZ(e,`OF THE MONTH`,265,73,7,DZ,700),DQ(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=DZ,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,yQ,36),e.fillStyle=DZ,e.fillRect(0,224,yQ,2),jZ(e,-6,xQ,332,14,`#f1d19b`,5,2.5),jZ(e,48,200,18,12,`#3d4152`,2,2),jZ(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=AZ[n*3%AZ.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=DZ,e.stroke();jZ(e,248,186,32,26,`#e07a5f`,5,2)}function jQ(e,t=1){e.save(),e.scale(t,t),jZ(e,-38,-56,76,56,`#d9a066`,6,2.5),e.fillStyle=`rgba(241,209,155,0.9)`,e.fillRect(-7,-55,14,54),jZ(e,-30,-34,38,16,`#ffffff`,3,1.5),NZ(e,`NEW HIRE`,-11,-26,7.5,DZ,700),e.restore()}function MQ(e,t,n,r){e.lineWidth=2,e.strokeStyle=DZ,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 NQ({onBack:e}){let t=(0,v.useSyncExternalStore)(hQ,pQ),[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>wQ&&c-t.say.at>5e3?t.say:null);(0,v.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),1e3);return()=>{clearInterval(e),wQ=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},LZ(a.current,yQ/2,152,AZ,16,140),_Q.happy()))},[u]);let d=()=>{if(pQ())return;let e=YZ(Date.now(),Math.random(),Math.random());o.current=e.say?.at??0,i.current={kind:`hatch`,t:0},LZ(a.current,yQ/2,182,[`#d9a066`,`#f1d19b`,...AZ],22,170),_Q.levelUp(),mQ(e)},f=e=>{let t=pQ();if(!t)return;let n=Date.now(),s=eQ(t,e,n);s.say?.at===n&&(o.current=n),mQ(s),r(n);let c=s.xp>t.xp,l=SQ[JZ(s.xp)];if(s.say?.text.startsWith(`Promoted`)){_Q.levelUp(),LZ(a.current,yQ/2,xQ-l,AZ,22,160),i.current={kind:`cheer`,t:0};return}switch(e){case`snack`:case`play`:c?(i.current={kind:e,t:0},(e===`snack`?_Q.nom:_Q.boing)()):s.asleep||_Q.grumble();break;case`coffee`:c?(i.current={kind:`coffee`,t:0},_Q.slurp()):s.asleep||(i.current={kind:`jitter`,t:0},_Q.grumble());break;case`nap`:s.asleep?_Q.snore():t.asleep&&(i.current={kind:`wake`,t:0},_Q.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:yQ/2+(e-1)*16,y:xQ-l-6,vx:(e-1)*14,vy:-50-e*8,life:1.1,color:`#ff6fb5`,size:16+e*2,text:`♥`});_Q.happy()}}};xZ(e=>{if(e.repeat)return!1;let t=TQ.find(t=>e.code===`Digit${t.key}`||e.code===`Numpad${t.key}`);return t?(f(t.action),!0):wZ(e.code)?(pQ()?f(`pet`):d(),!0):!1});let p=(e,t,n)=>{let r=pQ(),o=r?XZ(r,Date.now()):null,s=o?ZZ(o):`content`,c=o?JZ(o.xp):0;AQ(e,n,c>=2||s===`happy`);let l=i.current;if(l&&(l.t+=t,l.t>CQ&&(i.current=null)),o){let t=SQ[c],r=yQ/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/CQ: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;EQ(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=xQ-t-i;if(l?.kind===`snack`){let n=Math.min(1,f/.3);OQ(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`&&kQ(e,r+t/2+16,194,n),l?.kind===`play`){let t=yQ/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=DZ,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),PZ(e,`z`,r+t*.35+a*26,m-a*34,12+a*10,`#ffffff`)}e.globalAlpha=1}else if(s===`hungry`)MQ(e,r+t*.55+18,m-8+i,()=>OQ(e,0,0,9));else if(s===`bored`)MQ(e,r+t*.55+18,m-8+i,()=>NZ(e,`…`,0,-2,20,DZ,700));else if(s===`tired`)MQ(e,r+t*.55+18,m-8+i,()=>NZ(e,`💤`,0,0,14,DZ,400));else if(s===`grumpy`){let t=r,a=m-22+i;e.fillStyle=`#8e93a8`,e.strokeStyle=DZ,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),PZ(e,`✦`,r-t*.6,m+10-i*8,14,`#ffc93c`),PZ(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,yQ,bQ))}else{let t=n%2600<450?Math.sin(n/45)*.06:0;e.save(),e.translate(yQ/2,213),e.rotate(t),jQ(e),e.restore(),PZ(e,`?`,194,142+Math.sin(n/300)*3,20,`#ffc93c`)}zZ(e,a.current,t)},m=(e,t,n)=>{if(e!==`down`)return;let r=pQ();if(!r){Math.abs(t-yQ/2)<50&&n>142&&d();return}let i=SQ[JZ(r.xp)];Math.abs(t-yQ/2)<i/2+8&&n>xQ-i-12&&n<218&&f(`pet`)},h=t?XZ(t,n):null,g=h?ZZ(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}`:QZ[g]):`A delivery just arrived at your desk…`,b=h?KZ[JZ(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)(SZ,{title:`Desk Pet`,color:vQ,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)(bZ,{width:yQ,height:bQ,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:TQ.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 PQ(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 FQ=()=>Math.floor(Math.random()*2**31),IQ={up:{x:0,y:-1},down:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}},LQ={up:`down`,down:`up`,left:`right`,right:`left`},RQ={bug:10,coffee:50},zQ={bug:1,coffee:2},BQ=(e,t)=>e.x===t.x&&e.y===t.y;function VQ(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 HQ(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]=PQ(r);return{at:a[Math.floor(o*a.length)],seed:s}}function UQ(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=VQ(t,n),s=HQ(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 WQ(e,t){if(e.over)return e;let n=e.queue[e.queue.length-1]??e.dir;return t===n||t===LQ[n]||e.queue.length>=2?e:{...e,queue:[...e.queue,t]}}function GQ(e){if(e.over)return e;let[t=e.dir,...n]=e.queue,r=IQ[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=>BQ(e,i)))return a(`desk`);let o=e.grow>0?e.body:e.body.slice(0,-1);if(o.some(e=>BQ(e,i)))return a(`self`);let s=[i,...o],c=Math.max(0,e.grow-1);if(!BQ(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+=zQ[l];let d=HQ(e.cols,e.rows,[...s,...e.desks],e.seed),f={...e,body:s,dir:t,queue:n,grow:c,eaten:u,score:e.score+RQ[l],seed:d.seed,ate:l};return d.at?{...f,food:{...d.at,kind:(u+1)%5==0?`coffee`:`bug`}}:{...f,over:`won`}}var KQ=e=>Math.max(70,165-e.eaten*4),qQ=`#4fb3e8`,JQ=20,YQ=6,XQ=38,ZQ=16,QQ=16,$Q=332,e$=364,t$=`#4fb3e8`,n$=null,r$=()=>n$!==null,i$={wall:`Unplugged!`,self:`Tangled up!`,desk:`Desk crash!`,won:`Office wired! 🎉`},a$={right:0,down:Math.PI/2,left:Math.PI,up:-Math.PI/2},o$={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]},s$=e=>YQ+e.x*JQ+JQ/2,c$=e=>XQ+e.y*JQ+JQ/2;function l$({onBack:e}){let[t,n]=(0,v.useState)(n$?`paused`:`ready`),r=(0,v.useRef)({game:n$??UQ(FQ(),ZQ,QQ),status:n$?`paused`:`ready`,acc:0,best:sQ(`snake`),newBest:!1,particles:[],shake:0,chomp:0,swipe:null}),i=e=>{r.current.status=e,n(e),n$=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`&&(n$=e),e.ate){let n=e.body[0];e.ate===`coffee`?_Q.slurp():_Q.chomp(),t.chomp=.18,LZ(t.particles,s$(n),c$(n),e.ate===`coffee`?[`#8d5524`,`#ffffff`,`#ffc93c`]:[`#f25f5c`,`#8fd14f`,`#ffffff`],8,90),RZ(t.particles,s$(n),c$(n)-12,e.ate===`coffee`?`+50 ☕`:`+10`,e.ate===`coffee`?`#ffc93c`:`#ffffff`,15)}e.over&&!n.over&&(t.newBest=cQ(`snake`,e.score),t.newBest&&(t.best=e.score),t.shake=e.over===`won`?0:.3,e.over===`won`?_Q.best():_Q.over(),t.newBest&&e.over!==`won`&&_Q.best(),i(`over`))}},o=()=>{let e=r.current;e.status!==`playing`&&(e.status===`over`&&(e.game=UQ(FQ(),ZQ,QQ)),e.status!==`paused`&&(e.newBest=!1,e.particles.length=0),e.acc=0,_Q.start(),i(`playing`))},s=()=>{r.current.status===`playing`&&(_Q.pause(),i(`paused`))},c=e=>{if(r.current.status!==`playing`){if(r.current.status===`paused`)return o();o()}a(WQ(r.current.game,e))};xZ(e=>{let t=CZ(e.code);return t?(e.repeat||c(t),!0):wZ(e.code)?(e.repeat||(r.current.status===`playing`?s:o)(),!0):!1}),TZ(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=KQ(i.game);for(;i.acc>=e&&i.status===`playing`;)i.acc-=e,a(GQ(i.game)),e=KQ(i.game)}let o=i.game;MZ(e,YQ,4,96,26,`#ffffff`,9),NZ(e,`🐛 ${o.eaten} eaten`,54,17,12,DZ,700),MZ(e,$Q/2-50,4,100,26,`#ffffff`,9),NZ(e,`SCORE ${o.score}`,$Q/2,17,12,DZ,700),MZ(e,230,4,96,26,`#ffffff`,9),NZ(e,`BEST ${Math.max(i.best,o.score)}`,278,17,12,o.score>i.best?`#e05a2b`:kZ,700),e.save(),i.shake>0&&(i.shake-=t,e.translate((Math.random()-.5)*12*i.shake,(Math.random()-.5)*12*i.shake)),MZ(e,3,35,326,326,`#e6ebf3`,8),e.save(),e.beginPath(),e.roundRect(YQ,XQ,320,320,6),e.clip(),e.fillStyle=`#dce3ee`;for(let t=0;t<QQ;t++)for(let n=0;n<ZQ;n++)(n+t)%2&&e.fillRect(YQ+n*JQ,XQ+t*JQ,JQ,JQ);e.restore();for(let t=0;t+1<o.desks.length;t+=2){let n=o.desks[t],r=YQ+n.x*JQ,i=XQ+n.y*JQ;jZ(e,r+1,i+2,38,17,`#f1d19b`,5),jZ(e,r+JQ-8,i-3,16,12,`#2b2d42`,3,1.5),e.fillStyle=AZ[t/2%AZ.length],e.fillRect(r+JQ-5,i,10,5)}u$(e,o,n),d$(e,o,i.chomp,n),i.chomp=Math.max(0,i.chomp-t),e.restore(),zZ(e,i.particles,t),i.status===`ready`?BZ(e,$Q,e$,`Cable Snake`,[`Eat bugs 🐛, sip coffee ☕`,`Dodge desks, walls & yourself`,`Arrows, swipe or tap to start`],qQ):i.status===`paused`?BZ(e,$Q,e$,`Coffee break ☕`,[`Score ${o.score}`,`Space or tap to resume`],qQ):i.status===`over`&&BZ(e,$Q,e$,i$[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)(EZ,{label:n,className:`game-pad-${e}`,onPress:()=>c(e),children:t});return(0,K.jsxs)(`div`,{className:`game`,children:[(0,K.jsx)(SZ,{title:`Cable Snake`,color:qQ,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)(bZ,{width:$Q,height:e$,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 u$(e,t,n){let r=s$(t.food),i=c$(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=DZ,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=DZ,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=DZ,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=DZ;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 d$(e,t,n,r){let i=t.body;e.lineCap=`round`,e.lineJoin=`round`,(()=>{e.beginPath(),e.moveTo(s$(i[i.length-1]),c$(i[i.length-1]));for(let t=i.length-2;t>=0;t--)e.lineTo(s$(i[t]),c$(i[t]))})(),e.strokeStyle=DZ,e.lineWidth=14,e.stroke(),e.strokeStyle=t$,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=IZ(t$,-.45),e.lineWidth=3;for(let t=3;t<i.length-1;t+=4){let n=i[t],r=i[t+1],a=(s$(n)+s$(r))/2,o=(c$(n)+c$(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=s$(a),c=c$(a);e.save(),e.translate(s,c),e.rotate(a$[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=DZ,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]=o$[o],f=s-o$[t.dir][0]*2,p=c-o$[t.dir][1]*2-1;if(t.over&&t.over!==`won`){e.strokeStyle=DZ,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 FZ(e,f,p,8,3.2,u,d,Math.floor(r/170)%25==0)}var f$=[`I`,`O`,`T`,`S`,`Z`,`J`,`L`],p$={I:[`....`,`XXXX`,`....`,`....`],O:[`XX`,`XX`],T:[`.X.`,`XXX`,`...`],S:[`.XX`,`XX.`,`...`],Z:[`XX.`,`.XX`,`...`],J:[`X..`,`XXX`,`...`],L:[`..X`,`XXX`,`...`]};function m$(e){let t=[];return e.forEach((e,n)=>[...e].forEach((e,r)=>e===`X`&&t.push([r,n]))),t}function h$(e){let t=e.length;return e.map((n,r)=>e.map((n,i)=>e[t-1-i][r]).join(``))}var g$=Object.fromEntries(f$.map(e=>{let t=[p$[e]];for(let e=1;e<4;e++)t.push(h$(t[e-1]));return[e,t.map(m$)]})),_$=()=>Array.from({length:20},()=>Array(10).fill(null));function v$(e){return g$[e.type][e.rot].map(([t,n])=>[e.x+t,e.y+n])}var y$=e=>g$[e][0];function b$(e,t){return v$(t).some(([t,n])=>t<0||t>=10||n>=20||n>=0&&e[n][t]!==null)}function x$(e){let t=p$[e].length,n=Math.min(...g$[e][0].map(([,e])=>e));return{type:e,rot:0,x:Math.floor((10-t)/2),y:-n}}function S$(e,t){let n=[...e],r=t;for(;n.length<f$.length;){let e=[...f$];for(let t=e.length-1;t>0;t--){let[n,i]=PQ(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 C$(e){let t=S$([],e),[n,...r]=t.queue,i=S$(r,t.seed);return{board:_$(),piece:x$(n),queue:i.queue,seed:i.seed,score:0,lines:0,level:1,over:!1,cleared:[],locks:0}}var w$=e=>Math.max(80,Math.round(800*.85**(e-1))),T$=[0,100,300,500,800];function E$(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 D$(e,t,n=0){if(e.over)return e;let r={...e.piece,x:e.piece.x+t,y:e.piece.y+n};return b$(e.board,r)?e:{...e,piece:r}}var O$=[[0,0],[-1,0],[1,0],[0,-1],[-1,-1],[1,-1]],k$=[[0,0],[-1,0],[1,0],[-2,0],[2,0],[0,-1]];function A$(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`?k$:O$){let i={...e.piece,rot:n,x:e.piece.x+t,y:e.piece.y+r};if(!b$(e.board,i))return{...e,piece:i}}return e}function j$(e){let t=0;for(;!b$(e.board,{...e.piece,y:e.piece.y+t+1});)t++;return t}function M$(e){if(e.over)return e;let t=v$(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}=E$(n),o=e.lines+a.length,s=e.score+T$[a.length]*e.level,c=1+Math.floor(o/10),[l,...u]=e.queue,d=S$(u,e.seed),f=x$(l),p=r||b$(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 N$(e){if(e.over)return e;let t=D$(e,0,1);return t===e?M$(e):t}function P$(e){if(e.over)return e;let t=D$(e,0,1);return t===e?M$(e):{...t,score:t.score+1}}function F$(e){if(e.over)return e;let t=j$(e);return M$({...e,piece:{...e.piece,y:e.piece.y+t},score:e.score+t*2})}var I$=`#c77dff`,L$={I:AZ[1],O:AZ[4],T:AZ[3],S:AZ[2],Z:AZ[7],J:AZ[6],L:AZ[0]},R$=18,z$=8,B$=8,V$=10*R$,H$=20*R$,U$=z$+V$+12,W$=U$+92+6,G$=B$+H$+8,K$=null,q$=()=>K$!==null,J$=[``,`Shipped!`,`Double ship!`,`Triple ship!`,`CUBETRIS!`];function Y$({onBack:e}){let[t,n]=(0,v.useState)(K$?`paused`:`ready`),r=(0,v.useRef)({game:K$??C$(FQ()),status:K$?`paused`:`ready`,acc:0,best:sQ(`tetris`),newBest:!1,flash:[],particles:[],shake:0,lastDx:0}),i=e=>{r.current.status=e,n(e),K$=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,K$=t.status===`playing`?e:K$,e.locks!==n.locks){let r=e.cleared.length;if(r){_Q.lines(r);let i=e.score-n.score;for(let n of e.cleared)t.flash.push({y:n,t:.35}),LZ(t.particles,z$+V$/2,B$+n*R$+R$/2,AZ,10,150);let a=B$+e.cleared.reduce((e,t)=>e+t,0)/r*R$;RZ(t.particles,z$+V$/2,a-14,J$[r],r===4?`#ffc93c`:`#ffffff`,r===4?26:20),RZ(t.particles,z$+V$/2,a+12,`+${i}`,`#80ed99`,16),r===4&&(t.shake=.35)}else _Q.land();e.level>n.level&&(_Q.levelUp(),RZ(t.particles,z$+V$/2,B$+H$/3,`Level ${e.level}!`,`#4fb3e8`,24)),e.over&&(t.newBest=cQ(`tetris`,e.score),t.newBest&&(t.best=e.score),_Q.over(),t.newBest&&_Q.best(),i(`over`))}return!0},o=()=>{let e=r.current;e.status!==`playing`&&((e.status===`over`||e.status===`ready`)&&(e.status===`over`&&(e.game=C$(FQ())),e.newBest=!1,e.particles.length=0),e.acc=0,_Q.start(),i(`playing`))},s=()=>{r.current.status===`playing`&&(_Q.pause(),i(`paused`))},c=e=>{r.current.lastDx=e,a(D$(r.current.game,e))&&_Q.move()},l=e=>a(A$(r.current.game,e))&&_Q.rotate(),u=()=>{r.current.acc=0,a(P$(r.current.game))},d=()=>{r.current.acc=0,a(F$(r.current.game))},f=e=>()=>r.current.status===`playing`?e():o();return xZ(e=>{let t=r.current.status===`playing`,n=CZ(e.code);return wZ(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}),TZ(s),(0,K.jsxs)(`div`,{className:`game`,children:[(0,K.jsx)(SZ,{title:`Cubetris`,color:I$,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)(bZ,{width:W$,height:G$,frame:(e,t,n)=>{let i=r.current;if(i.status===`playing`){i.acc+=t*1e3;let e=w$(i.game.level);for(;i.acc>=e&&i.status===`playing`;)i.acc-=e,a(N$(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)),MZ(e,5,5,V$+6,H$+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(z$+t*R$,B$),e.lineTo(z$+t*R$,B$+H$);for(let t=1;t<20;t++)e.moveTo(z$,B$+t*R$),e.lineTo(z$+V$,B$+t*R$);if(e.stroke(),o.board.forEach((t,n)=>t.forEach((t,r)=>t&&jZ(e,z$+r*R$,B$+n*R$,R$,R$,L$[t],4.5))),!o.over){let t=j$(o);e.setLineDash([3,3]);for(let[n,r]of v$({...o.piece,y:o.piece.y+t}))r<0||(e.beginPath(),e.roundRect(z$+n*R$+2,B$+r*R$+2,14,14,4),e.fillStyle=`${L$[o.piece.type]}44`,e.fill(),e.strokeStyle=`rgba(31,29,43,0.45)`,e.lineWidth=1.5,e.stroke());e.setLineDash([]);let r=v$(o.piece);e.save(),e.beginPath(),e.rect(6,B$,V$+4,H$+4),e.clip();for(let[t,n]of r)jZ(e,z$+t*R$,B$+n*R$,R$,R$,L$[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&&FZ(e,z$+c*R$+R$/2,B$+l*R$+R$/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(z$,B$+t.y*R$,V$,R$);e.restore(),MZ(e,U$,B$,92,110,`#ffffff`,10),NZ(e,`NEXT`,U$+46,21,11,kZ,700),o.queue.slice(0,3).forEach((t,n)=>{let r=n===0?14:9,i=y$(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?U$+46-s/2:U$+(n===1?24:68)-s/2,u=n===0?52-c/2:98-c/2;for(let[s,c]of i)jZ(e,l+(s-Math.min(...a))*r,u+(c-Math.min(...o))*r,r,r,L$[t],r*.25,n===0?2:1.5)});let s=(t,n,r,i=DZ)=>{MZ(e,U$,r,92,46,`#ffffff`,10),NZ(e,t,U$+46,r+13,10,kZ,700),NZ(e,n,U$+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`:DZ),zZ(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`?BZ(e,W$,G$,`Cubetris`,[`Stack the blocks.`,`Fill a row to ship it!`,t],I$):i.status===`paused`?BZ(e,W$,G$,`Coffee break ☕`,[`Score ${o.score.toLocaleString()}`,t],I$):BZ(e,W$,G$,`Stack overflow!`,[`Score ${o.score.toLocaleString()}`,i.newBest?`🏆 New best!`:`Best ${i.best.toLocaleString()}`,t],`#f25f5c`)}else o.score===0&&o.locks===0&&PZ(e,`Go!`,z$+V$/2,B$+H$/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)(EZ,{label:`Move left`,repeat:!0,onPress:f(()=>c(-1)),children:`◀`}),(0,K.jsx)(EZ,{label:`Soft drop`,repeat:!0,onPress:f(u),children:`▼`}),(0,K.jsx)(EZ,{label:`Move right`,repeat:!0,onPress:f(()=>c(1)),children:`▶`}),(0,K.jsx)(`span`,{className:`game-pad-gap`}),(0,K.jsx)(EZ,{label:`Rotate`,className:`game-pad-round`,onPress:f(()=>l(1)),children:`⟳`}),(0,K.jsx)(EZ,{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 X$({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 Z$=e=>{let t=(t,n,r)=>jZ(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);FZ(e,21.5,8.5,7,2.4,0,.5)},Q$=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=DZ,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=DZ,e.stroke(),e.fillStyle=`#ffc93c`;for(let t=0;t<3;t++)e.fillRect(44,11+t*3.6,2.5,1.8);FZ(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=DZ,e.fill()};function $$({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)(X$,{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 e1({onGame:e}){let t=(0,v.useSyncExternalStore)(hQ,pQ),[n]=(0,v.useState)(Date.now),r=t?XZ(t,n):null,i=e=>{e.translate(28,50),r?EQ(e,{size:38,color:r.color,mood:ZZ(r),stage:JZ(r.xp),blink:!1}):jQ(e,.6)},a=e=>sQ(e)?`Best ${sQ(e).toLocaleString()}`:`No best score yet`;return xZ(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)($$,{icon:Z$,name:`Cubetris`,what:`Falling blocks (a Tetris clone)`,status:q$()?`⏸ Game paused, tap to resume`:a(`tetris`),color:I$,onOpen:()=>e(`tetris`)}),(0,K.jsx)($$,{icon:Q$,name:`Cable Snake`,what:`Eat the bugs (a Snake clone)`,status:r$()?`⏸ Game paused, tap to resume`:a(`snake`),color:qQ,onOpen:()=>e(`snake`)}),(0,K.jsx)($$,{icon:i,name:`Desk Pet`,what:`Your office pet (a Tamagotchi clone)`,status:r?`${r.name} the ${KZ[JZ(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`}[ZZ(r)]}`:`📦 A delivery is waiting for you`,color:vQ,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 t1({game:e,onGame:t}){xZ(n=>!e||n.code!==`Backspace`?!1:(t(null),!0));let n=()=>t(null);return e===`tetris`?(0,K.jsx)(Y$,{onBack:n}):e===`snake`?(0,K.jsx)(l$,{onBack:n}):e===`pet`?(0,K.jsx)(NQ,{onBack:n}):(0,K.jsx)(e1,{onGame:t})}async function n1(e){try{return await e()}catch{return}}var r1=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function i1({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 a1({req:e,highlight:t}){let n=J(t=>t.repos.find(t=>t.id===e.repoId)),r=J(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 n1(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)(i1,{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)(vZ,{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)(vZ,{className:`resume-brief`,text:e.brief}),m&&p&&(0,K.jsxs)(`div`,{className:`muted small`,children:[KM(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(()=>PA.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(()=>PA.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 o1({focusId:e}){let t=J(e=>e.requests),n=Lx(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)(a1,{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)(a1,{req:e},e.id))]})]})}var s1=[`What's everyone working on?`,`Do we need anyone new?`,`Plan the next milestone for the busiest floor.`];function c1({m:e,ceoName:t}){let n=J(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)(vZ,{className:`bubble-md`,text:e.text}),n&&n.status===`pending`&&e.from===`ceo`&&(0,K.jsx)(a1,{req:n}),(0,K.jsx)(`div`,{className:`bubble-time`,children:r1(e.at)})]})})}function l1(){let e=J(e=>e.messages),t=J(e=>e.phoneReadAt),n=J(e=>e.agents.ceo),r=J(e=>e.ceo),i=J(e=>e.settings),a=J(e=>Object.values(e.agents).filter(Fx).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&&n1(()=>PA.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(``),n1(()=>PA.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)(i1,{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)(c1,{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:s1.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)(yZ,{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 u1(){let e=J(e=>e.repos),t=J(e=>e.agents),n=J(e=>e.qa),r=J(e=>e.requests),i=J(e=>e.settings),a=J(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(Fx).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[jx(e.id,t.number)]);return{repo:e,team:t.length,working:t.filter(Fx).length,idleDevs:t.filter(e=>e.role===`dev`&&!Fx(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=Lx(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 ${r1(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 d1(){let e=u1(),t=J(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 f1=null,p1=()=>{let e=J.getState();return Lx(e.requests).length+Ix(e.messages,e.phoneReadAt)};function m1({tab:e,requestId:t}){let[n,r]=(0,v.useState)(()=>f1&&!t&&p1()<=f1.waiting?`games`:e??(t?`hires`:`chat`)),[i,a]=(0,v.useState)(()=>n===`games`?f1?.game??null:null),o=(0,v.useRef)({tab:n,game:i});(0,v.useEffect)(()=>{o.current={tab:n,game:i}}),(0,v.useEffect)(()=>()=>{f1=o.current.tab===`games`?{game:o.current.game,waiting:p1()}:null},[]);let s=J(e=>e.openOverlay),c=J(e=>e.requests),l=J(e=>e.messages),u=J(e=>e.phoneReadAt),d=J(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(),I1())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let m=Lx(c).length,h=Ix(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&&I1(),children:(0,K.jsxs)(`div`,{className:`phone`,children:[(0,K.jsxs)(`div`,{className:`phone-status`,children:[(0,K.jsx)(`span`,{children:r1(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)(l1,{}),n===`hires`&&(0,K.jsx)(o1,{focusId:t}),n===`company`&&(0,K.jsx)(d1,{}),n===`games`&&(0,K.jsx)(t1,{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 h1(e){try{return await e()}catch{return}}var g1=e=>e.includes(`\\`)?`\\`:`/`;function _1({floor:e,onDone:t}){let n=J(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),h1(()=>PA.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 h1(n);f(null),r?t(r):p(a)},g=async t=>{await YA({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,()=>PA.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 h1(()=>PA.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,()=>PA.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 v1({floor:e,onDone:t}){let n=J(e=>e.repos),r=J(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),h1(()=>PA.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 h1(()=>PA.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,g1(r),`<name>.`]})]})}function y1({floor:e,onDone:t}){let n=J(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 h1(()=>PA.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}${g1(n)}${d}`:`${n}${g1(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 b1({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)(_1,{floor:c,onDone:l}),n===`github`&&(0,K.jsx)(v1,{floor:c,onDone:l}),n===`new`&&(0,K.jsx)(y1,{floor:c,onDone:l})]})}var x1={idle:`free`,preparing:`setting up`,working:`working`,done:`done`,error:`needs help`,stopped:`stopped`};function S1({status:e}){return(0,K.jsx)(`span`,{className:`status status-${e}`,children:x1[e]??e})}function C1(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 w1({agentId:e}){let t=J(t=>t.agents[e]),n=J(t=>t.logs[e])??[],r=J(t=>t.screens[e]),i=J(t=>t.repos.find(n=>n.id===t.agents[e]?.repoId)),a=J(e=>e.agents),o=J(e=>e.settings),s=J(e=>e.clis),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[,g]=(0,v.useState)(0),_=(0,v.useRef)(null),y=(0,v.useRef)(!0);(0,v.useEffect)(()=>{let e=setInterval(()=>g(e=>e+1),1e3);return()=>clearInterval(e)},[]),(0,v.useLayoutEffect)(()=>{let e=_.current;e&&y.current&&(e.scrollTop=e.scrollHeight)},[n.length]);let b=J(e=>e.qa),x=(0,v.useMemo)(()=>i?zx(i,Nx(a,i.id),b):null,[i,a,b]),S=t?.role===`qa`,C=x?S?x.qa.filter(e=>!e.qa||e.qa.status===`needs-human`||e.qa.status===`queued`):x.backlog:[];if(!t||!i)return(0,K.jsx)(L1,{title:`Terminal`,children:(0,K.jsx)(`p`,{className:`muted`,children:`That agent has left the building.`})});let w=async e=>{p(!0);try{await e()}catch{}finally{p(!1)}},T=Fx(t),E=t.role===`ceo`?`claude`:t.cli||o.defaultCli,D=s.find(e=>e.id===E)?.label??E,O=t.issueNumber?`https://github.com/${i.fullName}/issues/${t.issueNumber}`:null,k=T||!S&&!!t.branch&&t.status!==`idle`,A=t.prNumber?b[`${i.id}#${t.prNumber}`]:void 0;return(0,K.jsxs)(L1,{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:[S?`🔍`:`💻`,` `,t.title||(S?`QA tester`:`Developer`),t.specialty?` · 🎯 ${t.specialty}`:``]}),(0,K.jsx)(S1,{status:t.status}),T&&t.currentTool&&(0,K.jsxs)(`span`,{className:`muted small`,children:[Nw(t.currentTool),`…`]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-small setup-toggle ${m?`setup-toggle-on`:``}`,"aria-expanded":m,"aria-controls":`agent-setup`,title:`${t.name}'s coding agent, model, effort and job`,onClick:()=>h(e=>!e),children:`⚙️ Setup`})]}),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:O,target:`_blank`,rel:`noreferrer`,children:[`Issue #`,t.issueNumber,`: `,t.issueTitle]}):(0,K.jsx)(`span`,{className:`muted`,children:S?`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]}),A&&t.status!==`idle`&&(0,K.jsxs)(`span`,{className:`chip ${A.status===`passed`?`chip-good`:``}`,children:[`QA: `,A.status,A.round>1?` · round ${A.round}`:``]}),A?.commentUrl&&(0,K.jsx)(`a`,{href:A.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:[`⌨️ `,D]}),(0,K.jsxs)(`span`,{className:`muted`,children:[(t.role===`ceo`?t.model:KM(t.model,o.runtime===`terminal`?E:`claude`,o,`claude-opus-5-5`))||`default model`,` ·`,` `,t.effort||o.defaultEffort,` effort`]}),t.startedAt&&(0,K.jsxs)(`span`,{className:`muted`,children:[`⏱ `,C1(t.startedAt,T?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]}),m&&(0,K.jsx)(`div`,{id:`agent-setup`,className:`setup-wrap`,children:(0,K.jsx)(uN,{agent:t})}),t.brief&&!m&&(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)(vZ,{text:t.brief})]}),(0,K.jsxs)(`div`,{className:`term-split ${t.hasScreenshot?`term-split-2`:``}`,children:[t.terminal?(0,K.jsx)(vV,{agentId:t.id}):(0,K.jsxs)(`div`,{className:`term`,ref:_,onScroll:e=>{let t=e.currentTarget;y.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)),T&&(0,K.jsxs)(`div`,{className:`term-line term-spin`,children:[`✻ `,t.status===`preparing`?`Setting up worktree`:Nw(t.currentTool)||`Thinking`,`… (`,C1(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(``),w(()=>PA.message(t.id,n)))},children:[(0,K.jsx)(yZ,{value:c,onChange:l,"aria-label":`Message ${t.name}`,title:`Enter sends · Shift+Enter adds a new line`,placeholder:T?`Tell ${t.name} something while they work${t.terminal?` (typed into their terminal)`:``}…`:k?`Ask ${t.name} for a follow-up (resumes their session)…`:`Assign an issue to get ${t.name} started`,disabled:!k,autoFocus:!t.terminal}),(0,K.jsx)(`button`,{className:`btn`,disabled:f||!k||!c.trim(),children:`Send`})]}),(0,K.jsxs)(`div`,{className:`term-actions`,children:[T?(0,K.jsx)(`button`,{className:`btn btn-bad`,disabled:f,onClick:()=>w(()=>PA.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:S?`Pick a pull request to test…`:`Pick an issue from the backlog…`}),C.map(e=>(0,K.jsxs)(`option`,{value:e.number,children:[S?`PR `:``,`#`,e.number,` `,e.title]},e.key))]}),(0,K.jsx)(`button`,{className:`btn btn-good`,disabled:f||!u,onClick:()=>w(async()=>{S?await PA.sendToQa(i.id,Number(u)):await PA.assign(t.id,Number(u)),d(``)}),children:S?`🔍 Send to QA`:`▶ Start issue`}),t.status!==`idle`&&(0,K.jsx)(`button`,{className:`btn`,disabled:f,onClick:()=>w(()=>PA.reset(t.id)),children:`↺ Clear desk`})]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`btn btn-ghost`,disabled:f,onClick:()=>{w(async()=>{await YA({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 PA.fireAgent(t.id),I1())})},children:`Let go`})]})]})}async function T1(e){try{return await e()}catch{return}}var E1=`Start the office with npm run dev or npm start so it can install updates and restart itself.`;function D1({update:e}){let t=J(e=>e.officeCommit),n=J(e=>e.settings.autoUpdate),[r,i]=(0,v.useState)(!1),a=e=>{i(!0),T1(()=>PA.updateOffice(e)).finally(()=>i(!1))},o=SM(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:E1;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:bM(e)})]}),s&&(0,K.jsxs)(`div`,{className:`office-actions`,title:e.launcher?void 0:E1,children:[(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:r||!CM(e),title:l(CM(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||!wM(e),title:l(wM(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:E1}),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 T1(()=>PA.updateSettings({autoUpdate:e.target.checked}))}),` Update automatically`]})]})}function O1({repo:e,all:t}){let n=J(e=>e.agents),r=J(e=>e.goToFloor),i=J(e=>e.openOverlay),a=J(e=>!!e.officeUpdate)&&!!e.folderSync?.startsWith(`update ready`),o=Nx(n,e.id),s=t.filter(t=>t.id!==e.id),c=t=>void T1(()=>PA.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&&(0,K.jsxs)(`span`,{title:e.folderSync,children:[` · `,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 T1(()=>PA.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:()=>{YA({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&&T1(()=>PA.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)(FM,{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)(RM,{repo:e}),(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>i({kind:`app`,repoId:e.id}),children:`Open the app viewer`})]})]})}function k1(){let e=J(e=>e.repos),t=J(e=>e.officeUpdate);return(0,K.jsxs)(`div`,{className:`tab-grid`,children:[(0,K.jsxs)(`div`,{children:[t&&(0,K.jsx)(D1,{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)(O1,{repo:t,all:e},t.id))]}),(0,K.jsxs)(`div`,{className:`card`,children:[(0,K.jsx)(`h3`,{children:`➕ Add a project`}),(0,K.jsx)(b1,{})]})]})}function A1({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 T1(()=>PA.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 T1(()=>PA.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 T1(()=>PA.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 T1(()=>PA.updateRepo(e.id,{qaBrief:t.target.value}))},e.qaBrief)]})]})}function j1(){let e=J(e=>e.agents.ceo),t=J(e=>e.logs.ceo)??[],n=J(e=>e.ceo),r=J(e=>e.repos),i=J(e=>e.requests),a=J(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=Lx(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)(tN,{agent:e,style:{maxWidth:140,fontWeight:700}}),(0,K.jsx)(`span`,{className:`muted small`,children:`CEO`}),(0,K.jsx)(S1,{status:e.status}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(rN,{agent:e,style:{maxWidth:150}}),(0,K.jsx)(iN,{agent:e,style:{width:`auto`}})]}),(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).`}),(0,K.jsx)(lN,{agent:e}),e.terminal?(0,K.jsx)(vV,{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(``),T1(()=>PA.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 T1(()=>PA.stop(e.id)),children:`■ Stop`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:r.length===0,onClick:()=>void T1(()=>PA.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)(a1,{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)(a1,{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)(A1,{repo:e},e.id))]})]})}function M1(){let e=J(e=>e.repos),t=J(e=>e.agents),n=J(e=>e.settings),r=J(e=>e.openOverlay),i=n.runtime===`terminal`,[a,o]=(0,v.useState)({}),[s,c]=(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.jsx)(`div`,{children:[...e].sort((e,t)=>e.floor-t.floor).map(e=>{let n=Nx(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:a[e.id]??``,onChange:t=>o({...a,[e.id]:t.target.value}),placeholder:`Name (optional)`,style:{maxWidth:160}}),(0,K.jsx)(`button`,{className:`btn btn-small btn-good`,disabled:n.filter(e=>e.role===`dev`).length>=12,onClick:()=>void T1(()=>PA.hireAgent(e.id,{name:a[e.id]||void 0,role:`dev`})).then(()=>o({...a,[e.id]:``})),children:`+ Developer`}),(0,K.jsx)(`button`,{className:`btn btn-small`,disabled:n.filter(e=>e.role===`qa`).length>=3,onClick:()=>void T1(()=>PA.hireAgent(e.id,{name:a[e.id]||void 0,role:`qa`})).then(()=>o({...a,[e.id]:``})),children:`+ QA tester`})]}),n.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:n.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)(tN,{agent:e})}),(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)(aN,{agent:e})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(oN,{agent:e,style:{width:96}})}),(0,K.jsx)(`td`,{children:(0,K.jsxs)(`button`,{className:`btn btn-small btn-ghost`,title:`Job description and look`,onClick:()=>c(s===e.id?null:e.id),children:[`📝`,e.brief?``:` +`]})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(S1,{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)}),i&&(0,K.jsx)(`td`,{children:(0,K.jsx)(nN,{agent:e,style:{width:112}})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(rN,{agent:e,style:{minWidth:110}})}),(0,K.jsx)(`td`,{children:(0,K.jsx)(iN,{agent:e,style:{width:124}})}),(0,K.jsxs)(`td`,{className:`nowrap`,children:[(0,K.jsx)(`button`,{className:`btn btn-small`,onClick:()=>r({kind:`terminal`,agentId:e.id}),children:`Terminal`}),` `,(0,K.jsx)(`button`,{className:`btn btn-small btn-ghost`,onClick:()=>void YA({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&&T1(()=>PA.fireAgent(e.id))),children:`Let go`})]})]}),s===e.id&&(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{}),(0,K.jsxs)(`td`,{colSpan:i?11:10,children:[(0,K.jsxs)(`label`,{className:`row small`,children:[(0,K.jsx)(`span`,{children:`Drawn as`}),(0,K.jsx)(sN,{agent:e})]}),(0,K.jsx)(cN,{agent:e,compact:!0})]})]})]},e.id))})})]},e.id)})})}function N1({initialRepo:e}){let t=J(e=>e.repos),n=J(e=>e.agents),[r,i]=(0,v.useState)(e??t[0]?.id??``),a=t.find(e=>e.id===r),o=(0,v.useMemo)(()=>Nx(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)(HM,{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 T1(()=>PA.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 P1(){let e=J(e=>e.settings),t=J(e=>e.clis),n=J(e=>e.user),r=J(e=>e.workspaceRoot),i=J(e=>e.demo),a=e=>void T1(()=>PA.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)(eN,{clis:t})})]}),(0,K.jsxs)(`label`,{className:`field`,children:[(0,K.jsxs)(`span`,{children:[`Default model`,o?` for ${ZM(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:qM.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:YM.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 F1({initialTab:e,initialRepo:t}){let[n,r]=(0,v.useState)(e??`floors`),i=J(e=>Lx(e.requests).length),a=[[`floors`,`🏢 Floors & repos`],[`ceo`,`🧠 CEO & hiring${i?` (${i})`:``}`],[`team`,`👩💻 Team`],[`issues`,`📝 Issues`],[`settings`,`⚙️ Settings`]];return(0,K.jsxs)(L1,{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)(k1,{}),n===`ceo`&&(0,K.jsx)(j1,{}),n===`team`&&(0,K.jsx)(M1,{}),n===`issues`&&(0,K.jsx)(N1,{initialRepo:t}),n===`settings`&&(0,K.jsx)(P1,{})]})]})}function I1(){J.getState().openOverlay(null)}function L1({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():I1())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,K.jsx)(`div`,{className:`overlay`,onMouseDown:e=>e.target===e.currentTarget&&I1(),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():I1(),"aria-label":`Close`,children:`✕`})]}),(0,K.jsx)(`div`,{className:`panel-body`,children:t})]})})}var R1={steps:`Footsteps`,typing:`Typing`,toys:`Toys`,alerts:`Alerts`};function z1(){let e=(0,v.useSyncExternalStore)(db,ub),{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=>mb({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=>mb({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:R1[t]}),(0,K.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e[t],disabled:n,"aria-label":`${R1[t]} volume`,"aria-valuetext":`${e[t]}%`,onChange:e=>mb({[t]:Number(e.target.value)})}),(0,K.jsxs)(`span`,{className:`small sound-pct`,children:[e[t],`%`]})]},t))})]})}function B1(){let{sensitivity:e,invertY:t,grabOnClose:n,set:r}=qA();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:HA,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 V1(){return(0,K.jsx)(L1,{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)(B1,{}),(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:`Coffee`}),(0,K.jsxs)(`p`,{children:[`Every office floor's kitchenette has a coffee machine and a stack of mugs. Take a mug (`,(0,K.jsx)(`kbd`,{children:`E`}),`), aim at the machine's drip tray and press `,(0,K.jsx)(`kbd`,{children:`E`}),` to put it under the spout, then press the machine's round button. After a few seconds of grinding and gurgling it beeps: aim at the mug and press `,(0,K.jsx)(`kbd`,{children:`E`}),` to take your coffee. You can take the mug out early (it keeps what it has), and a dropped mug can go back in for a refill.`]}),(0,K.jsxs)(`p`,{children:[`With coffee in hand, `,(0,K.jsx)(`kbd`,{children:`E`}),` takes a sip wherever you're looking (except at the machine). A full mug is three sips: the last is one big gulp, and then you drop the empty mug. Pick it up and refill it, or take a fresh one.`]}),(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. A merge on the floor you're on bangs its gong (by the whiteboard) and the whole floor cheers; press `,(0,K.jsx)(`kbd`,{children:`E`}),` at the gong to bang it yourself. `,(0,K.jsx)(`kbd`,{children:`M`}),` mutes or unmutes anywhere. Under the volume, turn footsteps, typing, toys and alerts (the phone, the elevator, the gong and these cues) up or down on their own.`]}),(0,K.jsx)(z1,{}),(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 H1(){let e=J(e=>e.overlay);if(!e)return null;switch(e.kind){case`terminal`:return e.agentId===`ceo`?(0,K.jsx)(F1,{initialTab:`ceo`}):(0,K.jsx)(w1,{agentId:e.agentId});case`phone`:return(0,K.jsx)(m1,{tab:e.tab,requestId:e.requestId});case`kanban`:return(0,K.jsx)(WM,{repoId:e.repoId});case`app`:return(0,K.jsx)(zM,{repoId:e.repoId});case`elevator`:return(0,K.jsx)(BM,{});case`manager`:return(0,K.jsx)(F1,{initialTab:e.tab,initialRepo:e.repoId});case`help`:return(0,K.jsx)(V1,{})}}var U1=[`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`],W1=[`Morgan`,`Avery`,`Jordan`,`Riley`,`Quinn`,`Harper`,`Rowan`,`Sasha`,`Casey`,`Jamie`,`Alex`,`Robin`],G1=[`#e63946`,`#3a86ff`,`#06d6a0`,`#ffbe0b`,`#9b5de5`,`#fb5607`],K1=[`Welcome`,`You`,`Your CEO`,`First project`,`Ready`],q1=(e,t)=>{let n=e.filter(e=>e!==t);return n[Math.floor(Math.random()*n.length)]};function J1({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 Y1(){let e=J(e=>e.user),t=J(e=>e.demo),n=J(e=>e.ghReady),r=J(e=>e.ghError),i=J(e=>e.agents.ceo),a=J(e=>e.start),[o,s]=(0,v.useState)(0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(()=>U1[Math.floor(Math.random()*U1.length)]),[f,p]=(0,v.useState)(i?.name??`Morgan`),[m,h]=(0,v.useState)(i?.look??`masculine`),[g,_]=(0,v.useState)(i?.color??G1[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()||U1[0],O=()=>PA.setup({managerName:T,companyName:D,hiring:y,ceoName:E,ceoLook:m,ceoColor:g}),k=async()=>{w(!0);try{await O(),await PA.updateSettings({setupDone:!0,tutorialStep:0}),a(),Zj()}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:K1.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:U1[0]}),(0,K.jsx)(`button`,{type:`button`,className:`btn btn-small`,title:`Suggest another name`,onClick:()=>d(q1(U1,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)(J1,{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(q1(W1,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`}),G1.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)(b1,{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 X1(){let e=J(e=>e.started),t=J(e=>e.loaded),n=J(e=>e.connected),r=J(e=>e.demo),i=J(e=>e.repos),a=J(e=>e.agents),o=J(e=>e.settings),s=J(e=>e.start),c=Rx();if(e)return null;if(t&&!o.setupDone)return(0,K.jsx)(Y1,{});let l=()=>{s(),lb(),Zj()},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 Z1=[{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 Q1(){let e=J(e=>e.settings.tutorialStep),t=J(e=>e.settings.setupDone),n=J(e=>e.started),r=J(e=>e.settings.companyName),i=J(e=>e.agents.ceo?.name??`the CEO`),a=J(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<Z1.length,d=e=>{c.current||(c.current=!0,PA.updateSettings({tutorialStep:e>=Z1.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=Z1[e];if(!t.done)return;let n=null,r=()=>{if(n||c.current)return;let r=J.getState();if(!t.done(r))return;let i=Math.max(0,(t.minMs??0)-(Date.now()-l.current));n=setTimeout(()=>{if(!t.done(J.getState())){n=null;return}s(!0),n=setTimeout(()=>d(e+1),900)},i)};r();let i=J.subscribe(r),a=setInterval(r,1e3);return()=>{i(),clearInterval(a),n&&clearTimeout(n)}},[u,e]),!u)return null;let f=Z1[e],p=e===Z1.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,`/`,Z1.length]}),(0,K.jsx)(`span`,{className:`spacer`}),(0,K.jsx)(`button`,{className:`linkish small`,onClick:()=>d(Z1.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 $1(){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(aM,{}),(0,K.jsx)(kM,{}),(0,K.jsx)(H1,{}),(0,K.jsx)(Q1,{}),(0,K.jsx)(X1,{}),(0,K.jsx)($A,{}),Vx&&(0,K.jsx)(Zx,{})]})}var e0=0,t0=`office-swarm:reloaded-for`;function n0(){try{return sessionStorage.getItem(t0)}catch{return null}}function r0(e){if(!EM(J.getState().officeCommit,e,n0()))return!1;try{sessionStorage.setItem(t0,e)}catch{return!1}return location.reload(),!0}function i0(){let e=location.protocol===`https:`?`wss`:`ws`,t=new WebSocket(`${e}://${location.host}/ws`);t.onopen=()=>{e0=0,J.getState().setConnected(!0)},t.onmessage=e=>{try{let t=JSON.parse(e.data);if(t.type===`snapshot`&&t.data.officeCommit&&r0(t.data.officeCommit))return;J.getState().apply(t)}catch(e){console.error(`bad server event`,e)}},t.onclose=()=>{let e=J.getState();e.setConnected(!1);let t=e.restarting||TM(e.officeUpdate);t!==e.restarting&&e.setRestarting(t),setTimeout(i0,Math.min(t?2e3:8e3,500*2**e0++))}}i0(),(0,y.createRoot)(document.getElementById(`root`)).render((0,K.jsx)($1,{}));export{_T as $,xt as $t,zk as A,jy as At,eO as B,Es as Bt,oA as C,wb as Ct,Gk as D,zb as Dt,$k as E,Rb as Et,pO as F,Tg as Ft,QD as G,Rn as Gt,qD as H,Nt as Ht,CO as I,Pi as It,Y as J,D as Jt,$D as K,fr as Kt,TO as L,W as Lt,PO as M,G_ as Mt,IO as N,W_ as Nt,Hk as O,q as Ot,jO as P,Hg as Pt,gT as Q,w as Qt,SO as R,vs as Rt,cA as S,jb as St,tA as T,Db as Tt,oO as U,Sr as Ut,aO as V,ao as Vt,nO as W,vo as Wt,nT as X,zn as Xt,IE as Y,zr as Yt,tT as Z,ge as Zt,tj as _,Mx as _t,kj as a,Ow as at,_A as b,Eb as bt,Ij as c,$C as ct,Cj as d,Qx as dt,V as en,yT as et,Dj as f,oS as ft,rj as g,Wx as gt,oj as h,rS as ht,Oj as i,Ww as it,kO as j,Ey as jt,Bk as k,Fy as kt,Nj as l,hS as lt,_j as m,CS as mt,Hj as n,s as nn,Zw as nt,jj as o,nw as ot,gj as p,MS as pt,sD as q,Na as qt,Lj as r,l as rn,Dw as rt,Mj as s,QC as st,Vj as t,p as tn,Qw as tt,yj as u,eS as ut,ij as v,J as vt,Xk as w,Pb as wt,sA as x,Tb as xt,aj as y,cb as yt,UD as z,H as zt};
|