glimmervoid 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bin/glimmervoid.js +5 -5
- package/dist/chunks/{adapters-CUBEhjOR.js → adapters-BY8slY95.js} +1 -1
- package/dist/chunks/{adapters-C9gI2MHS.js → adapters-_HwpLy0R.js} +1 -1
- package/dist/chunks/{config-Cneb8Ujj.js → config-DTwMFUjx.js} +13 -9
- package/dist/chunks/config-store-BmdXeUz1.js +2 -0
- package/dist/chunks/{config-store-DYsZJDux.js → config-store-CggAQLUB.js} +17 -9
- package/dist/chunks/{contracts-DWv6q8ir.js → contracts-D1wLN5iO.js} +1 -1
- package/dist/chunks/{knowledge-graph-cli-C7G-x5sY.js → knowledge-graph-cli-BBE3R9DJ.js} +1 -1
- package/dist/chunks/{main-J6y2RTri.js → main-Dh4udE7P.js} +175 -112
- package/dist/chunks/{pair-cli-BuyzST-U.js → pair-cli-Nnrd0il_.js} +2 -2
- package/dist/chunks/{remote-config-DJHVb-HU.js → remote-config-DKMQEIZh.js} +1 -1
- package/dist/chunks/{sandbox-deps-DuaNFq7n.js → sandbox-deps-C63o3mZs.js} +4 -4
- package/dist/client/assets/{index-CoFsm_PF.js → index-BiTwrj1H.js} +15 -15
- package/dist/client/index.html +1 -1
- package/dist/scripts/postinstall-path-check.js +1 -1
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/config-store-DaRS2c2d.js +0 -2
|
@@ -60,13 +60,13 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
60
60
|
|
|
61
61
|
`+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 Rm(e){Bm(e)||Lm.onUnexpectedError(e)}var zm=`Canceled`;function Bm(e){return e instanceof Vm||e instanceof Error&&e.name===zm&&e.message===zm}var Vm=class extends Error{constructor(){super(zm),this.name=this.message}};function Hm(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var Um=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`}},Wm=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function Gm(e,t=0){return e[e.length-(1+t)]}var Km;(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})(Km||={});var qm=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||Km.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};qm.empty=new qm(e=>{});function Jm(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 Ym;(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})(Ym||={});var Xm=null;function Zm(e){return Xm?.trackDisposable(e),e}function Qm(e){Xm?.markAsDisposed(e)}function $m(e,t){Xm?.setParent(e,t)}function eh(e){return Xm?.markAsSingleton(e),e}function th(e){if(Ym.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 nh(...e){return rh(()=>th(e))}function rh(e){let t=Zm({dispose:Jm(()=>{Qm(t),e()})});return t}var ih=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Zm(this)}dispose(){this._isDisposed||(Qm(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{th(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return $m(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),$m(e,null))}};ih.DISABLE_DISPOSED_WARNING=!1;var ah=ih,G=class{constructor(){this._store=new ah,Zm(this),$m(this._store,this)}dispose(){Qm(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};G.None=Object.freeze({dispose(){}});var oh=class{constructor(){this._isDisposed=!1,Zm(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&$m(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Qm(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&$m(e,null),e}},sh=typeof window==`object`?window:globalThis,ch=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};ch.Undefined=new ch(void 0);var lh=ch,uh=class{constructor(){this._first=lh.Undefined,this._last=lh.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===lh.Undefined}clear(){let e=this._first;for(;e!==lh.Undefined;){let t=e.next;e.prev=lh.Undefined,e.next=lh.Undefined,e=t}this._first=lh.Undefined,this._last=lh.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new lh(e);if(this._first===lh.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!==lh.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==lh.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==lh.Undefined&&e.next!==lh.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===lh.Undefined&&e.next===lh.Undefined?(this._first=lh.Undefined,this._last=lh.Undefined):e.next===lh.Undefined?(this._last=this._last.prev,this._last.next=lh.Undefined):e.prev===lh.Undefined&&(this._first=this._first.next,this._first.prev=lh.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==lh.Undefined;)yield e.element,e=e.next}},dh=globalThis.performance&&typeof globalThis.performance.now==`function`,fh=class e{static create(t){return new e(t)}constructor(e){this._now=dh&&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}},ph;(e=>{e.None=()=>G.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(nh(...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 K({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 K({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 K({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 K({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function ee(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new K({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=ee;function b(e){return new Promise(t=>n(e)(t))}e.toPromise=b;function te(e){let t=new K;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=te;function ne(e,t){return e(e=>t.fire(e))}e.forward=ne;function re(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=re;class ie{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 K(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 ae(e,t){return new ie(e,t).emitter.event}e.fromObservable=ae;function x(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 ah?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=x})(ph||={});var mh=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 fh,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}}};mh.all=new Set,mh._idPool=0;var hh=mh,gh=-1,_h=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 bh(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}};_h._idPool=1;var vh=_h,yh=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??``)}print(){console.warn(this.value.split(`
|
|
62
62
|
`).slice(2).join(`
|
|
63
|
-
`))}},bh=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},xh=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Sh=0,Ch=class{constructor(e){this.value=e,this.id=Sh++}},wh=2,K=class{constructor(e){this._size=0,this._options=e,this._leakageMon=gh>0||this._options?.leakWarningThreshold?new vh(e?.onListenerError??Rm,this._options?.leakWarningThreshold??gh):void 0,this._perfMon=this._options?._profName?new hh(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 xh(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Rm)(n),G.None}if(this._disposed)return G.None;t&&(e=e.bind(t));let r=new Ch(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=yh.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ch?(this._deliveryQueue??=new Th,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=rh(()=>{i?.(),this._removeListener(r)});return n instanceof ah?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*wh<=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||Rm;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 Ch)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}},Th=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}},Eh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new K,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new K,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}};Eh.INSTANCE=new Eh;var Dh=Eh;function Oh(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Dh.INSTANCE.onDidChangeZoomLevel;function kh(e){return Dh.INSTANCE.getZoomFactor(e)}Dh.INSTANCE.onDidChangeFullscreen;var Ah=typeof navigator==`object`?navigator.userAgent:``,jh=Ah.indexOf(`Firefox`)>=0,Mh=Ah.indexOf(`AppleWebKit`)>=0,Nh=Ah.indexOf(`Chrome`)>=0,Ph=!Nh&&Ah.indexOf(`Safari`)>=0;Ah.indexOf(`Electron/`),Ah.indexOf(`Android`);var Fh=!1;if(typeof sh.matchMedia==`function`){let e=sh.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=sh.matchMedia(`(display-mode: fullscreen)`);Fh=e.matches,Oh(sh,e,({matches:e})=>{Fh&&t.matches||(Fh=e)})}function Ih(){return Fh}var Lh=`en`,Rh=!1,zh=!1,Bh=!1,Vh=!1,Hh=!1,Uh=Lh,Wh,Gh=globalThis,Kh;typeof Gh.vscode<`u`&&typeof Gh.vscode.process<`u`?Kh=Gh.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Kh=process);var qh=typeof Kh?.versions?.electron==`string`&&Kh?.type===`renderer`;if(typeof Kh==`object`){Rh=Kh.platform===`win32`,zh=Kh.platform===`darwin`,Bh=Kh.platform===`linux`,Bh&&Kh.env.SNAP&&Kh.env.SNAP_REVISION,Kh.env.CI||Kh.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Uh=Lh;let e=Kh.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Uh=t.resolvedLanguage||Lh,t.languagePack?.translationsConfigFile}catch{}Vh=!0}else typeof navigator==`object`&&!qh?(Wh=navigator.userAgent,Rh=Wh.indexOf(`Windows`)>=0,zh=Wh.indexOf(`Macintosh`)>=0,(Wh.indexOf(`Macintosh`)>=0||Wh.indexOf(`iPad`)>=0||Wh.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Bh=Wh.indexOf(`Linux`)>=0,Wh?.indexOf(`Mobi`),Hh=!0,Uh=globalThis._VSCODE_NLS_LANGUAGE||Lh,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Jh=Rh,Yh=zh,Xh=Bh,Zh=Vh;Hh&&typeof Gh.importScripts==`function`&&Gh.origin;var Qh=Wh,$h=Uh,eg;(e=>{function t(){return $h}e.value=t;function n(){return $h.length===2?$h===`en`:$h.length>=3&&$h[0]===`e`&&$h[1]===`n`&&$h[2]===`-`}e.isDefaultVariant=n;function r(){return $h===`en`}e.isDefault=r})(eg||={});var xte=typeof Gh.postMessage==`function`&&!Gh.importScripts;(()=>{if(xte){let e=[];Gh.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}),Gh.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Ste=!!(Qh&&Qh.indexOf(`Chrome`)>=0);Qh&&Qh.indexOf(`Firefox`),!Ste&&Qh&&Qh.indexOf(`Safari`),Qh&&Qh.indexOf(`Edg/`),Qh&&Qh.indexOf(`Android`);var tg=typeof navigator==`object`?navigator:{};Zh||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||tg&&tg.clipboard&&tg.clipboard.writeText,Zh||tg&&tg.clipboard&&tg.clipboard.readText,Zh||Ih()||tg.keyboard,`ontouchstart`in sh||tg.maxTouchPoints,sh.PointerEvent&&(`ontouchstart`in sh||navigator.maxTouchPoints);var ng=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}},rg=new ng,ig=new ng,ag=new ng,Cte=Array(230),og;(e=>{function t(e){return rg.keyCodeToStr(e)}e.toString=t;function n(e){return rg.strToKeyCode(e)}e.fromString=n;function r(e){return ig.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return ag.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return ig.strToKeyCode(e)||ag.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 rg.keyCodeToStr(e)}e.toElectronAccelerator=o})(og||={});var wte=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 Tte([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Tte=class{constructor(e){if(e.length===0)throw Hm(`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 Ete(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return og.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(jh)switch(t){case 59:return 85;case 60:if(Xh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Yh)return 57}else if(Mh&&(Yh&&t===93||!Yh&&t===92))return 57;return Cte[t]||0}var Dte=Yh?256:2048,Ote=512,kte=1024,Ate=Yh?2048:256,sg=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=Ete(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|=Dte),this.altKey&&(t|=Ote),this.shiftKey&&(t|=kte),this.metaKey&&(t|=Ate),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new wte(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},cg=new WeakMap;function jte(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 Mte=class{static getSameOriginWindowChain(e){let t=cg.get(e);if(!t){t=[],cg.set(e,t);let n=e,r;do r=jte(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}}},lg=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=Mte.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},ug=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(Nh){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?jh&&!Yh?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=Ph&&Jh?-(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?jh&&!Yh?-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()}},dg=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Nte;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Pte?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ph.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:dg})})(Nte||={});var Pte=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?dg:(this._emitter||=new K,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},fg=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 Wm(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Wm(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Fte=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 Wm(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=rh(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Ite;(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})(Ite||={});var pg=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 K,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 ph.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())}};pg.EMPTY=pg.fromArray([]);function Lte(e){return mg(e,0)}function mg(e,t){switch(typeof e){case`object`:return e===null?hg(349,t):Array.isArray(e)?zte(e,t):Bte(e,t);case`string`:return gg(e,t);case`boolean`:return Rte(e,t);case`number`:return hg(e,t);case`undefined`:return hg(937,t);default:return hg(617,t)}}function hg(e,t){return(t<<5)-t+e|0}function Rte(e,t){return hg(e?433:863,t)}function gg(e,t){t=hg(149417,t);for(let n=0,r=e.length;n<r;n++)t=hg(e.charCodeAt(n),t);return t}function zte(e,t){return t=hg(104579,t),e.reduce((e,t)=>mg(t,e),t)}function Bte(e,t){return t=hg(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=gg(n,t),mg(e[n],t)),t)}var{registerWindow:Vte,getWindow:_g,getDocument:Hte,getWindows:Ute,getWindowsCount:Wte,getWindowId:Gte,getWindowById:Kte,hasWindow:qte,onDidRegisterWindow:Jte,onWillUnregisterWindow:Yte,onDidUnregisterWindow:Xte}=function(){let e=new Map,t={window:sh,disposables:new ah};e.set(sh.vscodeWindowId,t);let n=new K,r=new K,i=new K;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 G.None;let a=new ah,o={window:t,disposables:a.add(new ah)};return e.set(t.vscodeWindowId,o),a.add(rh(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(q(t,Sg.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:sh},getDocument(e){return _g(e).document}}}(),Zte=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 q(e,t,n,r){return new Zte(e,t,n,r)}function Qte(e,t){return function(n){return t(new lg(e,n))}}function $te(e){return function(t){return e(new sg(t))}}var vg=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=Qte(_g(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=$te(n)),q(e,t,i,r)},yg,ene=class extends Fte{constructor(e){super(),this.defaultTarget=e&&_g(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},bg=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){Rm(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(bg.sort),a.shift().execute();r.set(i,!1)};yg=(t,r,a=0)=>{let o=Gte(t),s=new bg(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 xg=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}};xg.None=new xg(0,0);function tne(e){let t=e.getBoundingClientRect(),n=_g(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=Lte(n),a=r.get(i);if(a)a.users+=1;else{let o=new K,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(rh(()=>{--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 Sg={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:Mh?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Mh?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Mh?`webkitAnimationIteration`:`animationiteration`},nne=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=Cg(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Cg(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Cg(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Cg(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Cg(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Cg(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Cg(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Cg(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Cg(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Cg(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Cg(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=Cg(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=Cg(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Cg(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 Cg(e){return typeof e==`number`?`${e}px`:e}function wg(e){return new nne(e)}var Tg=class{constructor(){this._hooks=new ah,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(rh(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=_g(e)}this._hooks.add(q(a,Sg.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(q(a,Sg.POINTER_UP,e=>this.stopMonitoring(!0)))}};function rne(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 Eg;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Eg||={});var Dg=class e extends G{constructor(){super(),this.dispatched=!1,this.targets=new uh,this.ignoreTargets=new uh,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ph.runAndSubscribe(Jte,({window:e,disposables:t})=>{t.add(q(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(q(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(q(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:sh,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=eh(new e),rh(e.INSTANCE.targets.push(t))):G.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=eh(new e),rh(e.INSTANCE.ignoreTargets.push(t))):G.None}static isTouchDevice(){return`ontouchstart`in sh||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(Eg.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-Gm(s.rollingPageX))<30&&Math.abs(s.initialPageY-Gm(s.rollingPageY))<30){let e=this.newGestureEvent(Eg.Tap,s.initialTarget);e.pageX=Gm(s.rollingPageX),e.pageY=Gm(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-Gm(s.rollingPageX))<30&&Math.abs(s.initialPageY-Gm(s.rollingPageY))<30){let e=this.newGestureEvent(Eg.Contextmenu,s.initialTarget);e.pageX=Gm(s.rollingPageX),e.pageY=Gm(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Gm(s.rollingPageX),n=Gm(s.rollingPageY),i=Gm(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(Eg.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===Eg.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===Eg.Change||t.type===Eg.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=yg(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(Eg.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(Eg.Change,i.initialTarget);a.translationX=r.pageX-Gm(i.rollingPageX),a.translationY=r.pageY-Gm(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)}};Dg.SCROLL_FRICTION=-.005,Dg.HOLD_DELAY=700,Dg.CLEAR_TAP_COUNT_TIME=400,Wp([rne],Dg,`isTouchDevice`,1);var ine=Dg,Og=class extends G{onclick(e,t){this._register(q(e,Sg.CLICK,n=>t(new lg(_g(e),n))))}onmousedown(e,t){this._register(q(e,Sg.MOUSE_DOWN,n=>t(new lg(_g(e),n))))}onmouseover(e,t){this._register(q(e,Sg.MOUSE_OVER,n=>t(new lg(_g(e),n))))}onmouseleave(e,t){this._register(q(e,Sg.MOUSE_LEAVE,n=>t(new lg(_g(e),n))))}onkeydown(e,t){this._register(q(e,Sg.KEY_DOWN,e=>t(new sg(e))))}onkeyup(e,t){this._register(q(e,Sg.KEY_UP,e=>t(new sg(e))))}oninput(e,t){this._register(q(e,Sg.INPUT,t))}onblur(e,t){this._register(q(e,Sg.BLUR,t))}onfocus(e,t){this._register(q(e,Sg.FOCUS,t))}onchange(e,t){this._register(q(e,Sg.CHANGE,t))}ignoreGesture(e){return ine.ignoreTarget(e)}},kg=11,ane=class extends Og{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=kg+`px`,this.domNode.style.height=kg+`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 Tg),this._register(vg(this.bgDomNode,Sg.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(vg(this.domNode,Sg.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new ene),this._pointerdownScheduleRepeatTimer=this._register(new fg)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,_g(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},one=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}}},sne=class extends G{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new one(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 Mg(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=Mg.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)))}},Ag=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function jg(e,t){let n=t-e;return function(t){return e+n*une(t)}}function cne(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var Mg=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),cne(jg(e,r),jg(i,t),.33)}return jg(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 Ag(this.scrollLeft(t),this.scrollTop(t),!1):new Ag(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 lne(e){return e**3}function une(e){return 1-lne(1-e)}var dne=class extends G{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 fg)}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`:``)))}},fne=140,Ng=class extends Og{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 dne(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Tg),this._shouldRender=!0,this.domNode=wg(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(q(this.domNode.domNode,Sg.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new ane(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=wg(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(q(this.slider.domNode,Sg.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=tne(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(Jh&&a>fne){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()}},Pg=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)}},pne=class extends Ng{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Pg(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}},mne=class extends Ng{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Pg(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}},hne=500,Fg=50,Ig=!0,gne=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Lg=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(Nh){let t=kh(_g(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 gne(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}};Lg.INSTANCE=new Lg;var _ne=Lg,vne=class extends Og{constructor(e,t,n){super(),this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new K),this.onWillScroll=this._onWillScroll.event,this._options=bne(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 mne(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new pne(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=wg(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=wg(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=wg(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 fg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=th(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,Yh&&(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 ug(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=th(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(q(this._listenOnDomNode,Sg.MOUSE_WHEEL,e=>{this._onMouseWheel(new ug(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=_ne.INSTANCE;Ig&&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=!Yh&&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=Fg*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=Fg*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)&&(Ig&&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(),hne)}},yne=class extends vne{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 bne(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,Yh&&(t.className+=` mac`),t}var Rg=class extends G{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new K),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new sne({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>yg(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new yne(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(ph.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(rh(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(rh(()=>this._styleElement.remove())),this._register(ph.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(`
|
|
64
|
-
`)})),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}};Rg=Wp([W(2,_m),W(3,Am),W(4,vm),W(5,Fm),W(6,Cm),W(7,Mm)],Rg);var zg=class extends G{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(rh(()=>{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()}};zg=Wp([W(1,_m),W(2,Am),W(3,Em),W(4,Mm)],zg);var xne=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)}},Bg={full:0,left:0,center:0,right:0},Vg={full:0,left:0,center:0,right:0},Hg={full:0,left:0,center:0,right:0},Ug=class extends G{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 xne,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(rh(()=>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);Vg.full=this._canvas.width,Vg.left=e,Vg.center=t,Vg.right=e,this._refreshDrawHeightConstants(),Hg.full=1,Hg.left=1,Hg.center=1+Vg.left,Hg.right=1+Vg.left+Vg.center}_refreshDrawHeightConstants(){Bg.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);Bg.left=t,Bg.center=t,Bg.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Bg.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Bg.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Bg.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Bg.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(Hg[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Bg[e.position||`full`]/2),Vg[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Bg[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}))}};Ug=Wp([W(2,_m),W(3,Em),W(4,Mm),W(5,Cm),W(6,Fm),W(7,Am)],Ug);var J;(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=`
|
|
65
|
-
`,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=``))(J||={});var Wg;(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=``))(Wg||={});var Gg;(e=>e.ST=`${J.ESC}\\`)(Gg||={});var Kg=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(`${J.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)}}};Kg=Wp([W(2,_m),W(3,Cm),W(4,ym),W(5,Mm)],Kg);var qg=0,Jg=0,Yg=0,Xg=0,Zg={css:`#00000000`,rgba:0},Qg;(e=>{function t(e,t,n,r){return r===void 0?`#${r_(e)}${r_(t)}${r_(n)}`:`#${r_(e)}${r_(t)}${r_(n)}${r_(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})(Qg||={});var $g;(e=>{function t(e,t){if(Xg=(t.rgba&255)/255,Xg===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 qg=a+Math.round((n-a)*Xg),Jg=o+Math.round((r-o)*Xg),Yg=s+Math.round((i-s)*Xg),{css:Qg.toCss(qg,Jg,Yg),rgba:Qg.toRgba(qg,Jg,Yg)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=n_.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Qg.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[qg,Jg,Yg]=n_.toChannels(t),{css:Qg.toCss(qg,Jg,Yg),rgba:t}}e.opaque=i;function a(e,t){return Xg=Math.round(t*255),[qg,Jg,Yg]=n_.toChannels(e.rgba),{css:Qg.toCss(qg,Jg,Yg,Xg),rgba:Qg.toRgba(qg,Jg,Yg,Xg)}}e.opacity=a;function o(e,t){return Xg=e.rgba&255,a(e,Xg*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})($g||={});var e_;(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 qg=parseInt(e.slice(1,2).repeat(2),16),Jg=parseInt(e.slice(2,3).repeat(2),16),Yg=parseInt(e.slice(3,4).repeat(2),16),Qg.toColor(qg,Jg,Yg);case 5:return qg=parseInt(e.slice(1,2).repeat(2),16),Jg=parseInt(e.slice(2,3).repeat(2),16),Yg=parseInt(e.slice(3,4).repeat(2),16),Xg=parseInt(e.slice(4,5).repeat(2),16),Qg.toColor(qg,Jg,Yg,Xg);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 qg=parseInt(r[1]),Jg=parseInt(r[2]),Yg=parseInt(r[3]),Xg=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Qg.toColor(qg,Jg,Yg,Xg);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[qg,Jg,Yg,Xg]=t.getImageData(0,0,1,1).data,Xg!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Qg.toRgba(qg,Jg,Yg,Xg),css:e}}e.toColor=r})(e_||={});var t_;(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})(t_||={});var n_;(e=>{function t(e,t){if(Xg=(t&255)/255,Xg===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 qg=a+Math.round((n-a)*Xg),Jg=o+Math.round((r-o)*Xg),Yg=s+Math.round((i-s)*Xg),Qg.toRgba(qg,Jg,Yg)}e.blend=t;function n(e,t,n){let a=t_.relativeLuminance(e>>8),o=t_.relativeLuminance(t>>8);if(i_(a,o)<n){if(o<a){let o=r(e,t,n),s=i_(a,t_.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>i_(a,t_.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=i_(a,t_.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>i_(a,t_.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=i_(t_.relativeLuminance2(o,s,c),t_.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=i_(t_.relativeLuminance2(o,s,c),t_.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=i_(t_.relativeLuminance2(o,s,c),t_.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=i_(t_.relativeLuminance2(o,s,c),t_.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})(n_||={});function r_(e){let t=e.toString(16);return t.length<2?`0`+t:t}function i_(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Sne=class extends cm{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()]}},a_=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new um}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||sm.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++)a_._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||sm.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}};a_=Wp([W(0,_m)],a_);function Cne(e){return 57508<=e&&e<=57558}function wne(e){return 9472<=e&&e<=9631}function Tne(e){return Cne(e)||wne(e)}function Ene(){return{css:{canvas:o_(),cell:o_()},device:{canvas:o_(),cell:o_(),char:{width:0,height:0,left:0,top:0}}}}function o_(){return{width:0,height:0}}var s_=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 um,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,ee=0,b=0,te=!1,ne=0,re=!1,ie=0,ae=0,x=[],oe=l!==-1&&u!==-1;for(let se=0;se<m;se++){e.loadCell(se,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let ce=!1,le=se>=ae,ue=se,S=this._workCell;if(f.length>0&&se===f[0][0]&&le){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)le&&=i===this._isCellInSelection(v,t);le&&=!n||a<r[0]||a>=r[1],le?(ce=!0,S=new Sne(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ue=r[1]-1,m=S.getWidth()):ae=r[1]}let C=this._isCellInSelection(se,t),w=n&&se===a,de=oe&&se>=l&&se<=u,fe=!1;this._decorationService.forEachDecorationAtCell(se,t,void 0,e=>{fe=!0});let pe=S.getChars()||sm;if(pe===` `&&(S.isUnderline()||S.isOverline())&&(pe=`\xA0`),ie=m*s-c.get(pe,S.isBold(),S.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(C&&re||!C&&!re&&S.bg===y)&&(C&&re&&p.selectionForeground||S.fg===ee)&&S.extended.ext===b&&de===te&&ie===ne&&!w&&!ce&&!fe&&le){S.isInvisible()?_+=sm:_+=pe,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=S.bg,ee=S.fg,b=S.extended.ext,te=de,ne=ie,re=C,ce&&a>=se&&a<=ue&&(a=se),!this._coreService.isCursorHidden&&w&&this._coreService.isCursorInitialized){if(x.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&x.push(`xterm-cursor-blink`),x.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:x.push(`xterm-cursor-outline`);break;case`block`:x.push(`xterm-cursor-block`);break;case`bar`:x.push(`xterm-cursor-bar`);break;case`underline`:x.push(`xterm-cursor-underline`)}}if(S.isBold()&&x.push(`xterm-bold`),S.isItalic()&&x.push(`xterm-italic`),S.isDim()&&x.push(`xterm-dim`),_=S.isInvisible()?sm:S.getChars()||sm,S.isUnderline()&&(x.push(`xterm-underline-${S.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!S.isUnderlineColorDefault())){if(S.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${cm.toColorRGB(S.getUnderlineColor()).join(`,`)})`;else{let e=S.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&S.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}S.isOverline()&&(x.push(`xterm-overline`),_===` `&&(_=`\xA0`)),S.isStrikethrough()&&x.push(`xterm-strikethrough`),de&&(h.style.textDecoration=`underline`);let me=S.getFgColor(),he=S.getFgColorMode(),ge=S.getBgColor(),_e=S.getBgColorMode(),ve=!!S.isInverse();if(ve){let e=me;me=ge,ge=e;let t=he;he=_e,_e=t}let ye,be,T=!1;this._decorationService.forEachDecorationAtCell(se,t,void 0,e=>{e.options.layer!==`top`&&T||(e.backgroundColorRGB&&(_e=50331648,ge=e.backgroundColorRGB.rgba>>8&16777215,ye=e.backgroundColorRGB),e.foregroundColorRGB&&(he=50331648,me=e.foregroundColorRGB.rgba>>8&16777215,be=e.foregroundColorRGB),T=e.options.layer===`top`)}),!T&&C&&(ye=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ge=ye.rgba>>8&16777215,_e=50331648,T=!0,p.selectionForeground&&(he=50331648,me=p.selectionForeground.rgba>>8&16777215,be=p.selectionForeground)),T&&x.push(`xterm-decoration-top`);let xe;switch(_e){case 16777216:case 33554432:xe=p.ansi[ge],x.push(`xterm-bg-${ge}`);break;case 50331648:xe=Qg.toColor(ge>>16,ge>>8&255,ge&255),this._addStyle(h,`background-color:#${c_((ge>>>0).toString(16),`0`,6)}`);break;default:ve?(xe=p.foreground,x.push(`xterm-bg-257`)):xe=p.background}switch(ye||S.isDim()&&(ye=$g.multiplyOpacity(xe,.5)),he){case 16777216:case 33554432:S.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(h,xe,p.ansi[me],S,ye,void 0)||x.push(`xterm-fg-${me}`);break;case 50331648:let e=Qg.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(h,xe,e,S,ye,be)||this._addStyle(h,`color:#${c_(me.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,xe,p.foreground,S,ye,be)||ve&&x.push(`xterm-fg-257`)}x.length&&=(h.className=x.join(` `),0),!w&&!ce&&!fe&&le?g++:h.textContent=_,ie!==this.defaultSpacing&&(h.style.letterSpacing=`${ie}px`),d.push(h),se=ue}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Tne(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=$g.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]}};s_=Wp([W(1,Pm),W(2,Cm),W(3,Am),W(4,ym),W(5,Em),W(6,Fm)],s_);function c_(e,t,n){for(;e.length<n;)e=t+e;return e}var Dne=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}},One=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 kne(){return new One}var l_=`xterm-dom-renderer-owner-`,u_=`xterm-rows`,d_=`xterm-fg-`,f_=`xterm-bg-`,p_=`xterm-focus`,m_=`xterm-selection`,Ane=1,h_=class extends G{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=Ane++,this._rowElements=[],this._selectionRenderModel=kne(),this.onRequestRedraw=this._register(new K).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(u_),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(m_),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Ene(),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(s_,document),this._element.classList.add(l_+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(rh(()=>{this._element.classList.remove(l_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Dne(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} .${u_} 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} .${u_} { 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} .${u_} .xterm-dim { color: ${$g.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} .${u_}.${p_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${u_}.${p_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${u_}.${p_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${u_} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${u_} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${u_} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${u_} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${u_} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${m_} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${m_} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${m_} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${d_}${n} { color: ${r.css}; }${this._terminalSelector} .${d_}${n}.xterm-dim { color: ${$g.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${f_}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${d_}257 { color: ${$g.opaque(e.background).css}; }${this._terminalSelector} .${d_}257.xterm-dim { color: ${$g.multiplyOpacity($g.opaque(e.background),.5).css}; }${this._terminalSelector} .${f_}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(p_),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(p_),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`.${l_}${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))}}};h_=Wp([W(7,xm),W(8,km),W(9,Cm),W(10,_m),W(11,ym),W(12,Am),W(13,Fm)],h_);var g_=class extends G{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new K),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Mne(this._optionsService))}catch{this._measureStrategy=this._register(new jne(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())}};g_=Wp([W(2,Cm)],g_);var __=class extends G{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)}},jne=class extends __{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}},Mne=class extends __{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}},Nne=class extends G{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 Pne(this._window)),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new K),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(ph.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(q(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(q(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}},Pne=class extends G{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new oh),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rh(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=q(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)}},Fne=class extends G{constructor(){super(),this.linkProviders=[],this._register(rh(()=>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 v_(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 Ine(e,t,n,r,i,a,o,s,c){if(!a)return;let l=v_(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 y_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Ine(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=v_(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])}}};y_=Wp([W(0,Mm),W(1,km)],y_);var Lne=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=[]}},b_={};Up(b_,{getSafariVersion:()=>D_,isChromeOS:()=>N_,isFirefox:()=>w_,isIpad:()=>k_,isIphone:()=>A_,isLegacyEdge:()=>T_,isLinux:()=>M_,isMac:()=>O_,isNode:()=>x_,isSafari:()=>E_,isWindows:()=>j_});var x_=typeof process<`u`&&`title`in process,S_=x_?`node`:navigator.userAgent,C_=x_?`node`:navigator.platform,w_=S_.includes(`Firefox`),T_=S_.includes(`Edge`),E_=/^((?!chrome|android).)*safari/i.test(S_);function D_(){if(!E_)return 0;let e=S_.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var O_=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(C_),k_=C_===`iPad`,A_=C_===`iPhone`,j_=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(C_),M_=C_.indexOf(`Linux`)>=0,N_=/\bCrOS\b/.test(S_),P_=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()}},F_=class extends P_{_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())}}},I_=class extends P_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},L_=!x_&&`requestIdleCallback`in window?I_:F_,R_=class{constructor(){this._queue=new L_}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},z_=class extends G{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 oh),this._pausedResizeTask=new R_,this._observerDisposable=this._register(new oh),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 K),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new K),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new K),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Lne((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new B_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(rh(()=>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=rh(()=>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()}};z_=Wp([W(2,Cm),W(3,km),W(4,ym),W(5,Em),W(6,_m),W(7,Am),W(8,Fm)],z_);var B_=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 V_(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return W_(i,a,e,t,n,r)+G_(a,t,n,r)+K_(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,$_(Math.abs(i-e),Q_(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return $_(U_(a>t?e:i,n)+(s-1)*n.cols+1+H_(a>t?i:e,n),Q_(o,r))}function H_(e,t){return e-1}function U_(e,t){return t.cols-e}function W_(e,t,n,r,i,a){return G_(t,r,i,a).length===0?``:$_(Z_(e,t,e,t-J_(t,i),!1,i).length,Q_(`D`,a))}function G_(e,t,n,r){let i=e-J_(e,n),a=t-J_(t,n);return $_(Math.abs(i-a)-q_(e,t,n),Q_(X_(e,t),r))}function K_(e,t,n,r,i,a){let o;o=G_(t,r,i,a).length>0?r-J_(r,i):t;let s=r,c=Y_(e,t,n,r,i,a);return $_(Z_(e,o,n,s,c===`C`,i).length,Q_(c,a))}function q_(e,t,n){let r=0,i=e-J_(e,n),a=t-J_(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=X_(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function J_(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 Y_(e,t,n,r,i,a){let o;return o=G_(n,r,i,a).length>0?r-J_(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function X_(e,t){return e>t?`A`:`B`}function Z_(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 Q_(e,t){let n=t?`O`:`[`;return J.ESC+n+e}function $_(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var ev=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 tv(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 nv=50,rv=15,iv=50,av=500,ov=RegExp(`\xA0`,`g`),sv=class extends G{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 um,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new K),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new K),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new K),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 ev(this._bufferService),this._activeSelectionMode=0,this._register(rh(()=>{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(ov,` `)).join(j_?`\r
|
|
63
|
+
`))}},bh=class extends Error{constructor(e,t){super(e),this.name=`ListenerLeakError`,this.stack=t}},xh=class extends Error{constructor(e,t){super(e),this.name=`ListenerRefusalError`,this.stack=t}},Sh=0,Ch=class{constructor(e){this.value=e,this.id=Sh++}},wh=2,K=class{constructor(e){this._size=0,this._options=e,this._leakageMon=gh>0||this._options?.leakWarningThreshold?new vh(e?.onListenerError??Rm,this._options?.leakWarningThreshold??gh):void 0,this._perfMon=this._options?._profName?new hh(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 xh(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Rm)(n),G.None}if(this._disposed)return G.None;t&&(e=e.bind(t));let r=new Ch(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=yh.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Ch?(this._deliveryQueue??=new Th,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=rh(()=>{i?.(),this._removeListener(r)});return n instanceof ah?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*wh<=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||Rm;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 Ch)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}},Th=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}},Eh=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new K,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new K,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}};Eh.INSTANCE=new Eh;var Dh=Eh;function Oh(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}Dh.INSTANCE.onDidChangeZoomLevel;function kh(e){return Dh.INSTANCE.getZoomFactor(e)}Dh.INSTANCE.onDidChangeFullscreen;var Ah=typeof navigator==`object`?navigator.userAgent:``,jh=Ah.indexOf(`Firefox`)>=0,Mh=Ah.indexOf(`AppleWebKit`)>=0,Nh=Ah.indexOf(`Chrome`)>=0,Ph=!Nh&&Ah.indexOf(`Safari`)>=0;Ah.indexOf(`Electron/`),Ah.indexOf(`Android`);var Fh=!1;if(typeof sh.matchMedia==`function`){let e=sh.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=sh.matchMedia(`(display-mode: fullscreen)`);Fh=e.matches,Oh(sh,e,({matches:e})=>{Fh&&t.matches||(Fh=e)})}function Ih(){return Fh}var Lh=`en`,Rh=!1,zh=!1,Bh=!1,Vh=!1,Hh=!1,Uh=Lh,Wh,Gh=globalThis,Kh;typeof Gh.vscode<`u`&&typeof Gh.vscode.process<`u`?Kh=Gh.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Kh=process);var qh=typeof Kh?.versions?.electron==`string`&&Kh?.type===`renderer`;if(typeof Kh==`object`){Rh=Kh.platform===`win32`,zh=Kh.platform===`darwin`,Bh=Kh.platform===`linux`,Bh&&Kh.env.SNAP&&Kh.env.SNAP_REVISION,Kh.env.CI||Kh.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Uh=Lh;let e=Kh.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Uh=t.resolvedLanguage||Lh,t.languagePack?.translationsConfigFile}catch{}Vh=!0}else typeof navigator==`object`&&!qh?(Wh=navigator.userAgent,Rh=Wh.indexOf(`Windows`)>=0,zh=Wh.indexOf(`Macintosh`)>=0,(Wh.indexOf(`Macintosh`)>=0||Wh.indexOf(`iPad`)>=0||Wh.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Bh=Wh.indexOf(`Linux`)>=0,Wh?.indexOf(`Mobi`),Hh=!0,Uh=globalThis._VSCODE_NLS_LANGUAGE||Lh,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Jh=Rh,Yh=zh,Xh=Bh,Zh=Vh;Hh&&typeof Gh.importScripts==`function`&&Gh.origin;var Qh=Wh,$h=Uh,xte;(e=>{function t(){return $h}e.value=t;function n(){return $h.length===2?$h===`en`:$h.length>=3&&$h[0]===`e`&&$h[1]===`n`&&$h[2]===`-`}e.isDefaultVariant=n;function r(){return $h===`en`}e.isDefault=r})(xte||={});var Ste=typeof Gh.postMessage==`function`&&!Gh.importScripts;(()=>{if(Ste){let e=[];Gh.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}),Gh.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Cte=!!(Qh&&Qh.indexOf(`Chrome`)>=0);Qh&&Qh.indexOf(`Firefox`),!Cte&&Qh&&Qh.indexOf(`Safari`),Qh&&Qh.indexOf(`Edg/`),Qh&&Qh.indexOf(`Android`);var eg=typeof navigator==`object`?navigator:{};Zh||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||eg&&eg.clipboard&&eg.clipboard.writeText,Zh||eg&&eg.clipboard&&eg.clipboard.readText,Zh||Ih()||eg.keyboard,`ontouchstart`in sh||eg.maxTouchPoints,sh.PointerEvent&&(`ontouchstart`in sh||navigator.maxTouchPoints);var tg=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}},ng=new tg,rg=new tg,ig=new tg,wte=Array(230),ag;(e=>{function t(e){return ng.keyCodeToStr(e)}e.toString=t;function n(e){return ng.strToKeyCode(e)}e.fromString=n;function r(e){return rg.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return ig.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return rg.strToKeyCode(e)||ig.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 ng.keyCodeToStr(e)}e.toElectronAccelerator=o})(ag||={});var Tte=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 Ete([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Ete=class{constructor(e){if(e.length===0)throw Hm(`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 Dte(e){if(e.charCode){let t=String.fromCharCode(e.charCode).toUpperCase();return ag.fromString(t)}let t=e.keyCode;if(t===3)return 7;if(jh)switch(t){case 59:return 85;case 60:if(Xh)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Yh)return 57}else if(Mh&&(Yh&&t===93||!Yh&&t===92))return 57;return wte[t]||0}var Ote=Yh?256:2048,kte=512,Ate=1024,jte=Yh?2048:256,og=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=Dte(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|=Ote),this.altKey&&(t|=kte),this.shiftKey&&(t|=Ate),this.metaKey&&(t|=jte),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Tte(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},sg=new WeakMap;function Mte(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 Nte=class{static getSameOriginWindowChain(e){let t=sg.get(e);if(!t){t=[],sg.set(e,t);let n=e,r;do r=Mte(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}}},cg=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=Nte.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=n.left,this.posy-=n.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},lg=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(Nh){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?jh&&!Yh?-e.deltaY/3:-e.deltaY:-e.deltaY/40}if(typeof t.wheelDeltaX<`u`)this.deltaX=Ph&&Jh?-(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?jh&&!Yh?-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()}},ug=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Pte;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Fte?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ph.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ug})})(Pte||={});var Fte=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?ug:(this._emitter||=new K,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},dg=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 Wm(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Wm(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Ite=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 Wm(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=rh(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var Lte;(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})(Lte||={});var fg=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 K,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 ph.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())}};fg.EMPTY=fg.fromArray([]);function Rte(e){return pg(e,0)}function pg(e,t){switch(typeof e){case`object`:return e===null?mg(349,t):Array.isArray(e)?Bte(e,t):Vte(e,t);case`string`:return hg(e,t);case`boolean`:return zte(e,t);case`number`:return mg(e,t);case`undefined`:return mg(937,t);default:return mg(617,t)}}function mg(e,t){return(t<<5)-t+e|0}function zte(e,t){return mg(e?433:863,t)}function hg(e,t){t=mg(149417,t);for(let n=0,r=e.length;n<r;n++)t=mg(e.charCodeAt(n),t);return t}function Bte(e,t){return t=mg(104579,t),e.reduce((e,t)=>pg(t,e),t)}function Vte(e,t){return t=mg(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=hg(n,t),pg(e[n],t)),t)}var{registerWindow:Hte,getWindow:gg,getDocument:Ute,getWindows:Wte,getWindowsCount:Gte,getWindowId:Kte,getWindowById:qte,hasWindow:Jte,onDidRegisterWindow:Yte,onWillUnregisterWindow:Xte,onDidUnregisterWindow:Zte}=function(){let e=new Map,t={window:sh,disposables:new ah};e.set(sh.vscodeWindowId,t);let n=new K,r=new K,i=new K;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 G.None;let a=new ah,o={window:t,disposables:a.add(new ah)};return e.set(t.vscodeWindowId,o),a.add(rh(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(q(t,xg.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:sh},getDocument(e){return gg(e).document}}}(),Qte=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 q(e,t,n,r){return new Qte(e,t,n,r)}function $te(e,t){return function(n){return t(new cg(e,n))}}function ene(e){return function(t){return e(new og(t))}}var _g=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=$te(gg(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=ene(n)),q(e,t,i,r)},vg,tne=class extends Ite{constructor(e){super(),this.defaultTarget=e&&gg(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},yg=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){Rm(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(yg.sort),a.shift().execute();r.set(i,!1)};vg=(t,r,a=0)=>{let o=Kte(t),s=new yg(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 bg=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}};bg.None=new bg(0,0);function nne(e){let t=e.getBoundingClientRect(),n=gg(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=Rte(n),a=r.get(i);if(a)a.users+=1;else{let o=new K,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(rh(()=>{--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 xg={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:Mh?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Mh?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Mh?`webkitAnimationIteration`:`animationiteration`},rne=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=Sg(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Sg(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Sg(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Sg(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Sg(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Sg(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Sg(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Sg(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Sg(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Sg(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Sg(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=Sg(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=Sg(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Sg(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 Sg(e){return typeof e==`number`?`${e}px`:e}function Cg(e){return new rne(e)}var wg=class{constructor(){this._hooks=new ah,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(rh(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=gg(e)}this._hooks.add(q(a,xg.POINTER_MOVE,e=>{if(e.buttons!==n){this.stopMonitoring(!0);return}e.preventDefault(),this._pointerMoveCallback(e)})),this._hooks.add(q(a,xg.POINTER_UP,e=>this.stopMonitoring(!0)))}};function ine(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 Tg;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Tg||={});var Eg=class e extends G{constructor(){super(),this.dispatched=!1,this.targets=new uh,this.ignoreTargets=new uh,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ph.runAndSubscribe(Yte,({window:e,disposables:t})=>{t.add(q(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(q(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(q(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:sh,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=eh(new e),rh(e.INSTANCE.targets.push(t))):G.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=eh(new e),rh(e.INSTANCE.ignoreTargets.push(t))):G.None}static isTouchDevice(){return`ontouchstart`in sh||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(Tg.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-Gm(s.rollingPageX))<30&&Math.abs(s.initialPageY-Gm(s.rollingPageY))<30){let e=this.newGestureEvent(Tg.Tap,s.initialTarget);e.pageX=Gm(s.rollingPageX),e.pageY=Gm(s.rollingPageY),this.dispatchEvent(e)}else if(c>=e.HOLD_DELAY&&Math.abs(s.initialPageX-Gm(s.rollingPageX))<30&&Math.abs(s.initialPageY-Gm(s.rollingPageY))<30){let e=this.newGestureEvent(Tg.Contextmenu,s.initialTarget);e.pageX=Gm(s.rollingPageX),e.pageY=Gm(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Gm(s.rollingPageX),n=Gm(s.rollingPageY),i=Gm(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(Tg.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===Tg.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===Tg.Change||t.type===Tg.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=vg(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(Tg.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(Tg.Change,i.initialTarget);a.translationX=r.pageX-Gm(i.rollingPageX),a.translationY=r.pageY-Gm(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)}};Eg.SCROLL_FRICTION=-.005,Eg.HOLD_DELAY=700,Eg.CLEAR_TAP_COUNT_TIME=400,Wp([ine],Eg,`isTouchDevice`,1);var ane=Eg,Dg=class extends G{onclick(e,t){this._register(q(e,xg.CLICK,n=>t(new cg(gg(e),n))))}onmousedown(e,t){this._register(q(e,xg.MOUSE_DOWN,n=>t(new cg(gg(e),n))))}onmouseover(e,t){this._register(q(e,xg.MOUSE_OVER,n=>t(new cg(gg(e),n))))}onmouseleave(e,t){this._register(q(e,xg.MOUSE_LEAVE,n=>t(new cg(gg(e),n))))}onkeydown(e,t){this._register(q(e,xg.KEY_DOWN,e=>t(new og(e))))}onkeyup(e,t){this._register(q(e,xg.KEY_UP,e=>t(new og(e))))}oninput(e,t){this._register(q(e,xg.INPUT,t))}onblur(e,t){this._register(q(e,xg.BLUR,t))}onfocus(e,t){this._register(q(e,xg.FOCUS,t))}onchange(e,t){this._register(q(e,xg.CHANGE,t))}ignoreGesture(e){return ane.ignoreTarget(e)}},Og=11,one=class extends Dg{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=Og+`px`,this.domNode.style.height=Og+`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 wg),this._register(_g(this.bgDomNode,xg.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(_g(this.domNode,xg.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new tne),this._pointerdownScheduleRepeatTimer=this._register(new dg)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,gg(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},sne=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}}},cne=class extends G{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new sne(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 jg(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=jg.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)))}},kg=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Ag(e,t){let n=t-e;return function(t){return e+n*dne(t)}}function lne(e,t,n){return function(r){return r<n?e(r/n):t((r-n)/(1-n))}}var jg=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),lne(Ag(e,r),Ag(i,t),.33)}return Ag(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 kg(this.scrollLeft(t),this.scrollTop(t),!1):new kg(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 une(e){return e**3}function dne(e){return 1-une(1-e)}var fne=class extends G{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 dg)}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`:``)))}},pne=140,Mg=class extends Dg{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 fne(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new wg),this._shouldRender=!0,this.domNode=Cg(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(q(this.domNode.domNode,xg.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new one(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Cg(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(q(this.slider.domNode,xg.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=nne(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(Jh&&a>pne){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()}},Ng=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)}},mne=class extends Mg{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Ng(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}},hne=class extends Mg{constructor(e,t,n){let r=e.getScrollDimensions(),i=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:n,scrollbarState:new Ng(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}},gne=500,Pg=50,Fg=!0,_ne=class{constructor(e,t,n){this.timestamp=e,this.deltaX=t,this.deltaY=n,this.score=0}},Ig=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(Nh){let t=kh(gg(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 _ne(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}};Ig.INSTANCE=new Ig;var vne=Ig,yne=class extends Dg{constructor(e,t,n){super(),this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new K),this.onWillScroll=this._onWillScroll.event,this._options=xne(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 hne(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new mne(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=Cg(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Cg(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Cg(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 dg),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=th(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,Yh&&(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 lg(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=th(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(q(this._listenOnDomNode,xg.MOUSE_WHEEL,e=>{this._onMouseWheel(new lg(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=vne.INSTANCE;Fg&&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=!Yh&&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=Pg*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=Pg*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)&&(Fg&&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(),gne)}},bne=class extends yne{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 xne(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,Yh&&(t.className+=` mac`),t}var Lg=class extends G{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new K),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new cne({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>vg(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new bne(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(ph.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(rh(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(rh(()=>this._styleElement.remove())),this._register(ph.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(`
|
|
64
|
+
`)})),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}};Lg=Wp([W(2,_m),W(3,Am),W(4,vm),W(5,Fm),W(6,Cm),W(7,Mm)],Lg);var Rg=class extends G{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(rh(()=>{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()}};Rg=Wp([W(1,_m),W(2,Am),W(3,Em),W(4,Mm)],Rg);var Sne=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)}},zg={full:0,left:0,center:0,right:0},Bg={full:0,left:0,center:0,right:0},Vg={full:0,left:0,center:0,right:0},Hg=class extends G{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 Sne,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(rh(()=>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);Bg.full=this._canvas.width,Bg.left=e,Bg.center=t,Bg.right=e,this._refreshDrawHeightConstants(),Vg.full=1,Vg.left=1,Vg.center=1+Bg.left,Vg.right=1+Bg.left+Bg.center}_refreshDrawHeightConstants(){zg.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);zg.left=t,zg.center=t,zg.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zg.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zg.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zg.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*zg.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(Vg[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-zg[e.position||`full`]/2),Bg[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+zg[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}))}};Hg=Wp([W(2,_m),W(3,Em),W(4,Mm),W(5,Cm),W(6,Fm),W(7,Am)],Hg);var J;(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=`
|
|
65
|
+
`,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=``))(J||={});var Ug;(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=``))(Ug||={});var Wg;(e=>e.ST=`${J.ESC}\\`)(Wg||={});var Gg=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(`${J.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)}}};Gg=Wp([W(2,_m),W(3,Cm),W(4,ym),W(5,Mm)],Gg);var Kg=0,qg=0,Jg=0,Yg=0,Xg={css:`#00000000`,rgba:0},Zg;(e=>{function t(e,t,n,r){return r===void 0?`#${n_(e)}${n_(t)}${n_(n)}`:`#${n_(e)}${n_(t)}${n_(n)}${n_(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})(Zg||={});var Qg;(e=>{function t(e,t){if(Yg=(t.rgba&255)/255,Yg===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 Kg=a+Math.round((n-a)*Yg),qg=o+Math.round((r-o)*Yg),Jg=s+Math.round((i-s)*Yg),{css:Zg.toCss(Kg,qg,Jg),rgba:Zg.toRgba(Kg,qg,Jg)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=t_.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return Zg.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Kg,qg,Jg]=t_.toChannels(t),{css:Zg.toCss(Kg,qg,Jg),rgba:t}}e.opaque=i;function a(e,t){return Yg=Math.round(t*255),[Kg,qg,Jg]=t_.toChannels(e.rgba),{css:Zg.toCss(Kg,qg,Jg,Yg),rgba:Zg.toRgba(Kg,qg,Jg,Yg)}}e.opacity=a;function o(e,t){return Yg=e.rgba&255,a(e,Yg*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Qg||={});var $g;(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 Kg=parseInt(e.slice(1,2).repeat(2),16),qg=parseInt(e.slice(2,3).repeat(2),16),Jg=parseInt(e.slice(3,4).repeat(2),16),Zg.toColor(Kg,qg,Jg);case 5:return Kg=parseInt(e.slice(1,2).repeat(2),16),qg=parseInt(e.slice(2,3).repeat(2),16),Jg=parseInt(e.slice(3,4).repeat(2),16),Yg=parseInt(e.slice(4,5).repeat(2),16),Zg.toColor(Kg,qg,Jg,Yg);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 Kg=parseInt(r[1]),qg=parseInt(r[2]),Jg=parseInt(r[3]),Yg=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),Zg.toColor(Kg,qg,Jg,Yg);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Kg,qg,Jg,Yg]=t.getImageData(0,0,1,1).data,Yg!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:Zg.toRgba(Kg,qg,Jg,Yg),css:e}}e.toColor=r})($g||={});var e_;(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})(e_||={});var t_;(e=>{function t(e,t){if(Yg=(t&255)/255,Yg===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 Kg=a+Math.round((n-a)*Yg),qg=o+Math.round((r-o)*Yg),Jg=s+Math.round((i-s)*Yg),Zg.toRgba(Kg,qg,Jg)}e.blend=t;function n(e,t,n){let a=e_.relativeLuminance(e>>8),o=e_.relativeLuminance(t>>8);if(r_(a,o)<n){if(o<a){let o=r(e,t,n),s=r_(a,e_.relativeLuminance(o>>8));if(s<n){let r=i(e,t,n);return s>r_(a,e_.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=r_(a,e_.relativeLuminance(s>>8));if(c<n){let i=r(e,t,n);return c>r_(a,e_.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=r_(e_.relativeLuminance2(o,s,c),e_.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=r_(e_.relativeLuminance2(o,s,c),e_.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=r_(e_.relativeLuminance2(o,s,c),e_.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=r_(e_.relativeLuminance2(o,s,c),e_.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})(t_||={});function n_(e){let t=e.toString(16);return t.length<2?`0`+t:t}function r_(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Cne=class extends cm{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()]}},i_=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new um}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||sm.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++)i_._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||sm.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}};i_=Wp([W(0,_m)],i_);function wne(e){return 57508<=e&&e<=57558}function Tne(e){return 9472<=e&&e<=9631}function Ene(e){return wne(e)||Tne(e)}function Dne(){return{css:{canvas:a_(),cell:a_()},device:{canvas:a_(),cell:a_(),char:{width:0,height:0,left:0,top:0}}}}function a_(){return{width:0,height:0}}var o_=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 um,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,ee=0,b=0,te=!1,ne=0,re=!1,ie=0,ae=0,x=[],oe=l!==-1&&u!==-1;for(let se=0;se<m;se++){e.loadCell(se,this._workCell);let m=this._workCell.getWidth();if(m===0)continue;let ce=!1,le=se>=ae,ue=se,S=this._workCell;if(f.length>0&&se===f[0][0]&&le){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v<r[1];v++)le&&=i===this._isCellInSelection(v,t);le&&=!n||a<r[0]||a>=r[1],le?(ce=!0,S=new Cne(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ue=r[1]-1,m=S.getWidth()):ae=r[1]}let C=this._isCellInSelection(se,t),w=n&&se===a,de=oe&&se>=l&&se<=u,fe=!1;this._decorationService.forEachDecorationAtCell(se,t,void 0,e=>{fe=!0});let pe=S.getChars()||sm;if(pe===` `&&(S.isUnderline()||S.isOverline())&&(pe=`\xA0`),ie=m*s-c.get(pe,S.isBold(),S.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(C&&re||!C&&!re&&S.bg===y)&&(C&&re&&p.selectionForeground||S.fg===ee)&&S.extended.ext===b&&de===te&&ie===ne&&!w&&!ce&&!fe&&le){S.isInvisible()?_+=sm:_+=pe,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=S.bg,ee=S.fg,b=S.extended.ext,te=de,ne=ie,re=C,ce&&a>=se&&a<=ue&&(a=se),!this._coreService.isCursorHidden&&w&&this._coreService.isCursorInitialized){if(x.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&x.push(`xterm-cursor-blink`),x.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:x.push(`xterm-cursor-outline`);break;case`block`:x.push(`xterm-cursor-block`);break;case`bar`:x.push(`xterm-cursor-bar`);break;case`underline`:x.push(`xterm-cursor-underline`)}}if(S.isBold()&&x.push(`xterm-bold`),S.isItalic()&&x.push(`xterm-italic`),S.isDim()&&x.push(`xterm-dim`),_=S.isInvisible()?sm:S.getChars()||sm,S.isUnderline()&&(x.push(`xterm-underline-${S.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!S.isUnderlineColorDefault())){if(S.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${cm.toColorRGB(S.getUnderlineColor()).join(`,`)})`;else{let e=S.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&S.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}S.isOverline()&&(x.push(`xterm-overline`),_===` `&&(_=`\xA0`)),S.isStrikethrough()&&x.push(`xterm-strikethrough`),de&&(h.style.textDecoration=`underline`);let me=S.getFgColor(),he=S.getFgColorMode(),ge=S.getBgColor(),_e=S.getBgColorMode(),ve=!!S.isInverse();if(ve){let e=me;me=ge,ge=e;let t=he;he=_e,_e=t}let ye,be,T=!1;this._decorationService.forEachDecorationAtCell(se,t,void 0,e=>{e.options.layer!==`top`&&T||(e.backgroundColorRGB&&(_e=50331648,ge=e.backgroundColorRGB.rgba>>8&16777215,ye=e.backgroundColorRGB),e.foregroundColorRGB&&(he=50331648,me=e.foregroundColorRGB.rgba>>8&16777215,be=e.foregroundColorRGB),T=e.options.layer===`top`)}),!T&&C&&(ye=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ge=ye.rgba>>8&16777215,_e=50331648,T=!0,p.selectionForeground&&(he=50331648,me=p.selectionForeground.rgba>>8&16777215,be=p.selectionForeground)),T&&x.push(`xterm-decoration-top`);let xe;switch(_e){case 16777216:case 33554432:xe=p.ansi[ge],x.push(`xterm-bg-${ge}`);break;case 50331648:xe=Zg.toColor(ge>>16,ge>>8&255,ge&255),this._addStyle(h,`background-color:#${s_((ge>>>0).toString(16),`0`,6)}`);break;default:ve?(xe=p.foreground,x.push(`xterm-bg-257`)):xe=p.background}switch(ye||S.isDim()&&(ye=Qg.multiplyOpacity(xe,.5)),he){case 16777216:case 33554432:S.isBold()&&me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(me+=8),this._applyMinimumContrast(h,xe,p.ansi[me],S,ye,void 0)||x.push(`xterm-fg-${me}`);break;case 50331648:let e=Zg.toColor(me>>16&255,me>>8&255,me&255);this._applyMinimumContrast(h,xe,e,S,ye,be)||this._addStyle(h,`color:#${s_(me.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,xe,p.foreground,S,ye,be)||ve&&x.push(`xterm-fg-257`)}x.length&&=(h.className=x.join(` `),0),!w&&!ce&&!fe&&le?g++:h.textContent=_,ie!==this.defaultSpacing&&(h.style.letterSpacing=`${ie}px`),d.push(h),se=ue}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ene(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=Qg.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]}};o_=Wp([W(1,Pm),W(2,Cm),W(3,Am),W(4,ym),W(5,Em),W(6,Fm)],o_);function s_(e,t,n){for(;e.length<n;)e=t+e;return e}var One=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}},kne=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 Ane(){return new kne}var c_=`xterm-dom-renderer-owner-`,l_=`xterm-rows`,u_=`xterm-fg-`,d_=`xterm-bg-`,f_=`xterm-focus`,p_=`xterm-selection`,jne=1,m_=class extends G{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=jne++,this._rowElements=[],this._selectionRenderModel=Ane(),this.onRequestRedraw=this._register(new K).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(l_),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(p_),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Dne(),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(o_,document),this._element.classList.add(c_+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(rh(()=>{this._element.classList.remove(c_+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new One(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} .${l_} 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} .${l_} { 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} .${l_} .xterm-dim { color: ${Qg.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} .${l_}.${f_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${l_}.${f_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${l_}.${f_} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${l_} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${l_} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${l_} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${l_} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${l_} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${p_} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${p_} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${p_} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${u_}${n} { color: ${r.css}; }${this._terminalSelector} .${u_}${n}.xterm-dim { color: ${Qg.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${d_}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${u_}257 { color: ${Qg.opaque(e.background).css}; }${this._terminalSelector} .${u_}257.xterm-dim { color: ${Qg.multiplyOpacity(Qg.opaque(e.background),.5).css}; }${this._terminalSelector} .${d_}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(f_),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(f_),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`.${c_}${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))}}};m_=Wp([W(7,xm),W(8,km),W(9,Cm),W(10,_m),W(11,ym),W(12,Am),W(13,Fm)],m_);var h_=class extends G{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new K),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Nne(this._optionsService))}catch{this._measureStrategy=this._register(new Mne(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())}};h_=Wp([W(2,Cm)],h_);var g_=class extends G{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)}},Mne=class extends g_{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}},Nne=class extends g_{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}},Pne=class extends G{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 Fne(this._window)),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new K),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(ph.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(q(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(q(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}},Fne=class extends G{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new oh),this._onDprChange=this._register(new K),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(rh(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=q(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)}},Ine=class extends G{constructor(){super(),this.linkProviders=[],this._register(rh(()=>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 __(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 Lne(e,t,n,r,i,a,o,s,c){if(!a)return;let l=__(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 v_=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return Lne(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=__(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])}}};v_=Wp([W(0,Mm),W(1,km)],v_);var y_=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=[]}},b_={};Up(b_,{getSafariVersion:()=>D_,isChromeOS:()=>N_,isFirefox:()=>w_,isIpad:()=>k_,isIphone:()=>A_,isLegacyEdge:()=>T_,isLinux:()=>M_,isMac:()=>O_,isNode:()=>x_,isSafari:()=>E_,isWindows:()=>j_});var x_=typeof process<`u`&&`title`in process,S_=x_?`node`:navigator.userAgent,C_=x_?`node`:navigator.platform,w_=S_.includes(`Firefox`),T_=S_.includes(`Edge`),E_=/^((?!chrome|android).)*safari/i.test(S_);function D_(){if(!E_)return 0;let e=S_.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var O_=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(C_),k_=C_===`iPad`,A_=C_===`iPhone`,j_=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(C_),M_=C_.indexOf(`Linux`)>=0,N_=/\bCrOS\b/.test(S_),P_=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()}},F_=class extends P_{_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())}}},I_=class extends P_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},L_=!x_&&`requestIdleCallback`in window?I_:F_,R_=class{constructor(){this._queue=new L_}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},z_=class extends G{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 oh),this._pausedResizeTask=new R_,this._observerDisposable=this._register(new oh),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 K),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new K),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new K),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new y_((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new B_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(rh(()=>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=rh(()=>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()}};z_=Wp([W(2,Cm),W(3,km),W(4,ym),W(5,Em),W(6,_m),W(7,Am),W(8,Fm)],z_);var B_=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 V_(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return W_(i,a,e,t,n,r)+G_(a,t,n,r)+K_(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,$_(Math.abs(i-e),Q_(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return $_(U_(a>t?e:i,n)+(s-1)*n.cols+1+H_(a>t?i:e,n),Q_(o,r))}function H_(e,t){return e-1}function U_(e,t){return t.cols-e}function W_(e,t,n,r,i,a){return G_(t,r,i,a).length===0?``:$_(Z_(e,t,e,t-J_(t,i),!1,i).length,Q_(`D`,a))}function G_(e,t,n,r){let i=e-J_(e,n),a=t-J_(t,n);return $_(Math.abs(i-a)-q_(e,t,n),Q_(X_(e,t),r))}function K_(e,t,n,r,i,a){let o;o=G_(t,r,i,a).length>0?r-J_(r,i):t;let s=r,c=Y_(e,t,n,r,i,a);return $_(Z_(e,o,n,s,c===`C`,i).length,Q_(c,a))}function q_(e,t,n){let r=0,i=e-J_(e,n),a=t-J_(t,n);for(let o=0;o<Math.abs(i-a);o++){let a=X_(e,t)===`A`?-1:1;n.buffer.lines.get(i+a*o)?.isWrapped&&r++}return r}function J_(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 Y_(e,t,n,r,i,a){let o;return o=G_(n,r,i,a).length>0?r-J_(r,i):t,e<n&&o<=r||e>=n&&o<r?`C`:`D`}function X_(e,t){return e>t?`A`:`B`}function Z_(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 Q_(e,t){let n=t?`O`:`[`;return J.ESC+n+e}function $_(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}var ev=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 tv(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 nv=50,rv=15,iv=50,av=500,ov=RegExp(`\xA0`,`g`),sv=class extends G{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 um,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new K),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new K),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new K),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 ev(this._bufferService),this._activeSelectionMode=0,this._register(rh(()=>{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(ov,` `)).join(j_?`\r
|
|
66
66
|
`:`
|
|
67
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),M_&&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=tv(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=v_(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,-nv),nv),t/=nv,t/Math.abs(t)+Math.round(t*(rv-1)))}shouldForceSelection(e){return O_?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(),iv)}_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&&!(O_&&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<av&&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=V_(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=tv(n,this._bufferService.cols)}};sv=Wp([W(3,_m),W(4,ym),W(5,jm),W(6,Cm),W(7,Mm),W(8,Am)],sv);var cv=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={}}},lv=class{constructor(){this._color=new cv,this._css=new cv}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()}},uv=Object.freeze((()=>{let e=[e_.toColor(`#2e3436`),e_.toColor(`#cc0000`),e_.toColor(`#4e9a06`),e_.toColor(`#c4a000`),e_.toColor(`#3465a4`),e_.toColor(`#75507b`),e_.toColor(`#06989a`),e_.toColor(`#d3d7cf`),e_.toColor(`#555753`),e_.toColor(`#ef2929`),e_.toColor(`#8ae234`),e_.toColor(`#fce94f`),e_.toColor(`#729fcf`),e_.toColor(`#ad7fa8`),e_.toColor(`#34e2e2`),e_.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:Qg.toCss(r,i,a),rgba:Qg.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Qg.toCss(n,n,n),rgba:Qg.toRgba(n,n,n)})}return e})()),dv=e_.toColor(`#ffffff`),fv=e_.toColor(`#000000`),pv=e_.toColor(`#ffffff`),mv=fv,hv={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},gv=dv,_v=class extends G{constructor(e){super(),this._optionsService=e,this._contrastCache=new lv,this._halfContrastCache=new lv,this._onChangeColors=this._register(new K),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:dv,background:fv,cursor:pv,cursorAccent:mv,selectionForeground:void 0,selectionBackgroundTransparent:hv,selectionBackgroundOpaque:$g.blend(fv,hv),selectionInactiveBackgroundTransparent:hv,selectionInactiveBackgroundOpaque:$g.blend(fv,hv),scrollbarSliderBackground:$g.opacity(dv,.2),scrollbarSliderHoverBackground:$g.opacity(dv,.4),scrollbarSliderActiveBackground:$g.opacity(dv,.5),overviewRulerBorder:dv,ansi:uv.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=vv(e.foreground,dv),t.background=vv(e.background,fv),t.cursor=$g.blend(t.background,vv(e.cursor,pv)),t.cursorAccent=$g.blend(t.background,vv(e.cursorAccent,mv)),t.selectionBackgroundTransparent=vv(e.selectionBackground,hv),t.selectionBackgroundOpaque=$g.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=vv(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=$g.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?vv(e.selectionForeground,Zg):void 0,t.selectionForeground===Zg&&(t.selectionForeground=void 0),$g.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=$g.opacity(t.selectionBackgroundTransparent,.3)),$g.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=$g.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=vv(e.scrollbarSliderBackground,$g.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=vv(e.scrollbarSliderHoverBackground,$g.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=vv(e.scrollbarSliderActiveBackground,$g.opacity(t.foreground,.5)),t.overviewRulerBorder=vv(e.overviewRulerBorder,gv),t.ansi=uv.slice(),t.ansi[0]=vv(e.black,uv[0]),t.ansi[1]=vv(e.red,uv[1]),t.ansi[2]=vv(e.green,uv[2]),t.ansi[3]=vv(e.yellow,uv[3]),t.ansi[4]=vv(e.blue,uv[4]),t.ansi[5]=vv(e.magenta,uv[5]),t.ansi[6]=vv(e.cyan,uv[6]),t.ansi[7]=vv(e.white,uv[7]),t.ansi[8]=vv(e.brightBlack,uv[8]),t.ansi[9]=vv(e.brightRed,uv[9]),t.ansi[10]=vv(e.brightGreen,uv[10]),t.ansi[11]=vv(e.brightYellow,uv[11]),t.ansi[12]=vv(e.brightBlue,uv[12]),t.ansi[13]=vv(e.brightMagenta,uv[13]),t.ansi[14]=vv(e.brightCyan,uv[14]),t.ansi[15]=vv(e.brightWhite,uv[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]=vv(e.extendedAnsi[r],uv[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()}}};_v=Wp([W(0,Cm)],_v);function vv(e,t){if(e!==void 0)try{return e_.toColor(e)}catch{}return t}var yv=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)}},bv=class{constructor(){this._services=new yv,this._services.set(xm,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=mm(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)}},xv={trace:0,debug:1,info:2,warn:3,error:4,off:5},Sv=`xterm.js: `,Cv=class extends G{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),wv=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=xv[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?``:Sv)+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)}};Cv=Wp([W(0,Cm)],Cv);var wv,Tv=class extends G{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new K),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new K),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new K),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}},Y=3,Ev=Object.freeze(new cm),Dv=0,Ov=2,kv=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Y);let r=t||um.fromCharData([0,om,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*Y+0],n=t&2097151;return[this._data[e*Y+1],t&2097152?this._combined[e]:n?nm(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*Y+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*Y+0]=e|2097152|t[2]<<22):this._data[e*Y+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*Y+0]>>22}hasWidth(e){return this._data[e*Y+0]&12582912}getFg(e){return this._data[e*Y+1]}getBg(e){return this._data[e*Y+2]}hasContent(e){return this._data[e*Y+0]&4194303}getCodePoint(e){let t=this._data[e*Y+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*Y+0]&2097152}getString(e){let t=this._data[e*Y+0];return t&2097152?this._combined[e]:t&2097151?nm(t&2097151):``}isProtected(e){return this._data[e*Y+2]&536870912}loadCell(e,t){return Dv=e*Y,t.content=this._data[Dv+0],t.fg=this._data[Dv+1],t.bg=this._data[Dv+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*Y+0]=t.content,this._data[e*Y+1]=t.fg,this._data[e*Y+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Y+0]=t|n<<22,this._data[e*Y+1]=r.fg,this._data[e*Y+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*Y+0];r&2097152?this._combined[e]+=nm(t):r&2097151?(this._combined[e]=nm(r&2097151)+nm(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Y+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 um;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 um;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*Ov<this._data.buffer.byteLength;let n=e*Y;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*Ov<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ov<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*Y+0]&4194303)return e+(this._data[e*Y+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Y+0]&4194303||this._data[e*Y+2]&50331648)return e+(this._data[e*Y+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<Y;e++)this._data[(n+i)*Y+e]=a[(t+i)*Y+e];a[(t+i)*Y+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<Y;e++)this._data[(n+i)*Y+e]=a[(t+i)*Y+e];a[(t+i)*Y+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*Y+0],n=e&2097151,a=e&2097152?this._combined[t]:n?nm(n):sm;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 Av(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=Pv(u,d,t),p=1,m=0;for(;p<u.length;){let e=Pv(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 jv(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 Mv(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 Nv(e,t,n){let r=[],i=e.map((n,r)=>Pv(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=Pv(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 Pv(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 Fv=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new K),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),th(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Fv._nextId=1;var Iv=Fv,Lv={},Rv=Lv.B;Lv[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},Lv.A={"#":`£`},Lv.B=void 0,Lv[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},Lv.C=Lv[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Lv.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},Lv.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},Lv.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},Lv.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},Lv.E=Lv[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},Lv.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},Lv.H=Lv[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Lv[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var zv=4294967295,Bv=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=Ev.clone(),this.savedCharset=Rv,this.markers=[],this._nullCell=um.fromCharData([0,om,1,0]),this._whitespaceCell=um.fromCharData([0,sm,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new L_,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Tv(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 lm),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 lm),this._whitespaceCell}getBlankLine(e,t){return new kv(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>zv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ev);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 Tv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ev),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 kv(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 kv(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=Av(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ev),n);if(r.length>0){let n=jv(this.lines,r);Mv(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Ev),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new kv(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(Ev),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=Nv(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(Ev,!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--,_=Pv(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 Iv(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)}},Vv=class extends G{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new K),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 Bv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Bv(!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)}},Hv=2,Uv=1,Wv=class extends G{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Hv),this.rows=Math.max(e.rawOptions.rows||0,Uv),this.buffers=this._register(new Vv(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))}};Wv=Wp([W(0,Cm)],Wv);var Gv={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:O_,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Kv=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],qv=class extends G{constructor(e){super(),this._onOptionChange=this._register(new K),this.onOptionChange=this._onOptionChange.event;let t={...Gv};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(rh(()=>{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 Gv))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Gv))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||=Gv[e],!Jv(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Gv[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Kv.includes(t)?t:Gv[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 Jv(e){return e===`block`||e===`underline`||e===`bar`}function Yv(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]&&Yv(e[r],t-1);return n}var Xv=Object.freeze({insertMode:!1}),Zv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Qv=class extends G{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 K),this.onData=this._onData.event,this._onUserInput=this._register(new K),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new K),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Yv(Xv),this.decPrivateModes=Yv(Zv)}reset(){this.modes=Yv(Xv),this.decPrivateModes=Yv(Zv)}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))}};Qv=Wp([W(0,_m),W(1,Sm),W(2,Cm)],Qv);var $v={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 ey(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 ty=String.fromCharCode,ny={DEFAULT:e=>{let t=[ey(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${ty(t[0])}${ty(t[1])}${ty(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${ey(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${ey(e,!0)};${e.x};${e.y}${t}`}},ry=class extends G{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 K),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys($v))this.addProtocol(e,$v[e]);for(let e of Object.keys(ny))this.addEncoding(e,ny[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}};ry=Wp([W(0,_m),W(1,ym),W(2,Cm)],ry);var iy=[[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]],ay=[[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]],oy;function sy(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 cy=class{constructor(){if(this.version=`6`,!oy){oy=new Uint8Array(65536),oy.fill(1),oy[0]=0,oy.fill(0,1,32),oy.fill(0,127,160),oy.fill(2,4352,4448),oy[9001]=2,oy[9002]=2,oy.fill(2,11904,42192),oy[12351]=1,oy.fill(2,44032,55204),oy.fill(2,63744,64256),oy.fill(2,65040,65050),oy.fill(2,65072,65136),oy.fill(2,65280,65377),oy.fill(2,65504,65511);for(let e=0;e<iy.length;++e)oy.fill(0,iy[e][0],iy[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?oy[e]:sy(e,ay)?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=ly.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return ly.createPropertyValue(0,n,r)}},ly=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new K,this.onChange=this._onChange.event;let e=new cy;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)}},uy=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 dy(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 fy=2147483647,py=256,my=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>py)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>fy?fy: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>fy?fy: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,fy):e}},hy=[],gy=class{constructor(){this._state=0,this._active=hy,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=hy}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=hy,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||hy,!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`,rm(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=hy,this._id=-1,this._state=0}}},_y=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+=rm(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}},vy=[],yy=class{constructor(){this._handlers=Object.create(null),this._active=vy,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=vy}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=vy,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||vy,!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`,rm(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=vy,this._ident=0}},by=new my;by.addParam(0);var xy=class{constructor(e){this._handler=e,this._data=``,this._params=by,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():by,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=rm(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=by,this._data=``,this._hitLimit=!1,e));return this._params=by,this._data=``,this._hitLimit=!1,t}},Sy=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}},Cy=160,wy=function(){let e=new Sy(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(Cy,0,2,0),e.add(Cy,8,5,8),e.add(Cy,6,0,6),e.add(Cy,11,0,11),e.add(Cy,13,13,13),e}(),Ty=class extends G{constructor(e=wy){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 my,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(rh(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new gy),this._dcsParser=this._register(new yy),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:Cy)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<Cy){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Cy){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Cy){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Cy){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<Cy){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<Cy){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}}},Ey=/^([\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})$/,Dy=/^[\da-f]+$/;function Oy(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=Ey.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),Dy.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 ky(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 Ay(e,t=16){let[n,r,i]=e;return`rgb:${ky(n,t)}/${ky(r,t)}/${ky(i,t)}`}var jy={"(":0,")":1,"*":2,"+":3,"-":1,".":2},My=131072,Ny=10;function Py(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 Fy=5e3,Iy=0,Ly=class extends G{constructor(e,t,n,r,i,a,o,s,c=new Ty){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 im,this._utf8Decoder=new am,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ev.clone(),this._eraseAttrDataInternal=Ev.clone(),this._onRequestBell=this._register(new K),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new K),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new K),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new K),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new K),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new K),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new K),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new K),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new K),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 Ry(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(J.BEL,()=>this.bell()),this._parser.setExecuteHandler(J.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(J.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(J.BS,()=>this.backspace()),this._parser.setExecuteHandler(J.HT,()=>this.tab()),this._parser.setExecuteHandler(J.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(J.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Wg.IND,()=>this.index()),this._parser.setExecuteHandler(Wg.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Wg.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new _y(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new _y(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new _y(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new _y(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new _y(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new _y(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new _y(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new _y(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new _y(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new _y(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new _y(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new _y(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 Lv)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 xy((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`),Fy))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${Fy} 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>My&&(a=this._parseStack.position+My)}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<My&&(this._parseBuffer=new Uint32Array(Math.min(e.length,My))),o||this._dirtyRowTracker.clearRange(),e.length>My)for(let t=a;t<e.length;t+=My){let a=t+My<e.length?t+My: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=ly.extractWidth(t);let n=ly.extractShouldJoin(t),m=n?ly.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(nm(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 kv&&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=>!Py(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new xy(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new _y(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(Ev));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=ly.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(J.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(J.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(J.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(J.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(J.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,Rv),this._charsetService.setgCharset(1,Rv),this._charsetService.setgCharset(2,Rv),this._charsetService.setgCharset(3,Rv);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(`${J.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|=cm.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=Ev.fg,e.bg=Ev.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|=Ev.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Ev.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|=Ev.fg&16777215,r.bg&=-67108864,r.bg|=Ev.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${J.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${J.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(`${J.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=Ev.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(!Py(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(`${J.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ny&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ny&&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(zy(n)){if(r===`?`)t.push({type:0,index:n});else{let e=Oy(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=Oy(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]);zy(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,Rv),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(jy[e[0]],Lv[e[1]]||Rv),!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=Ev.clone(),this._eraseAttrDataInternal=Ev.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 um;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(`${J.ESC}${e}${J.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)}},Ry=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&&(Iy=e,e=t,t=Iy),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ry=Wp([W(0,_m)],Ry);function zy(e){return 0<=e&&e<256}var By=5e7,Vy=12,Hy=50,Uy=class extends G{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 K),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>By)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>=Vy?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>=Vy)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Hy&&(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()}},Wy=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)))}};Wy=Wp([W(0,_m)],Wy);var Gy=!1,Ky=class extends G{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new oh),this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onData=this._register(new K),this.onData=this._onData.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new K),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new K),this._instantiationService=new bv,this.optionsService=this._register(new qv(e)),this._instantiationService.setService(Cm,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Wv)),this._instantiationService.setService(_m,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Cv)),this._instantiationService.setService(Sm,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Qv)),this._instantiationService.setService(ym,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ry)),this._instantiationService.setService(vm,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ly)),this._instantiationService.setService(Tm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(uy),this._instantiationService.setService(bm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wy),this._instantiationService.setService(wm,this._oscLinkService),this._inputHandler=this._register(new Ly(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ph.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ph.forward(this._bufferService.onResize,this._onResize)),this._register(ph.forward(this.coreService.onData,this._onData)),this._register(ph.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 Uy((e,t)=>this._inputHandler.parse(e,t))),this._register(ph.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new K),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&&!Gy&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Gy=!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,Hv),t=Math.max(t,Uv),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(dy.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(dy(this._bufferService),!1))),this._windowsWrappingHeuristics.value=rh(()=>{for(let t of e)t.dispose()})}}},qy={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 Jy(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?J.ESC+`OA`:J.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?J.ESC+`OD`:J.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?J.ESC+`OC`:J.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?J.ESC+`OB`:J.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:J.DEL,e.altKey&&(i.key=J.ESC+i.key);break;case 9:if(e.shiftKey){i.key=J.ESC+`[Z`;break}i.key=J.HT,i.cancel=!0;break;case 13:i.key=e.altKey?J.ESC+J.CR:J.CR,i.cancel=!0;break;case 27:i.key=J.ESC,e.altKey&&(i.key=J.ESC+J.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`D`:t?J.ESC+`OD`:J.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`C`:t?J.ESC+`OC`:J.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`A`:t?J.ESC+`OA`:J.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`B`:t?J.ESC+`OB`:J.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=J.ESC+`[2~`);break;case 46:i.key=a?J.ESC+`[3;`+(a+1)+`~`:J.ESC+`[3~`;break;case 36:i.key=a?J.ESC+`[1;`+(a+1)+`H`:t?J.ESC+`OH`:J.ESC+`[H`;break;case 35:i.key=a?J.ESC+`[1;`+(a+1)+`F`:t?J.ESC+`OF`:J.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?J.ESC+`[5;`+(a+1)+`~`:J.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?J.ESC+`[6;`+(a+1)+`~`:J.ESC+`[6~`;break;case 112:i.key=a?J.ESC+`[1;`+(a+1)+`P`:J.ESC+`OP`;break;case 113:i.key=a?J.ESC+`[1;`+(a+1)+`Q`:J.ESC+`OQ`;break;case 114:i.key=a?J.ESC+`[1;`+(a+1)+`R`:J.ESC+`OR`;break;case 115:i.key=a?J.ESC+`[1;`+(a+1)+`S`:J.ESC+`OS`;break;case 116:i.key=a?J.ESC+`[15;`+(a+1)+`~`:J.ESC+`[15~`;break;case 117:i.key=a?J.ESC+`[17;`+(a+1)+`~`:J.ESC+`[17~`;break;case 118:i.key=a?J.ESC+`[18;`+(a+1)+`~`:J.ESC+`[18~`;break;case 119:i.key=a?J.ESC+`[19;`+(a+1)+`~`:J.ESC+`[19~`;break;case 120:i.key=a?J.ESC+`[20;`+(a+1)+`~`:J.ESC+`[20~`;break;case 121:i.key=a?J.ESC+`[21;`+(a+1)+`~`:J.ESC+`[21~`;break;case 122:i.key=a?J.ESC+`[23;`+(a+1)+`~`:J.ESC+`[23~`;break;case 123:i.key=a?J.ESC+`[24;`+(a+1)+`~`:J.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=J.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=J.DEL:e.keyCode===219?i.key=J.ESC:e.keyCode===220?i.key=J.FS:e.keyCode===221&&(i.key=J.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=qy[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=J.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=J.ESC+n}else if(e.keyCode===32)i.key=J.ESC+(e.ctrlKey?J.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=J.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=J.US),e.key===`@`&&(i.key=J.NUL))}return i}var Yy=0,Xy=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new L_,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new L_,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||(Yy=this._search(t),Yy===-1)||this._getKey(this._array[Yy])!==t)return!1;do if(this._array[Yy]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Yy),!0;while(++Yy<this._array.length&&this._getKey(this._array[Yy])===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&&(Yy=this._search(e),!(Yy<0||Yy>=this._array.length)&&this._getKey(this._array[Yy])===e))do yield this._array[Yy];while(++Yy<this._array.length&&this._getKey(this._array[Yy])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Yy=this._search(e),!(Yy<0||Yy>=this._array.length)&&this._getKey(this._array[Yy])===e))do t(this._array[Yy]);while(++Yy<this._array.length&&this._getKey(this._array[Yy])===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}},Zy=0,Qy=0,$y=class extends G{constructor(){super(),this._decorations=new Xy(e=>e?.marker.line),this._onDecorationRegistered=this._register(new K),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new K),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rh(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new eb(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=>{Zy=t.options.x??0,Qy=Zy+(t.options.width??1),e>=Zy&&e<Qy&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},eb=class extends ah{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new K),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new K),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?e_.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?e_.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},tb=1e3,nb=class{constructor(e,t=tb){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)}},rb=20,ib=class extends G{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 nb(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(`
|
|
67
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),M_&&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=tv(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=__(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,-nv),nv),t/=nv,t/Math.abs(t)+Math.round(t*(rv-1)))}shouldForceSelection(e){return O_?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(),iv)}_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&&!(O_&&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<av&&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=V_(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=tv(n,this._bufferService.cols)}};sv=Wp([W(3,_m),W(4,ym),W(5,jm),W(6,Cm),W(7,Mm),W(8,Am)],sv);var cv=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={}}},lv=class{constructor(){this._color=new cv,this._css=new cv}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()}},uv=Object.freeze((()=>{let e=[$g.toColor(`#2e3436`),$g.toColor(`#cc0000`),$g.toColor(`#4e9a06`),$g.toColor(`#c4a000`),$g.toColor(`#3465a4`),$g.toColor(`#75507b`),$g.toColor(`#06989a`),$g.toColor(`#d3d7cf`),$g.toColor(`#555753`),$g.toColor(`#ef2929`),$g.toColor(`#8ae234`),$g.toColor(`#fce94f`),$g.toColor(`#729fcf`),$g.toColor(`#ad7fa8`),$g.toColor(`#34e2e2`),$g.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:Zg.toCss(r,i,a),rgba:Zg.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Zg.toCss(n,n,n),rgba:Zg.toRgba(n,n,n)})}return e})()),dv=$g.toColor(`#ffffff`),fv=$g.toColor(`#000000`),pv=$g.toColor(`#ffffff`),mv=fv,hv={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},gv=dv,_v=class extends G{constructor(e){super(),this._optionsService=e,this._contrastCache=new lv,this._halfContrastCache=new lv,this._onChangeColors=this._register(new K),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:dv,background:fv,cursor:pv,cursorAccent:mv,selectionForeground:void 0,selectionBackgroundTransparent:hv,selectionBackgroundOpaque:Qg.blend(fv,hv),selectionInactiveBackgroundTransparent:hv,selectionInactiveBackgroundOpaque:Qg.blend(fv,hv),scrollbarSliderBackground:Qg.opacity(dv,.2),scrollbarSliderHoverBackground:Qg.opacity(dv,.4),scrollbarSliderActiveBackground:Qg.opacity(dv,.5),overviewRulerBorder:dv,ansi:uv.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=vv(e.foreground,dv),t.background=vv(e.background,fv),t.cursor=Qg.blend(t.background,vv(e.cursor,pv)),t.cursorAccent=Qg.blend(t.background,vv(e.cursorAccent,mv)),t.selectionBackgroundTransparent=vv(e.selectionBackground,hv),t.selectionBackgroundOpaque=Qg.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=vv(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Qg.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?vv(e.selectionForeground,Xg):void 0,t.selectionForeground===Xg&&(t.selectionForeground=void 0),Qg.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Qg.opacity(t.selectionBackgroundTransparent,.3)),Qg.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Qg.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=vv(e.scrollbarSliderBackground,Qg.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=vv(e.scrollbarSliderHoverBackground,Qg.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=vv(e.scrollbarSliderActiveBackground,Qg.opacity(t.foreground,.5)),t.overviewRulerBorder=vv(e.overviewRulerBorder,gv),t.ansi=uv.slice(),t.ansi[0]=vv(e.black,uv[0]),t.ansi[1]=vv(e.red,uv[1]),t.ansi[2]=vv(e.green,uv[2]),t.ansi[3]=vv(e.yellow,uv[3]),t.ansi[4]=vv(e.blue,uv[4]),t.ansi[5]=vv(e.magenta,uv[5]),t.ansi[6]=vv(e.cyan,uv[6]),t.ansi[7]=vv(e.white,uv[7]),t.ansi[8]=vv(e.brightBlack,uv[8]),t.ansi[9]=vv(e.brightRed,uv[9]),t.ansi[10]=vv(e.brightGreen,uv[10]),t.ansi[11]=vv(e.brightYellow,uv[11]),t.ansi[12]=vv(e.brightBlue,uv[12]),t.ansi[13]=vv(e.brightMagenta,uv[13]),t.ansi[14]=vv(e.brightCyan,uv[14]),t.ansi[15]=vv(e.brightWhite,uv[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]=vv(e.extendedAnsi[r],uv[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()}}};_v=Wp([W(0,Cm)],_v);function vv(e,t){if(e!==void 0)try{return $g.toColor(e)}catch{}return t}var yv=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)}},bv=class{constructor(){this._services=new yv,this._services.set(xm,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=mm(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)}},xv={trace:0,debug:1,info:2,warn:3,error:4,off:5},Sv=`xterm.js: `,Cv=class extends G{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),wv=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=xv[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?``:Sv)+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)}};Cv=Wp([W(0,Cm)],Cv);var wv,Tv=class extends G{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new K),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new K),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new K),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}},Y=3,Ev=Object.freeze(new cm),Dv=0,Ov=2,kv=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*Y);let r=t||um.fromCharData([0,om,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*Y+0],n=t&2097151;return[this._data[e*Y+1],t&2097152?this._combined[e]:n?nm(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*Y+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*Y+0]=e|2097152|t[2]<<22):this._data[e*Y+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*Y+0]>>22}hasWidth(e){return this._data[e*Y+0]&12582912}getFg(e){return this._data[e*Y+1]}getBg(e){return this._data[e*Y+2]}hasContent(e){return this._data[e*Y+0]&4194303}getCodePoint(e){let t=this._data[e*Y+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*Y+0]&2097152}getString(e){let t=this._data[e*Y+0];return t&2097152?this._combined[e]:t&2097151?nm(t&2097151):``}isProtected(e){return this._data[e*Y+2]&536870912}loadCell(e,t){return Dv=e*Y,t.content=this._data[Dv+0],t.fg=this._data[Dv+1],t.bg=this._data[Dv+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*Y+0]=t.content,this._data[e*Y+1]=t.fg,this._data[e*Y+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*Y+0]=t|n<<22,this._data[e*Y+1]=r.fg,this._data[e*Y+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*Y+0];r&2097152?this._combined[e]+=nm(t):r&2097151?(this._combined[e]=nm(r&2097151)+nm(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*Y+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 um;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 um;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*Ov<this._data.buffer.byteLength;let n=e*Y;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*Ov<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ov<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*Y+0]&4194303)return e+(this._data[e*Y+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*Y+0]&4194303||this._data[e*Y+2]&50331648)return e+(this._data[e*Y+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<Y;e++)this._data[(n+i)*Y+e]=a[(t+i)*Y+e];a[(t+i)*Y+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<Y;e++)this._data[(n+i)*Y+e]=a[(t+i)*Y+e];a[(t+i)*Y+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*Y+0],n=e&2097151,a=e&2097152?this._combined[t]:n?nm(n):sm;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 Av(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=Pv(u,d,t),p=1,m=0;for(;p<u.length;){let e=Pv(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 jv(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 Mv(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 Nv(e,t,n){let r=[],i=e.map((n,r)=>Pv(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=Pv(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 Pv(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 Fv=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new K),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),th(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Fv._nextId=1;var Iv=Fv,Lv={},Rv=Lv.B;Lv[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:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},Lv.A={"#":`£`},Lv.B=void 0,Lv[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},Lv.C=Lv[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Lv.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},Lv.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},Lv.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},Lv.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},Lv.E=Lv[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},Lv.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},Lv.H=Lv[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Lv[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var zv=4294967295,Bv=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=Ev.clone(),this.savedCharset=Rv,this.markers=[],this._nullCell=um.fromCharData([0,om,1,0]),this._whitespaceCell=um.fromCharData([0,sm,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new L_,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Tv(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 lm),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 lm),this._whitespaceCell}getBlankLine(e,t){return new kv(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>zv?zv:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ev);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 Tv(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ev),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 kv(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 kv(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=Av(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ev),n);if(r.length>0){let n=jv(this.lines,r);Mv(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Ev),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new kv(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(Ev),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=Nv(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(Ev,!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--,_=Pv(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 Iv(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)}},Vv=class extends G{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new K),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 Bv(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Bv(!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)}},Hv=2,Uv=1,Wv=class extends G{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Hv),this.rows=Math.max(e.rawOptions.rows||0,Uv),this.buffers=this._register(new Vv(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))}};Wv=Wp([W(0,Cm)],Wv);var Gv={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:O_,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Kv=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],qv=class extends G{constructor(e){super(),this._onOptionChange=this._register(new K),this.onOptionChange=this._onOptionChange.event;let t={...Gv};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(rh(()=>{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 Gv))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Gv))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||=Gv[e],!Jv(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Gv[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Kv.includes(t)?t:Gv[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 Jv(e){return e===`block`||e===`underline`||e===`bar`}function Yv(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]&&Yv(e[r],t-1);return n}var Xv=Object.freeze({insertMode:!1}),Zv=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Qv=class extends G{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 K),this.onData=this._onData.event,this._onUserInput=this._register(new K),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new K),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Yv(Xv),this.decPrivateModes=Yv(Zv)}reset(){this.modes=Yv(Xv),this.decPrivateModes=Yv(Zv)}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))}};Qv=Wp([W(0,_m),W(1,Sm),W(2,Cm)],Qv);var $v={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 ey(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 ty=String.fromCharCode,ny={DEFAULT:e=>{let t=[ey(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${ty(t[0])}${ty(t[1])}${ty(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${ey(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${ey(e,!0)};${e.x};${e.y}${t}`}},ry=class extends G{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 K),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys($v))this.addProtocol(e,$v[e]);for(let e of Object.keys(ny))this.addEncoding(e,ny[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}};ry=Wp([W(0,_m),W(1,ym),W(2,Cm)],ry);var iy=[[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]],ay=[[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]],oy;function sy(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 cy=class{constructor(){if(this.version=`6`,!oy){oy=new Uint8Array(65536),oy.fill(1),oy[0]=0,oy.fill(0,1,32),oy.fill(0,127,160),oy.fill(2,4352,4448),oy[9001]=2,oy[9002]=2,oy.fill(2,11904,42192),oy[12351]=1,oy.fill(2,44032,55204),oy.fill(2,63744,64256),oy.fill(2,65040,65050),oy.fill(2,65072,65136),oy.fill(2,65280,65377),oy.fill(2,65504,65511);for(let e=0;e<iy.length;++e)oy.fill(0,iy[e][0],iy[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?oy[e]:sy(e,ay)?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=ly.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return ly.createPropertyValue(0,n,r)}},ly=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new K,this.onChange=this._onChange.event;let e=new cy;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)}},uy=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 dy(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 fy=2147483647,py=256,my=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>py)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>fy?fy: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>fy?fy: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,fy):e}},hy=[],gy=class{constructor(){this._state=0,this._active=hy,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=hy}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=hy,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||hy,!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`,rm(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=hy,this._id=-1,this._state=0}}},_y=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+=rm(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}},vy=[],yy=class{constructor(){this._handlers=Object.create(null),this._active=vy,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=vy}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=vy,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||vy,!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`,rm(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=vy,this._ident=0}},by=new my;by.addParam(0);var xy=class{constructor(e){this._handler=e,this._data=``,this._params=by,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():by,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=rm(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=by,this._data=``,this._hitLimit=!1,e));return this._params=by,this._data=``,this._hitLimit=!1,t}},Sy=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}},Cy=160,wy=function(){let e=new Sy(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(Cy,0,2,0),e.add(Cy,8,5,8),e.add(Cy,6,0,6),e.add(Cy,11,0,11),e.add(Cy,13,13,13),e}(),Ty=class extends G{constructor(e=wy){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 my,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(rh(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new gy),this._dcsParser=this._register(new yy),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:Cy)],i>>4){case 2:for(let i=n+1;;++i){if(i>=t||(r=e[i])<32||r>126&&r<Cy){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Cy){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Cy){this._printHandler(e,n,i),n=i-1;break}if(++i>=t||(r=e[i])<32||r>126&&r<Cy){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<Cy){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<Cy){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}}},Ey=/^([\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})$/,Dy=/^[\da-f]+$/;function Oy(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=Ey.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),Dy.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 ky(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 Ay(e,t=16){let[n,r,i]=e;return`rgb:${ky(n,t)}/${ky(r,t)}/${ky(i,t)}`}var jy={"(":0,")":1,"*":2,"+":3,"-":1,".":2},My=131072,Ny=10;function Py(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 Fy=5e3,Iy=0,Ly=class extends G{constructor(e,t,n,r,i,a,o,s,c=new Ty){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 im,this._utf8Decoder=new am,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ev.clone(),this._eraseAttrDataInternal=Ev.clone(),this._onRequestBell=this._register(new K),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new K),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new K),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new K),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new K),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new K),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new K),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new K),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new K),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new K),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 Ry(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(J.BEL,()=>this.bell()),this._parser.setExecuteHandler(J.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(J.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(J.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(J.BS,()=>this.backspace()),this._parser.setExecuteHandler(J.HT,()=>this.tab()),this._parser.setExecuteHandler(J.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(J.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ug.IND,()=>this.index()),this._parser.setExecuteHandler(Ug.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ug.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new _y(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new _y(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new _y(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new _y(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new _y(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new _y(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new _y(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new _y(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new _y(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new _y(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new _y(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new _y(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 Lv)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 xy((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`),Fy))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${Fy} 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>My&&(a=this._parseStack.position+My)}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<My&&(this._parseBuffer=new Uint32Array(Math.min(e.length,My))),o||this._dirtyRowTracker.clearRange(),e.length>My)for(let t=a;t<e.length;t+=My){let a=t+My<e.length?t+My: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=ly.extractWidth(t);let n=ly.extractShouldJoin(t),m=n?ly.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(nm(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 kv&&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=>!Py(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new xy(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new _y(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(Ev));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=ly.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(J.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(J.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(J.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(J.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(J.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,Rv),this._charsetService.setgCharset(1,Rv),this._charsetService.setgCharset(2,Rv),this._charsetService.setgCharset(3,Rv);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(`${J.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|=cm.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=Ev.fg,e.bg=Ev.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|=Ev.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Ev.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|=Ev.fg&16777215,r.bg&=-67108864,r.bg|=Ev.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${J.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${J.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(`${J.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=Ev.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(!Py(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(`${J.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ny&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ny&&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(zy(n)){if(r===`?`)t.push({type:0,index:n});else{let e=Oy(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=Oy(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]);zy(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,Rv),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(jy[e[0]],Lv[e[1]]||Rv),!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=Ev.clone(),this._eraseAttrDataInternal=Ev.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 um;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(`${J.ESC}${e}${J.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)}},Ry=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&&(Iy=e,e=t,t=Iy),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ry=Wp([W(0,_m)],Ry);function zy(e){return 0<=e&&e<256}var By=5e7,Vy=12,Hy=50,Uy=class extends G{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 K),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>By)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>=Vy?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>=Vy)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Hy&&(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()}},Wy=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)))}};Wy=Wp([W(0,_m)],Wy);var Gy=!1,Ky=class extends G{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new oh),this._onBinary=this._register(new K),this.onBinary=this._onBinary.event,this._onData=this._register(new K),this.onData=this._onData.event,this._onLineFeed=this._register(new K),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new K),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new K),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new K),this._instantiationService=new bv,this.optionsService=this._register(new qv(e)),this._instantiationService.setService(Cm,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Wv)),this._instantiationService.setService(_m,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Cv)),this._instantiationService.setService(Sm,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Qv)),this._instantiationService.setService(ym,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ry)),this._instantiationService.setService(vm,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ly)),this._instantiationService.setService(Tm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(uy),this._instantiationService.setService(bm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Wy),this._instantiationService.setService(wm,this._oscLinkService),this._inputHandler=this._register(new Ly(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ph.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ph.forward(this._bufferService.onResize,this._onResize)),this._register(ph.forward(this.coreService.onData,this._onData)),this._register(ph.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 Uy((e,t)=>this._inputHandler.parse(e,t))),this._register(ph.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new K),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&&!Gy&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Gy=!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,Hv),t=Math.max(t,Uv),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(dy.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(dy(this._bufferService),!1))),this._windowsWrappingHeuristics.value=rh(()=>{for(let t of e)t.dispose()})}}},qy={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 Jy(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?J.ESC+`OA`:J.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?J.ESC+`OD`:J.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?J.ESC+`OC`:J.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?J.ESC+`OB`:J.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:J.DEL,e.altKey&&(i.key=J.ESC+i.key);break;case 9:if(e.shiftKey){i.key=J.ESC+`[Z`;break}i.key=J.HT,i.cancel=!0;break;case 13:i.key=e.altKey?J.ESC+J.CR:J.CR,i.cancel=!0;break;case 27:i.key=J.ESC,e.altKey&&(i.key=J.ESC+J.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`D`:t?J.ESC+`OD`:J.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`C`:t?J.ESC+`OC`:J.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`A`:t?J.ESC+`OA`:J.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?J.ESC+`[1;`+(a+1)+`B`:t?J.ESC+`OB`:J.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=J.ESC+`[2~`);break;case 46:i.key=a?J.ESC+`[3;`+(a+1)+`~`:J.ESC+`[3~`;break;case 36:i.key=a?J.ESC+`[1;`+(a+1)+`H`:t?J.ESC+`OH`:J.ESC+`[H`;break;case 35:i.key=a?J.ESC+`[1;`+(a+1)+`F`:t?J.ESC+`OF`:J.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?J.ESC+`[5;`+(a+1)+`~`:J.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?J.ESC+`[6;`+(a+1)+`~`:J.ESC+`[6~`;break;case 112:i.key=a?J.ESC+`[1;`+(a+1)+`P`:J.ESC+`OP`;break;case 113:i.key=a?J.ESC+`[1;`+(a+1)+`Q`:J.ESC+`OQ`;break;case 114:i.key=a?J.ESC+`[1;`+(a+1)+`R`:J.ESC+`OR`;break;case 115:i.key=a?J.ESC+`[1;`+(a+1)+`S`:J.ESC+`OS`;break;case 116:i.key=a?J.ESC+`[15;`+(a+1)+`~`:J.ESC+`[15~`;break;case 117:i.key=a?J.ESC+`[17;`+(a+1)+`~`:J.ESC+`[17~`;break;case 118:i.key=a?J.ESC+`[18;`+(a+1)+`~`:J.ESC+`[18~`;break;case 119:i.key=a?J.ESC+`[19;`+(a+1)+`~`:J.ESC+`[19~`;break;case 120:i.key=a?J.ESC+`[20;`+(a+1)+`~`:J.ESC+`[20~`;break;case 121:i.key=a?J.ESC+`[21;`+(a+1)+`~`:J.ESC+`[21~`;break;case 122:i.key=a?J.ESC+`[23;`+(a+1)+`~`:J.ESC+`[23~`;break;case 123:i.key=a?J.ESC+`[24;`+(a+1)+`~`:J.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=J.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=J.DEL:e.keyCode===219?i.key=J.ESC:e.keyCode===220?i.key=J.FS:e.keyCode===221&&(i.key=J.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=qy[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=J.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=J.ESC+n}else if(e.keyCode===32)i.key=J.ESC+(e.ctrlKey?J.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=J.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=J.US),e.key===`@`&&(i.key=J.NUL))}return i}var Yy=0,Xy=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new L_,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new L_,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||(Yy=this._search(t),Yy===-1)||this._getKey(this._array[Yy])!==t)return!1;do if(this._array[Yy]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Yy),!0;while(++Yy<this._array.length&&this._getKey(this._array[Yy])===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&&(Yy=this._search(e),!(Yy<0||Yy>=this._array.length)&&this._getKey(this._array[Yy])===e))do yield this._array[Yy];while(++Yy<this._array.length&&this._getKey(this._array[Yy])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Yy=this._search(e),!(Yy<0||Yy>=this._array.length)&&this._getKey(this._array[Yy])===e))do t(this._array[Yy]);while(++Yy<this._array.length&&this._getKey(this._array[Yy])===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}},Zy=0,Qy=0,$y=class extends G{constructor(){super(),this._decorations=new Xy(e=>e?.marker.line),this._onDecorationRegistered=this._register(new K),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new K),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(rh(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new eb(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=>{Zy=t.options.x??0,Qy=Zy+(t.options.width??1),e>=Zy&&e<Qy&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},eb=class extends ah{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new K),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new K),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?$g.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?$g.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},tb=1e3,nb=class{constructor(e,t=tb){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)}},rb=20,ib=class extends G{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 nb(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(`
|
|
68
68
|
`))),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(q(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(rh(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<rb+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
69
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===rb+1&&(this._liveRegion.textContent+=Jp.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})`}};ib=Wp([W(1,xm),W(2,Am),W(3,Mm)],ib);var ab=class extends G{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 K),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new K),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(rh(()=>{th(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(q(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(q(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(q(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(q(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&&ob(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,th(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}}};ab=Wp([W(1,jm),W(2,Mm),W(3,_m),W(4,Im)],ab);function ob(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 sb=class extends Ky{constructor(e={}){super(e),this._linkifier=this._register(new oh),this.browser=b_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new oh),this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new K),this.onKey=this._onKey.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new K),this.onBell=this._onBell.event,this._onFocus=this._register(new K),this._onBlur=this._register(new K),this._onA11yCharEmitter=this._register(new K),this._onA11yTabEmitter=this._register(new K),this._onWillOpen=this._register(new K),this._setup(),this._decorationService=this._instantiationService.createInstance($y),this._instantiationService.setService(Em,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Fne),this._instantiationService.setService(Im,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Dm)),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(ph.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ph.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ph.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ph.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(rh(()=>{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=$g.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${J.ESC}]${n};${Ay(r)}${Gg.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Qg.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Qg.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(ib,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(J.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(J.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(q(this.element,`copy`,e=>{this.hasSelection()&&Zp(e,this._selectionService)}));let e=e=>Qp(e,this.textarea,this.coreService,this.optionsService);this._register(q(this.textarea,`paste`,e)),this._register(q(this.element,`paste`,e)),w_?this._register(q(this.element,`mousedown`,e=>{e.button===2&&tm(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(q(this.element,`contextmenu`,e=>{tm(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),M_&&this._register(q(this.element,`auxclick`,e=>{e.button===1&&em(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(q(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(q(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(q(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(q(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(q(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(q(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(q(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(q(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`,Kp.get()),N_||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(Nne,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Am,this._coreBrowserService),this._register(q(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(q(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(g_,this._document,this._helperContainer),this._instantiationService.setService(km,this._charSizeService),this._themeService=this._instantiationService.createInstance(_v),this._instantiationService.setService(Fm,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(a_),this._instantiationService.setService(Pm,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(z_,this.rows,this.screenElement)),this._instantiationService.setService(Mm,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(Kg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(y_),this._instantiationService.setService(jm,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(ab,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(Rg,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(sv,this.element,this.screenElement,r)),this._instantiationService.setService(Nm,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(ph.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(zg,this.screenElement)),this._register(q(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(ib,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ug,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ug,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(h_,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(q(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(q(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=J.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){$p(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=Jy(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===J.ETX||n.key===J.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)&&(cb(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(Ev));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(J.ESC+`[I`):this.coreService.triggerDataEvent(J.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(`${J.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(`${J.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function cb(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var lb=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)}},ub=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 um)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},db=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 ub(t)}getNullCell(){return new um}},fb=class extends G{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new K),this.onBufferChange=this._onBufferChange.event,this._normal=new db(this._core.buffers.normal,`normal`),this._alternate=new db(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)}},pb=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)}},mb=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}},hb=[`cols`,`rows`],gb=0,_b=class extends G{constructor(e){super(),this._core=this._register(new sb(e)),this._addonManager=this._register(new lb),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(hb.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 pb(this._core),this._parser}get unicode(){return this._checkProposedApi(),new mb(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 fb(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
|
|
69
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===rb+1&&(this._liveRegion.textContent+=Jp.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})`}};ib=Wp([W(1,xm),W(2,Am),W(3,Mm)],ib);var ab=class extends G{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 K),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new K),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(rh(()=>{th(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(q(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(q(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(q(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(q(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&&ob(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,th(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}}};ab=Wp([W(1,jm),W(2,Mm),W(3,_m),W(4,Im)],ab);function ob(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 sb=class extends Ky{constructor(e={}){super(e),this._linkifier=this._register(new oh),this.browser=b_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new oh),this._onCursorMove=this._register(new K),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new K),this.onKey=this._onKey.event,this._onRender=this._register(new K),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new K),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new K),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new K),this.onBell=this._onBell.event,this._onFocus=this._register(new K),this._onBlur=this._register(new K),this._onA11yCharEmitter=this._register(new K),this._onA11yTabEmitter=this._register(new K),this._onWillOpen=this._register(new K),this._setup(),this._decorationService=this._instantiationService.createInstance($y),this._instantiationService.setService(Em,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Ine),this._instantiationService.setService(Im,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Dm)),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(ph.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ph.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ph.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ph.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(rh(()=>{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=Qg.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${J.ESC}]${n};${Ay(r)}${Wg.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Zg.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Zg.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(ib,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(J.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(J.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(q(this.element,`copy`,e=>{this.hasSelection()&&Zp(e,this._selectionService)}));let e=e=>Qp(e,this.textarea,this.coreService,this.optionsService);this._register(q(this.textarea,`paste`,e)),this._register(q(this.element,`paste`,e)),w_?this._register(q(this.element,`mousedown`,e=>{e.button===2&&tm(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(q(this.element,`contextmenu`,e=>{tm(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),M_&&this._register(q(this.element,`auxclick`,e=>{e.button===1&&em(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(q(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(q(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(q(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(q(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(q(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(q(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(q(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(q(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`,Kp.get()),N_||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(Pne,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Am,this._coreBrowserService),this._register(q(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(q(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(h_,this._document,this._helperContainer),this._instantiationService.setService(km,this._charSizeService),this._themeService=this._instantiationService.createInstance(_v),this._instantiationService.setService(Fm,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(i_),this._instantiationService.setService(Pm,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(z_,this.rows,this.screenElement)),this._instantiationService.setService(Mm,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(Gg,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(v_),this._instantiationService.setService(jm,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(ab,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(Lg,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(sv,this.element,this.screenElement,r)),this._instantiationService.setService(Nm,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(ph.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Rg,this.screenElement)),this._register(q(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(ib,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Hg,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Hg,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(m_,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(q(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(q(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=J.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){$p(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=Jy(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===J.ETX||n.key===J.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)&&(cb(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(Ev));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(J.ESC+`[I`):this.coreService.triggerDataEvent(J.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(`${J.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(`${J.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function cb(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var lb=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)}},ub=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 um)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},db=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 ub(t)}getNullCell(){return new um}},fb=class extends G{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new K),this.onBufferChange=this._onBufferChange.event,this._normal=new db(this._core.buffers.normal,`normal`),this._alternate=new db(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)}},pb=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)}},mb=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}},hb=[`cols`,`rows`],gb=0,_b=class extends G{constructor(e){super(),this._core=this._register(new sb(e)),this._addonManager=this._register(new lb),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(hb.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 pb(this._core),this._parser}get unicode(){return this._checkProposedApi(),new mb(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 fb(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
|
|
70
70
|
`,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 Kp.get()},set promptLabel(e){Kp.set(e)},get tooMuchOutput(){return Jp.get()},set tooMuchOutput(e){Jp.set(e)}}}_verifyIntegers(...e){for(gb of e)if(gb===1/0||isNaN(gb)||gb%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(gb of e)if(gb&&(gb===1/0||isNaN(gb)||gb%1!=0||gb<0))throw Error(`This API only accepts positive integers`)}},vb=`CommitMono`,yb=[400,700].map(e=>`${e} 14px ${vb}`),bb=`monospace`;function xb(e){return e.trim().replace(/^['"]|['"]$/g,``)}function Sb(e,t){let n=e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),r=t?n:n.filter(e=>xb(e)!==vb);return r.length>0?r.join(`, `):bb}function Cb(e,t,n){return Promise.all(t.map(t=>e.load(t))).then(n,()=>void 0)}function wb(e,t){for(let n of e)n.term&&(n.term.options.fontFamily=t,n._syncGrid?.())}function Tb(){return document.fonts?yb.every(e=>document.fonts.check(e)):!1}function Eb(){return Sb(getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`),Tb())}function Db(e){document.fonts&&Cb(document.fonts,yb,e)}var Ob=`↑`,kb=`↓`,Ab=`←`,jb=`→`,Mb=`⌘`,Nb={always:()=>!0,"calm-surface":e=>e.isCalmAvailable,"calm-view":e=>e.isCalmAvailable&&e.isCalmViewActive},Pb=Array.from({length:9},(e,t)=>[`Digit${t+1}`,t+1]),Fb=[{action:`next-attention`,keyCaptions:[`J`],label:`Jump to the next session needing you`,stepByCode:new Map([[`KeyJ`,0]]),availability:`always`},{action:`rail-step`,keyCaptions:[Ob,kb],label:`Previous / next session in the rail`,stepByCode:new Map([[`ArrowUp`,-1],[`ArrowDown`,1]]),availability:`always`},{action:`view-step`,keyCaptions:[Ab,jb],label:`Previous / next view tab`,stepByCode:new Map([[`ArrowLeft`,-1],[`ArrowRight`,1]]),availability:`always`,unavailablePlatform:`other`},{action:`view-step`,keyCaptions:[`PgUp`,`PgDn`],label:`Previous / next view tab`,stepByCode:new Map([[`PageUp`,-1],[`PageDown`,1]]),availability:`always`,unavailablePlatform:`mac`},{action:`session-nth`,keyCaptions:[`1..9`],label:`Jump to session 1 to 9`,stepByCode:new Map(Pb),availability:`always`},{action:`new-session`,keyCaptions:[`0`],label:`Add a session`,stepByCode:new Map([[`Digit0`,0]]),availability:`always`},{action:`merge`,keyCaptions:[`I`],label:`Merge the selected session`,stepByCode:new Map([[`KeyI`,0]]),availability:`always`},{action:`resolve-or-resync`,keyCaptions:[`U`],label:`Resolve a parked merge, or resync the base branch`,stepByCode:new Map([[`KeyU`,0]]),availability:`always`},{action:`calm-home`,keyCaptions:[`H`],label:`Go to the Calm view (Calm layout)`,stepByCode:new Map([[`KeyH`,0]]),availability:`calm-surface`,unavailablePlatform:`mac`},{action:`calm-terminal`,keyCaptions:[`T`],label:`Open the terminal of the open Calm panel (Calm layout)`,stepByCode:new Map([[`KeyT`,0]]),availability:`calm-view`,unavailablePlatform:`mac`}];function Ib(e){return Fb.filter(t=>t.unavailablePlatform!==e)}function Lb(e){return/Mac|iPhone|iPad/.test(e)?`mac`:`other`}function Rb(e,t){return e.ctrlKey||e.shiftKey?!1:t===`mac`?e.metaKey&&!e.altKey:e.altKey&&!e.metaKey}var zb=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`]);function Bb(e){return zb.has(e.key)?e.key:e.code}function Vb(e,t,n){if(!Rb(e,t))return null;let r=Bb(e);for(let e of Ib(t)){if(!Nb[e.availability](n))continue;let t=e.stepByCode.get(r);if(t!==void 0)return{action:e.action,step:t}}return null}function Hb(e){return e===`mac`?Mb:`Alt`}function Ub(e,t){let n=Ib(t).find(t=>t.action===e);if(!n)throw Error(`Unknown dashboard shortcut: ${e}`);return n}function Wb(e,t){return[Hb(t),Ub(e,t).keyCaptions.join(` `)]}function Gb(e,t){let[n,r]=Wb(e,t);return t===`mac`?`${n}${r}`:`${n}+${r}`}function Kb(e){let t=e===`mac`?`Meta`:`Alt`;return`ArrowUp ArrowDown ${t}+ArrowUp ${t}+ArrowDown`}function qb(e){let t=Hb(e),n=e===`mac`?Mb:`Ctrl`;return[{title:`Dashboard`,items:Ib(e).map(e=>({combos:e.keyCaptions.map(e=>[t,e]),label:e.label}))},{title:`Navigation`,items:[{combos:[[Ob],[kb]],label:`Move rail highlight (rail focused)`},{combos:[[Ab],[jb]],label:`Switch view tab (tab focused)`}]},{title:`Terminal`,items:[{combos:[[n,`C`]],label:`Copy selection`},{combos:[[n,`V`]],label:`Paste`},{combos:[[n,`Backspace`]],label:`Delete previous word`}]},{title:`General`,items:[{combos:[[`Esc`]],label:`Close dialog / cancel rename`}]}]}var Jb=Lb(navigator.userAgent),Yb=()=>({isCalmAvailable:!1,isCalmViewActive:!1});function Xb(e){Yb=e}function Zb(){return Yb()}function Qb(e,t){t.forEach((t,n)=>{n>0&&e.appendChild(V(`span`,`shortcut-sep`,`+`)),e.appendChild(V(`kbd`,`kbd`,t))})}function $b(e){let t=V(`span`,`shortcut-keys`);return Qb(t,e),t}var ex=6,tx=262144,nx=16384,rx=()=>{};function ix(e,t){if(t.length<=nx){e.push(t);return}for(let n=0;n<t.length;n+=nx)e.push(t.slice(n,n+nx))}function ax({budget:e=ex,maxChunkBytes:t=tx,requestFrame:n,cancelFrame:r}={}){let i=n||(e=>requestAnimationFrame(e)),a=r||(e=>cancelAnimationFrame(e)),o=new Map,s=[],c=0,l=null;function u(){l===null&&(l=i(h))}function d(e){return e.readIdx<e.pending.length}function f(e){d(e)||(e.pending.length=0,e.readIdx=0,e.dirty=!1)}function p(e){return!!(e?.live&&e.dirty&&!e.inFlight&&d(e))}function m(){for(let e of o.values())if(p(e))return!0;return!1}function h(){l=null;let n=s.length,r=0;for(let i=0;i<n&&r<e;i++){let e=s[(c+i)%n],a=o.get(e);if(!p(a))continue;let l=[],m=0;for(;a.readIdx<a.pending.length;){let e=a.pending[a.readIdx];if(typeof e!=`string`){if(m>0)break;a.readIdx++,e.run();continue}let n=t-m;if(m+e.length<=t){ix(l,e),m+=e.length,a.readIdx++;continue}m===0&&(ix(l,e.slice(0,n)),m+=n,a.pending[a.readIdx]=e.slice(n));break}let h=l.pop();if(h===void 0){f(a),r++;continue}f(a),d(a)&&a.readIdx>=64&&(a.pending.splice(0,a.readIdx),a.readIdx=0),a.inFlight=!0;for(let e of l)a.write(e,rx);a.write(h,()=>{a.live&&(a.inFlight=!1,d(a)&&(a.dirty=!0,u()))}),r++}n>0&&(c=(c+1)%n),m()&&u()}return{register(e,t){let n=o.get(e);if(n){n.write=t,n.live=!0;return}o.set(e,{write:t,pending:[],readIdx:0,inFlight:!1,dirty:!1,live:!0}),s.push(e)},unregister(e){let t=o.get(e);if(!t)return;t.live=!1,o.delete(e);let n=s.indexOf(e);n!==-1&&s.splice(n,1),c>=s.length&&(c=0)},enqueue(e,t){let n=o.get(e);n&&t&&(n.pending.push(t),n.dirty=!0,u())},enqueueAction(e,t){let n=o.get(e);n&&(n.pending.push({run:t}),n.dirty=!0,u())},has(e){return o.has(e)},size(){return o.size},running(){return l!==null},stop(){l!==null&&(a(l),l=null)}}}var ox=ax(),sx=`chime`,cx=`custom:`,lx=`/custom-sounds`,ux=Object.freeze({chime:{label:`Chime`,peakGain:.12,tones:[{frequency:659.25,startSeconds:0,durationSeconds:.35,waveform:`sine`},{frequency:987.77,startSeconds:.14,durationSeconds:.5,waveform:`sine`}]},ping:{label:`Soft ping`,peakGain:.08,tones:[{frequency:1046.5,startSeconds:0,durationSeconds:.12,waveform:`triangle`},{frequency:1046.5,startSeconds:.13,durationSeconds:.12,waveform:`triangle`},{frequency:1318.51,startSeconds:.26,durationSeconds:.2,waveform:`triangle`}]},beep:{label:`Beep`,peakGain:.15,tones:[{frequency:880,startSeconds:0,durationSeconds:.2,waveform:`sine`}]}}),dx=Object.freeze(Object.entries(ux).map(([e,t])=>({id:e,label:t.label})));function fx(e){return`${cx}${e}`}function px(e){return`${lx}/${encodeURIComponent(e)}`}function mx(e){return e.startsWith(cx)&&e.slice(7)||null}function hx(e){let t=(e??[]).map(e=>({id:fx(e),label:e}));return[...dx,...t]}function gx(e,t){if(typeof e!=`string`)return sx;if(Object.hasOwn(ux,e))return e;let n=mx(e);return n&&(t===null||t.includes(n))?e:sx}function _x(e){return typeof e!=`object`||!e||!(`sounds`in e)||!Array.isArray(e.sounds)?[]:e.sounds.filter(e=>typeof e==`string`&&e!==``)}var vx=.3,yx=null;function bx(){return hx(yx)}function xx(e){return gx(e,yx)}async function Sx(){try{let e=await fetch(lx,{credentials:`same-origin`,cache:`no-store`});e.ok&&(yx=_x(await e.json()))}catch{}}function Cx(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function wx(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function Tx(e){Ex(ux[e]??ux.chime)}function Ex(e){let t=Cx(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}wx(t,i)}async function Dx(e){try{let t=await fetch(px(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function Ox(e){let t=await Dx(e);if(!t)return!1;let n=Cx();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=vx,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),wx(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var kx=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function Ax(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<kx.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=kx[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+kx.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function jx(){try{Tx(sx)}catch{}}function Mx(e){try{let t=xx(e),n=mx(t);if(!n){Tx(t);return}Ox(n).then(e=>{e||jx()})}catch{}}var Nx={"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.06)`,"--state-running":`#22c55e`,"--state-running-bg":`rgba(34, 197, 94, 0.06)`,"--state-waiting":`#f59e0b`,"--state-waiting-bg":`rgba(245, 158, 11, 0.08)`,"--state-failed":`#ef4444`,"--state-failed-bg":`rgba(239, 68, 68, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#eab308`,"--state-idle-bg":`rgba(234, 179, 8, 0.06)`},Px={background:`--bg-card`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#ef4444`,brightRed:`#f87171`,green:`#22c55e`,brightGreen:`#4ade80`,yellow:`#eab308`,brightYellow:`#facc15`,cyan:`#06b6d4`,brightCyan:`#22d3ee`},Fx={golgari:{label:`Golgari (Green/Black)`,colors:{"--bg":`#060b08`,"--bg-card":`#0a120e`,"--bg-header":`#081009`,"--bg-surface":`#0e1a12`,"--border":`#1a2e1f`,"--border-dim":`#122016`,"--border-hover":`#2a4a32`,"--text":`#b8ccbe`,"--text-dim":`#6a9070`,"--text-head":`#dceede`,"--text-muted":`#7a9a80`,"--accent":`#2dd4a0`,"--accent-dim":`#1a9a6e`,...Nx,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#2dd4a0`,"--state-done-bg":`rgba(45, 212, 160, 0.06)`,"--state-starting":`#a78bfa`,"--state-starting-bg":`rgba(167, 139, 250, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...Px,foreground:`#c8dece`,blue:`--accent`,brightBlue:`#5ee8bc`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8dece`,brightWhite:`#e8f5ea`}},midnight:{label:`Midnight (Blue/Purple)`,colors:{"--bg":`#080816`,"--bg-card":`#0e0e20`,"--bg-header":`#0b0b1a`,"--bg-surface":`#131328`,"--border":`#1c1c38`,"--border-dim":`#141430`,"--border-hover":`#2a2a50`,"--text":`#b8b8d4`,"--text-dim":`#8585b3`,"--text-head":`#dcdcf0`,"--text-muted":`#7c7ca9`,"--accent":`#4f6ef7`,"--accent-dim":`#3a54c0`,...Nx,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#3b82f6`,"--state-done-bg":`rgba(59, 130, 246, 0.06)`,"--state-starting":`#a855f7`,"--state-starting-bg":`rgba(168, 85, 247, 0.06)`,"--state-complete":`#60a5fa`,"--state-complete-bg":`rgba(96, 165, 250, 0.06)`},terminal:{...Px,foreground:`#c8c8e0`,blue:`--accent`,brightBlue:`#60a5fa`,magenta:`#a855f7`,brightMagenta:`#c084fc`,white:`#c8c8e0`,brightWhite:`#e8e8ff`}},phyrexian:{label:`Phyrexian (Iridescent)`,colors:{"--bg":`#0a0810`,"--bg-card":`#100e18`,"--bg-header":`#0c0a14`,"--bg-surface":`#16122a`,"--border":`#2a2440`,"--border-dim":`#1e1a32`,"--border-hover":`#3e3660`,"--text":`#c8c0e0`,"--text-dim":`#8d82b9`,"--text-head":`#e8e0ff`,"--text-muted":`#8579b1`,"--accent":`#c084fc`,"--accent-dim":`#9656d6`,...Nx,"--state-monitoring":`#60a5fa`,"--state-monitoring-bg":`rgba(96, 165, 250, 0.08)`,"--state-done":`#67e8f9`,"--state-done-bg":`rgba(103, 232, 249, 0.06)`,"--state-starting":`#f472b6`,"--state-starting-bg":`rgba(244, 114, 182, 0.06)`,"--state-complete":`#34d399`,"--state-complete-bg":`rgba(52, 211, 153, 0.06)`},terminal:{...Px,foreground:`#c8c0e0`,blue:`#67e8f9`,brightBlue:`#a5f3fc`,magenta:`--accent`,brightMagenta:`#d8b4fe`,white:`#c8c0e0`,brightWhite:`#e8e0ff`}},compleated:{label:`Compleated (Light)`,colors:{"--bg":`#ece8e0`,"--bg-card":`#f7f4ee`,"--bg-header":`#f0ece4`,"--bg-surface":`#e4e0d6`,"--border":`#b8b0a0`,"--border-dim":`#ccc6b8`,"--border-hover":`#908878`,"--text":`#2a2622`,"--text-dim":`#5a5448`,"--text-head":`#0e0c0a`,"--text-muted":`#676157`,"--accent":`#0e0c0a`,"--accent-dim":`#2a2622`,"--state-running":`#16803c`,"--state-running-bg":`rgba(22, 128, 60, 0.08)`,"--state-waiting":`#b45309`,"--state-waiting-bg":`rgba(180, 83, 9, 0.08)`,"--state-failed":`#dc2626`,"--state-failed-bg":`rgba(220, 38, 38, 0.06)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#1a1816`,"--state-done-bg":`rgba(26, 24, 22, 0.06)`,"--state-initializing":`#6b7280`,"--state-initializing-bg":`rgba(107, 114, 128, 0.06)`,"--state-idle":`#a16207`,"--state-idle-bg":`rgba(161, 98, 7, 0.06)`,"--state-starting":`#7c3aed`,"--state-starting-bg":`rgba(124, 58, 237, 0.06)`,"--state-complete":`#059669`,"--state-complete-bg":`rgba(5, 150, 105, 0.06)`},terminal:{background:`#faf8f4`,foreground:`#1a1816`,cursor:`#1a1816`,cursorAccent:`#faf8f4`,black:`#1a1816`,brightBlack:`#5a5448`,red:`#b91c1c`,brightRed:`#dc2626`,green:`#15803d`,brightGreen:`#16a34a`,yellow:`#92400e`,brightYellow:`#a16207`,blue:`#1d4ed8`,brightBlue:`#2563eb`,magenta:`#6d28d9`,brightMagenta:`#7c3aed`,cyan:`#0e7490`,brightCyan:`#0891b2`,white:`#5a5448`,brightWhite:`#3a3630`}},unicorn:{label:`Rainbow Unicorns (Dark)`,colors:{"--bg":`#191022`,"--bg-card":`#201730`,"--bg-header":`#1c1329`,"--bg-surface":`#281c3c`,"--border":`#3a2c52`,"--border-dim":`#2a2040`,"--border-hover":`#55407a`,"--text":`#d4c8e6`,"--text-dim":`#9a88b8`,"--text-head":`#ede4fa`,"--text-muted":`#a897c4`,"--accent":`#e8a3c4`,"--accent-dim":`#c4739e`,"--state-running":`#42d780`,"--state-running-bg":`rgba(66, 215, 128, 0.10)`,"--state-waiting":`#f79f3b`,"--state-waiting-bg":`rgba(247, 159, 59, 0.10)`,"--state-failed":`#f05442`,"--state-failed-bg":`rgba(240, 84, 66, 0.13)`,"--state-monitoring":`#2dd4bf`,"--state-monitoring-bg":`rgba(45, 212, 191, 0.08)`,"--state-done":`#f04ca4`,"--state-done-bg":`rgba(240, 76, 164, 0.13)`,"--state-initializing":`#8f87a6`,"--state-initializing-bg":`rgba(143, 135, 166, 0.08)`,"--state-idle":`#bcb02f`,"--state-idle-bg":`rgba(188, 176, 47, 0.08)`,"--state-starting":`#a17ef1`,"--state-starting-bg":`rgba(161, 126, 241, 0.08)`,"--state-complete":`#34baf4`,"--state-complete-bg":`rgba(52, 186, 244, 0.14)`},terminal:{background:`#201730`,foreground:`#d4c8e6`,cursor:`--accent`,cursorAccent:`#201730`,black:`#8c7dab`,brightBlack:`#9c8fb5`,red:`#e8887e`,brightRed:`#f4a89f`,green:`#86e0ab`,brightGreen:`#a3edc0`,yellow:`#f0c674`,brightYellow:`#f5d896`,blue:`#9cb3f0`,brightBlue:`#b5c8f5`,magenta:`#dd8ecf`,brightMagenta:`#e6a8dc`,cyan:`#7fd4d0`,brightCyan:`#a0e6e2`,white:`#d4c8e6`,brightWhite:`#f4ecfc`}},"posthog-light":{label:`PostHog (Light)`,colors:{"--bg":`#eeefe9`,"--bg-card":`#fdfdf8`,"--bg-header":`#eeefe9`,"--bg-surface":`#e5e7e0`,"--border":`#bfc1b7`,"--border-dim":`#d2d3cc`,"--border-hover":`#9ea096`,"--text":`#23251d`,"--text-dim":`#65675e`,"--text-head":`#111111`,"--text-muted":`#73756b`,"--accent":`#c03300`,"--accent-dim":`#8e2600`,"--state-running":`#4d7533`,"--state-running-bg":`rgba(77, 117, 51, 0.08)`,"--state-waiting":`#b17816`,"--state-waiting-bg":`rgba(177, 120, 22, 0.10)`,"--state-failed":`#8c0d3b`,"--state-failed-bg":`rgba(140, 13, 59, 0.07)`,"--state-monitoring":`#0e7490`,"--state-monitoring-bg":`rgba(14, 116, 144, 0.08)`,"--state-done":`#3e6b9e`,"--state-done-bg":`rgba(62, 107, 158, 0.08)`,"--state-initializing":`#73756b`,"--state-initializing-bg":`rgba(115, 117, 107, 0.07)`,"--state-idle":`#835c19`,"--state-idle-bg":`rgba(131, 92, 25, 0.07)`,"--state-starting":`#a621c8`,"--state-starting-bg":`rgba(166, 33, 200, 0.07)`,"--state-complete":`#34796f`,"--state-complete-bg":`rgba(52, 121, 111, 0.08)`},terminal:{background:`--bg-card`,foreground:`#23251d`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`#23251d`,brightBlack:`#65675e`,red:`#c03300`,brightRed:`#df6133`,green:`#4d7533`,brightGreen:`#6aa84f`,yellow:`#835c19`,brightYellow:`#b17816`,blue:`#3e6b9e`,brightBlue:`#2f80fa`,magenta:`#74108d`,brightMagenta:`#a621c8`,cyan:`#34796f`,brightCyan:`#30abc6`,white:`#4d4f46`,brightWhite:`#23251d`}},"posthog-dark":{label:`PostHog (Dark)`,colors:{"--bg":`#1e1f23`,"--bg-card":`#25262b`,"--bg-header":`#232429`,"--bg-surface":`#2d2e37`,"--border":`#3e424f`,"--border-dim":`#32343f`,"--border-hover":`#626674`,"--text":`#edeef4`,"--text-dim":`#aeb3c2`,"--text-head":`#fafafa`,"--text-muted":`#9ea096`,"--accent":`#f87a4c`,"--accent-dim":`#f54e00`,"--state-running":`#36c46f`,"--state-running-bg":`rgba(54, 196, 111, 0.08)`,"--state-waiting":`#f7a501`,"--state-waiting-bg":`rgba(247, 165, 1, 0.09)`,"--state-failed":`#f35454`,"--state-failed-bg":`rgba(243, 84, 84, 0.09)`,"--state-monitoring":`#22d3ee`,"--state-monitoring-bg":`rgba(34, 211, 238, 0.08)`,"--state-done":`#589df8`,"--state-done-bg":`rgba(88, 157, 248, 0.08)`,"--state-initializing":`#8f8f8c`,"--state-initializing-bg":`rgba(143, 143, 140, 0.07)`,"--state-idle":`#ffce5c`,"--state-idle-bg":`rgba(255, 206, 92, 0.07)`,"--state-starting":`#8567ff`,"--state-starting-bg":`rgba(133, 103, 255, 0.09)`,"--state-complete":`#29dbbb`,"--state-complete-bg":`rgba(41, 219, 187, 0.08)`},terminal:{background:`--bg-card`,foreground:`#edeef4`,cursor:`--accent`,cursorAccent:`--bg-card`,black:`--border`,brightBlack:`--text-muted`,red:`#f35454`,brightRed:`#f87a4c`,green:`#36c46f`,brightGreen:`#96e5b6`,yellow:`#f7a501`,brightYellow:`#ffce5c`,blue:`#2f80fa`,brightBlue:`#9fc4ff`,magenta:`#8567ff`,brightMagenta:`#e2d6ff`,cyan:`#30abc6`,brightCyan:`#29dbbb`,white:`#aeb3c2`,brightWhite:`#fafafa`}}},Ix=`phyrexian`,Lx=null;function Rx(e){let t=Fx[e];if(!t)return;let n=Lx;Lx=e;let r=document.documentElement;r.dataset.theme=e;for(let[e,n]of Object.entries(t.colors))r.style.setProperty(e,n);e===`unicorn`&&n!==null&&n!==`unicorn`&&Ax()}function zx(e){document.documentElement.toggleAttribute(`data-compact-status`,e)}function Bx(e){document.documentElement.toggleAttribute(`data-show-usage`,e)}function Vx(){let e=Fx[Lx||Ix];if(!e)return{};let t=getComputedStyle(document.documentElement),n={};for(let[r,i]of Object.entries(e.terminal))n[r]=i.startsWith(`--`)?t.getPropertyValue(i).trim():i;return n}function Hx(){return Object.entries(Fx).map(([e,t])=>({id:e,label:t.label}))}var Ux=O().int().min(1).max(500),Wx=O().int().min(1).max(200);As(`type`,[j({type:P(`input`),data:D()}),j({type:P(`claim`),cols:Ux,rows:Wx}),j({type:P(`unview`)})]);var Gx=j({type:P(`pty-size`),cols:Ux,rows:Wx,seq:O().int().nonnegative()});function Kx(e){try{return JSON.parse(e)}catch{return null}}function qx(e){let t=Gx.safeParse(Kx(e));return t.success?t.data:null}function Jx(e,t){return!e||!t?!1:e.cols===t.cols&&e.rows===t.rows}function Yx(e){return!e||!Number.isInteger(e.cols)||!Number.isInteger(e.rows)?!1:e.cols>0&&e.rows>0}function Xx(e){return{cols:Math.min(Math.max(e.cols,1),500),rows:Math.min(Math.max(e.rows,1),200)}}function Zx({authoritative:e,isActiveViewer:t,lastClaim:n}){return!(t&&Jx(e,n))}function Qx({isDocumentVisible:e,isDocumentFocused:t,hasFocusInsideCard:n,hasWindowBlurredSinceFocus:r,isPhoneLayout:i}){return e?i||t?!0:n&&!r:!1}function $x({authoritative:e,isActiveViewer:t,isDocumentEngaged:n,isDataWsOpen:r,lastClaim:i}){return!t||!n||!r?`none`:Zx({authoritative:e,isActiveViewer:t,lastClaim:i})?`rebid`:`resync`}function eS({isActiveViewer:e,lastClaim:t,owedClaim:n}){return e?n??t:null}function tS({authoritative:e,applied:t,proposal:n,isActiveViewer:r,isDataWsOpen:i,lastClaim:a}){let o=!!e&&!Jx(e,t),s=Yx(n)?Xx(n):null,c=r&&!!s&&!Jx(s,a);return{resizeTo:o?e:null,owedClaim:c?s:null,keepsPendingSettle:r&&!s,sendUnview:!r&&i&&!!a,isFollowing:Zx({authoritative:e,isActiveViewer:r,lastClaim:a})}}function nS(e){return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):null}function rS(e){let t=nS(e);return t===null?null:qx(t)}function iS(e,t){if(typeof e==`string`)return{kind:`bytes`,data:e};let n=rS(e);return n?t.hasSeenSize?n.seq<=t.lastSeq?{kind:`stale`}:{kind:`size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`attach-size`,cols:n.cols,rows:n.rows,seq:n.seq}:{kind:`ignored`}}var aS=new Map([[`deleteContentBackward`,``],[`deleteByComposition`,``],[`deleteCompositionText`,``],[`deleteWordBackward`,`\x1B`],[`deleteSoftLineBackward`,`\x1B`],[`deleteHardLineBackward`,`\x1B`]]);function oS(e){return aS.get(e)??``}var sS=new Set([`insertFromPaste`,`insertFromPasteAsQuotation`,`insertFromDrop`,`insertFromYank`,`historyUndo`,`historyRedo`]);function cS(e){return typeof e!=`string`||e===``||!sS.has(e)}function lS(e){return e?e.keyCode===229||e.key===`Process`:!1}function uS(e,t){let n=Array.from(e??``),r=Array.from(t??``),i=Math.min(n.length,r.length),a=0;for(;a<i&&n[a]===r[a];)a++;return``.repeat(n.length-a)+r.slice(a).join(``).replace(/\r\n|\n|\r/g,`\r`)}var dS=new Set([`http:`,`https:`]);function fS(e){let t;try{t=new URL(e)}catch{return null}return dS.has(t.protocol)?t.href:null}var pS=/\bElectron\/\d/,mS=new Set([`localhost`,`127.0.0.1`]);function hS(e){return pS.test(e)}function gS({userAgent:e,pageHostname:t}){return hS(e)&&mS.has(t)}function _S(e){return fS(e)!==null}var vS=new Set([0,1]);function yS({button:e,opensInNewTab:t}){return t&&vS.has(e)}function bS(){return gS({userAgent:navigator.userAgent,pageHostname:location.hostname})}function xS(e){window.open(e,`_blank`,`noopener,noreferrer`)}async function SS(e){try{let t=await g();return(await fetch(`/open-external`,{method:`POST`,credentials:`same-origin`,cache:`no-store`,headers:{"content-type":`application/json`,"x-glimmervoid-page-token":t},body:JSON.stringify({url:e})})).ok}catch{return!1}}function CS(e){if(!bS()||!_S(e)){xS(e);return}SS(e).then(t=>{t||xS(e)})}function wS(e){if(e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href]`):null;t instanceof HTMLAnchorElement&&yS({button:e.button,opensInNewTab:t.target===`_blank`})&&_S(t.href)&&(e.preventDefault(),CS(t.href))}function TS(e){bS()&&(e.addEventListener(`click`,wS,!0),e.addEventListener(`auxclick`,wS,!0))}var ES=/https?:\/\/[^\s<>"']+/g,DS=new Set([`.`,`,`,`;`,`:`,`!`,`?`,`'`,`"`]),OS={")":`(`,"]":`[`,"}":`{`};function kS(e,t){let n=0;for(let r of e)r===t&&n++;return n}function AS(e){for(;;){let t=e[e.length-1];if(t===void 0)return e;if(DS.has(t)){e=e.slice(0,-1);continue}let n=OS[t];if(n&&kS(e,n)<kS(e,t)){e=e.slice(0,-1);continue}return e}}function jS(e){let t=[];for(let n of e.matchAll(ES)){let e=AS(n[0]);e.length<=8||t.push({start:n.index,end:n.index+e.length,url:e})}return t}var MS=50;function NS(){return{activate(e,t){CS(t)},allowNonHttpProtocols:!1}}function PS(e,t){let n=t-1;for(;n>0&&e.getLine(n)?.isWrapped&&t-1-n<MS;)n--;let r=t-1;for(;e.getLine(r+1)?.isWrapped&&r-(t-1)<MS;)r++;let i=``,a=[];for(let t=n;t<=r;t++){let n=e.getLine(t);if(!n)break;for(let e=0;e<n.length;e++){let r=n.getCell(e);if(!r)break;if(r.getWidth()===0)continue;let o=r.getChars()||` `;for(let n=0;n<o.length;n++)i+=o[n],a.push({x:e+1,y:t+1})}}return{text:i,cellAt:a}}function FS(e){return e.registerLinkProvider({provideLinks(t,n){let r=e.buffer?.active;if(!r)return n(void 0);let{text:i,cellAt:a}=PS(r,t),o=[];for(let{start:e,end:t,url:n}of jS(i)){let r=a[e],i=a[t-1];r&&i&&o.push({range:{start:r,end:i},text:n,activate(e,t){CS(t)}})}n(o.length?o:void 0)}})}function IS(e){return e===`\r`}function LS({hasTerminal:e,isSocketOpen:t,isInputHeld:n}){return e?n||!t?`connecting`:`live`:`none`}var RS=6e3,zS=400,BS=`×`,VS=new WeakMap;function HS(){let e=document.getElementById(`notice-region`);return e||(e=V(`div`,`notice-region`),e.id=`notice-region`,e.setAttribute(`role`,`region`),e.setAttribute(`aria-label`,`Notifications`),document.body.appendChild(e)),e}function US(e){let t=VS.get(e);t&&!t.dismissed&&(t.dismissed=!0,t.timer&&clearTimeout(t.timer),e.classList.add(`is-leaving`),e.addEventListener(`transitionend`,()=>e.remove(),{once:!0}),setTimeout(()=>e.remove(),zS))}function WS(e,t={}){let n=typeof e==`string`?e:String(e),r=t.persist===!0,i=HS(),a=i.firstElementChild,o=a?VS.get(a):null;if(o&&o.message===n&&!o.dismissed){if(!a)throw Error(`Toast state exists without a notice element`);o.count++;let e=H(a,`.notice-count`,`span`);return e.textContent=`x${o.count}`,e.hidden=!1,!r&&o.timer&&(clearTimeout(o.timer),o.timer=setTimeout(()=>US(a),RS)),a}let s=V(`div`,r?`notice is-persistent`:`notice`),c={message:n,count:1,timer:null,dismissed:!1};VS.set(s,c),s.setAttribute(`role`,`alert`);let l=V(`span`,`notice-glyph`,`!`);l.setAttribute(`aria-hidden`,`true`);let u=V(`span`,`notice-msg`,n),d=V(`span`,`notice-count`);d.hidden=!0;let f=V(`button`,`notice-close`,BS);return f.type=`button`,f.setAttribute(`aria-label`,`Dismiss notification`),f.addEventListener(`click`,()=>US(s)),s.append(l,u,d,f),i.prepend(s),requestAnimationFrame(()=>s.classList.add(`is-visible`)),r||(c.timer=setTimeout(()=>US(s),RS)),s}var GS=1.2,KS=.005;function qS(e,t){let n=Math.abs(t);return n<10?!1:n>Math.abs(e)*GS}function JS(e,t,n=1/0){if(!(t>0))return{scrollLines:0,remainderPx:e};let r=Math.trunc(e/t),i=Math.max(-n,Math.min(n,r));return{scrollLines:i===0?0:-i,remainderPx:e-i*t}}function YS(e,t,n){let r=e.length>=4?e.slice(1):e.slice();return r.push({positionPx:t,timestampMs:n}),r}function XS(e){if(!e||e.length<2)return 0;let t=e[0],n=e[e.length-1],r=n.timestampMs-t.timestampMs;if(!(r>0))return 0;let i=(n.positionPx-t.positionPx)/r,a=Math.abs(i);if(!(a>=.08))return 0;let o=Math.min(a,5);return i<0?-o:o}function ZS({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:n,pendingPx:r=0}){return!e||!(n>0)?null:{velocityPxPerMs:e,lastMs:t,cellHeightPx:n,pendingPx:r}}function QS(e,t){if(!e)return{scrollLines:0,state:null};let n=t-e.lastMs;if(!(n>0))return{scrollLines:0,state:e};let r=Math.abs(e.velocityPxPerMs)-KS*n;if(!(r>0))return{scrollLines:0,state:null};let i=e.velocityPxPerMs<0?-1:1,a=i*r*n,{scrollLines:o,remainderPx:s}=JS(e.pendingPx+a,e.cellHeightPx);return{scrollLines:o,state:{velocityPxPerMs:i*r,lastMs:t,cellHeightPx:e.cellHeightPx,pendingPx:s}}}function $S(e,t){return e===`alternate`||!!t&&t!==`none`}function eC(e,t){return!(e>0)||!(t>0)?0:e/t}var tC=1;function nC(e){return typeof e._core?._viewport?.handleTouchScroll==`function`}function rC(e,t){for(let n of e)if(n.identifier===t)return n;return null}function iC(e,t){if(nC(t))return;let n=()=>document.documentElement.dataset.layout===`phone`,r=null,i=0,a=0,o=0,s=!1,c=0,l=[],u=null,d=null,f=()=>{d!==null&&cancelAnimationFrame(d),d=null,u=null},p=()=>$S(t.buffer?.active?.type,t.modes?.mouseTrackingMode),m=()=>{let e=t.element?.querySelector(`.xterm-screen`);return eC(e?.clientHeight||t.element?.clientHeight||0,t.rows)},h=()=>{r=null,s=!1,c=0,l=[]},g=(e,n,r)=>{let i=e<0?-1:1;for(let a=0;a<Math.abs(e);a++)t.element?.dispatchEvent(new WheelEvent(`wheel`,{deltaY:i,deltaMode:tC,clientX:n,clientY:r,bubbles:!0,cancelable:!0}))},_=()=>{if(d=null,!u)return;if(!e.isConnected||!n()||p()){f();return}let r=t.buffer?.active?.viewportY,{scrollLines:i,state:a}=QS(u,performance.now());if(u=a,i!==0&&t.scrollLines(i),u){if(i!==0&&t.buffer?.active?.viewportY===r){f();return}d=requestAnimationFrame(_)}},v=(e,t,n)=>{u=ZS({velocityPxPerMs:e,startedAtMs:t,cellHeightPx:m(),pendingPx:n}),u&&(d=requestAnimationFrame(_))};e.addEventListener(`touchstart`,e=>{if(f(),!n()||e.touches.length!==1){h();return}let t=e.touches[0];r=t.identifier,i=t.clientX,a=t.clientY,o=t.clientY,s=!1,c=0,l=[]},{passive:!0}),e.addEventListener(`touchmove`,e=>{if(r===null||!n())return;let u=rC(e.touches,r);if(!u)return;if(!s){if(!qS(u.clientX-i,u.clientY-a))return;s=!0,o=u.clientY,c=0,l=YS([],u.clientY,e.timeStamp)}e.cancelable&&e.preventDefault(),c+=u.clientY-o,o=u.clientY,l=YS(l,u.clientY,e.timeStamp);let d=p(),{scrollLines:f,remainderPx:h}=JS(c,m(),d?8:void 0);if(c=h,f!==0){if(d){g(f,u.clientX,u.clientY);return}t.scrollLines(f)}},{passive:!1}),e.addEventListener(`touchend`,e=>{if(!s||p()){h();return}l=YS(l,o,e.timeStamp);let t=XS(l),n=c;h(),t!==0&&v(t,performance.now(),n)},{passive:!0}),e.addEventListener(`touchcancel`,()=>{f(),h()},{passive:!0})}var aC=Object.defineProperty,oC=Object.getOwnPropertyDescriptor,sC=(e,t,n,r)=>{for(var i=r>1?void 0:r?oC(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&&aC(t,n,i),i},cC=(e,t)=>(n,r)=>t(n,r,e),lC=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?mC.isErrorNoTelemetry(e)?new mC(e.message+`
|
|
71
71
|
|
|
72
72
|
`+e.stack):Error(e.message+`
|
|
@@ -167,8 +167,8 @@ void main() {
|
|
|
167
167
|
</label>
|
|
168
168
|
<label class="dialog-label dialog-checkbox-label" id="add-session-unconfined-label">
|
|
169
169
|
<input type="checkbox" class="dialog-checkbox" id="add-session-unconfined">
|
|
170
|
-
<span>Run
|
|
171
|
-
<span class="dialog-hint">Claude Code sessions run
|
|
170
|
+
<span>Run without guardrails</span>
|
|
171
|
+
<span class="dialog-hint">Claude Code sessions run with guardrails that block writes to credentials and Glimmervoid's own state and hide credentials and other agents' settings. Turn this on only for work the guardrails cannot serve.</span>
|
|
172
172
|
</label>
|
|
173
173
|
<div class="dialog-error" id="add-session-error"></div>
|
|
174
174
|
<div class="dialog-actions">
|
|
@@ -243,12 +243,12 @@ void main() {
|
|
|
243
243
|
`}function qI(){if(!RI)return;let e=NI(II,FI?.anomalies),t=RI.hidden;RI.hidden=!e,e&&t&&FI&&(GI(),LI&&KI())}function JI(e){II=e,qI()}function YI(e){if(RI)return RI;let t=WI();return e.appendChild(t),qI(),t}function XI(e){FI=e,qI(),RI&&!RI.hidden&&(GI(),LI&&KI())}function ZI(e){return e.replace(/\r\n?/g,`
|
|
244
244
|
`).split(`
|
|
245
245
|
`)}function QI(e){return{kind:`unchanged`,text:e}}function $I(e){return{kind:`skipped`,text:`${e} unchanged lines`}}function eL(e,t){return e.length<=7?e.map(t):[...e.slice(0,3).map(t),$I(e.length-6),...e.slice(e.length-3).map(t)]}function tL(e){return e}function nL(e){let t=[],n=0;for(;n<e.length;){if(e[n].kind!==`unchanged`){t.push(e[n]),n++;continue}let r=n;for(;r<e.length&&e[r].kind===`unchanged`;)r++;t.push(...eL(e.slice(n,r),tL)),n=r}return t}function rL(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return r}function iL(e,t,n){let r=Math.min(e.length,t.length)-n,i=0;for(;i<r&&e[e.length-1-i]===t[t.length-1-i];)i++;return i}function aL(e,t){let n=e.length,r=t.length;if(n===0)return t.map(e=>({kind:`added`,text:e}));if(r===0)return e.map(e=>({kind:`removed`,text:e}));let i=r+1,a=new Int32Array((n+1)*i);for(let o=n-1;o>=0;o--)for(let n=r-1;n>=0;n--){let r=o*i+n;if(e[o]===t[n]){a[r]=a[r+i+1]+1;continue}a[r]=Math.max(a[r+i],a[r+1])}let o=[],s=0,c=0;for(;s<n&&c<r;){if(e[s]===t[c]){o.push(QI(e[s])),s++,c++;continue}if(a[(s+1)*i+c]>=a[s*i+c+1]){o.push({kind:`removed`,text:e[s]}),s++;continue}o.push({kind:`added`,text:t[c]}),c++}for(;s<n;)o.push({kind:`removed`,text:e[s]}),s++;for(;c<r;)o.push({kind:`added`,text:t[c]}),c++;return o}function oL(e,t){let n=ZI(e),r=ZI(t),i=rL(n,r),a=iL(n,r,i),o=n.slice(i,n.length-a),s=r.slice(i,r.length-a);return o.length+s.length>2e3?{lines:[],isTooLarge:!0}:{lines:nL([...eL(n.slice(0,i),QI),...aL(o,s),...eL(n.slice(n.length-a),QI)]),isTooLarge:!1}}var sL=Object.freeze([{kind:`approve`,label:`Approve`},{kind:`revise`,label:`Send feedback`},{kind:`terminal`,label:`Answer in terminal`}]);function cL(e){return e===`approve`||e===`approve-accept-edits`}function lL(e){return(e.state===`decided`||e.state===`closed`)&&cL(e.lastDecision)}function uL(e,t){let n=e.reviews.find(e=>e.agentId===t);return n!==void 0&&lL(n)}function dL(e,t){return e.reviews.find(e=>e.agentId===t)??e.reviews[0]??null}function fL(e){let t=dL(e.state,e.selectedAgentId);return t?e.selectedRevision&&t.revisions.some(t=>t.revision===e.selectedRevision)?e.selectedRevision:t.revisions.at(-1)?.revision??null:null}function pL(e,t){return dL(e,t)?.openRevision?.revision??null}function mL(e,t,n){if(n===null)return null;let r=dL(e,t)?.revisions??[],i=r.findIndex(e=>e.revision===n);return i<=0?null:r[i-1].revision}function hL(e,t){let n=t-e;return Number.isFinite(n)?_p(n,{rounding:`floor`,wording:`abbreviated`,suffix:` ago`,justNowBelowSeconds:60}):`just now`}function gL(e,t,n){return t!==null&&t.state===`open`&&t.openRevision!==null&&t.openRevision.revision===n&&e.body!==null&&e.isConnected&&e.isDraft!==!0&&!e.isDecisionInFlight}function _L(e,t,n){let r=gL(e,t,n),i=(e.pendingCommentCount??0)>0,a=e.hasUnsavedComment!==!0;return sL.map(({kind:e,label:t})=>({kind:e,label:t,enabled:r&&(e===`terminal`||a&&(e===`revise`?i:!i))}))}function vL(e,t){return e.openRevision===null?t!==null&&e.approvedRevision===t?`Approved`:e.state===`released`?`Answer in the terminal`:e.state===`decided`?e.lastDecision===`revise`?`Feedback sent, waiting for the next revision`:`Approved`:`Closed`:e.openRevision.revision===t?``:`Rev ${e.openRevision.revision} is the one open`}function yL(e){let t=0;for(let n of e.comments??[])t+=n.comment.trim().length+(n.heading?.length??0);return t}function bL(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength+Pd}function xL(e){let t=e.plan;if(t!==void 0&&t.length===0)return`the edited plan is empty, so nothing was sent`;if(t!==void 0&&new TextEncoder().encode(t).byteLength>524288)return`the edited plan is over the plan size cap, so nothing was sent`;let n=e.comments??[];return n.length>40?`more than 40 section comments are pending, so nothing was sent`:n.find(e=>e.comment.length>4e3||(e.heading?.length??0)>4e3)?`a section comment is over ${dl} characters, so nothing was sent`:yL(e)>1e4?`the feedback composes more than the ${Kee} characters the hook reply carries, so nothing was sent`:bL(e)>Fd?`the decision is larger than one control frame carries, so nothing was sent`:null}function SL(e){return e?`, ${e}`:``}function CL(e,t,n){if(!e.isConnected)return`Disconnected`;if(!t||n===null)return`No plan revision selected`;if(e.isDecisionInFlight)return`Sending your decision`;if(e.body===null)return`Loading`;if(e.isDraft===!0)return`Draft`;let r=vL(t,n);if(r)return r;if(e.hasUnsavedComment===!0)return`Save or cancel the open comment first.`;let i=e.pendingCommentCount??0;return i<=0?``:i===1?`1 comment to send. Remove it to approve.`:`${i} comments to send. Remove them to approve.`}function wL(e,t,n){let r=CL(e,t,n);return r?`${r}${SL(e.problem)}`:e.problem??``}function TL(e){let t=dL(e.state,e.selectedAgentId),n=fL(e);return{tabs:e.state.reviews.map(e=>({agentId:e.agentId,label:e.agentId===null?`Main`:e.agentType||`Agent`,selected:e===t})),revisions:(t?.revisions??[]).map(e=>({revision:e.revision,label:`Rev ${e.revision}`,isOpen:e.revision===t?.openRevision?.revision,receivedAt:e.receivedAt,selected:e.revision===n})),selectedAgentId:t?.agentId??null,selectedRevision:n,previousRevision:mL(e.state,t?.agentId??null,n),status:wL(e,t,n),actions:_L(e,t,n),modes:[{kind:`read`,label:`Read`,enabled:!0},{kind:`changes`,label:`Changes`,enabled:mL(e.state,t?.agentId??null,n)!==null&&e.isDraft!==!0},{kind:`edit`,label:`Edit`,enabled:gL(e,t,n)}]}}function EL(e,t){let n=e.reviews.findIndex(e=>e.agentId===t.agentId),r=[...(n===-1?null:e.reviews[n])?.revisions??[]],i=r.findIndex(e=>e.revision===t.revision),a={revision:t.revision,receivedAt:t.receivedAt,chars:t.chars,title:t.title};r[i===-1?r.length:i]=a,r.sort((e,t)=>e.revision-t.revision);let o={agentId:t.agentId,agentType:t.agentType,revisions:r,state:t.state,openRevision:t.state===`open`?{revision:t.revision,since:t.receivedAt}:null,approvedRevision:t.approvedRevision,lastDecision:t.lastDecision},s=[...e.reviews];return s[n===-1?s.length:n]=o,{reviews:s}}function DL({headingOffsets:e,scrollTop:t,isScrolledToEnd:n,readingLineOffset:r}){if(e.length===0)return null;if(n)return e.length-1;let i=t+r,a=0;for(let t=0;t<e.length&&!(e[t]>i);t++)a=t;return a}var OL=12,kL=8,AL=``,jL=48,ML=new Map;function NL(e,t){return JSON.stringify([e,t])}function PL(e){return e.id??AL}function FL(e,t){let n=ML.get(e);n||(n=new Map,ML.set(e,n));let r=NL(t.agentId,t.revision);for(n.delete(r),n.set(r,t.plan);n.size>OL;){let e=n.keys().next().value;if(typeof e!=`string`)break;n.delete(e)}}function IL(e){ML.delete(e)}function LL(e,t,n){return!e||n===null?null:ML.get(e)?.get(NL(t,n))??null}function RL(e){let t=V(`section`,`plan-face`);t.hidden=!0;let n=V(`header`,`plan-head`),r=V(`select`,`plan-heading-picker`);r.setAttribute(`aria-label`,`Plan section`);let i=V(`div`,`plan-view-panel`),a=V(`div`,`plan-sheet-head`),o=V(`button`,`plan-control plan-sheet-close`,`×`);o.type=`button`,o.setAttribute(`aria-label`,`Close`),a.append(V(`span`,null,`View`),o);let s=V(`div`,`plan-view-group plan-author-group`),c=V(`div`,`plan-tabs`);c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,`Plan author`),s.append(V(`span`,`plan-sheet-label`,`Author`),c);let l=V(`div`,`plan-view-group plan-revision-group`),u=V(`div`,`plan-revision-stepper`),d=V(`button`,`plan-control plan-revision-previous`,`‹`);d.type=`button`,d.setAttribute(`aria-label`,`Previous revision`);let f=V(`button`,`plan-control plan-revision-next`,`›`);f.type=`button`,f.setAttribute(`aria-label`,`Next revision`);let p=V(`span`,`plan-revision-label`),m=V(`span`,`plan-revision-age`);u.append(d,p,f,m);let h=V(`div`,`plan-revision-list`);h.setAttribute(`role`,`radiogroup`),h.setAttribute(`aria-label`,`Revision`),l.append(V(`span`,`plan-sheet-label`,`Revision`),u,h);let g=V(`div`,`plan-view-group plan-mode-group`),_=V(`div`,`plan-modes`);_.setAttribute(`role`,`radiogroup`),_.setAttribute(`aria-label`,`Show`),g.append(V(`span`,`plan-sheet-label`,`Show`),_);let v=V(`div`,`plan-head-spacer`),y=V(`div`,`plan-draft-notice`),ee=V(`span`,`plan-draft-dot`);ee.setAttribute(`aria-hidden`,`true`);let b=V(`button`,`plan-control plan-draft-chip`,`Peek draft`);b.type=`button`,y.append(ee,b),i.append(a,s,l,g,v,y);let te=V(`button`,`plan-control plan-view-button`,`View`);te.type=`button`,te.setAttribute(`aria-haspopup`,`dialog`),te.setAttribute(`aria-expanded`,`false`);let ne=V(`button`,`plan-control plan-minimize-button`,`Minimize`);ne.type=`button`,ne.addEventListener(`click`,e.showTerminal),n.append(r,i,te,ne);let re=V(`div`,`plan-sheet-backdrop`),ie=V(`div`,`plan-body-layout`),ae=V(`nav`,`plan-heading-rail`);ae.setAttribute(`aria-label`,`Plan sections`);let x=V(`article`,`plan-reading-column`);ie.append(ae,x);let oe=V(`textarea`,`plan-editor`);oe.setAttribute(`aria-label`,`Plan markdown`),oe.spellcheck=!1;let se=V(`footer`,`plan-action-bar`),ce=V(`span`,`plan-status`);ce.setAttribute(`role`,`status`);let le=V(`div`,`plan-decision-slot`),ue=V(`label`,`plan-accept-edits`),S=V(`input`,`plan-accept-edits-checkbox`);S.type=`checkbox`,ue.append(S,V(`span`,null,`Accept edits`)),le.append(ue,ce),se.append(le);let C=new Map;for(let[e,t]of[[`terminal`,`Answer in terminal`],[`revise`,`Send feedback`],[`approve`,`Approve`]]){let n=V(`button`,`plan-action`,t);n.type=`button`,n.dataset.decision=e,n.addEventListener(`click`,()=>{n.disabled||at(e)}),C.set(e,n),se.append(n)}t.append(n,ie,se,re);let w=null,de={reviews:[]},fe=null,pe=null,me=!0,he=``,ge=``,_e=``,ve=``,ye=!1,be=null,T=!1,xe=null,Se=!1,Ce=!1,we=null,Te=[],Ee=null,De=null,Oe=new Map,ke=new Map,Ae=new Map,je=[],Me=!1,Ne=null,Pe=!1;function Fe(e,t=!0){Pe=e,i.replaceChildren(...e?[a,g,l,s,y,v]:[a,s,l,g,v,y]),c.setAttribute(`role`,e?`radiogroup`:`tablist`);for(let t of c.querySelectorAll(`button`)){let n=t.getAttribute(`aria-selected`)===`true`||t.getAttribute(`aria-checked`)===`true`;t.setAttribute(`role`,e?`radio`:`tab`),t.removeAttribute(e?`aria-selected`:`aria-checked`),t.setAttribute(e?`aria-checked`:`aria-selected`,String(n))}if(i.dataset.open=String(e),re.dataset.open=String(e),te.setAttribute(`aria-expanded`,String(e)),ie.inert=e,se.inert=e,r.inert=e,te.inert=e,ne.inert=e,e){i.setAttribute(`role`,`dialog`),i.setAttribute(`aria-label`,`Plan view`),i.setAttribute(`aria-modal`,`true`),o.focus();return}i.removeAttribute(`role`),i.removeAttribute(`aria-modal`),t&&te.focus()}function Ie(e){e.addEventListener(`keydown`,t=>{let n={ArrowLeft:-1,ArrowUp:-1,ArrowRight:1,ArrowDown:1}[t.key];if(n===void 0&&t.key!==`Home`&&t.key!==`End`)return;let r=[...e.querySelectorAll(`button:not(:disabled)`)];if(r.length===0)return;t.preventDefault();let i=(r.indexOf(document.activeElement)+(n??0)+r.length)%r.length;t.key===`Home`&&(i=0),t.key===`End`&&(i=r.length-1);let a=Pe;r[i].click(),!(a&&e!==_)&&(e===_||!Pe)&&e.querySelector(`[aria-checked="true"], [aria-selected="true"]`)?.focus()})}let Le=Lf.subscribe((e,t)=>{t.includes(`layout`)&&Pe&&Fe(!1,!1)});e.signal?.addEventListener(`abort`,Le,{once:!0}),Ie(_),Ie(c),Ie(h),te.addEventListener(`click`,()=>Fe(!Pe)),o.addEventListener(`click`,()=>Fe(!1)),re.addEventListener(`click`,()=>Fe(!1)),i.addEventListener(`keydown`,e=>{if(!Pe)return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Fe(!1);return}if(e.key!==`Tab`)return;let t=[...i.querySelectorAll(`button:not(:disabled)`)].filter(e=>e.getClientRects().length>0&&e.tabIndex>=0),n=t[0],r=t.at(-1);if(e.shiftKey&&document.activeElement===n){e.preventDefault(),r?.focus();return}!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())});function Re(e){x.querySelector(`#${CSS.escape(e)}`)?.scrollIntoView({behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`,block:`start`})}r.addEventListener(`change`,()=>Re(r.value));function ze(){Me=!1;let e=je.map(e=>x.querySelector(`#${CSS.escape(e.dataset.headingId??``)}`)).filter(e=>e!==null),t=x.getBoundingClientRect().top-x.scrollTop,n=DL({headingOffsets:e.map(e=>e.getBoundingClientRect().top-t),scrollTop:x.scrollTop,isScrolledToEnd:x.scrollTop>0&&x.scrollTop+x.clientHeight>=x.scrollHeight-2,readingLineOffset:jL}),i=n===null?null:e[n]?.id??null;for(let e of je){if(e.dataset.headingId===i){e.setAttribute(`aria-current`,`location`);continue}e.removeAttribute(`aria-current`)}i!==null&&(r.value=i)}function Be(){Me||t.hidden||je.length===0||(Me=!0,requestAnimationFrame(ze))}x.addEventListener(`scroll`,Be,{passive:!0});function Ve(){Ne=null,T=!1,Se=!1,Ce=!1,we=null}function He(t){Ee=t,e.reportProblem(t),kt()}function Ue(e){pe=e,Ee=null,Ve(),Fe(!1,Pe),kt()}function We(e){let t=de.reviews.find(e=>e.agentId===fe)?.revisions??[],n=t[t.findIndex(e=>e.revision===pe)+e];n&&Ue(n.revision)}d.addEventListener(`click`,()=>We(-1)),f.addEventListener(`click`,()=>We(1));function Ge(e,t){return`${w??``}:${e??`main`}:${t??`latest`}`}function Ke(){return Ge(fe,pe)}function qe(e,t,n){return`${e??``}:${NL(t,n??0)}`}function Je(){return qe(w,fe,pe)}function Ye(){return ke.get(Je())??null}function Xe(){return Ye()?.size??0}function Ze(){if(Ne===null)return!1;let e=ke.get(Ne.target.bucketKey)?.get(Ne.target.sectionSlot)??``;return Ne.field.value.trim()!==e}function Qe(e){let t=ke.get(e);if(!t)return[];let n=[];for(let e of Te){let r=t.get(PL(e));r&&n.push({heading:e.heading,comment:r})}return n}function $e(e,t){let n=t.trim(),r=ke.get(e.bucketKey)??new Map;ke.set(e.bucketKey,r),n.length===0&&r.delete(e.sectionSlot),n.length>0&&r.set(e.sectionSlot,n),r.size===0&&ke.delete(e.bucketKey),kt()}function et(e){if(Ce||ye)return;let t={bucketKey:Je(),sectionSlot:PL(e)},n=V(`div`,`plan-comment-composer`),r=V(`label`,`plan-comment-label`,`Comment on ${e.heading??`Introduction`}`),i=V(`textarea`,`plan-comment-input`);i.maxLength=dl,i.value=ke.get(t.bucketKey)?.get(t.sectionSlot)??``,r.append(i);let a=V(`div`,`plan-comment-actions`),o=V(`button`,`plan-control plan-comment-cancel`,`Cancel`);o.type=`button`;let s=V(`button`,`plan-control plan-comment-save`,`Save comment`);s.type=`button`,a.append(o,s),n.append(r,a);let c={target:t,element:n,field:i};Ne=c,i.addEventListener(`input`,Ot),o.addEventListener(`click`,()=>{Ne===c&&(Ne=null,kt())}),s.addEventListener(`click`,()=>{Ne===c&&(Ne=null),$e(t,i.value)}),kt(),i.focus()}function tt(e){let t={bucketKey:Je(),sectionSlot:PL(e)};if(Ne?.target.bucketKey===t.bucketKey&&Ne.target.sectionSlot===t.sectionSlot)return Ne.element;let n=Ye()?.get(t.sectionSlot);if(!n)return null;let r=V(`div`,`plan-comment-card`),i=V(`div`,`plan-comment-head`),a=V(`button`,`plan-control plan-comment-edit`,`Edit`);a.type=`button`,a.addEventListener(`click`,()=>et(e));let o=V(`button`,`plan-control plan-comment-remove`,`Remove`);return o.type=`button`,o.disabled=ye,a.disabled=ye,o.addEventListener(`click`,()=>$e(t,``)),i.append(V(`span`,`plan-comment-label`,`Your comment`),a,o),r.append(i,V(`p`,`plan-comment-text`,n)),r}function nt(t,n,r={}){if(!w||n.revision===null||ye)return!1;let i=xL(r);if(i!==null)return He(i),!1;let a={agentId:n.agentId,revision:n.revision,decision:t,...r};return e.sendDecision(w,a)?(Ee=null,ye=!0,be=cL(t)?n:null,kt(),!0):!1}function rt(e){if(!T)return{};let t=oe.value;return t===LL(w,e.agentId,e.revision)?{}:{plan:t}}function it(e){let t=qe(w,e.agentId,e.revision),n=Qe(t);n.length!==0&&nt(`revise`,e,{comments:n})&&e.revision!==null&&(De={bucketKey:t,agentId:e.agentId,revision:e.revision},kt())}function at(e){let t={agentId:fe,revision:pe};if(e===`revise`){it(t);return}nt(e===`approve`&&!ue.hidden&&S.checked?`approve-accept-edits`:e,t,rt(t))}function ot(e){Ne=null,T=e===`edit`,Se=e===`changes`,T&&xe!==Je()&&(oe.value=LL(w,fe,pe)??``,xe=Je()),Ee=null,kt()}function st(e){return`${e.kind}:${Ge(e.agentId,e.revision)}`}function E(e){for(Ae.set(st(e),e);Ae.size>kL;){let e=Ae.keys().next().value;if(typeof e!=`string`)break;Ae.delete(e)}}function ct(e,t){return e.agentId===t.agentId?e.kind===`draft`?t.revision===0:t.revision===0?!1:e.revision===null||e.revision===t.revision:!1}function lt(e){for(let[t,n]of Ae)if(ct(n,e))return Ae.delete(t),n;return null}function ut(){for(let[e,t]of Ae)if(t.kind===`draft`)return Ae.delete(e),t;return null}function dt(){if(Ae.size!==1)return null;let e=Ae.entries().next().value;return e?(Ae.delete(e[0]),e[1]):null}function ft(){if(!w)return;let t=Ke();he!==t&&e.requestPlan(w,fe,pe??void 0)&&(he=t,E({kind:`selection`,agentId:fe,revision:pe}))}function pt(){t.hidden||ft()}function mt(){return mL(de,fe,pe)}function ht(t){if(!w)return;let n=Ge(fe,t);_e!==n&&e.requestPlan(w,fe,t)&&(_e=n,E({kind:`diff-base`,agentId:fe,revision:t}))}function gt(){if(!w)return;let t=`${w}:${fe??`main`}`;ve!==t&&e.requestDraft(w,fe)&&(ve=t,E({kind:`draft`,agentId:fe,revision:null}))}function _t(e,t){return`${e??``}:${t??``}`}function vt(){return de.reviews.find(e=>e.agentId===fe)?.revisions.find(e=>e.revision===pe)?.receivedAt??0}function yt(){let e=Oe.get(_t(w,fe));return e!==void 0&&e>vt()}function bt(){if(Ce){Ve(),kt();return}Ne=null,T=!1,Se=!1,gt(),kt()}b.addEventListener(`click`,bt);function xt(e){ae.replaceChildren(),r.replaceChildren(),je=[];for(let t of e){let e=t.id??`plan-introduction`,n=t.heading??`Introduction`,i=V(`button`,`plan-heading-link`,n);i.type=`button`,i.dataset.level=String(t.level),i.dataset.headingId=e,i.title=n,i.dataset.commented=String(Ye()?.has(PL(t))===!0),je.push(i),i.addEventListener(`click`,()=>Re(e)),ae.append(i);let a=V(`option`,null,n);a.value=e,r.append(a)}}function St(e){let t=mt();if(t===null){x.append(V(`p`,`plan-loading`,`This is the first revision, so there is nothing to diff`));return}let n=LL(w,fe,t);if(n===null){x.append(V(`p`,`plan-loading`,`Loading the previous revision`)),ht(t);return}let r=oL(n,e);if(r.isTooLarge){x.append(V(`p`,`plan-loading`,`This diff is too large to show, so the newer revision stands alone`)),x.append(NF(OF(e)));return}x.append(IF(r))}function Ct(e){if(x.replaceChildren(),T){xt(Te),x.append(oe);return}if(e===null){if(Te=[],xt(Te),ge===Ke()){x.append(V(`p`,`plan-loading`,`This plan revision could not be loaded`));return}x.append(V(`p`,`plan-loading`,`Loading plan`)),ft();return}let t=OF(e);if(Te=kF(t),xt(Te),Se){St(e);return}if(Ce){x.append(NF(t));return}let n=Ye();x.append(PF(Te,{hasComment:e=>n?.has(PL(e))===!0,isComposing:e=>Ne?.target.bucketKey===Je()&&Ne.target.sectionSlot===PL(e),onComment:et,attachmentFor:tt}))}function wt(e){s.hidden=e.tabs.length<2,c.replaceChildren();for(let t of e.tabs){let e=V(`button`,`plan-tab`,t.label);e.type=`button`,e.setAttribute(`role`,Pe?`radio`:`tab`),e.setAttribute(Pe?`aria-checked`:`aria-selected`,String(t.selected)),e.tabIndex=t.selected?0:-1,e.addEventListener(`click`,()=>{fe=t.agentId,pe=null,Ee=null,he=``,ge=``,_e=``,ve=``,Ve(),Fe(!1,Pe),kt()}),c.append(e)}}function Tt(){return Ce?we:LL(w,fe,pe)}function Et(e){return TL({state:de,selectedAgentId:fe,selectedRevision:pe,body:e,isConnected:me,isDecisionInFlight:ye,isDraft:Ce,pendingCommentCount:Xe(),hasUnsavedComment:Ze(),problem:Ee})}function Dt(e){ce.textContent=e.status,ce.hidden=e.status.length===0;let t=e.actions.some(e=>e.kind===`approve`&&e.enabled);ue.hidden=!t,S.disabled=!t;for(let t of e.actions){let e=C.get(t.kind);e&&(e.disabled=!t.enabled)}}function Ot(){Dt(Et(Tt()))}function kt(){let e=Pe&&i.contains(document.activeElement),t=TL({state:de,selectedAgentId:fe,selectedRevision:pe,body:null,isConnected:me});(fe!==t.selectedAgentId||pe!==t.selectedRevision)&&Ve(),fe=t.selectedAgentId,pe=t.selectedRevision,xe!==Je()&&(xe=null);let n=Tt(),a=Et(n);wt(a);let s=a.revisions.findIndex(e=>e.selected),c=a.revisions[s],l=Date.now();u.hidden=a.revisions.length<2,p.textContent=`Rev ${s+1} of ${a.revisions.length}`,m.textContent=c?hL(c.receivedAt,l):``,d.disabled=s<=0,f.disabled=s<0||s>=a.revisions.length-1,h.replaceChildren();for(let e of[...a.revisions].reverse()){let t=V(`button`,`plan-revision-option`);t.type=`button`,t.dataset.revision=String(e.revision),t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.selected)),t.tabIndex=e.selected?0:-1,t.append(V(`span`,`plan-revision-name`,e.label),V(`span`,`plan-revision-age`,hL(e.receivedAt,l))),e.isOpen&&t.append(V(`span`,`plan-revision-open`,`OPEN`)),t.addEventListener(`click`,()=>Ue(e.revision)),h.append(t)}_.replaceChildren();let g=T?`edit`:Se?`changes`:`read`,v=a.modes.find(e=>e.kind===g&&e.enabled)??a.modes[0];for(let e of a.modes){let t=V(`button`,`plan-control plan-mode`,e.label);t.type=`button`,t.dataset.mode=e.kind,t.disabled=!e.enabled,t.setAttribute(`role`,`radio`),t.setAttribute(`aria-checked`,String(e.kind===g)),t.tabIndex=e.kind===v.kind?0:-1,t.addEventListener(`click`,()=>{t.disabled||(ot(e.kind),_.querySelector(`[aria-checked="true"]`)?.focus())}),_.append(t)}y.hidden=!yt()&&!Ce,b.hidden=y.hidden,b.setAttribute(`aria-pressed`,String(Ce)),Dt(a),Ct(n),r.disabled=je.length===0,Be(),e&&!i.contains(document.activeElement)&&o.focus()}function At(t){be!==null&&uL(t,be.agentId)&&(be=null,xe=null,e.showTerminal())}function jt(e){Ne=null,e!==w&&(be=null,ye=!1,Ee=null,Ae.clear()),Fe(!1,!1),w=e,t.hidden=!1,he=``,ge=``,kt(),pt()}function Mt(){Ne=null,Fe(!1,!1),t.hidden=!0}function Nt(e,t){return t.kind!==`selection`||e.agentId!==fe?!1:t.revision===null?pe===null||pe===e.revision:t.revision===pe}function Pt(e){if(e.kind===`draft`){ve=``,He(`the draft could not be read, so nothing was shown`);return}if(e.kind===`diff-base`){_e=``;return}ge=Ge(e.agentId,e.revision)}function Ft(e){De!==null&&pL(e,De.agentId)!==De.revision&&(ke.delete(De.bucketKey),De=null)}function It(e){ye=!1,Lt({reviews:e.reviews});let t=e.body;if(!t){let e=dt()??ut();e!==null&&Pt(e);return}let n=lt(t);if(t.revision===0){if(ve=``,n===null||t.agentId!==fe)return;we=t.plan,Ce=!0;return}FL(e.id,t),n!==null&&Nt(t,n)&&(fe=t.agentId,pe=t.revision,he=``,ge=``)}function Lt(e){let t=pL(e,fe);t!==null&&t!==pL(de,fe)&&(pe=t,Ve()),Ft(e),de=e,ye=!1,At(e)}function Rt(e){let n=!1;e.state&&Lt(e.state),e.draft&&Oe.set(_t(e.draft.id,e.draft.agentId),e.draft.changedAt),e.decisionRefused&&(be=null,ye=!1,De=null),typeof e.isConnected==`boolean`&&(n=e.isConnected&&!me,me=e.isConnected,n&&(he=``,ge=``,_e=``,ve=``,ye=!1)),e.requestFailed&&(ge=he),e.response&&It(e.response),t.hidden||kt(),(n||e.decisionRefused)&&pt()}return{el:t,show:jt,hide:Mt,update:Rt}}var zL=`#plan/`;function BL(e){return`${zL}${encodeURIComponent(e)}`}function VL(e){if(!e.startsWith(zL))return null;let t=e.slice(6);if(!t||t.includes(`/`))return null;try{return decodeURIComponent(t)||null}catch{return null}}var HL=`http://www.w3.org/2000/svg`;function UL(e,t){let n=document.createElementNS(HL,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}function WL(e,t){let n=document.createElementNS(HL,`svg`);return n.setAttribute(`width`,String(e)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${e} ${t}`),n.setAttribute(`aria-hidden`,`true`),n}function GL(e){let t=new Map;for(let n of e.files){let e=n.path.split(`/`);for(let r=0;r<e.length;r++){let i=e.slice(0,r).join(`/`),a=t.get(i);a!==void 0&&a.localeCompare(n.path)<=0||t.set(i,n.path)}}return t}function KL(e,t){let n=[],r=new Set(e.files.map(e=>e.path));for(let i of e.links){let a=t.get(i.providerRepo),o=a?.firstChangedPathByDirectory.get(i.packageDir),s=o??i.importers.find(e=>r.has(e))??i.importers[0]??i.consumerManifest,c=o&&a?a.repo:e,l=i.importerCount===1?`file`:`files`,u=i.providerChangedPathCount===1?`file`:`files`,d=i.changedImporterCount===1?`file`:`files`,f=i.isLocalLink?`Linked locally (${i.versionSpec}), so ${i.providerRepo} changes reach it now.`:`Uses ${i.versionSpec} from the registry, so ${i.providerRepo} changes reach it only after a publish.`;i.providerChangedPathCount>0&&(f+=` ${i.providerRepo} changed ${i.providerChangedPathCount} ${u} in ${i.packageDir||`the repository root`}.`),i.changedImporterCount>0&&(f+=` ${i.changedImporterCount} importing ${d} changed here.`),n.push({factId:i.factId,kind:`link`,severity:6,path:s,openPath:`${c.sessionPathPrefix}${s}`,headline:`${e.name} imports ${i.packageName} from ${i.providerRepo} in ${i.importerCount} ${l}`,detail:f})}for(let t of e.collisions)n.push({factId:t.factId,kind:`collision`,severity:5,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`${t.path} is also changed in "${t.otherSessionName}"`,detail:`Another live session is changing this file.`});for(let t of e.coChangeGaps){let r=t.confidence>0?Math.round(t.support/t.confidence):0;n.push({factId:t.factId,kind:`co-change`,severity:4,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`Usually changes with ${t.partner} (${t.support} of ${r} commits)`,detail:`${t.partner} is absent from these changes.`})}for(let t of e.untestedFiles)n.push({factId:t.factId,kind:`untested`,severity:3,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`No test reaches ${t.path}`,detail:`No dependent test was found in the import graph.`});for(let t of e.hotspots)n.push({factId:t.factId,kind:`hotspot`,severity:2,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`${t.path} is a hotspot`,detail:`${t.fixCommitCount} of its last ${t.commitCount} commits were fixes.`});for(let t of e.blastRadius)t.transitiveDependentCount<10||n.push({factId:t.factId,kind:`blast`,severity:1,path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,headline:`Wide blast radius: ${t.transitiveDependentCount} files depend on ${t.path}`,detail:`${t.directDependentCount} direct dependents; ${t.dependentTestCount} dependent tests.`});return n.sort((e,t)=>t.severity-e.severity||e.path.localeCompare(t.path)||e.factId.localeCompare(t.factId))}function qL(e,t){let n=new Map(e.blastRadius.map(e=>[e.path,e])),r=e.files.filter(e=>e.isCommitted).length;return{header:{name:e.name,fileCount:e.files.length,committedCount:r,uncommittedCount:e.files.length-r,base:e.base},subsystems:e.subsystems.map(e=>({title:e.title,fileCount:e.paths.length})),warnings:KL(e,t),files:e.files.map(t=>({path:t.path,openPath:`${e.sessionPathPrefix}${t.path}`,status:t.status,isCommitted:t.isCommitted,dependentCount:n.get(t.path)?.transitiveDependentCount??0,testCount:n.get(t.path)?.dependentTestCount??0})),error:e.error}}function JL(e){let t=new Set(e.repos.flatMap(e=>e.links.map(e=>e.providerRepo))),n=new Map;for(let r of e.repos)t.has(r.name)&&!n.has(r.name)&&n.set(r.name,{repo:r,firstChangedPathByDirectory:GL(r)});let r=e.repos.map(e=>qL(e,n));return{repos:!e.error&&r.every(e=>e.header.fileCount===0&&e.warnings.length===0&&!e.error)?[]:r,narrative:{state:e.narratorState,claims:e.narratorState===`ready`?e.narrative?.claims.map(e=>({text:e.text,factIds:e.factIds}))??[]:[],status:{disabled:null,pending:`Narrative is being prepared.`,ready:null,failed:`Narrative could not be prepared.`}[e.narratorState]},error:e.error??null}}function YL(e,t,n,r){let i=V(`button`,n);return i.type=`button`,i.title=`Open ${e} in the diff`,i.addEventListener(`click`,()=>r(t)),i}function XL(e,t){let n=V(`section`,`review-map-repo`),r=V(`div`,`review-map-repo-head`);r.append(V(`strong`,`review-map-repo-name`,e.header.name)),n.append(r);let i=V(`div`,`review-map-summary`);if(i.append(V(`span`,``,`${e.header.committedCount} committed`)),i.append(V(`span`,``,`${e.header.uncommittedCount} uncommitted`)),i.append(V(`span`,``,`Base: ${jl(e.header.base,{chars:8})||`unknown`}`)),n.append(i),e.error&&n.append(V(`p`,`review-map-error`,e.error)),e.subsystems.length>0){let t=V(`div`,`review-map-subsystems`);for(let n of e.subsystems)t.append(V(`span`,`review-map-chip`,`${n.title} (${n.fileCount})`));n.append(t)}if(e.warnings.length>0){n.append(V(`h3`,`review-map-label`,`Signals`));let r=V(`div`,`review-map-warnings`);for(let n of e.warnings){let e=YL(n.path,n.openPath,`review-map-warning`,t);e.dataset.severity=String(n.severity),e.dataset.kind=n.kind,e.append(V(`span`,`review-map-warning-headline`,n.headline)),e.append(V(`span`,`review-map-detail`,n.detail)),r.append(e)}n.append(r)}if(e.files.length>0){n.append(V(`h3`,`review-map-label`,`Files`));let r=V(`div`,`review-map-files`);for(let n of e.files){let e=YL(n.path,n.openPath,`review-map-file`,t);e.dataset.status=n.status,e.append(V(`span`,`review-map-file-path`,n.path)),e.append(V(`span`,`review-map-file-meta`,`${n.status} · ${n.isCommitted?`committed`:`uncommitted`} · ${n.dependentCount} dependents · ${n.testCount} tests`)),r.append(e)}n.append(r)}return n}function ZL(e,t){let n=V(`div`,`review-map`);if(e.error&&n.append(V(`p`,`review-map-error`,e.error)),e.narrative.status&&n.append(V(`p`,`review-map-narrative-status`,e.narrative.status)),e.narrative.claims.length>0){let t=V(`section`,`review-map-narrative`);t.append(V(`h3`,`review-map-label`,`Narrative`));for(let n of e.narrative.claims){let e=V(`p`,`review-map-claim`,n.text);e.dataset.factIds=n.factIds.join(` `),t.append(e)}n.append(t)}for(let r of e.repos)n.append(XL(r,t));return n}function QL({status:e,mergeReason:t,fetched:n,hasDiffError:r,hasChanges:i,hasCommits:a,canMerge:o,isWorkspace:s,live:c,effectiveBase:l}){return e===`parked`&&t===`base-diverged`?{text:`Parked: base branch diverged`,namesMergeTarget:!1}:e===`parked`?{text:`Parked: merge conflict`,namesMergeTarget:!1}:e===`merging`?{text:`Merging`,namesMergeTarget:!1}:e===`merged`?{text:`Merged`,namesMergeTarget:!1}:r?{text:`Could not read changes`,namesMergeTarget:!1}:n?i?s?{text:`Changes in this worktree`,namesMergeTarget:!1}:o?{text:`Ready to merge into ${tR(l)}`,namesMergeTarget:!0}:c?a?{text:`Not ready to merge`,namesMergeTarget:!1}:{text:`Uncommitted changes`,namesMergeTarget:!1}:{text:`Session ended`,namesMergeTarget:!1}:{text:`No changes yet`,namesMergeTarget:!1}:{text:`Checking for changes`,namesMergeTarget:!1}}function $L(e,t){return e.namesMergeTarget?null:`merges into ${tR(t)}`}function eR({status:e,mergeReason:t,live:n,isMergeRendered:r,hasChanges:i}){return e===`parked`&&n&&t!==`base-diverged`?`resolve`:!i&&e!==`parked`&&e!==`merging`?`none`:r?`merge`:`none`}function tR(e){return e||`base`}function nR(e,t){return`Merge into ${tR(e)}, push it, and rebase this worktree, then keep working (${t})`}function rR(e){return e===`base-diverged`?`Resync the base branch by hand, then Merge again.`:`Needs manual merge`}function iR(e,t,n){let r=e!==`parked`||e===`parked`&&t===`base-diverged`;return{isRendered:r,isEnabled:r&&e!==`merging`&&n}}function aR({status:e,hasCommits:t,live:n,state:r}){return e===`merging`||!t?null:!n&&(e===`parked`||e===`merged`)?`Session ended.`:!n||e===`parked`?null:r===`INITIALIZING`||r===`STARTING`?`Starting up. Mergeable once the session is live.`:null}function oR({fetched:e,changedFileCount:t,hasCommits:n}){return!e||t>0||n}function sR(e){return e||`its upstream`}function cR(e){if(!e)return null;let t=e.branch||`Base branch`,{state:n,ahead:r,behind:i}=e,a=sR(e.upstream);return n===`no-upstream`?`${t}: no upstream`:n===`unknown`&&e.error&&e.action===void 0?`${t}: sync check failed: ${e.error}`:n===`unknown`?`${t}: sync state unknown vs ${a}`:n===`in-sync`?`${t}: in sync with ${a}`:n===`ahead`?`${t}: ${r} ahead of ${a}`:n===`behind`?`${t}: ${i} behind ${a}`:n===`diverged`?`${t}: ${r} ahead, ${i} behind ${a}`:null}function lR(e){return!e||e.fetched===!1?`recheck`:e.state===`ahead`||e.state===`behind`?`resync`:`recheck`}function uR(e,t,n){let r=n?` (${t})`:``;if(!e||lR(e)===`recheck`)return`Click to fetch and check again${r}`;let i=e.branch||`Base branch`,a=sR(e.upstream);return e.state===`behind`?`Click to fast-forward ${i} to ${a}${r}`:`Click to push ${i} to ${a}${r}`}function dR(e){return e?.state!==`in-sync`||e.fetched===!1}function fR({fetched:e,changedFileCount:t,view:n}){return!e||t===0?!1:n!==`diff`}function pR(e){if(e.error)return`Resync failed: ${e.error}`;let t=e.branch||`The base branch`,n=sR(e.upstream);return e.action===`fast-forwarded`?`Fast-forwarded ${t} to ${n}.`:e.action===`pushed`?`Pushed ${t} to ${n}.`:e.state===`diverged`?`${t} has diverged from ${n}. Resolve manually.`:e.state===`in-sync`?null:e.state===`no-upstream`?`${t} has no upstream to resync against.`:`Could not determine sync status.`}var mR=new Set([`pending-review`,`parked`]),hR=600,gR=Gb(`merge`,Jb),_R=Gb(`resolve-or-resync`,Jb),vR=260,yR=700,bR=new Map,xR=new Map,SR=new Map,CR=new Map,wR=new Map,TR=new Map,ER=new Set,DR=new Set,OR=new Set,kR=rk(),AR=null,jR=null,MR=null,NR=null,PR=new Map,FR=null,IR=null,LR=null,RR=null,zR=null,BR=!1,VR=!1,HR=null,UR=null,WR=null,GR=null,KR=new Map,qR=null,JR=null,YR=null,XR=null,ZR=null,QR=new Map,$R=null,ez=!1,tz=null;function nz(e,t){let n=V(`button`,`review-icon-button`);n.type=`button`,n.title=e,n.setAttribute(`aria-label`,e);let r=WL(16,16);return r.append(UL(`path`,{d:t,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),n.append(r),n}function rz(){BR=!1,MR?.querySelector(`.review-more-menu`)?.remove(),MR?.querySelector(`.review-more-button`)?.setAttribute(`aria-expanded`,`false`)}function iz({panel:e}){if(jR=e,!jR)return;let t=jR,n=V(`div`,`review-sidebar-head`),r=V(`span`,`review-sidebar-title`,`Review`),i=e=>{t.toggleAttribute(`data-collapsed`,e),nk(!e)},a=V(`div`,`review-header-tabs`);a.setAttribute(`role`,`group`),a.setAttribute(`aria-label`,`Review view`);for(let[e,t]of[[`map`,`Map`],[`diff`,`Diff`],[`notes`,`Notes`]]){let n=V(`button`,`review-header-tab`,t);n.type=`button`,n.addEventListener(`click`,()=>rB(e)),PR.set(e,n),a.append(n)}FR=V(`span`,`review-notes-count`),a.append(FR);let o=nz(`Close review`,`M6 3L11 8L6 13`);o.classList.add(`review-sidebar-close`),o.addEventListener(`click`,()=>i(!0)),n.append(r,a,o);let s=V(`div`,`review-sidebar-rail`),c=nz(`Open review`,`M10 3L5 8L10 13`);c.classList.add(`review-sidebar-open`),c.addEventListener(`click`,()=>i(!1)),LR=V(`div`,`review-rail-status`),RR=V(`span`,`review-rail-added`),zR=V(`span`,`review-rail-removed`),LR.append(RR,zR),IR=V(`span`,`review-rail-label`,`Review`),s.append(c,IR,LR),MR=V(`div`,`review-controls`),NR=V(`div`,`review-sidebar-body`),qR=V(`div`,`review-notes-footer`),JR=V(`button`,`review-btn review-btn-primary`,`Send notes`),JR.type=`button`,JR.title=`Paste the drafted review notes into this session as one message`,JR.addEventListener(`click`,Uz),YR=V(`div`,`review-notes-status`),qR.append(YR,JR),ZR=V(`div`,`review-notes-list`),XR=V(`div`,`review-notes-outcome`),XR.setAttribute(`role`,`status`);let l=V(`div`,`review-resize-handle`);l.setAttribute(`aria-hidden`,`true`),t.append(s,n,MR,NR,XR,qR,l),t.toggleAttribute(`data-collapsed`,!tk()),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&BR&&(e.preventDefault(),rz(),MR?.querySelector(`.review-more-button`)?.focus())}),document.addEventListener(`pointerdown`,e=>{BR&&e.target instanceof Element&&(MR?.contains(e.target)&&e.target.closest(`.review-more-button, .review-more-menu`)||rz())});let u=0,d=0,f=e=>{let n=Math.max(vR,Math.min(yR,e));return Number.isFinite(n)?(t.style.setProperty(`--sidebar-width`,`${n}px`),n):null},p=e=>{l.hasPointerCapture(e.pointerId)&&f(d+(u-e.clientX))},m=!1,h=e=>{if(!m)return;m=!1,l.hasPointerCapture(e.pointerId)&&l.releasePointerCapture(e.pointerId),document.documentElement.style.cursor=``,document.documentElement.style.userSelect=``;let n=t.style.getPropertyValue(`--sidebar-width`);n&&Ak(parseInt(n,10))};l.addEventListener(`pointerdown`,e=>{e.button===0&&(e.preventDefault(),u=e.clientX,d=t.getBoundingClientRect().width,l.setPointerCapture(e.pointerId),m=!0,document.documentElement.style.cursor=`col-resize`,document.documentElement.style.userSelect=`none`)}),l.addEventListener(`pointermove`,p),l.addEventListener(`pointerup`,h),l.addEventListener(`pointercancel`,h),l.addEventListener(`lostpointercapture`,h);let g=kk();g!==null&&f(g),SI(e=>{BR=!1,DR.clear(),OR.clear(),AR=null,Iz(),e&&Dz(e),e&&!kz(e)&&Az(e),sB()}),sB()}function az(e){if(jR){if(e){Of(jR,e);return}kf(jR)}}function oz(e,t){let n=bR.get(e);bR.set(e,t),ere(n,t)&&(SR.delete(e),CR.delete(e),wR.delete(e),e===bI()&&Oz(e)),e===bI()&&sB()}function sz(e,t,n=null){let r=bR.get(e)||`none`,i=t||`none`;if(xR.set(e,n),oz(e,i),mR.has(i)&&!mR.has(r)){let t=bI(),n=t?mR.has(bR.get(t)||`none`):!1;(!t||!U.has(t)||!n)&&xI(e)}}function cz(e,t,n=null){xR.set(e,n),oz(e,t||`none`)}function lz(e,t){let n=SR.get(e)??null;SR.set(e,t),CR.delete(e),e===bI()&&(pz(n,t),AR&&iB(AR,t),sB(),aB())}function uz(e,t){let n=qf(e);n&&(CR.set(n,t),n===bI()&&sB())}function dz(e,t){let n=qf(e);if(!n)return;let r=bl.safeParse(t);r.success&&r.data.sessionId===n&&(wR.set(n,r.data),n===bI()&&sB())}function fz(e){return{committed:e?.committed?.diff||``,uncommitted:e?.uncommitted?.diff||``}}function pz(e,t){if(QR.size===0||!e)return;let n=Qne(fz(e),fz(t),QR.keys());if(n.length!==0){for(let e of n)QR.delete(e);$R!==null&&n.includes($R)&&($R=null),tz=`${n.length} note${n.length===1?``:`s`} dropped because the diff changed.`}}function mz(e,t){let n=qf(e),r=t;TR.set(n,r),r&&r.action!==void 0&&hz(n,r),n===bI()&&sB()}function hz(e,t){ER.delete(e),clearTimeout(GR??void 0),GR=null;let n=pR(t);WR=n?{forId:e,text:n,isError:!!t.error}:null,WR&&!WR.isError&&(GR=setTimeout(()=>{WR&&WR.forId===e&&(WR=null),sB()},5e3))}function gz(e){let t=qf(e);t&&t===bI()&&Dz(t)}function _z(e){let t=qf(e);if(t!==bI())return;let n=!SR.has(t)||CR.has(t),r=!wR.has(t)||vz(wR.get(t));n&&Dz(t),r&&!n&&Oz(t),sB()}function vz(e){return e?!!e.error||e.repos.some(e=>e.error!==null):!1}function yz(e){let t=qf(e);if(bR.delete(t),xR.delete(t),SR.delete(t),CR.delete(t),wR.delete(t),TR.delete(t),ER.delete(t),WR&&WR.forId===t&&(clearTimeout(GR??void 0),WR=null),t===bI()){xI(null);return}sB()}function bz(){let e=bI();if(!e||kz(e))return!1;let t=U.get(e);if(!t)return!1;let n=bR.get(e)||`none`,r=!!SR.get(e)?.hasCommits,i=iR(n,xR.get(e)||null,wz(t.currentState,r));return eR({status:n,mergeReason:xR.get(e)||null,live:Ez(t.currentState),isMergeRendered:i.isRendered,hasChanges:Cz(e)})!==`merge`||!i.isEnabled?!1:(Tz(e,t.currentState),!0)}function xz(){let e=bI();if(!e||kz(e))return!1;let t=U.get(e);if(!t)return!1;let n=bR.get(e)||`none`,r=xR.get(e)||null;return eR({status:n,mergeReason:r,live:Ez(t.currentState),isMergeRendered:iR(n,r,!1).isRendered,hasChanges:Cz(e)})===`resolve`&&(B({type:`resolve-session-merge`,id:e}),!0)}function Sz(){let e=bI();return!e||!U.has(e)||kz(e)||Mz(e)?!1:(Nz(e),!0)}function Cz(e){let t=SR.get(e)??null,n=[...EA(t?.committed?.diff||``),...EA(t?.uncommitted?.diff||``)];return oR({fetched:SR.has(e),changedFileCount:DA(n).files,hasCommits:!!t?.hasCommits})}function wz(e,t){return(Nc.includes(e)||e===F.RUNNING)&&t}function Tz(e,t){if(t!==F.RUNNING){B({type:`merge-continue-session`,id:e});return}tp({title:`Merge while working`,message:`This session still looks like it is working. Merging rebases its worktree under it. Merge anyway?`,confirmLabel:`Merge anyway`,onConfirm:()=>B({type:`merge-continue-session`,id:e,force:!0})})}function Ez(e){return e!==F.DORMANT&&e!==F.DONE&&e!==F.FAILED}function Dz(e){B({type:`request-session-diff`,id:e}),Oz(e)}function Oz(e){wR.has(e)||wR.set(e,null),B({type:`request-change-map`,id:e})}function kz(e){return U.get(e)?.card.dataset.workspace!==void 0}function Az(e){TR.set(e,null),B({type:`request-branch-sync`,id:e}),e===bI()&&sB()}function jz(e){ER.add(e),clearTimeout(GR??void 0),WR&&WR.forId===e&&(WR=null),B({type:`resync-branch`,id:e}),e===bI()&&sB()}function Mz(e){return ER.has(e)||TR.get(e)===null}function Nz(e){if(!Mz(e)){if(lR(TR.get(e))===`resync`){jz(e);return}Az(e)}}function Pz(e,t){return t?{text:`Resyncing...`,loading:!0,error:!1}:WR&&WR.forId===e?{text:WR.text,loading:!1,error:WR.isError}:null}function Fz(e,t){return e?.card?.dataset.session||t}function Iz(){QR.clear(),$R=null,tz=null,ez=!1}function Lz(e){return QR.get(e)??null}function Rz(){return`${QR.size} note${QR.size===1?``:`s`} drafted`}function zz(e,t){let n=V(`div`,`review-notes-entry`),r=t.side===`old`?` (removed line)`:``;n.append(V(`span`,`review-notes-entry-where`,`${t.section} ${t.path}:${t.line}${r}`)),n.append(V(`span`,`review-notes-entry-note`,t.note));let i=V(`button`,`review-note-remove`,`Remove`);return i.type=`button`,i.title=`Drop this note`,i.addEventListener(`click`,()=>nB(e)),n.append(i),n}function Bz(){if(ZR){ZR.replaceChildren(),ZR.hidden=QR.size===0;for(let[e,t]of QR)ZR.append(zz(e,t))}}function Vz(){if(!qR||!JR||!YR)return;let e=bI(),t=!!e&&U.has(e);qR.hidden=!t||kR===`map`||QR.size===0,JR.disabled=ez||QR.size===0,YR.textContent=Rz(),FR&&(FR.hidden=QR.size===0,FR.textContent=String(QR.size),FR.setAttribute(`aria-label`,Rz())),XR&&(XR.textContent=ez?`Sending notes...`:tz,XR.hidden=!t||kR===`map`||!XR.textContent),Bz(),kR===`notes`&&t&&Hz()}function Hz(){if(NR&&ZR){if(NR.replaceChildren(),QR.size===0){cB(`No notes yet`,`Open the Diff tab and press note on a line to draft one.`);return}NR.append(ZR)}}function Uz(){let e=bI();e&&!ez&&QR.size!==0&&(ez=!0,tz=null,Vz(),of(`send-diff-annotations`,{id:e,annotations:[...QR.values()]}).then(Kz,Wz))}function Wz(e){ez=!1;let t=e instanceof Error?e.message:``;tz=t?`Could not send the notes: ${t}.`:`Could not send the notes.`,Vz()}function Gz(e){return e.type===`send-diff-annotations-result`&&typeof e.error==`string`&&e.error?e.error:e.type===`error`&&typeof e.message==`string`&&e.message?e.message:`Could not send the notes.`}function Kz(e){if(ez=!1,e.type!==`send-diff-annotations-result`||e.ok!==!0){tz=Gz(e),Vz();return}if(e.pending===!0){tz=`Notes queued until the session wakes. They stay drafted here, and pressing Send notes again re-sends them.`,Vz();return}tz=`Notes sent.`,QR.clear(),$R=null,sB()}function qz(e,t){let n=V(`div`,`review-note`);n.dataset.noteFor=e,n.append(V(`span`,`review-note-text`,t));let r=V(`button`,`review-note-remove`,`Remove`);return r.type=`button`,r.title=`Drop this note`,r.addEventListener(`click`,()=>nB(e)),n.append(r),n}function Jz(e,t){let n=V(`div`,`review-note-editor`);n.dataset.editorFor=e;let r=V(`input`,`review-note-input`);r.type=`text`,r.value=t,r.maxLength=jd,r.placeholder=`Note for this line`,r.addEventListener(`keydown`,t=>{if(t.key===`Enter`){t.preventDefault(),tB(e,r.value);return}t.key===`Escape`&&(t.preventDefault(),eB())});let i=V(`button`,`review-note-save`,`Save`);i.type=`button`,i.addEventListener(`click`,()=>tB(e,r.value));let a=V(`button`,`review-note-cancel`,`Cancel`);return a.type=`button`,a.addEventListener(`click`,eB),n.append(r,i,a),n}function Yz(e){let t=[],n=Lz(e);return $R===e&&t.push(Jz(e,n?n.note:``)),n&&t.push(qz(e,n.note)),t}function Xz(e,t){let n=Yz(t);return e.after(...n),n}function Zz(e){let t=e.nextElementSibling;for(;t instanceof HTMLElement&&(t.dataset.noteFor!==void 0||t.dataset.editorFor!==void 0);){let e=t.nextElementSibling;t.remove(),t=e}}function Qz(e){let t=KR.get(e);if(!t)return;let n=null;for(let r of t.rows){Zz(r);let t=Xz(r,e);for(let e of t){let t=e.querySelector(`input`);!n&&t instanceof HTMLInputElement&&(n=t)}}n&&(n.focus(),n.select())}function $z(e){let t=$R;$R=e,t&&t!==e&&Qz(t),Qz(e)}function eB(){let e=$R;e&&($R=null,Qz(e))}function tB(e,t){let n=KR.get(e);if(!n)return;let r=t.trim();if(r){if(QR.size>=50&&!QR.has(e)){tz=`Only 50 notes can be sent at once.`,Vz();return}QR.set(e,{...n.target,section:n.section,note:r}),tz=null,$R=null,Qz(e),Vz()}}function nB(e){QR.delete(e),tz=null,Qz(e),Vz()}function rB(e){kR=e,e!==`diff`&&(AR=null),ik(e),sB()}function iB(e,t){if(!t)return;let n=EA(t.committed?.diff),r=EA(t.uncommitted?.diff);for(let t of n)(t.path===e||t.oldPath===e)&&DR.add(`committed:${t.path}`);for(let t of r)(t.path===e||t.oldPath===e)&&DR.add(`uncommitted:${t.path}`)}function aB(){if(!NR||!AR)return;let e=NR.querySelectorAll(`.review-file`);for(let t of e)if(t.dataset.path===AR||t.dataset.oldPath===AR){t.scrollIntoView({block:`nearest`}),AR=null;return}}function oB(e){AR=e,iB(e,SR.get(bI()??``)),rB(`diff`),aB()}function sB(){if(!MR||!NR)return;MR.replaceChildren(),NR.replaceChildren();for(let[e,t]of PR)t.setAttribute(`aria-pressed`,String(kR===e));KR.clear(),Vz(),IR&&(IR.hidden=!0),LR&&(LR.hidden=!0);let e=bI(),t=e?U.get(e):null;if(!e||!t){cB(`No session selected`,`Click a session name to review its changes here.`);return}let n=kz(e),r=bR.get(e)||`none`,i=xR.get(e)||null,a=t.currentState,o=mR.has(r),s=SR.has(e),c=s?SR.get(e):null,l=CR.get(e)??null,u=c?EA(c.committed?.diff||``):[],d=c?EA(c.uncommitted?.diff||``):[],f=!!c?.hasCommits,p=Ez(a),m=iR(r,i,wz(a,f)),h=TR.get(e),g=ER.has(e),_=tR(t.effectiveBase),v=DA([...u,...d]),y=eR({status:r,mergeReason:i,live:p,hasChanges:oR({fetched:s,changedFileCount:v.files,hasCommits:f}),isMergeRendered:m.isRendered}),ee=QL({status:r,mergeReason:i,fetched:s,hasDiffError:l!==null,hasChanges:v.files>0||f,hasCommits:f,canMerge:!n&&m.isEnabled,isWorkspace:n,live:p,effectiveBase:_}),b=V(`div`,`review-status-headline`);if(b.append(V(`span`,`review-status-text`,ee.text)),!n&&!dR(h)){let t=cR(h);if(t){b.title=t;let n=nz(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);n.classList.add(`review-branch-sync-refresh`),n.title=uR(h,_R,y!==`resolve`),n.disabled=Mz(e),n.setAttribute(`aria-description`,t),n.addEventListener(`click`,()=>Nz(e)),b.append(V(`span`,`sr-only`,t),n)}}MR.append(b);let te=V(`div`,`review-status-meta`);if(fR({fetched:s,changedFileCount:v.files,view:kR})&&te.append(V(`span`,`review-status-files`,`${v.files} file${v.files===1?``:`s`}`),V(`span`,`review-status-added`,`+${v.added}`),V(`span`,`review-status-removed`,`-${v.removed}`),V(`span`,`review-status-spacer`)),!n&&dR(h)){let t=lB(e,y!==`resolve`);t&&te.append(t)}te.childElementCount>0&&MR.append(te),r===`parked`&&MR.append(V(`div`,`review-status-explanation`,rR(i))),IR&&(IR.hidden=!1),LR&&(LR.hidden=!1,LR.setAttribute(`aria-label`,`${ee.text}, +${v.added}, -${v.removed}`),LR.title=ee.text),RR&&(RR.textContent=`+${v.added}`),zR&&(zR.textContent=`-${v.removed}`);let ne=n?null:pB(e,{status:r,reviewable:o,mergeAction:m,live:p,state:a,effectiveBase:_,primaryAction:y});ne&&MR.append(ne);let re=n?null:Pz(e,g),ie=!n&&y===`merge`&&!m.isEnabled?aR({status:r,hasCommits:f,live:p,state:a}):null;if(ie){let e=V(`div`,`review-control-reason`,ie);e.id=`review-merge-reason`,MR.append(e),MR.querySelector(`#review-merge-btn`)?.setAttribute(`aria-describedby`,e.id)}if(re?.text){let e=V(`div`,re.loading?`review-control-reason review-loading`:`review-control-reason`,re.text);e.id=`review-resync-reason`,re.error&&e.classList.add(`review-control-reason-error`),e.setAttribute(`role`,`status`),te.append(e),te.isConnected||MR.insertBefore(te,b.nextSibling),MR.querySelector(`.review-branch-sync-text, .review-branch-sync-refresh`)?.setAttribute(`aria-describedby`,e.id)}if(VR&&HR===e&&MR.append(V(`div`,`review-resolve-sent`,`Resolve prompt sent`)),kR!==`notes`){if(kR===`map`){let t=wR.get(e);if(!t){NR.append(V(`div`,`review-nochanges review-loading`,`Loading map...`));return}NR.append(ZL(JL(t),oB));return}if(l){NR.append(V(`p`,`review-diff-error`,l));return}u.length>0&&NR.append(uB(`committed`,`Committed`,$L(ee,_),u)),d.length>0&&NR.append(uB(`uncommitted`,`Uncommitted`,null,d))}}function cB(e,t){if(!NR)return;let n=V(`div`,`review-empty`);n.append(V(`div`,`review-empty-title`,e),V(`div`,`review-empty-desc`,t)),NR.append(n)}function lB(e,t){let n=TR.get(e);if(n===void 0)return null;if(n===null)return V(`span`,`review-branch-sync-text review-loading`,`Checking branch sync...`);let r=cR(n)||`Base branch: sync state unknown`,i=nz(`Refresh branch sync`,`M13 6A5 5 0 1 0 13 10M13 2v4H9`);return i.className=`review-branch-sync-text`,i.removeAttribute(`aria-label`),i.append(V(`span`,`review-branch-sync-label`,r)),i.disabled=ER.has(e),n.state&&(i.dataset.syncState=n.state),n.fetched===!1&&(i.dataset.stale=`true`),i.title=uR(n,_R,t),i.addEventListener(`click`,()=>Nz(e)),i}function uB(e,t,n,r){let i=V(`div`,`review-section`);i.dataset.kind=e;let a=DA(r),o=V(`div`,`review-section-head`),s=V(`div`,`review-section-id`);s.append(V(`span`,`review-section-label`,t)),n&&s.append(V(`span`,`review-section-meaning`,n)),o.append(s);let c=V(`div`,`review-section-stat`);c.append(V(`span`,`review-stat-files`,`${a.files} file${a.files===1?``:`s`}`)),c.append(V(`span`,`review-add`,`+${a.added}`),V(`span`,`review-del`,`-${a.removed}`)),o.append(c),i.append(o);let l=V(`div`,`review-diff`);for(let t of r)l.append(dB(t,e));return i.append(l),i}function dB(e,t){let n=`${t}:${e.path}`,r=DR.has(n),i=V(`div`,`review-file`);i.dataset.path=e.path,e.oldPath&&(i.dataset.oldPath=e.oldPath),i.dataset.status=e.status,i.dataset.open=r?`true`:`false`;let a=V(`button`,`review-file-head`);a.type=`button`,a.setAttribute(`aria-expanded`,r?`true`:`false`);let o=V(`span`,`review-file-twisty`,r?`▾`:`▸`);o.setAttribute(`aria-hidden`,`true`),a.append(o,V(`span`,`review-file-path`,e.path));let s=V(`span`,`review-file-counts`);if(e.binary&&s.append(V(`span`,`review-bin`,`bin`)),e.binary||s.append(V(`span`,`review-add`,`+${e.added}`),V(`span`,`review-del`,`-${e.removed}`)),a.append(s),a.addEventListener(`click`,()=>{let e=DR.has(n);e&&DR.delete(n),e||DR.add(n),sB()}),i.append(a),!r)return i;let c=V(`div`,`review-file-body`);if(e.binary)return c.append(V(`div`,`review-file-binary`,`Binary file not shown`)),i.append(c),i;let l=0,u=!1;for(let r of e.hunks){if(l>=hR&&!OR.has(n)){u=!0;break}c.append(V(`div`,`review-hunk-head`,r.header));for(let i of r.lines){if(l>=hR&&!OR.has(n)){u=!0;break}let r=V(`div`,`review-line review-line-${i.type}`),a=i.type===`add`?`+`:i.type===`del`?`-`:i.type===`meta`?`\\`:` `;r.append(V(`span`,`review-line-gutter`,a)),r.append(V(`span`,`review-line-text`,i.text));let o=$ne(e,i);if(c.append(r),l++,!o)continue;let s=Zne(t,o.path,o.line,o.side),d=KR.get(s)??{target:o,section:t,rows:[]};d.rows.push(r),KR.set(s,d),r.dataset.noteKey=s;let f=V(`button`,`review-annotate`,`note`);f.type=`button`,f.title=`Note on ${o.path}:${o.line}`,f.addEventListener(`click`,()=>$z(s)),r.append(f),Xz(r,s)}if(u)break}if(u){let e=V(`button`,`review-expand`,`Show the rest of this file`);e.type=`button`,e.addEventListener(`click`,()=>{OR.add(n),sB()}),c.append(e)}return i.append(c),i}function fB({id:e,label:t,shortcut:n,title:r,disabled:i=!1,danger:a=!1,onClick:o}){let s=V(`button`,a?`review-btn review-btn-danger`:`review-btn review-btn-primary`);return s.type=`button`,e&&(s.id=e),r&&(s.title=r),s.disabled=i,s.innerHTML=n?`${t} <kbd class="review-shortcut" aria-hidden="true">${n}</kbd>`:t,s.addEventListener(`click`,o),s}function pB(e,{status:t,reviewable:n,mergeAction:r,live:i,state:a,effectiveBase:o,primaryAction:s}){let c=V(`div`,`review-actions`),l=s===`resolve`;s===`merge`&&c.append(fB({id:`review-merge-btn`,label:`Merge`,shortcut:gR,title:nR(o,gR),disabled:!r.isEnabled,onClick:()=>Tz(e,a)})),l&&c.append(fB({label:`Resolve`,shortcut:_R,title:`Paste a resolve prompt into this session so the agent can finish the merge (${_R})`,onClick:()=>{B({type:`resolve-session-merge`,id:e}),VR=!0,HR=e,clearTimeout(UR??void 0),UR=setTimeout(()=>{VR=!1,HR=null,sB()},3e3),sB()}}));let u=V(`div`,`review-action-controls`);if(u.append(c),!n||i)return c.childElementCount>0?u:null;let d=nz(`More review actions`,`M3 8h0.01M8 8h0.01M13 8h0.01`);if(d.classList.add(`review-more-button`),d.setAttribute(`aria-haspopup`,`menu`),d.setAttribute(`aria-expanded`,String(BR)),d.setAttribute(`aria-controls`,`review-more-menu`),d.addEventListener(`click`,()=>{BR=!BR,sB(),(MR?.querySelector(BR?`.review-more-menu button:not(:disabled)`:`.review-more-button`)??MR?.querySelector(`.review-more-button`))?.focus()}),c.append(d),!BR)return u;let f=V(`div`,`review-more-menu`);if(f.id=`review-more-menu`,f.setAttribute(`role`,`menu`),f.setAttribute(`aria-label`,`More review actions`),n&&!i){let n=fB({label:`Discard worktree`,danger:!0,disabled:t===`merging`,onClick:()=>{BR=!1,sB(),tp({title:`Discard worktree`,message:`Throw away the worktree changes for "${Fz(U.get(e),e)}"? This cannot be undone.`,confirmLabel:`Discard`,onConfirm:()=>B({type:`discard-session-worktree`,id:e})})}});n.setAttribute(`role`,`menuitem`),f.append(n)}return u.append(f),u}var mB=1e4,hB=null,gB=null,_B=null,vB=null,yB=[],bB=!1,xB=pk(),SB=null,CB=null,wB=[],TB=null,EB=null,DB=null,OB=null,kB=!1;function AB(){return!!hB&&!Ef(hB)}function jB(){return wB.find(e=>e.id===TB)??null}function MB(){OB&&=(clearTimeout(OB.timeoutHandle),null)}function NB(){OB=null,rV()}function PB(e){MB(),kB=!1,TB=e,DB=e?{sessionId:e,grouping:ZA(),firstOffset:0,nextOffset:0,hasDroppedEarliestRows:!1,filePath:``,hasLoadedOnce:!1}:null,bB=!0}function FB(e){let t=nie(wB,EB,TB,e);return EB&&t===EB&&(EB=null),t!==TB&&(PB(t),!0)}function IB(e){if(!SB)return;let t=e.endingAt===void 0?{type:`session-trace`,id:e.id,after:e.after}:{type:`session-trace`,id:e.id,endingAt:e.endingAt};SB(t)&&(OB={request:e,timeoutHandle:setTimeout(NB,mB)})}function LB(e=!1){if(!SB)return;let t=rie({selectedSessionId:TB,isPanelVisible:e||AB(),hasPendingRequest:!!OB,hasLoadedOnce:DB?.hasLoadedOnce??!1,nextOffset:DB?.nextOffset??0});t&&IB(t)}function RB(){return{selectedSessionId:TB,hasPendingRequest:!!OB,hasLoadedOnce:DB?.hasLoadedOnce??!1,hasDroppedEarliestRows:DB?.hasDroppedEarliestRows??!1,firstOffset:DB?.firstOffset??0,residentRowCount:DB?rj(DB.grouping):0}}function zB(){if(!SB)return;let e=iie(RB());e&&IB(e)}function BB(e){wB.some(t=>t.id===e)&&e!==TB&&(EB=null,PB(e),LB(),rV())}function VB(){let e=V(`label`,`trace-session-field`),t=V(`span`,`trace-session-label`,`Session`),n=V(`select`,`trace-session-select`);n.disabled=wB.length===0;for(let e of wB){let t=V(`option`,null,e.label);t.value=e.id,t.selected=e.id===TB,n.append(t)}return n.addEventListener(`change`,()=>BB(n.value)),e.append(t,n),e}function HB(e){e.toggleAttribute(`data-hidden`,oj(xB,e.dataset.kind??``))}function UB(){if(_B)for(let e of _B.querySelectorAll(`.trace-row`))HB(e)}function WB(e){if(_B)for(let t of _B.querySelectorAll(`details`))t.open=e}function GB(){let e=V(`div`,`trace-filters`);for(let t of Wre){let n=V(`button`,`trace-filter`,t.label);n.type=`button`;let r=()=>{n.setAttribute(`aria-pressed`,String(!oj(xB,t.kind)))};r(),n.addEventListener(`click`,()=>{xB=cie(xB,t.kind),mk(xB),r(),UB()}),e.append(n)}for(let[t,n]of[[`Expand all`,!0],[`Collapse all`,!1]]){let r=V(`button`,`trace-expand-control`,t);r.type=`button`,r.addEventListener(`click`,()=>{WB(n)}),e.append(r)}return e}function KB(){let e=Cf(`trace`,`Session trace`,`Bodies load from the local trace file only when requested.`),t=V(`div`,`trace-controls`);t.append(VB());let n=DB?.filePath??``,r=V(`code`,`trace-path`,n);r.title=n,t.append(r);let i=DB?sie(DB.firstOffset,DB.hasDroppedEarliestRows,DB.grouping.turns[0]):null;return i!==null&&t.append(V(`span`,`trace-session-start`,`Started ${new Date(i).toLocaleString()}`)),e.append(t,GB()),e}function qB(e){let t=V(`div`,`trace-copy-wrap`),n=V(`button`,`trace-copy`,`Copy`);n.type=`button`;let r=V(`span`,`trace-copy-status`);return r.setAttribute(`role`,`status`),n.addEventListener(`click`,()=>{let t=Df(e);if(!t){r.textContent=`Copy failed`;return}t.then(()=>{r.textContent=`Copied`}).catch(()=>{r.textContent=`Copy failed`}),setTimeout(()=>{r.textContent=``},1600)}),t.append(n,r),t}function JB(){let e=V(`div`,`trace-earlier-wrap`),t=V(`button`,`trace-load-earlier`,`Load earlier`);return t.type=`button`,t.addEventListener(`click`,()=>{zB()}),e.append(t),e}function YB(e,t,n=``){let r=V(`details`,`trace-row${n?` ${n}`:``}`);r.dataset.kind=e.kind,r.dataset.tone=e.tone,HB(r);let i=V(`summary`,`trace-row-summary`);i.append(V(`span`,`trace-offset`,RA(t,e.record.ts)),V(`span`,`trace-kind`,e.tag),V(`span`,`trace-row-label`,e.text));for(let t of e.badges){let e=V(`span`,`trace-badge`,t);e.dataset.badge=t,i.append(e)}let a=V(`div`,`trace-row-body`);r.append(i,a);let o=!1;return r.addEventListener(`toggle`,()=>{if(!r.open||o)return;o=!0;let t=Hre(e.record);a.append(qB(t),V(`pre`,`trace-row-pre`,t))}),r}function XB(e){return V(`span`,`trace-turn-metrics`,QA(e))}function ZB(e,t){e&&t&&(t.textContent=QA(e))}function QB(e,t){let n=e.children,r=Math.min(t.rows.length,n.length);for(let e=0;e<r;e+=1){let r=n[e]?.querySelector(`.trace-offset`);r&&(r.textContent=RA(t.startedAt,t.rows[e].record.ts))}}function $B(e,t,n){let r=YB(t,e.startedAt,`trace-turn-head`);return _f(r,`.trace-row-summary`).append(n),r}function eV(e){let t=V(`section`,`trace-turn`),n=XB(e);if(e.head&&t.append($B(e,e.head,n)),!e.head){let e=V(`h2`,`trace-leading-title`);e.append(V(`span`,`trace-leading-label`,`Before first prompt`),n),t.append(e)}let r=V(`div`,`trace-rows`);for(let t of e.rows)r.append(YB(t,e.startedAt));return e.hasTrimmedRows&&t.append(V(`p`,`trace-trimmed`,`Earlier rows trimmed`)),t.append(r),{section:t,rowsElement:r,metricsElement:n}}function tV(e){return e?OB?.request.id===e.id&&!DB?.hasLoadedOnce?`Loading trace.`:sj(e):sj(null)}function nV(){if(!hB)return;let e=V(`div`,`trace-content`);gB=KB(),e.append(gB),_B=null,vB=null,yB=[];let t=jB(),n=DB?.grouping.turns??[];if(!t||n.length===0){e.append(V(`p`,`trace-empty`,tV(t))),hB.replaceChildren(e),bB=!1;return}aj(RB())&&(vB=JB(),e.append(vB));let r=V(`div`,`trace-turns`);for(let e of n){let t=eV(e);yB.push(t),r.append(t.section)}_B=r,UB(),e.append(r),hB.replaceChildren(e),bB=!1}function rV(){if(hB){if(!AB()){bB=!0;return}nV()}}function iV(){if(!gB||!AB())return;let e=KB();gB.replaceWith(e),gB=e}function aV(e){if(!_B)return;let t=DB?.grouping.turns[e.turnIndex];if(!t)return;if(e.isNewTurn){let e=eV(t);yB.push(e),_B.append(e.section);return}let n=yB[e.turnIndex];if(n){for(let r of e.rows)n.rowsElement.append(YB(r,t.startedAt));ZB(t,n.metricsElement)}}function oV(e){let t=e.parentElement;t&&!t.querySelector(`.trace-trimmed`)&&t.insertBefore(V(`p`,`trace-trimmed`,`Earlier rows trimmed`),e)}function sV(){if(!aj(RB())){vB?.remove(),vB=null;return}!vB&&_B?.parentElement&&(vB=JB(),_B.parentElement.insertBefore(vB,_B))}function cV(){if(!DB)return;let e=eie(DB.grouping);if(!(e.droppedTurnCount>0||e.droppedRowCount>0)){sV();return}let t=!DB.hasDroppedEarliestRows;if(DB.hasDroppedEarliestRows=!0,yB=yB.slice(e.droppedTurnCount),_B)for(let t=0;t<e.droppedTurnCount;t+=1)_B.firstElementChild?.remove();let n=yB[0];if(n&&e.droppedRowCount>0){for(let t=0;t<e.droppedRowCount;t+=1)n.rowsElement.firstElementChild?.remove();oV(n.rowsElement),ZB(DB.grouping.turns[0],n.metricsElement)}t&&iV(),sV()}function lV(e){if(!DB)return;let t=tj(DB.grouping,e);if(AB()&&!bB&&_B){for(let e of t)aV(e);cV();return}if(_B=null,cV(),!AB()){bB=!0;return}nV()}function uV(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.id!=`string`||!Array.isArray(t.records)||typeof t.next!=`number`||typeof t.start!=`number`?null:{id:t.id,records:t.records,start:t.start,next:t.next,reset:t.reset===!0,path:typeof t.path==`string`?t.path:``}}function dV(){kB&&!OB&&(kB=!1,LB())}function fV(e){if(!_B)return;let t=yB[0]??null,n=t?.rowsElement.parentElement??null,r=DB?.grouping.turns[e.newTurns.length]??null;if((e.mergedHead||e.mergedRows.length>0)&&t&&n&&r){let i=t.rowsElement;if(e.mergedHead){n.querySelector(`.trace-leading-title`)?.remove();let a=XB(r),o=$B(r,e.mergedHead,a);n.insertBefore(o,i),t.metricsElement=a}e.mergedHead||ZB(r,t.metricsElement);let a=document.createDocumentFragment();for(let t of e.mergedRows)a.append(YB(t,r.startedAt));i.prepend(a),QB(i,r)}let i=document.createDocumentFragment(),a=[];for(let t of e.newTurns){let e=eV(t);a.push(e),i.append(e.section)}_B.prepend(i),yB.unshift(...a)}function pV(e){if(!DB)return;let t=Zre(DB.grouping,e),n=AB()&&!bB&&!!_B&&!t.needsRerender,r=hB?.parentElement??null,i=r?.scrollHeight??0,a=r?.scrollTop??0;n&&fV(t),cV(),n||rV(),n&&iV(),r&&(r.scrollTop=a+r.scrollHeight-i)}function mV(e){hB||(hB=V(`div`,`trace-panel`),e.append(hB),nV())}function hV(e){SB=e}function gV(e){CB=e}function _V(e){EB=e,CB?.()}function vV(e){wB=tie(e);let t=FB(AB());t&&LB(),(t||!gB)&&rV(),!t&&gB&&iV()}function yV(){if(!hB)return;let e=FB(!0);LB(!0),oie({hasSelectionChanged:e,isRenderedTraceStale:bB,hasRenderedOnce:!!gB})&&nV()}function bV(e){let t=uV(e);if(!t)return;let n=aie({pendingRequest:OB?.request??null,resident:DB?{sessionId:DB.sessionId,firstOffset:DB.firstOffset,nextOffset:DB.nextOffset,hasLoadedOnce:DB.hasLoadedOnce}:null,reply:{id:t.id,start:t.start,next:t.next,reset:t.reset}});if(n===`ignore`){dV();return}if(MB(),n===`stale`){dV();return}if(n===`reset`){PB(t.id),DB&&(DB.filePath=t.path),LB(),rV(),dV();return}if(DB){if(DB.filePath=t.path,n===`prepend`){DB.firstOffset=t.start,pV(t.records),dV();return}n===`seed`&&(DB.hasLoadedOnce=!0,DB.firstOffset=t.start),DB.nextOffset=t.next,lV(t.records),dV()}}function xV(e){let t=e?.id;if(typeof t==`string`&&t===TB&&AB()){if(OB){kB=!0;return}LB()}}function SV(e){let t=e?.id;typeof t==`string`&&OB?.request.id===t&&(MB(),kB=!1,rV())}function CV(e){if(MB(),kB=!1,!e){rV();return}LB()}function wV(e){let{waiting:t,failed:n,done:r,complete:i,dormant:a,total:o}=e,s=e=>e>1?`s`:``,c=r+i,l=t+n;return t>0?{text:`${t} session${s(t)} need input`,severity:`warning`,alertCount:l}:n>0?{text:`${n} session${s(n)} failed`,severity:`critical`,alertCount:l}:o>0&&c===o?{text:`All sessions exited`,severity:`done`,alertCount:l}:o>0&&a===o?{text:`${a} session${s(a)} dormant`,severity:``,alertCount:l}:{text:``,severity:``,alertCount:l}}var TV=!1,EV=new Set;function DV(e){TV=!!e,ZV();for(let e of EV)e(TV)}function OV(e){return EV.add(e),()=>EV.delete(e)}function kV(){return TV}var AV=[{cls:`agent-badge`,title:`Agent CLI this session supervises`},{cls:`worktree-badge`,text:`worktree`,title:`Running in a linked git worktree`,ariaLabel:`Linked git worktree`},{cls:`post-turn-badge`,ariaHidden:!0},{cls:`usage-badge`,title:`Tokens and estimated API list-price cost for this conversation`},{cls:`wakeup-badge`},{cls:`prompt-badge`,title:`Waiting on a permission or input prompt`}];function jV({cls:e,text:t=``,title:n,ariaLabel:r,ariaHidden:i}){let a=V(`span`,e,t);return n&&(a.title=n),r&&a.setAttribute(`aria-label`,r),i&&a.setAttribute(`aria-hidden`,`true`),a}function MV(e,t){e.textContent=t?`SANE YOLO`:`YOLO`,e.title=t?`Skips permission prompts; Sane YOLO blocks catastrophic commands`:`Running with --dangerously-skip-permissions`}function NV(e,t){t&&(e.dataset.saneYolo=``),t||delete e.dataset.saneYolo;let n=e.querySelector(`.perms-badge`);n&&MV(n,t)}function PV(e,t){let n=Jf(e);n&&NV(n.card,t)}function FV(e,t,n,r={}){let i=n||F.INITIALIZING,a=V(`div`,`session-card`);a.dataset.id=e,a.dataset.session=t,a.dataset.state=i,r.skipPerms&&(a.dataset.skipPerms=``),r.saneYolo&&(a.dataset.saneYolo=``),r.worktree&&(a.dataset.worktree=``),r.workspace&&(a.dataset.workspace=``),r.path&&(a.dataset.path=String(r.path));let o=V(`div`,`session-card-header`),s=V(`span`,`session-name`,t);s.title=`Double-click or press F2 to rename`,s.tabIndex=0;let c=r.skipPerms?V(`span`,`perms-badge`):null;c&&MV(c,r.saneYolo===!0);let l=V(`span`,`session-task-title`);RV(l,r.taskTitle);let u=V(`span`,`card-elapsed`);u.setAttribute(`aria-hidden`,`true`);let d=V(`div`,`session-actions`),f=V(`div`,`session-overflow`),p=V(`button`,`btn-action btn-restart-menu visible`,`↻`);p.type=`button`,p.title=`Restart`,p.setAttribute(`aria-label`,`Restart`),p.setAttribute(`aria-haspopup`,`menu`),p.setAttribute(`aria-expanded`,`false`);let m=V(`div`,`session-overflow-menu`);m.id=`restart-menu-${e}`,m.setAttribute(`role`,`menu`),p.setAttribute(`aria-controls`,m.id);let h=IV(`Restart`,`Keeps this conversation`,`overflow-restart`),g=IV(`Restart fresh`,`Ends this conversation and starts a new one`,`overflow-restart-fresh`),_=IV(`Resume conversation...`,`Pick an earlier conversation`,`overflow-resume`);m.append(h,g,_),f.append(p,m);let v=V(`button`,`btn-action btn-debug`,`⚙`);v.title=`Debug state`,v.setAttribute(`aria-label`,`Debug session state`);let y=V(`button`,`btn-action btn-trace`,`≡`);y.type=`button`,y.title=`Trace`,y.setAttribute(`aria-label`,`Trace`);let ee=V(`button`,`btn-action btn-remove visible`,`×`);ee.type=`button`,ee.title=`Remove session`,ee.setAttribute(`aria-label`,`Remove session`);let b=V(`button`,`btn-action btn-face-plan`,`Plan`);b.type=`button`,b.title=`Show plan`;let te=V(`button`,`btn-action btn-face-plan btn-docs`,`Docs`);te.type=`button`,te.title=`Open docs the agent surfaced`,d.append(te,b,v,y,f,ee);let ne=V(`div`,`session-card-tags`),re=AV.map(e=>jV(e));c&&re.push(c),ne.append(...re),o.append(s,u,l,ne,d);let ie=V(`div`,`terminal-wrap`);return a.append(o,ie),{card:a,header:o,nameEl:s,elapsedEl:u,taskTitleEl:l,btnRestart:h,btnRestartFresh:g,btnRestartMenu:p,btnResume:_,btnTrace:y,btnRemove:ee,btnPlan:b,btnDocs:te,btnDebug:v,restartMenu:m,termWrap:ie}}function IV(e,t,n){let r=V(`button`,`overflow-item ${n}`);return r.type=`button`,r.setAttribute(`role`,`menuitem`),r.setAttribute(`aria-label`,e),r.append(V(`span`,`restart-menu-label`,e),V(`span`,`restart-menu-hint`,t)),r}function LV(e,t){e.tabIndex=0,e.setAttribute(`role`,`button`),e.addEventListener(`click`,t),e.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())})}function RV(e,t){e.title=t??``,t&&e.removeAttribute(`aria-label`),t||e.setAttribute(`aria-label`,`Describe the task`),!e.querySelector(`input`)&&(e.textContent=t??``)}function zV(e,t){let n=e.titleTargetEl?.isConnected?e.titleTargetEl:e.taskTitleEl;if(n.querySelector(`input`))return;let r=document.createElement(`input`);r.type=`text`,r.className=`session-title-input`,r.setAttribute(`aria-label`,`Task`),r.value=e.taskTitleIsCustom?e.taskTitle??``:``,r.placeholder=e.taskTitle??`What is this session working on?`,r.maxLength=120;let i=n.getAttribute(`role`),a=n.getAttribute(`tabindex`);n.removeAttribute(`role`),n.removeAttribute(`tabindex`),n.replaceChildren(r),r.focus(),r.select();function o(o){r.removeEventListener(`blur`,s),r.removeEventListener(`keydown`,c),o&&B({type:`set-session-title`,id:t,title:r.value.trim()}),n.replaceChildren(),i!==null&&n.setAttribute(`role`,i),a!==null&&n.setAttribute(`tabindex`,a),RV(n,e.taskTitle)}function s(){o(!0)}function c(e){e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),o(!0)),e.key===`Escape`&&(e.preventDefault(),o(!1))}r.addEventListener(`blur`,s),r.addEventListener(`keydown`,c)}var BV=`session-rename-input`;function VV(e){return!!e?.querySelector(`.${BV}`)}function HV(e,t){let n=e.renameTargetEl?.isConnected?e.renameTargetEl:e.nameEl;if(!n||VV(n))return;let r=e.card?.dataset.session??n.textContent??``;function i(){let t=e.card?.dataset.session??r;n.textContent=t,e.nameEl&&e.nameEl!==n&&(e.nameEl.textContent=t)}let a=document.createElement(`input`);a.type=`text`,a.className=BV,a.value=r,a.maxLength=64,n.textContent=``,n.appendChild(a),a.focus(),a.select();function o(){let n=a.value.trim();if(c(),!n||n===r){i();return}for(let[,t]of U)if(t!==e&&t.card.dataset.session===n){i(),WS(`Session "${n}" already exists.`);return}B({type:`rename-session`,id:t,newName:n}),i()}function s(){c(),i()}function c(){a.removeEventListener(`blur`,o),a.removeEventListener(`keydown`,l)}function l(e){e.key===`Enter`&&(e.preventDefault(),o()),e.key===`Escape`&&(e.preventDefault(),s()),e.stopPropagation()}a.addEventListener(`blur`,o),a.addEventListener(`keydown`,l)}var UV=`<button type="button" class="debug-close" aria-label="Close debug overlay" title="Close">×</button>`;function WV(e){return e?Cp(new Date(e)):`-`}function GV(e){return`${(Number(e||0)/1e3).toFixed(1)}s`}function KV(e){return e.decision===`gated`?`(${Number(e.active)||0} bg)`:e.decision===`wait`||e.decision===`release`?`(quiet ${GV(e.quietMs)})`:``}function qV(e){let t=`<span class="debug-dim">${WV(e.ts)}</span>`;if(e.kind===`signal`){let n=jI([e.signal,e.source].filter(Boolean).join(`/`));return e.action===`transition`?`${t} ${n} → <span class="debug-label">${jI(e.event||``)}</span>`:e.action===`gate-held`?`${t} ${n} → held <span class="debug-dim">(${Number(e.active)||0} bg)</span>`:`${t} ${n} → <span class="debug-dim">no-op</span>`}if(e.kind===`gate`){let n=(e.repeats??0)>1?` <span class="debug-dim">x${Number(e.repeats)}</span>`:``,r=KV(e),i=r?` <span class="debug-dim">${r}</span>`:``;return`${t} gate <span class="debug-label">${jI(e.decision||`?`)}</span>${i}${n}`}if(e.kind===`notify`){let n=jI(e.category||e.to||`?`);return e.category?`${t} notify <span class="debug-label">${n}</span>: fired`:`${t} notify ${n}: <span class="debug-dim">silent (${jI(e.reason||``)})</span>`}return e.kind===`notify-state`?`${t} notify ${jI(e.category||`?`)}: <span class="debug-dim">${jI(e.from||`?`)} → ${jI(e.to||`?`)}</span>`:`${t} <span class="debug-dim">${jI(e.kind||`decision`)}</span>`}function JV(e,t){if(!e.debugOverlay)return;let n=t,r=UV;if(r+=`<div class="debug-section"><div class="debug-section-title">State</div>`,r+=`<div class="debug-field"><span class="debug-label">Current:</span> <span class="debug-value">${jI(n.state)}</span></div>`,r+=`</div>`,r+=`<div class="debug-section"><div class="debug-section-title">Transitions (last ${n.transitions.length})</div>`,n.transitions.length===0&&(r+=`<div class="debug-field debug-dim">No transitions recorded</div>`),n.transitions.length>0)for(let e of n.transitions){let t=e.detail&&typeof e.detail==`object`?e.detail:null,n=t?[t.signal,t.source,t.deferred?`deferred`:null].filter(Boolean):[],i=n.length>0?` <span class="debug-dim">${jI(n.join(`/`))}</span>`:``;r+=`<div class="debug-field"><span class="debug-dim">${WV(e.timestamp)}</span> ${jI(e.from)} → ${jI(e.to)} <span class="debug-label">${jI(e.event)}</span>${i}</div>`}r+=`</div>`;let i=n.detection||{},a=i.lastSignal,o=i.titleState||{};r+=`<div class="debug-section"><div class="debug-section-title">Detection</div>`,r+=`<div class="debug-field"><span class="debug-label">Last signal:</span> <span class="debug-value">${a?`${jI(a.signal)} (${jI(a.source||`?`)}${a.confidence?`/${jI(a.confidence)}`:``})`:`none`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hooks injected:</span> <span class="debug-value">${i.hooksInjected?`yes`:`no`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Hook seen:</span> <span class="debug-value">${i.hookSeen?`yes`:`no (degraded → title)`}</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Title state:</span> <span class="debug-value">${jI(o.lastKind||`none`)}${o.hasSeenSpinner?` · spun`:``}</span></div>`,r+=`</div>`;let s=i.agents||{},c=i.gate;r+=`<div class="debug-section"><div class="debug-section-title">Agents</div>`,r+=`<div class="debug-field"><span class="debug-label">Active:</span> <span class="debug-value">${Number(s.active)||0} (counted ${Number(s.counted)||0}, declared ${Number(s.declared)||0})</span></div>`,r+=`<div class="debug-field"><span class="debug-label">Idle:</span> <span class="debug-value">${Number(s.idleNames)||0} names, ${Number(s.idleTasks)||0} tasks</span></div>`;let l=c?`held ${GV(c.heldForMs)} (seq ${Number(c.seq)||0}, lastActivity ${Number(c.lastActivitySeq)||0})`:`none`;r+=`<div class="debug-field"><span class="debug-label">Gate:</span> <span class="debug-value">${jI(l)}</span></div>`,r+=`</div>`;let u=Array.isArray(n.decisions)?n.decisions:[];r+=`<div class="debug-section"><div class="debug-section-title">Decisions (last ${u.length})</div>`,u.length===0&&(r+=`<div class="debug-field debug-dim">No decisions recorded</div>`);for(let e of u)r+=`<div class="debug-field">${qV(e)}</div>`;r+=`</div>`,e.debugOverlay.innerHTML=r}function YV(e,t){if(e.debugOpen){XV(e);return}let n=document.createElement(`div`);n.className=`debug-overlay`,n.innerHTML=`${UV}<div class="debug-field debug-dim">Loading...</div>`,e.card.appendChild(n),e.debugOverlay=n,e.debugOpen=!0,n.addEventListener(`click`,t=>{t.stopPropagation(),t.target instanceof Element&&t.target.closest(`.debug-close`)&&XV(e)}),B({type:`debug-state`,id:t})}function XV(e){e.debugOverlay&&=(e.debugOverlay.remove(),null),e.debugOpen=!1}function ZV(){for(let[,e]of U)e.btnDebug.classList.toggle(`visible`,TV),e.btnTrace.classList.toggle(`visible`,TV),!TV&&e.debugOpen&&XV(e)}function QV(e){let t=typeof e.id==`string`?U.get(e.id):void 0;t?.debugOpen&&JV(t,e.payload)}function $V(e){Jf(e)?.debugOpen&&B({type:`debug-state`,id:e})}function eH({hasPlan:e,pendingPromptKind:t,hasOpenReview:n,hasApprovedReview:r=!1}){return e&&(n||t===`plan`&&!r)?`plan`:`terminal`}function tH({hasPlan:e,isBorrowed:t,face:n}){return!e||n===`plan`?`hidden`:t?`face`:`navigate`}function nH(e){return e instanceof Error?e.message:String(e)}var rH=`DORMANT`;function iH(e){return e?_p(Date.now()-e,{rounding:`round`,wording:`compact`,suffix:` ago`,justNowBelowSeconds:60}):``}function aH(e,t,n){let r=V(`button`,`resume-item`);r.type=`button`,r.setAttribute(`role`,`option`),e.id===t&&r.classList.add(`resume-item-current`);let i=[e.worktreeName,e.gitBranch?e.gitBranch.replace(/^refs\/heads\//,``):null,iH(e.mtime)].filter(Boolean).join(` · `);return r.innerHTML=`<span class="resume-item-title">${jI(e.title||e.id)}</span><span class="resume-item-meta">${jI(i)}${e.id===t?` · current`:``}</span>`,r.addEventListener(`click`,()=>n(e.id)),r}function oH(e,t={}){let n=(t.currentState||``)===rH,{overlay:r,dialog:i,close:a,actions:o,btnCancel:s}=ep({title:`Resume a conversation`,dialogClass:`dialog resume-dialog`}),c=V(`p`,`dialog-message`,`Pick a Claude conversation from this repo (any worktree) to continue in this card.`),l=V(`div`,`resume-list`);l.setAttribute(`role`,`listbox`),l.setAttribute(`aria-label`,`Resumable conversations`),l.append(V(`div`,`resume-empty`,`Loading conversations...`));let u=V(`button`,`btn-dialog btn-dialog-cancel`,`Start fresh`);u.title=`Clear any resume binding so this card starts a new conversation`,o.prepend(u),i.append(c,l,o);function d(t){if(B({type:`resume-conversation`,id:e,conversationId:t||``}),a(),t){if(!n){WS(`Conversation will resume on this session's next restart.`);return}B({type:`start-session`,id:e})}}s.addEventListener(`click`,a),u.addEventListener(`click`,()=>d(null)),requestAnimationFrame(()=>s.focus()),of(`list-conversations`,{id:e}).then(e=>{if(!r.isConnected)return;let t=e.type===`conversations`?e.conversations:[];if(l.innerHTML=``,e.error){l.append(V(`div`,`resume-empty`,`Could not list conversations: ${e.error}`));return}if(t.length===0){l.append(V(`div`,`resume-empty`,`No prior conversations found for this repo.`));return}let n=e.type===`conversations`?e.current??null:null;for(let e of t)l.append(aH(e,n,d))}).catch(e=>{r.isConnected&&(l.innerHTML=``,l.append(V(`div`,`resume-empty`,`Could not list conversations: ${nH(e)}`)))})}var sH={critical:`✕`,warning:`▲`,done:`✓`,"":`▸`},cH=null,lH=null,uH=e=>e==null?``:String(e),dH=e=>jc.includes(e),fH=e=>Mc.includes(e);function pH(e){let t=e.currentState,n=dH(t)||fH(t);e.btnRestart.classList.toggle(`visible`,n),e.btnRestartFresh.classList.toggle(`visible`,n),e.btnResume.classList.add(`visible`),e.btnTrace.classList.toggle(`visible`,kV()),e.btnPlan.classList.toggle(`visible`,tH(e)!==`hidden`),e.btnRemove.classList.add(`visible`)}function mH(e){e.restartMenu.classList.remove(`open`),e.btnRestartMenu.setAttribute(`aria-expanded`,`false`)}function hH(e,t){LV(e.taskTitleEl,()=>zV(e,t)),e.nameEl.addEventListener(`dblclick`,n=>{n.preventDefault(),HV(e,t)}),e.nameEl.addEventListener(`click`,()=>{VV(e.nameEl)||xI(t)}),e.nameEl.addEventListener(`keydown`,n=>{n.target===e.nameEl&&(n.key===`F2`||n.key===`Enter`)&&(n.preventDefault(),HV(e,t))});function n(n){mH(e),e.btnRestartMenu.focus(),ap(n,t,{readState:()=>e.currentState,send:B,confirm:tp})}e.btnRestart.addEventListener(`click`,()=>n(`restart`)),e.btnRestartFresh.addEventListener(`click`,()=>n(`restart-fresh`)),e.btnResume.addEventListener(`click`,()=>{mH(e),oH(t,{currentState:e.currentState})}),e.btnTrace.addEventListener(`click`,()=>{mH(e),_V(t)}),e.btnDocs.addEventListener(`click`,()=>{mH(e),QF(t)}),e.btnPlan.addEventListener(`click`,()=>{let n=tH(e);if(n!==`hidden`){if(n===`face`){EH(t);return}location.hash=BL(t)}}),e.btnRemove.addEventListener(`click`,()=>{mH(e);let n=e.card.dataset.session,r=e.card.dataset.merge,i=r===`pending-review`||r===`parked`;tp({title:`Remove Session`,message:i?`"${n}" has unmerged worktree changes that will be permanently discarded if you remove it. Merge or review them first to keep them. Remove anyway?`:`Remove session "${n}"?`,confirmLabel:i?`Discard & Remove`:`Remove`,onConfirm:()=>B({type:`remove-session`,id:t})})}),e.btnRestartMenu.addEventListener(`click`,t=>{t.stopPropagation();for(let[,t]of U)t!==e&&mH(t);let n=e.restartMenu.classList.toggle(`open`);e.btnRestartMenu.setAttribute(`aria-expanded`,String(n))});let r=[e.btnRestart,e.btnRestartFresh,e.btnResume];function i(t){if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;t.preventDefault(),t.stopPropagation();for(let[,t]of U)t!==e&&mH(t);e.restartMenu.classList.add(`open`),e.btnRestartMenu.setAttribute(`aria-expanded`,`true`);let n=r.filter(e=>e.classList.contains(`visible`)),i=document.activeElement,a=i instanceof HTMLButtonElement?n.indexOf(i):-1;n[((t.key===`ArrowDown`?a+1:a<0?n.length-1:a-1)+n.length)%n.length]?.focus()}e.btnRestartMenu.addEventListener(`keydown`,i),e.restartMenu.addEventListener(`keydown`,i),document.addEventListener(`keydown`,t=>{t.key===`Escape`&&e.restartMenu.classList.contains(`open`)&&(t.preventDefault(),mH(e),e.btnRestartMenu.focus())},{signal:e.abortController.signal}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;!e.restartMenu.contains(n)&&n!==e.btnRestartMenu&&mH(e)},{signal:e.abortController.signal}),e.termWrap.addEventListener(`mousedown`,()=>{(e.currentState===F.WAITING||e.currentState===F.COMPLETE)&&B({type:`dismiss`,id:t})}),e.btnDebug.addEventListener(`click`,n=>{n.stopPropagation(),YV(e,t)}),document.addEventListener(`click`,t=>{let n=t.target instanceof Node?t.target:null;e.debugOpen&&!e.card.contains(n)&&XV(e)},{signal:e.abortController.signal})}function gH(e,t,n){let r=Jf(e);if(r){r.taskTitle=typeof t==`string`?t:null,r.taskTitleIsCustom=n===!0;for(let e of[r.taskTitleEl,r.titleTargetEl])e&&RV(e,r.taskTitle)}}function _H(e){return typeof e==`string`&&U.has(e)}function vH(){return U.size}function yH(){return[...U.keys()]}function bH(e){let t=e||{};t.cursorBlink!=null&&Zk(t.cursorBlink),t.debugMode!=null&&(DV(t.debugMode),JI(t.debugMode));for(let[,e]of U)e.term&&t.cursorBlink!=null&&(e.term.options.cursorBlink=t.cursorBlink)}function xH(){wb(U.values(),Eb())}function SH(){if(!Xf)return;let e=0,t=0,n=0,r=0,i=0,a=0;for(let[,o]of U){a++;let s=o.currentState;if(s===F.WAITING){e++;continue}if(s===F.FAILED){t++;continue}if(s===F.DONE){n++;continue}if(s===F.COMPLETE){r++;continue}s===F.DORMANT&&i++}let{text:o,severity:s,alertCount:c}=wV({waiting:e,failed:t,done:n,complete:r,dormant:i,total:a});if((o!==cH||s!==lH)&&(cH=o,lH=s,Xf.dataset.severity=s,Xf.textContent=``,o)){let e=V(`span`,`aggregate-glyph`,sH[s]??sH[``]);e.setAttribute(`aria-hidden`,`true`),Xf.append(e,document.createTextNode(o))}document.title=c>0?`(${c}) Glimmervoid`:`Glimmervoid`}function CH(e,t,n,r={}){if(!Yf)return;let i=qf(e),a=uH(n)||F.DORMANT,o=FV(i,uH(t),a,r),s=a===F.DORMANT;Yf.appendChild(o.card);let c;function l(){c.face=`terminal`,c.card.dataset.face=`terminal`,c.termWrap.hidden=!1,c.planFace.hide(),pH(c),wA(c,i)}let u=new AbortController,d=RL({signal:u.signal,requestPlan:(e,t,n)=>B({type:`session-plan`,id:e,agentId:t,revision:n}),requestDraft:(e,t)=>B({type:`session-plan`,id:e,agentId:t,draft:!0}),showTerminal:l,sendDecision:(e,t)=>B({type:`plan-decision`,id:e,...t}),reportProblem:e=>WS(`${o.nameEl.textContent||i}: ${e}`)});return c={term:null,fitAddon:null,webglAddon:null,needsWebGLReload:!1,webglAttachedWithoutLayout:!1,dataWs:null,card:o.card,nameEl:o.nameEl,taskTitleEl:o.taskTitleEl,taskTitle:r.taskTitle??null,taskTitleIsCustom:r.taskTitleIsCustom??!1,hasEndedTurn:!1,elapsedEl:o.elapsedEl,path:uH(r.path),stateSince:typeof r.stateSince==`number`&&Number.isFinite(r.stateSince)?r.stateSince:Date.now(),restartMenu:o.restartMenu,termWrap:o.termWrap,btnDebug:o.btnDebug,btnRestart:o.btnRestart,btnRestartFresh:o.btnRestartFresh,btnRestartMenu:o.btnRestartMenu,btnResume:o.btnResume,btnTrace:o.btnTrace,btnPlan:o.btnPlan,btnDocs:o.btnDocs,btnRemove:o.btnRemove,debugOverlay:null,debugOpen:!1,abortController:u,currentState:a,face:`terminal`,isBorrowed:!1,hasPlan:!1,pendingPromptKind:null,pendingPromptDetail:null,planReviewState:{reviews:[]},planFace:d},c._ensureTerminalReady=()=>wA(c,i),c._showTerminalFace=l,c._showPreferredFace=()=>{if(wH(c)===`plan`){EH(i);return}l()},c._setBorrowed=e=>{c.isBorrowed=e,pH(c)},o.card.append(d.el),U.set(i,c),hH(c,i),pH(c),c.btnDocs.classList.toggle(`visible`,BF(i)),a===F.RUNNING&&Ap(c,!0),s||(yA(o.termWrap,c),xA(c,i)),SH(),c}function wH(e){let t=e.planReviewState.reviews.some(e=>e.state===`open`),n=e.planReviewState.reviews.some(lL);return eH({hasPlan:e.hasPlan,pendingPromptKind:e.pendingPromptKind,hasOpenReview:t,hasApprovedReview:n})}function TH(e){let t=Jf(e);return!t?.isBorrowed||wH(t)!==`plan`?!1:EH(e)}function EH(e){let t=Jf(e);return!t?.isBorrowed||!t.hasPlan?!1:(t.face=`plan`,t.card.dataset.face=`plan`,t.termWrap.hidden=!0,t.planFace.show(qf(e)),pH(t),!0)}function DH(e,t){let n=Jf(e);n&&(n.hasPlan=t===!0,pH(n),TH(e))}function OH(e){let t=Jf(e.id);t&&(t.planReviewState=EL(t.planReviewState,e),t.hasPlan=e.hasPlan,t.planFace.update({state:t.planReviewState}),pH(t),TH(e.id))}function kH(e){let t=Jf(e.id);t&&t.planFace.update({draft:e})}function AH(e){let t=Jf(e.id);t&&(t.planReviewState={reviews:e.reviews},t.hasPlan=!0,t.planFace.update({response:e}),pH(t))}function jH(e){if(e.type!==`error`&&e.type!==`session-error`||e.scope!==`plan`&&e.scope!==`plan-decision`)return;let t=Jf(e.id);if(t){if(e.scope===`plan`){t.planFace.update({requestFailed:!0});return}t.planFace.update({decisionRefused:!0})}}function MH(e){for(let[,t]of U)t.planFace.update({isConnected:e})}function NH(e,t){let n=Jf(e);n&&(n.effectiveBase=typeof t==`string`?t:void 0)}function PH(e,t){let n=Jf(e);if(!n)return;n.agent=typeof t==`string`?t:null;let r=LP(t);IH(n,`.agent-badge`,`agent`,{on:r!==``,value:r,text:r})}function FH(e,t){let n=Jf(e);if(n){if(t){n.card.dataset.worktree=``;return}delete n.card.dataset.worktree}}function IH(e,t,n,r){let{on:i,value:a=``,text:o,title:s}=r,c=e.card.querySelector(t);if(!i){if(delete e.card.dataset[n],!c)return;o!==void 0&&(c.textContent=``),s!==void 0&&c.removeAttribute(`title`);return}e.card.dataset[n]=a,c&&(o!==void 0&&(c.textContent=o),s!==void 0&&(c.title=s))}function LH(e,t){let n=Jf(e);n&&(n.hasEndedTurn=t)}function RH(e,t,n=!1){let r=Jf(e);r&&(r.activeAgents=Math.max(0,Number(t)||0),r.awaitingBackgroundTasks=bf(r.currentState,n===!0),r.card.toggleAttribute(`data-monitoring`,r.awaitingBackgroundTasks))}function zH(e,t){let n=Jf(e);if(!n)return;let r=Hae(t);IH(n,`.usage-badge`,`usage`,{on:!!r,text:r||``,title:r?Uae(t):void 0})}function BH(e,t,n=null,r=!1){let i=Jf(e);i&&(i.pendingPromptKind=typeof t==`string`?t:null,i.pendingPromptDetail=n,IH(i,`.prompt-badge`,`prompt`,{on:!!t||r,value:r?`compacting`:uH(t),title:r?`Context compaction in progress`:`Waiting on a permission or input prompt`,text:r?`compacting`:t===`plan`?`Plan ready`:t===`permission`?`permission`:`input`}),TH(e))}function VH(e){return e?`sleeping until ~${Sp(new Date(e))}`:`scheduled`}function HH(e,t){let n=Jf(e);n&&IH(n,`.wakeup-badge`,`wakeup`,{on:!!t,value:t?.kind||`wakeup`,text:VH(t?.at),title:t?.reason?`Scheduled revival: ${t.reason}`:`Scheduled revival pending`})}function UH(e,t){let n=Jf(e);if(!n)return;let r=Array.isArray(t.findings)?t.findings:[],i=t.filesFixed||0,a=null,o=0;!t.skipped&&t.mode===`fix`&&i>0&&(a=`fixed`,o=i),!t.skipped&&t.mode===`report`&&r.length>0&&(a=`flagged`,o=new Set(r.map(e=>e.file)).size);let s={};for(let e of r)s[e.rule]=(s[e.rule]||0)+(e.count||0);let c=Object.keys(s).map(e=>`${e}: ${s[e]}`).join(`, `),l=a===`fixed`?`auto-fixed`:`flagged`;IH(n,`.post-turn-badge`,`pt`,{on:!!a,value:a||void 0,text:`${a===`fixed`?`✓`:`⚠`} ${o}`,title:`Post-turn ${l} ${o} file(s)${c?` (${c})`:``}`})}function WH(e,t){if(t===`pending-review`||t===`parked`||t===`merging`){e.dataset.merge=t;return}delete e.dataset.merge}function GH(e,t,n=null){let r=Jf(e),i=uH(t)||`none`;r&&WH(r.card,i),sz(qf(e),i,uH(n)||null)}function KH(e,t,n=null){let r=Jf(e),i=uH(t)||`none`;r&&WH(r.card,i),cz(qf(e),i,uH(n)||null)}function qH(e,t){lz(qf(e),t)}function JH(e,t){let n=Jf(e);if(!n)return;let r=uH(t);n.card.dataset.session=r,n.nameEl.textContent=r}function YH(e){let t=Jf(e);t&&(XV(t),U.delete(qf(e)),IL(qf(e)),t.resizeObserver&&t.resizeObserver.disconnect(),t.abortController&&t.abortController.abort(),t.dataWs&&t.dataWs.readyState<=WebSocket.OPEN&&t.dataWs.close(),gD(t),t.term&&t.term.dispose(),t.term=null,t.fitAddon=null,t.card&&t.card.remove(),SH())}function XH(e,t,n){if(!t||!e.term)return;e.term.clear(),e.term.reset();let r=n===F.DONE?`Session complete`:`Session failed`,i=n===F.DONE?`\x1B[34m`:`\x1B[31m`;e.term.write(`\r\n\x1b[2m${i} ${r}\x1b[0m\r\n\r\n\x1b[2m Press Restart to start a new session.\x1b[0m\r\n`)}function ZH(e,t){e.term&&(t===F.DONE||t===F.FAILED)&&(e.term.clear(),e.term.reset())}function QH(e,t,n){let r=document.activeElement;return vI({previousState:t,nextState:n,isPhoneLayout:Wf(),isDocumentVisible:document.visibilityState===`visible`,isDocumentFocused:document.hasFocus(),isActiveViewer:e._isActiveViewer?.()===!0,hasFocusInsideTerminal:r instanceof Node&&e.termWrap.contains(r)})}function $H(e,t,n,r=``){let i=Jf(e);if(!i)return;let a=uH(t),o=i.currentState;i.currentState=a,a!==F.RUNNING&&(i.awaitingBackgroundTasks=!1),a!==o&&(i.stateSince=typeof n==`number`&&Number.isFinite(n)?n:Date.now(),Ap(i,a===F.RUNNING)),o===F.DORMANT&&a!==F.DORMANT&&SA(i,qf(e)),i.card.dataset.state=a,i.card.toggleAttribute(`data-monitoring`,bf(a,i.awaitingBackgroundTasks)),pH(i),(a===F.WAITING&&o!==F.WAITING||a===F.COMPLETE&&o!==F.COMPLETE)&&!AI(r)&&LO()&&Mx(zO()),QH(i,o,a)&&B({type:`dismiss`,id:qf(e),expectedState:F.COMPLETE});let s=a===F.DONE||a===F.FAILED,c=o!==F.DONE&&o!==F.FAILED&&o!==F.INITIALIZING;s&&c&&(i.card.classList.remove(`completion-flash`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.card.classList.add(`completion-flash`),i.card.addEventListener(`animationend`,()=>i.card.classList.remove(`completion-flash`),{once:!0})})}),LO()&&Mx(zO())),(a===F.DONE||a===F.FAILED)&&XH(i,c,a),a===F.INITIALIZING&&ZH(i,o),SH(),Pp(i)}var eU=`(no path)`;function tU(e){if(!e)return eU;let t=String(e).replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return(n===-1?t:t.slice(n+1))||`(no path)`}function nU(e,t,n){let r=Array.isArray(e)?e:[],i=new Map;for(let e of r){let n=t(e),r=n?String(n):eU,a=i.get(r);a||(a={key:r,label:r===`(no path)`?eU:tU(r),title:r,rows:[]},i.set(r,a)),a.rows.push(e)}if(n)for(let e of n){if(!e)continue;let t=String(e);t===`(no path)`||i.has(t)||i.set(t,{key:t,label:tU(t),title:t,rows:[]})}let a=[...i.values()];return a.sort((e,t)=>e.label.localeCompare(t.label,void 0,{numeric:!0,sensitivity:`base`})||e.key.localeCompare(t.key)),{flat:i.size<=1,order:a.map(e=>e.key),groups:a}}function rU(e,t){if(!e||!Array.isArray(e.groups))return[];let n=t||new Set,r=[];if(e.flat){for(let t of e.groups)for(let e of t.rows)r.push(e.id);return r}let i=new Map(e.groups.map(e=>[e.key,e]));for(let t of e.order){if(n.has(t))continue;let e=i.get(t);if(e)for(let t of e.rows)r.push(t.id)}return r}function iU(e,t){let n=V(e,t);return n.innerHTML=`<span class="focus-pill-name"></span><span class="focus-pill-badge"><span class="focus-pill-glyph"></span><span class="focus-pill-label"></span></span><span class="focus-pill-merge"></span>`,{pill:n,refs:{glyph:_f(n,`.focus-pill-glyph`),label:_f(n,`.focus-pill-label`),name:_f(n,`.focus-pill-name`),merge:_f(n,`.focus-pill-merge`)}}}function aU(e,t,n,r=!1){e.dataset.state=n;let{glyph:i,label:a,isMonitoring:o}=xf(n,r);return e.toggleAttribute(`data-monitoring`,o),t.glyph.textContent=i,t.label.textContent=a,a}function oU(){let e=new Map,t=new Set;function n(n){let r=new Set(n.map(e=>e.id));for(let{id:r,state:i}of n){let n=e.get(r);if(e.set(r,i),i!==F.COMPLETE){t.delete(r);continue}n&&n!==F.COMPLETE&&t.add(r)}for(let n of e.keys())r.has(n)||(e.delete(n),t.delete(n))}function r(e){t.delete(e)}function i(e){return t.has(e)}return{noteStates:n,acknowledge:r,isUnseen:i}}var sU=e=>e.ui.path,cU=window.matchMedia?.(`(prefers-reduced-motion: reduce)`),lU=window.matchMedia?.(`(hover: none) and (min-width: 769px)`),uU=null,dU=null,fU=null,pU=null,mU=null,hU=null,gU=null,_U=null,vU=!1,yU=null,bU=new Map,xU=new Map,SU=oU(),CU=new Map,wU=new Map,TU=null,EU=new Set;function DU(){return rU(kU(zU()),EU)}function OU(e){let t=TU;if(TU=e||null,t&&t!==TU){let e=xU.get(t);e&&(e.tabIndex=-1,e.setAttribute(`aria-selected`,`false`))}if(TU){let e=xU.get(TU);e&&(e.tabIndex=0,e.setAttribute(`aria-selected`,`true`))}}function kU(e){return nU(e,sU,hI(e,sU))}function AU(e){let t=wU.get(e.key),n=CU.get(e.key);if(!t||!n){let r=Object.assign(V(`div`,`focus-rail-group`),{_addBtn:V(`button`,`focus-rail-group-add`,`+`),_forgetBtn:V(`button`,`focus-rail-group-remove`,`×`)});r.dataset.key=e.key,r.innerHTML=`<span class="focus-rail-group-label"></span><span class="focus-rail-group-rule" aria-hidden="true"></span>`;let i=r._addBtn;i.type=`button`,i.addEventListener(`click`,()=>DI(r.dataset.path,r.dataset.label));let a=r._forgetBtn;a.type=`button`,a.addEventListener(`click`,()=>{gI(r.dataset.path),GU()}),r.appendChild(a),r.appendChild(i),t=r,n=V(`div`,`focus-rail-list`),n.setAttribute(`role`,`listbox`),wU.set(e.key,t),CU.set(e.key,n)}_f(t,`.focus-rail-group-label`).textContent=e.label,t.title=e.title,t.dataset.path=e.key,t.dataset.label=e.label;let r=e.key===eU,i=e.rows.length===0;return t._addBtn.hidden=r,r||(t._addBtn.title=`Add a session to ${e.label}`,t._addBtn.setAttribute(`aria-label`,`Add a session to ${e.label}`)),t._forgetBtn.hidden=r||!i,!r&&i&&(t._forgetBtn.title=`Remove ${e.label} from the rail`,t._forgetBtn.setAttribute(`aria-label`,`Remove ${e.label} from the rail`)),t.toggleAttribute(`data-empty`,i),n.setAttribute(`aria-label`,`${e.label} sessions`),{header:t,list:n}}function jU(){return vU}function MU(){return mU}function NU(){return Lf.snapshot().focusedSessionId}function PU({rail:e,center:t,resizer:n}){if(uU=e,fU=t,!uU||!fU)return;let r=uU,i=fU;LU(n),r.removeAttribute(`role`),r.removeAttribute(`aria-label`),r.setAttribute(`aria-keyshortcuts`,Kb(Jb)),dU=V(`button`,`focus-rail-head`),dU.type=`button`,dU.append(V(`span`,`focus-rail-head-count`),$b(Wb(`next-attention`,Jb))),dU.addEventListener(`click`,YU),JU(!1,Sj(0)),r.append(dU),hU=V(`div`,`focus-empty`),hU.innerHTML=`<p class="focus-empty-title"></p><p class="focus-empty-desc"></p>`,gU=hU.querySelector(`.focus-empty-title`),_U=hU.querySelector(`.focus-empty-desc`),pU=V(`div`,`focus-card-slot`),mU=V(`div`,`focus-header-accessory-slot`),i.append(mU,hU,pU),r.addEventListener(`keydown`,RU)}var FU={minPx:180,maxPx:480},IU=16;function LU(e){e&&uU&&dI({resizer:e,column:uU,widthHost:uU,widthProperty:`--rail-width`,bounds:FU,keyStepPx:IU,getStoredWidth:$O,setStoredWidth:ek})}function RU(e){if(e.key===`Delete`||e.key===`Backspace`){let t=e.target instanceof HTMLElement?e.target:null,n=t?.dataset.id;if(!n||xU.get(n)!==t)return;e.preventDefault(),OI(n,bU.get(n));return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`||e.altKey||e.metaKey||e.ctrlKey||e.shiftKey)return;let t=yj(DU(),TU,e.key===`ArrowDown`?1:-1);t!=null&&(e.preventDefault(),OU(t),xU.get(t)?.focus())}function zU(e=EI(BU)){for(let t of e)t.unseen=SU.isUnseen(t.id);return _j(e)}function BU(e){return e.nameEl?e.nameEl.textContent:e.card&&(e.card.dataset.session||e.card.dataset.id)||``}function VU(e){let{pill:t,refs:n}=iU(`button`,`focus-pill`);t.type=`button`,t.dataset.id=e,t.setAttribute(`role`,`option`);let r=Object.assign(t,{_refs:n,_row:null});r.addEventListener(`click`,()=>HU(e));let i=V(`div`,`focus-pill-row`);i.setAttribute(`role`,`presentation`);let a=V(`button`,`focus-pill-remove`,`×`);return a.type=`button`,a.tabIndex=-1,lU?.matches||a.setAttribute(`aria-hidden`,`true`),a.title=`Remove session`,a.addEventListener(`click`,t=>{t.stopPropagation(),OI(e,bU.get(e))}),i.append(r,a),r._row=i,r}function HU(e){CI(e)&&eW(e)}function UU(e,{id:t,ui:n,state:r,name:i,unseen:a}){e.toggleAttribute(`data-unseen`,a);let o=aU(e,e._refs,r,n.awaitingBackgroundTasks),s=[i,n.taskTitle,o].filter(Boolean).join(`, `);e.setAttribute(`aria-label`,s),e.title=s,e._refs.name.textContent=i;let c=bU.get(t)||`none`;e.dataset.merge=c===`none`?``:c,e._refs.merge.textContent=yf[c]||``,e.dataset.activity=n._activity||``,e.classList.toggle(`focused`,t===NU());let l=t===TU;e.setAttribute(`aria-selected`,String(l)),e.tabIndex=l?0:-1}function WU(e,t){if(!vU)return;let n=e?.card?.dataset.id,r=n?xU.get(n):null;if(!r)return;if(t===`flag`){r.dataset.activity=e._activity||``;return}if(cU?.matches||document.hidden)return;let i=r._refs?.glyph;i?.animate&&i.animate([{transform:`scale(1)`,opacity:.65},{transform:`scale(1.35)`,opacity:1,offset:.3},{transform:`scale(1)`,opacity:.9}],{duration:300,easing:`cubic-bezier(0.22, 1, 0.36, 1)`})}Dp(WU);function GU(){if(!vU)return;let e=uU;if(!e)return;let t=EI(BU);SU.noteStates(t);let n=zU(t),r=kU(n),i=new Set,a=(e,t)=>{let n=e.map(e=>e.id).join(`,`),r=t._lastOrderKey===n&&t.childElementCount===e.length;for(let n of e){let{id:e}=n;i.add(e);let a=xU.get(e);a||(a=VU(e),xU.set(e,a)),UU(a,n),!r&&a._row&&t.appendChild(a._row)}t._lastOrderKey=n},o=new Set(r.order);for(let t of r.groups){let{header:n,list:r}=AU(t);e.appendChild(n),e.appendChild(r),a(t.rows,r)}for(let[e,t]of[...wU])o.has(e)||(t.remove(),CU.get(e)?.remove(),wU.delete(e),CU.delete(e));for(let[e,t]of xU)i.has(e)||((t._row||t).remove(),xU.delete(e),e===TU&&(TU=null));for(let e of[...bU.keys()])U.has(e)||bU.delete(e);let s=NU();if(s&&!U.has(s)){Lf.dispatch(`focusSession`,null),TU=null;let e=n.find(e=>U.has(e.id));if(e){eW(e.id);return}}tW();let c=NU();if(c){let e=U.get(c);e&&e.card.parentElement!==pU&&QU(e,c)}qU()}function KU(){return zU().filter(bj).map(({id:e})=>e)}function qU(){let e=xj(zU());JU(e>0,Sj(e))}function JU(e,t){if(dU){if(_f(dU,`.focus-rail-head-count`).textContent=t,dU.disabled=!e,e){dU.removeAttribute(`data-empty`),dU.removeAttribute(`aria-hidden`);return}dU.dataset.empty=``,dU.setAttribute(`aria-hidden`,`true`)}}function YU(){if(!vU)return;let e=KU();if(!e.length)return;let t=vj(e,yU);if(!t)return;yU=t;let n=U.get(t),r=t===NU();CI(t),eW(t),xU.get(t)?.scrollIntoView({block:`nearest`}),r&&ZU(t),XU(n,t)}function XU(e,t){e&&requestAnimationFrame(()=>requestAnimationFrame(()=>{vU&&NU()===t&&e.term?.focus()}))}function ZU(e){if(cU?.matches||document.hidden)return;let t=xU.get(e);t?.animate&&t.animate([{transform:`scale(1)`},{transform:`scale(1.045)`,offset:.3},{transform:`scale(1)`}],{duration:360,easing:`cubic-bezier(0.22, 1, 0.36, 1)`});let n=U.get(e)?.card;n?.animate&&n.animate([{opacity:.8},{opacity:1}],{duration:240,easing:`ease-out`})}function QU(e,t){pU&&(OP(e,t,pU,{className:`focus-centered`}),TA(e,t,!0))}function $U(){let e=NU();e&&(DP()===e&&kP(),Lf.dispatch(`focusSession`,null))}function eW(e){vU&&U.has(e)&&e!==NU()&&($U(),Lf.dispatch(`focusSession`,e),TU=e,SU.acknowledge(e),wI(e),GU())}function tW(){if(!hU||!gU||!_U)return;let e=NU(),t=!!(e&&U.has(e));if(hU.hidden=t,t)return;let n=U.size>0;gU.textContent=n?`No session selected`:`Nothing to focus`,_U.textContent=n?rW():`Spawn a session to start watching.`}function nW(){return uU?.closest(`.focus-view`)?.dataset.rail===`off`}function rW(){return nW()?`Pick a session in Calm to focus it here.`:`Select a session from the rail on the left to focus it here.`}function iW(e){let t=uU?.closest(`.focus-view`);t&&(e&&t.removeAttribute(`data-rail`),e||(t.dataset.rail=`off`),tW())}function aW(e,t){bU.set(qf(e),typeof t==`string`&&t?t:`none`),vU&&GU()}function oW(e){vU&&U.has(e)&&eW(e)}function sW(e){return!vU||!U.has(e)?!1:(eW(e),EH(e))}function cW(e){if(!vU)return;let t=DU()[e-1];t&&HU(t)}function lW(e){if(!vU)return;let t=yj(DU(),TU,e);t!=null&&(HU(t),xU.get(t)?.scrollIntoView({block:`nearest`}),XU(U.get(t),t))}function uW(){uU&&(vU=!0,$U(),TU=null,GU(),dW())}function dW(){if(!vU||NU())return;let e=TI();e&&eW(e)}function fW(){vU&&=($U(),TU=null,!1)}function pW(e,t,n){let r=V(`a`,`settings-link`,n);return r.href=`#settings/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,r}var mW=`t-[0-9a-f]{8}`,hW=`No findings. Open a markdown file in a connected editor.`,gW=`No intent yet. The visions proposes one after its first pass.`,_W=`Unowned`,vW=RegExp(`^${mW}$`);function yW(){return{byProject:{},unowned:[]}}function bW(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.text==`string`?t.text:``;if(!n)return null;let r=Number(t.ts),i=Number(t.hits);return{id:typeof t.id==`string`&&vW.test(t.id)?t.id:null,text:n,uris:Array.isArray(t.uris)?t.uris.filter(e=>typeof e==`string`&&e!==``):[],ts:Number.isFinite(r)&&r>0?r:0,hits:Number.isInteger(i)&&i>0?i:1}}function xW(e){if(Array.isArray(e))return e.map(bW).filter(e=>e!==null);let t=bW(e);return t?[t]:[]}function SW(e){let t=e?.intent;if(!t||typeof t!=`object`)return yW();let n=t;if(!(Object.hasOwn(n,`byProject`)||Object.hasOwn(n,`unowned`)||Object.hasOwn(n,`global`)))return{byProject:{},unowned:xW(n)};let r=n.byProject&&typeof n.byProject==`object`?n.byProject:{},i=[];for(let[e,t]of Object.entries(r)){let n=xW(t);n.length!==0&&e&&i.push([e,n])}return{byProject:Object.fromEntries(i),unowned:xW(Object.hasOwn(n,`unowned`)?n.unowned:n.global)}}function CW(e,t){let n=typeof t?.id==`string`?t.id:null;if(!n)return e;let r=e.findIndex(e=>e.id===n);return r<=0?e:[e[r],...e.slice(0,r),...e.slice(r+1)]}function wW(e,t){let n=e||yW(),r=t?.intent;if(!r||typeof r!=`object`)return n;let i=r,a=CW(Array.isArray(i.threads)?xW(i.threads):xW(i),i.active),o=typeof t?.projectId==`string`&&t.projectId?t.projectId:null;if(!o)return{byProject:{...n.byProject},unowned:a};let s={...n.byProject};return a.length===0&&delete s[o],a.length>0&&(s[o]=a),{byProject:s,unowned:n.unowned}}function TW(e,t=null){let n=t&&typeof t.get==`function`?t.get(e):null;return typeof n==`string`&&n?n:e}function EW(e,{key:t,label:n,now:r}){return e.map((e,i)=>({key:`${t}:${e.id||i}`,label:n,text:e.text,hasText:!0,active:i===0,meta:AW(e,r)}))}function DW(e,t=null,n=Date.now()){let r=e||yW(),i=Object.entries(r.byProject||{}).filter(([e,t])=>e&&Array.isArray(t)&&t.length>0).map(([e,n])=>({projectId:e,label:TW(e,t),threads:n})).sort((e,t)=>e.label.localeCompare(t.label)).flatMap(({projectId:e,label:t,threads:r})=>EW(r,{key:e,label:t,now:n})),a=EW(Array.isArray(r.unowned)?r.unowned:[],{key:`unowned`,label:_W,now:n});return i.length+a.length>0?[...a,...i]:[{key:`unowned`,label:_W,text:gW,hasText:!1,active:!1,meta:``}]}function OW(e){return e?.text?`proposed by visions`:``}function kW(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:_p(Number(t)-n,{rounding:`floor`,wording:`spelled`,suffix:` ago`,justNowBelowSeconds:60})}function AW(e,t=Date.now()){let n=OW(e);if(!n)return``;let r=typeof e?.id==`string`&&e.id?`thread ${e.id}, `:``,i=kW(e?.ts,t);return i?`${r}${n}, ${i}`:`${r}${n}`}function jW(e){let t=Number(e?.range?.start?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function MW(e){let t=Number(e?.range?.start?.character);return Number.isFinite(t)?t:0}function NW(e){let t=Number(e?.range?.start?.line);return Number.isFinite(t)?t:0}function PW(e){let t=typeof e==`string`?e:``;if(!t)return``;let n=t.lastIndexOf(`/`),r=n===-1?t:t.slice(n+1);if(!r)return t;try{return decodeURIComponent(r)}catch{return r}}function FW(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(Math.floor(e),0):0}function IW(e){let t=FW(e);return t===1?`1 finding`:`${t} findings`}function LW(e){let t=FW(e);return t===1?`1 comment`:`${t} comments`}function RW(e){let t=FW(e?.findings?.length),n=FW(e?.comments?.length),r=typeof e?.hand==`string`&&e.hand?1:0,i=[];return r>0&&i.push(`raised hand`),t>0&&i.push(IW(t)),n>0&&i.push(LW(n)),i.length>0?i.join(`, `):IW(0)}function zW(e){let t=typeof e==`string`?e.trim():``;return t?`Raised hand: ${t}`:``}function BW(e){return(typeof e?.hand==`string`?e.hand.trim():``)||null}function VW(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=BW(t);return i?(n.set(r,i),n):(n.delete(r),n)}function HW(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=typeof e?.hand==`string`?e.hand.trim():``;n&&r&&t.set(n,r)}return t}var UW=`hand`,WW=`unseen`,GW=`
|
|
246
|
-
`;function KW(e){let t=2166136261,n=3266489909;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2246822507)>>>0}return`${t.toString(36).padStart(7,`0`)}${n.toString(36).padStart(7,`0`)}`}function qW(e,t){return KW(JSON.stringify([e,...t]))}function JW(e,t){return qW(`finding`,[e,jW(t),String(t.code??``),String(t.message??``)])}function YW(e,t){return qW(`comment`,[e,eG(t),String(t.message??``)])}function XW(e){return qW(`fix`,[e.uri,dG(e),e.code,e.message,fG(e)])}function ZW(e){return qW(`intent`,[e.key,e.text,e.active])}function QW(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>qW(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(qW(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(JW(t,e));for(let[e,n]of t)for(let t of n)o.add(YW(e,t));for(let e of r)o.add(XW(e));for(let e of DW(i,null,0))e.hasText&&o.add(ZW(e));let s=[...o].sort();return{signature:[...a,...s].join(GW),handEntries:a,contentEntries:s}}function $W(e,t){let n=new Set(t.split(GW));return e.handEntries.some(e=>!n.has(e))?UW:e.contentEntries.some(e=>!n.has(e))?WW:null}function eG(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function tG(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function nG(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=tG(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function rG(e){return Array.isArray(e?.comments)?e.comments:[]}function iG(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=rG(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function aG(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.diagnostics)?e.diagnostics:[];n&&r.length!==0&&t.set(n,r)}return t}function oG(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.comments)?e.comments:[];n&&r.length!==0&&t.set(n,r)}return t}function sG(e,t=new Map,n=new Map){let r=[],i=new Set([...e.keys(),...t.keys(),...n.keys()]);for(let a of i){let i=e.get(a),o=t.get(a),s=n.get(a)||null,c=Array.isArray(i)?i:[],l=Array.isArray(o)?o:[];(c.length!==0||l.length!==0||s)&&r.push({uri:a,name:PW(a)||a,hand:s,findings:[...c].sort((e,t)=>NW(e)-NW(t)||MW(e)-MW(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>cG(e.name,t.name)||cG(e.uri,t.uri)),r}function cG(e,t){return e<t?-1:+(e>t)}var lG=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`;function uG(e){let t=FW(e);return t===1?`1 fix`:`${t} fixes`}function dG(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function fG(e){return e?.applied===!0?`applied`:`refused`}function pG(e,{uri:t=``,ts:n=0}={}){if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.message==`string`?r.message.trim():``;if(!i)return null;let a=Number(r.line),o=Number(r.ts??n);return{uri:typeof r.uri==`string`&&r.uri?r.uri:t,code:typeof r.code==`string`?r.code:``,line:Number.isFinite(a)&&a>0?Math.floor(a):0,message:i,applied:r.applied===!0,ts:Number.isFinite(o)&&o>0?o:0}}function mG(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return pG(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function hG(e,t,{max:n=20}={}){let r=mG(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function gG(e,{max:t=20}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=pG(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var _G=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,vG={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function yG(e){let t=typeof e==`string`?e:``;return vG[t]||t||`source`}function bG(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:_p(Number(t)-n,pp)}function xG(e){if(!e||typeof e!=`object`)return null;let t=e,n=Number(t.seq);if(!Number.isFinite(n))return null;let r=typeof t.summary==`string`?t.summary.trim():``;if(!r)return null;let i=Number(t.ts),a=t.scope&&typeof t.scope==`object`?t.scope:{};return{seq:Math.floor(n),source:typeof t.source==`string`?t.source:``,kind:typeof t.kind==`string`?t.kind:``,ts:Number.isFinite(i)&&i>0?i:0,summary:r,root:typeof a.root==`string`&&a.root?a.root:null,sessionId:typeof a.sessionId==`string`&&a.sessionId?a.sessionId:null}}function SG(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=xG(e);t&&n.push(t)}return n}function CG(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function wG(e){let t=FW(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function TG(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function EG(e,t,{max:n=100}={}){let r=SG(t);if(r.length===0)return TG(e,n);let i=new Map;for(let t of e)i.set(t.seq,t);for(let e of r)i.set(e.seq,e);return TG([...i.values()],n)}function DG(e,{max:t=100}={}){return TG(SG(e),t)}function OG(e){let t=FW(e);return t===1?`1 event`:`${t} events`}function kG(e){if(!e?.root)return`machine`;let t=e.root.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var AG=new Map,jG=new Map,MG=new Map,NG=yW(),PG=new Map,FG=null,IG=null,LG=null,RG=null,zG=null,BG=[],VG=0,HG=null,UG=[],WG=null,GG=QW(AG,jG,MG,UG,NG),KG=Tk(),qG=AA({getAck:()=>KG,setAck:e=>{KG=e,Ek(e)},signature:()=>GG.signature,isLooking:()=>!Ef(FG)});function JG(){let e=V(`section`,`visions-intent`);e.append(V(`h2`,`visions-intent-title`,`Intent`));let t=V(`div`,`visions-intent-list`);return e.append(t),LG={list:t},e}function YG(e){let t=V(`div`,`visions-intent-item`),n=V(`div`,`visions-intent-head`);n.append(V(`span`,`visions-intent-scope`,e.label),V(`span`,`visions-intent-meta`,e.meta));let r=V(`p`,`visions-intent-text`,e.text);return r.classList.toggle(`visions-intent-none`,!e.hasText),t.classList.toggle(`visions-intent-active`,e.active===!0),t.append(n,r),t}function XG(){LG&&LG.list.replaceChildren(...DW(NG,PG).map(YG))}function ZG(e){PG=e instanceof Map?e:new Map,XG()}function QG(e){let t=V(`section`,`visions-doc`),n=V(`div`,`visions-doc-head`),r=V(`h2`,`visions-doc-name`);if(r.textContent=e.name,r.title=e.uri,n.append(r,V(`span`,`visions-doc-count`,RW(e))),t.append(n),e.hand&&t.append($G(e.hand)),e.findings.length>0){let n=V(`div`,`visions-findings`);for(let t of e.findings)n.append(tK(t));t.append(n)}if(e.comments.length>0){let n=V(`div`,`visions-comments`);for(let t of e.comments)n.append(eK(t));t.append(n)}return t}function $G(e){let t=V(`div`,`visions-hand`);return t.textContent=zW(e),t}function eK(e){let t=V(`div`,`visions-comment`),n=V(`div`,`visions-comment-head`);n.append(V(`span`,`visions-comment-chip`,`visions`)),n.append(V(`span`,`visions-comment-line`,eG(e))),t.append(n);let r=V(`p`,`visions-comment-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function tK(e){let t=V(`div`,`visions-finding`);t.append(V(`span`,`visions-finding-line`,jW(e)));let n=e?.code==null?``:String(e.code);n&&t.append(V(`span`,`visions-finding-code`,n));let r=V(`span`,`visions-finding-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function nK({force:e=!1}={}){if(!IG||!e&&Ef(FG))return;IG.textContent=``;let t=sG(AG,jG,MG);if(t.length===0){let e=V(`p`,`visions-empty`,hW);if(zG===!1){let t=pW(`lanes-visions`,`visions-enabled`,`Enable Visions`);e.append(document.createTextNode(` `),t)}IG.append(e);return}for(let e of t)IG.append(QG(e))}function rK(e){zG=e?.visions?.enabled===!0,nK()}function iK(){let e=V(`section`,`visions-activity`),t=V(`div`,`visions-activity-head`);t.append(V(`h2`,`visions-activity-title`,`Activity`));let n=V(`span`,`visions-activity-count`);t.append(n),e.append(t);let r=V(`div`,`visions-activity-list`);e.append(r);let i=V(`p`,`visions-activity-overflow`);return e.append(i),HG={count:n,list:r,overflow:i},e}function aK(e,t){let n=V(`div`,`visions-activity-row`);n.append(V(`span`,`visions-activity-source`,yG(e.source))),n.append(V(`span`,`visions-activity-age`,bG(e.ts,t))),n.append(V(`span`,`visions-activity-scope`,kG(e)));let r=V(`span`,`visions-activity-summary`);return r.textContent=e.summary,n.append(r),n}function oK({force:e=!1}={}){if(!HG||!e&&Ef(FG))return;let{count:t,list:n,overflow:r}=HG;if(t.textContent=OG(BG.length),n.textContent=``,BG.length===0){n.append(V(`p`,`visions-empty`,_G)),r.textContent=``;return}let i=Date.now();for(let e of BG)n.append(aK(e,i));r.textContent=wG(VG)}function sK(){let e=V(`section`,`visions-fixes`),t=V(`div`,`visions-fixes-head`);t.append(V(`h2`,`visions-fixes-title`,`Fixes`));let n=V(`span`,`visions-fixes-count`);t.append(n),e.append(t);let r=V(`div`,`visions-fixes-list`);return e.append(r),WG={count:n,list:r},e}function cK(e){let t=V(`div`,`visions-fix-row`);t.dataset.applied=e.applied?`yes`:`no`;let n=V(`span`,`visions-fix-file`);n.textContent=PW(e.uri)||e.uri,n.title=e.uri,t.append(n),t.append(V(`span`,`visions-fix-line`,dG(e))),t.append(V(`span`,`visions-fix-outcome`,fG(e))),t.append(V(`span`,`visions-fix-code`,e.code||``));let r=V(`span`,`visions-fix-message`);return r.textContent=e.message,t.append(r),t}function lK({force:e=!1}={}){if(!WG||!e&&Ef(FG))return;let{count:t,list:n}=WG;if(t.textContent=uG(UG.length),n.textContent=``,UG.length===0){n.append(V(`p`,`visions-empty`,lG));return}for(let e of UG)n.append(cK(e))}function uK(){GG=QW(AG,jG,MG,UG,NG),GG.signature!==``&&qG.refresh(),RG&&RG($W(GG,KG))}function dK(e){RG=e,uK()}function fK(e){if(FG)return FG;let t=V(`div`,`visions-content`);t.append(JG());let n=V(`div`,`visions-feed`);return t.append(n),t.append(sK()),t.append(iK()),e.appendChild(t),FG=t,IG=n,XG(),nK({force:!0}),lK({force:!0}),oK({force:!0}),t}function pK(){XG(),nK({force:!0}),lK({force:!0}),oK({force:!0})}function mK(){GG.signature!==``&&qG.acknowledge(),uK()}function hK(e){UG=hG(UG,e),lK(),uK()}function gK(e){AG=nG(AG,e),nK(),uK()}function _K(e){jG=iG(jG,e),nK(),uK()}function vK(e){MG=VW(MG,e),nK(),uK()}function yK(e){NG=wW(NG,e),XG(),uK()}function bK(e){BG=EG(BG,e),VG=CG(e),oK(),uK()}function xK(e){BG=DG(e),VG=0,oK(),uK()}function SK(e){AG=aG(e),jG=oG(e),MG=HW(e),NG=SW(e),UG=gG(e),XG(),nK(),lK(),uK()}var CK=Ps(D(),xs());j({glimmervoidId:D().min(1),event:D().min(1),token:D().nullable().optional(),payload:CK}),j({id:D().min(1),name:D().min(1),event:D().min(1),matcher:D().optional(),type:N([`command`,`http`]),command:D().optional(),url:D().optional(),timeout:O().int().positive().optional(),enabled:k(),projects:A(D()).optional()}).passthrough();var wK=`Claude Code hooks injected into every session Glimmervoid spawns.`,TK=`Loading hooks`,EK=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,DK=`Start from`,OK=`Filter by name, event or command`,kK=`Nothing matches that filter.`,AK=`Preview`,jK=`The entry this becomes in the per-session settings file.`,MK=`Duplicate`,NK=`Discard changes`,PK=`Close the editor and lose the unsaved changes?`,FK=`Esc cancels. Ctrl+Enter saves.`,IK=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,LK=`Glimmervoid's own hooks`,RK=`Always present, read-only. Status detection depends on them.`,zK=`Your hooks`,BK=`New hook`,VK=`Edit hook`,HK=`Saved to config.json.`,UK=`All projects`,WK=`This event takes no matcher.`,GK=`Blank uses Claude Code's default for the event.`,KK=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),qK=Object.freeze([{id:`lint`,label:`Lint after edits`,summary:`PostToolUse on Edit|Write`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,summary:`Stop, command`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,summary:`PreToolUse on Bash, exit 2 blocks`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,summary:`UserPromptSubmit, appends JSON`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),JK=Object.freeze({hooks:[],builtin:[],events:[]});function YK(e){return!e||typeof e.error==`string`}function XK(e){return!e||typeof e.error!=`string`?``:e.error}function ZK(e,t){let n=e?.[t];return Array.isArray(n)?n:JK[t]}var QK=e=>ZK(e,`hooks`),$K=e=>ZK(e,`builtin`),eq=e=>ZK(e,`events`);function tq(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function nq(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function rq(e){let t=QK(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String($K(e).length),tone:null}]}function iq(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function aq(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function oq(e){return e.length>=4}function sq(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.event===n.event){e.hooks.push(n);continue}t.push({event:n.event,hooks:[n]})}return t}function cq(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function lq(e){return`${e} copy`}function uq(e,t){return e.find(e=>e.name===t)||null}function dq(e,t){let n=uq(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:WK:``}function fq(e){return e.type===`http`?e.url||``:e.command||``}function pq(e){let t=KK.find(t=>t.value===e);return t?t.label:String(e||``)}function mq(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function hq(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?UK:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function gq(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function _q(e){return gq(e)}function vq(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function yq(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function bq(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function xq(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=uq(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function Sq(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function Cq(e,t){let n={...yq(t),...e.draft};return uq(t,n.event)||(n.event=yq(t).event),n}function wq(e,t){return JSON.stringify(Sq(e))!==JSON.stringify(t)}function Tq(e){return{...e,enabled:e.enabled===!1}}function Eq(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var Dq=null,Oq=null,kq=null,Aq=null,jq=null,Mq=null,Nq=null,Pq=null,Fq=!1,Iq=null,Lq=``,Rq=new Set,zq=new Set,Bq=!1,Vq=(e,t)=>Cf(`hooks`,e,t);function Hq(e,t,n){let r=V(`p`,e,t);return n&&(r.dataset.tone=n),r}function Uq(e,t,n,r){let i=V(`button`,e,t);return i.type=`button`,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}function Wq(e){if(!kq)return null;let t=af(`hooks`);return kq({requestId:t,...e}),t}function Gq(e,t,n){let r=V(`label`,`hooks-field`);return r.append(V(`span`,`hooks-field-label`,e),t),n&&r.append(V(`span`,`hooks-field-hint`,n)),r}function Kq(e,t,n){let r=V(`input`,`settings-view-input`);return r.type=`text`,r.value=e,r.autocomplete=`off`,r.spellcheck=!1,t&&(r.placeholder=t),r.addEventListener(`input`,()=>n(r.value)),r}function qq(e,t){let n=V(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function Jq(e,t,n){let r=V(`select`,`settings-view-input hooks-select`);for(let n of t){let t=V(`option`,null,n.name);t.value=n.name,t.title=n.description,n.name===e.event&&(t.selected=!0),r.append(t)}return r.addEventListener(`change`,()=>n(r.value)),r}function Yq(e,t){let n=V(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of KK){let i=V(`label`,`settings-view-toggle hooks-choice`),a=V(`input`,`settings-view-checkbox`);a.type=`radio`,a.name=`hooks-type`,a.value=r.value,a.checked=e.type===r.value,a.title=r.hint,a.addEventListener(`change`,()=>{a.checked&&t(r.value)}),i.append(a,V(`span`,null,r.label)),n.append(i)}return n}function Xq(e,t){let n=V(`div`,`hooks-projects`);if(t.length===0)return n.append(V(`span`,`hooks-field-hint`,UK)),n;let r=V(`label`,`settings-view-project-choice hooks-choice`),i=V(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,V(`span`,null,UK)),n.append(r);let a=[];for(let r of t){let t=V(`label`,`settings-view-project-choice hooks-choice`),o=V(`input`,`settings-view-checkbox`);o.type=`checkbox`,o.value=r.id,o.checked=e.projects.includes(r.id),o.addEventListener(`change`,()=>{e.projects=a.filter(e=>e.checked).map(e=>e.value),i.checked=e.projects.length===0}),a.push(o),t.append(o,V(`span`,null,r.name)),r.agent!==`claude-code`&&(t.append(V(`span`,`hooks-choice-note`,r.agent)),t.title=`Not a Claude Code project: this hook will not reach its sessions.`),n.append(t)}return i.addEventListener(`change`,()=>{if(!i.checked){i.checked=e.projects.length===0;return}for(let e of a)e.checked=!1;e.projects=[]}),n}function Zq(e){let t=V(`div`,`hooks-templates`);t.append(V(`span`,`hooks-templates-label`,DK));for(let n of qK){let r=Uq(`hooks-chip`,n.label,()=>eJ(null,Cq(n,e)));r.title=n.summary,t.append(r)}return t}function Qq(e){Pq&&(Pq.textContent=e||``,Pq.hidden=!e)}function $q(e){let t=eq(Dq),n=Tf(Dq),r=Vq(e.id?VK:BK,HK);r.classList.add(`hooks-editor`);let i=V(`form`,`hooks-form`);i.addEventListener(`submit`,e=>{e.preventDefault(),rJ()}),i.addEventListener(`keydown`,e=>{if(e.key===`Escape`){e.preventDefault(),nJ();return}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),rJ())}),e.id||i.append(Zq(t));let a=V(`span`,`hooks-field-hint`,dq(t,e.event)),o=Kq(e.matcher,``,t=>{e.matcher=t}),s=Gq(`Command`,qq(e.command,t=>{e.command=t}),`Runs through the shell with the event JSON on stdin. Exit 2 blocks the action where the event allows it.`),c=Gq(`URL`,Kq(e.url,`http://127.0.0.1:8080/hook`,t=>{e.url=t}),`Claude Code POSTs the event JSON to it.`),l=()=>{s.hidden=e.type!==`command`,c.hidden=e.type!==`http`};l();let u=Gq(`Matcher`,o,null);u.append(a);let d=()=>{let n=t.find(t=>t.name===e.event);a.textContent=dq(t,e.event),o.disabled=!!n&&!n.matcher,o.disabled&&(o.value=``,e.matcher=``)};d();let f=V(`input`,`settings-view-input hooks-timeout`);f.type=`number`,f.inputMode=`numeric`,f.min=`1`,f.max=String(tq(Dq)),f.value=e.timeout,f.addEventListener(`input`,()=>{e.timeout=f.value});let p=V(`label`,`settings-view-toggle hooks-choice`),m=V(`input`,`settings-view-checkbox`);m.type=`checkbox`,m.checked=e.enabled,m.addEventListener(`change`,()=>{e.enabled=m.checked}),p.append(m,V(`span`,null,`Enabled`)),i.append(Gq(`Name`,Kq(e.name,`Lint after edits`,t=>{e.name=t}),null),Gq(`Event`,Jq(e,t,t=>{e.event=t,d()}),null),u,Gq(`Type`,Yq(e,t=>{e.type=t,l()}),null),s,c,Gq(`Timeout (seconds)`,f,GK),Gq(`Projects`,Xq(e,n),null),Gq(``,p,null)),Pq=V(`p`,`hooks-editor-error`),Pq.setAttribute(`role`,`alert`),Pq.hidden=!0;let h=V(`div`,`hooks-editor-footer`),g=V(`span`,`hooks-editor-shortcut`,FK),_=Uq(`btn-dialog btn-dialog-cancel`,`Cancel`,nJ),v=V(`button`,`btn-dialog btn-dialog-confirm`,e.id?`Save changes`:`Add hook`);return v.type=`submit`,h.append(Pq,g,_,v),i.append(h),r.append(i),r}function eJ(e,t=null){jq=t||(e?bq(e):yq(eq(Dq))),Mq=Sq(e?bq(e):yq(eq(Dq))),Nq=$q(jq),mJ({force:!0}),Nq.scrollIntoView({block:`nearest`});let n=Nq.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function tJ(){jq=null,Mq=null,Nq=null,Pq=null,Fq=!1,Iq=null,Bq=!0,mJ({force:!0})}function nJ(){if(!jq||!Mq||!wq(jq,Mq)){tJ();return}tp({title:NK,message:PK,confirmLabel:`Discard`,danger:!0,onConfirm:tJ})}function rJ(){if(!jq||Fq)return;let e=xq(jq,eq(Dq),tq(Dq));if(e){Qq(e);return}Fq=!0,Qq(``),Iq=Wq({type:`save-hook`,hook:Sq(jq)}),Iq||(Fq=!1)}function iJ(e){let t=V(`details`,`hooks-preview`);t.open=Rq.has(e.id),t.addEventListener(`toggle`,()=>{if(t.open){Rq.add(e.id);return}Rq.delete(e.id)});let n=V(`summary`,`hooks-preview-summary`,AK);n.title=jK;let r=V(`pre`,`hooks-preview-code`,cq(e));return t.append(n,r),t}function aJ(e,{grouped:t=!1}={}){let n=Tf(Dq),r=V(`article`,`hooks-row`);r.setAttribute(`aria-label`,e.name),e.enabled===!1&&(r.dataset.state=`off`);let i=V(`div`,`hooks-row-main`),a=V(`div`,`hooks-row-head`);a.append(V(`span`,`hooks-row-name`,e.name));let o=t?e.matcher||``:gq(e);o&&a.append(V(`span`,`hooks-row-event`,o));let s=V(`code`,`hooks-row-target`,fq(e));s.title=fq(e);let c=V(`p`,`hooks-row-meta`,[pq(e.type),mq(e),hq(e,n)].filter(Boolean).join(` / `));i.append(a,s,c);let l=vq(e,n);l.length>0&&i.append(Hq(`hooks-row-meta`,`Scoped to a project no longer in config: ${l.join(`, `)}`,`warn`)),i.append(iJ(e));let u=V(`div`,`hooks-row-actions`),d=V(`label`,`settings-view-toggle hooks-choice`),f=V(`input`,`settings-view-checkbox`);f.type=`checkbox`,f.checked=e.enabled!==!1,f.disabled=zq.has(e.id),f.setAttribute(`aria-label`,`${e.name} enabled`),f.addEventListener(`change`,()=>{zq.add(e.id),f.disabled=!0,Wq({type:`save-hook`,hook:Tq(e)})}),d.append(f,V(`span`,null,`On`));let p=Uq(`hooks-btn`,`Edit`,()=>eJ(e),`Edit ${e.name}`),m=Uq(`hooks-btn`,MK,()=>{let t=bq({...e,name:lq(e.name)});t.id=null,eJ(null,t)},`Duplicate ${e.name}`),h=Uq(`hooks-btn hooks-btn-danger`,`Delete`,()=>{tp({title:`Delete hook`,message:Eq(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{zq.add(e.id),Wq({type:`delete-hook`,id:e.id}),mJ({force:!0})}})},`Delete ${e.name}`);return h.disabled=zq.has(e.id),u.append(d,p,m,h),r.append(i,u),r}function oJ(e){let t=V(`article`,`hooks-row hooks-row-builtin`),n=V(`div`,`hooks-row-main`);return n.append(V(`span`,`hooks-row-event`,_q(e)),V(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function sJ(){let e=Vq(`Hooks`,wK),t=V(`div`,`hooks-stats`);for(let e of rq(Dq))t.append(wf(`hooks`,e.label,e.value,e.tone));return e.append(t,Hq(`hooks-meta`,IK)),e}function cJ(){let e=V(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=Lq,e.placeholder=OK,e.setAttribute(`aria-label`,OK),e.addEventListener(`input`,()=>{Lq=e.value;let t=Oq?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(uJ())}),e}function lJ(){let e=V(`div`,`hooks-empty-state`);return e.append(Hq(`hooks-empty`,EK),Zq(eq(Dq))),e}function uJ(){let e=V(`div`,`hooks-list-yours`),t=QK(Dq);if(t.length===0)return e.append(lJ()),e;let n=aq(iq(t,eq(Dq)),Lq);if(n.length===0)return e.append(Hq(`hooks-empty`,kK)),e;for(let t of sq(n)){let n=V(`div`,`hooks-group`);n.append(V(`h3`,`hooks-group-title`,t.event));let r=V(`div`,`hooks-list`);for(let e of t.hooks)r.append(aJ(e,{grouped:!0}));n.append(r),e.append(n)}return e}function dJ(){let e=Vq(zK,null),t=Uq(`hooks-btn hooks-btn-add`,`+ New hook`,()=>eJ(null));t.disabled=!!jq;let n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),oq(QK(Dq))&&e.append(cJ()),e.append(uJ()),e}function fJ(){let e=V(`details`,`hooks-builtin`),t=V(`summary`,`hooks-builtin-summary`);t.append(V(`span`,`hooks-section-title`,`${LK} (${$K(Dq).length})`),V(`span`,`hooks-section-hint`,RK));let n=V(`div`,`hooks-list`);for(let e of $K(Dq))n.append(oJ(e));return e.append(t,n),e}function pJ(){let e=V(`div`,`hooks-content`);return Dq?YK(Dq)?(e.append(Hq(`hooks-warning`,XK(Dq))),e):(e.append(sJ()),Nq&&e.append(Nq),e.append(dJ(),fJ()),e):(e.append(Hq(`hooks-empty`,TK)),e)}function mJ({force:e=!1}={}){if(!Oq||!e&&Ef(Oq)||(Oq.replaceChildren(pJ()),!Bq))return;Bq=!1;let t=Oq.querySelector(`.hooks-btn-add`);t instanceof HTMLButtonElement&&t.focus()}function hJ(e){kq=e}function gJ(){kq&&(Aq=af(`hooks-report`),kq({type:`request-hooks-report`,requestId:Aq}))}function _J(e){Oq||(Oq=V(`div`,`hooks-panel`),e.append(Oq),mJ({force:!0}))}function vJ(){mJ({force:!0})}function yJ(e){nq(e,Aq)&&(Dq=e,zq.clear(),Fq=!1,mJ())}function bJ(e){let t=Iq!==null&&e.requestId===Iq;if(t&&(Iq=null,Fq=!1),e.ok){t&&tJ(),gJ();return}let n=typeof e.error==`string`&&e.error?e.error:`Could not save the hook`;if(t){Qq(n);return}WS(n,{persist:!0}),gJ()}function xJ(e){e.ok||WS(typeof e.error==`string`&&e.error?e.error:`Could not delete the hook`,{persist:!0}),gJ()}function SJ(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:!0}}var CJ=4e3;function wJ(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function TJ(e,t,n,r=CJ){try{let i=e.getItem(t);if(i){let e=Number(i);if(Number.isFinite(e)&&n-e<r)return!1}return e.setItem(t,String(n)),!0}catch{return!0}}function EJ(){return typeof Notification>`u`?null:Notification}function DJ(){return EJ()!==null}function OJ(){let e=EJ();return e?e.permission:`unavailable`}async function kJ(){let e=EJ();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function AJ(){let e=EJ();e&&VO()&&e.permission==="default"&&kJ()}function jJ({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=EJ();if(a&&VO()&&a.permission===`granted`&&(i||typeof document>`u`||typeof document.hasFocus!=`function`||!document.hasFocus())&&TJ(window.localStorage,wJ(e,t),Date.now()))try{let i=new a(`Glimmervoid`,SJ(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&typeof e==`string`&&(window.location.hash=BL(e)),i.close()}}catch{}}function MJ(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>{let t=e.label.trim();return{id:e.view,label:t,glyph:e.glyph||t.charAt(0).toUpperCase(),el:e.el}})}var NJ=[{name:`glimmervoid`,state:F.RUNNING,awaitingBackgroundTasks:!1},{name:`glimmervoid (2)`,state:F.RUNNING,awaitingBackgroundTasks:!0},{name:`api`,state:F.WAITING,awaitingBackgroundTasks:!1},{name:`docs-site`,state:F.IDLE,awaitingBackgroundTasks:!1}];function PJ(){let e=V(`div`,`compact-status-preview`);e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,`Example sidebar sessions showing how status appears with this setting`);for(let t of NJ){let{pill:n,refs:r}=iU(`div`,`focus-pill compact-status-preview-pill`);r.name.textContent=t.name,aU(n,r,t.state,t.awaitingBackgroundTasks),e.append(n)}return e}var FJ=null,IJ=null,LJ=null,RJ=null,zJ=-1,BJ=null,VJ=1;function HJ(){if(!FJ||BJ===null)return;let e=bO({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:BJ});mf(FJ,xO(e,VJ))}function UJ(){RJ!==null&&(clearTimeout(RJ),RJ=null)}function WJ(e=YO()){return fO({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:Wf(),options:Rk()})}function GJ(e,t){if(!FJ||!IJ||!LJ||WJ())return;let n=Rk();UJ();let r=dO(n,zJ,Math.random,t);if(FJ.onanimationend=null,FJ.style.animation=`none`,!r){RJ=setTimeout(()=>GJ(!1),1e3);return}BJ=r.verticalProgress,VJ=n.flyingAnimalsScale,HJ();let i=iO[r.animalIndex];IJ.className=`nyan-sprite ${i.sprite}`,LJ.className=`nyan-trail ${i.trail}`,zJ=r.animalIndex,FJ.offsetWidth,FJ.style.animation=`nyan-fly ${r.durationSeconds}s linear`,e&&(FJ.style.animationDelay=`-${r.firstDelaySeconds}s`),FJ.onanimationend=e=>{FJ&&e.target===FJ&&(FJ.onanimationend=null,FJ.style.animation=`none`,RJ=setTimeout(()=>GJ(!1),r.gapMs))}}function KJ(){FJ||WJ()||(FJ=document.createElement(`div`),FJ.className=`nyan-flight`,FJ.setAttribute(`aria-hidden`,`true`),LJ=document.createElement(`div`),IJ=document.createElement(`div`),FJ.append(LJ,IJ),document.body.appendChild(FJ),window.addEventListener(`resize`,HJ),window.addEventListener(`orientationchange`,HJ),GJ(!0))}function qJ(e){KJ(),GJ(!1,e)}function JJ(){UJ(),window.removeEventListener(`resize`,HJ),window.removeEventListener(`orientationchange`,HJ),FJ?.remove(),FJ=null,IJ=null,LJ=null,zJ=-1,BJ=null}var YJ=!1;function XJ(e){let t=document.documentElement;if(YJ||(YJ=!0,Gf(()=>XJ(YO())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>XJ(YO()))),e){if(t.dataset.flyingAnimals=`true`,WJ(e)){JJ();return}KJ();return}delete t.dataset.flyingAnimals,JJ()}function ZJ(){let e=V(`div`),t=V(`p`,`flying-animals-status`);t.id=`flying-animals-gallery-status`,t.setAttribute(`role`,`status`);let n=V(`div`,`flying-animals-gallery`);n.setAttribute(`aria-label`,`Animal gallery`);let r=[],i=()=>{let e=WJ(),n=lO(Rk().flyingAnimalsExcludedSprites);t.textContent=[e,n?``:`No animals are included, so automatic flights are paused.`].filter(Boolean).join(` `);for(let t of r)t.disabled=e!==null},a=Rk();for(let e of iO){let o=V(`article`,`flying-animal-tile`),s=Hk(e),c=V(`label`,`flying-animal-include`),l=V(`input`,`settings-view-checkbox`);l.type=`checkbox`,l.checked=!a.flyingAnimalsExcludedSprites.includes(e.sprite),l.setAttribute(`aria-label`,`Include ${e.name}`),l.addEventListener(`change`,()=>{let t=new Set(Rk().flyingAnimalsExcludedSprites);l.checked&&t.delete(e.sprite),l.checked||t.add(e.sprite),Lk([...t]),XJ(YO()),i()}),c.append(l,document.createTextNode(`Include`));let u=V(`button`,`btn-dialog btn-dialog-cancel`,`Fly now`);u.type=`button`,u.setAttribute(`aria-describedby`,t.id),u.addEventListener(`click`,()=>qJ(e.sprite)),r.push(u),o.append(s,V(`h2`,`flying-animal-name`,e.name),c,u),n.append(o)}return i(),e.append(t,n),e}var QJ=`johncwaters/glimmervoid`,$J=Object.freeze([`opened`,`checks-failed`,`review-requested`,`approved`,`commented`,`merged`]),eY=Object.freeze([`notify`,`spawn`,`label`,`comment`]),tY=2e4,nY=65536,rY=/^[a-z0-9][a-z0-9-]{0,63}$/,iY=/[\x00-\x1f\x7f,]|^-/,aY=(e,t)=>{let n=`${e} must be an integer between ${t.min} and ${t.max}`;return O({error:n}).int({error:n}).min(t.min,{error:n}).max(t.max,{error:n})},oY=k({error:`workflows.enabled must be a boolean`}),sY=aY(`workflows.maxConcurrentSessions`,tO),cY=aY(`workflows.maxActionsPerPoll`,nO),lY=(e,t)=>A(t,{error:`${e} must be an array`}).min(1,{error:`${e} must list at least one entry when present`}),uY=D({error:`a workflow label name must be a string`}).trim().min(1,{error:`a workflow label name must not be empty`}).max(50,{error:`a workflow label name must be at most 50 characters`}).refine(e=>!iY.test(e),{error:`a workflow label name must not start with a dash or hold a comma or control character`}),dY=D({error:`a workflow comment body must be a string`}).min(1,{error:`a workflow comment body must not be empty`}).max(nY,{error:`a workflow comment body must be at most ${nY} characters`}).refine(e=>e.trim().length>0,{error:`a workflow comment body must not be blank`}),fY=N($J,{error:`workflows.rules[].trigger must be one of ${$J.join(`, `)}`}),pY=As(`type`,[M({type:P(`notify`)}),M({type:P(`spawn`),promptTemplate:D({error:`a spawn action needs a promptTemplate string`}).min(1,{error:`a spawn action promptTemplate must not be empty`}).max(tY,{error:`a spawn action promptTemplate must be at most ${tY} characters`}).refine(e=>e.trim().length>0,{error:`a spawn action promptTemplate must not be blank`})}),M({type:P(`label`),name:uY}),M({type:P(`comment`),body:dY})],{error:`workflows.rules[].actions[].type must be one of ${eY.join(`, `)}`}),mY=M({mine:k({error:`workflows.rules[].filters.mine must be a boolean`}).optional(),teamReviewRequested:k({error:`workflows.rules[].filters.teamReviewRequested must be a boolean`}).optional(),authors:lY(`workflows.rules[].filters.authors`,D({error:`workflows.rules[].filters.authors must hold GitHub logins`}).regex(dc,{error:`workflows.rules[].filters.authors must hold GitHub logins`})).optional(),labels:lY(`workflows.rules[].filters.labels`,uY).optional(),baseBranches:lY(`workflows.rules[].filters.baseBranches`,D({error:`workflows.rules[].filters.baseBranches must hold branch names`}).min(1,{error:`workflows.rules[].filters.baseBranches must hold branch names`})).optional()},{error:`workflows.rules[].filters must be an object`}),hY=D({error:`workflows.rules[].id must be a string`}).regex(rY,{error:`workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit`}),gY=k({error:`workflows.rules[].enabled must be a boolean`}),_Y=M({id:hY,name:D({error:`workflows.rules[].name must be a string`}).trim().min(1,{error:`workflows.rules[].name must not be empty`}).max(80,{error:`workflows.rules[].name must be at most 80 characters`}),enabled:gY.default(!1),repos:lY(`workflows.rules[].repos`,hu),filters:mY.default({}),trigger:fY,actions:lY(`workflows.rules[].actions`,pY)},{error:`workflows.rules[] must be an object`}),vY=M({enabled:oY.default(!0),maxConcurrentSessions:sY.default(2),maxActionsPerPoll:cY.default(20),rules:A(_Y,{error:`workflows.rules must be an array`}).default([])},{error:`workflows must be an object`}).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.rules.entries()){if(!n.has(i.id)){n.add(i.id);continue}t.addIssue({code:`custom`,path:[`rules`,r,`id`],message:`workflows.rules[${r}].id "${i.id}" is declared more than once`})}}),yY=M({id:hY,enabled:gY},{error:`a dashboard update of workflows.rules[] carries only id and enabled`});M({enabled:oY.optional(),maxConcurrentSessions:sY.optional(),maxActionsPerPoll:cY.optional(),rules:A(yY,{error:`workflows.rules must be an array`}).optional()},{error:`a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles`});var bY=O().int().nonnegative(),xY=N([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable();Ru.extend({author:j({login:D()}).nullable(),labels:j({nodes:A(j({name:D()}))}),comments:j({totalCount:bY})});var SY=M({polledAtMs:bY,prs:A(M({repo:hu,number:O().int().positive(),title:D(),url:Zo(),author:D().nullable(),state:N([`OPEN`,`MERGED`,`CLOSED`]),createdAt:D(),mergedAt:D().nullable(),isDraft:k(),isCrossRepository:k(),baseRefName:D(),headRefName:D().min(1),headRefOid:I,labels:A(D()),commentCount:bY,reviewRequests:A(D()),checksState:xY,reviewDecision:N([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable()}))});M({repos:Ps(D().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/),SY)});var CY={maxConcurrentInvestigations:Math.ceil,minUsersToInvestigate:Math.ceil,userEscalationThreshold:Math.ceil,trafficSpikeMinUsers:Math.ceil,trafficSpikeBaselineDays:Math.floor};[...Object.entries(CY).map(([e,t])=>({path:[`posthog`,e],min:1,round:t}))];var wY=Object.freeze([`auto`,`calculate`,`display`]),TY=Object.freeze([`codex`,`grok`]),EY=Object.freeze([`dailyUsd`,`monthlyUsd`]),DY=e=>k({error:`${e} must be a boolean`}).optional(),OY=(e,t=!1)=>{let n=D({error:`${e} must be a string`});return(t?n.transform(e=>e.trim()):n).optional()},kY=e=>e.label?e.label:e.max==null?e.exclusiveMin?`greater than ${e.min}`:`at least ${e.min}`:`between ${e.min} and ${e.max}`,AY=(e,t=SD)=>O({error:`${e} must be ${kY(t)}`}).finite().refine(e=>!t.exclusiveMin||e>t.min,{message:`${e} must be ${kY(t)}`}).refine(e=>t.exclusiveMin||e>=t.min,{message:`${e} must be ${kY(t)}`}).refine(e=>t.max==null||e<=t.max,{message:`${e} must be ${kY(t)}`}).optional(),jY=(e,t)=>AY(e,t).unwrap().int({error:`${e} must be a whole number ${kY(t)}`}).optional(),MY=(e,t)=>O({error:`${e} must be an integer between ${t.min} and ${t.max}`}).int({error:`${e} must be an integer between ${t.min} and ${t.max}`}).min(t.min,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).max(t.max,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).optional(),NY=(e,t)=>j(t,{error:`${e} must be an object`}).nullable().optional(),PY=Object.freeze([`claude`,`codex`]),FY=Object.freeze([`release`,`main`]),IY=Object.freeze([`report`,`fix`]);NY(`changeMap`,{narrator:NY(`changeMap.narrator`,{enabled:DY(`changeMap.narrator.enabled`),engine:N(PY,{error:`changeMap.narrator.engine must be one of ${PY.join(`, `)}`}).optional(),model:OY(`changeMap.narrator.model`,!0),timeoutSeconds:MY(`changeMap.narrator.timeoutSeconds`,$D)})}),j({refiner:j({enabled:DY(`taskTitle.refiner.enabled`),model:OY(`taskTitle.refiner.model`,!0),minIntervalSeconds:AY(`taskTitle.refiner.minIntervalSeconds`,{min:0}),timeoutSeconds:AY(`taskTitle.refiner.timeoutSeconds`,{min:0,exclusiveMin:!0,max:2147483647/1e3})},{error:`taskTitle.refiner must be an object`}).nullable().optional()},{error:`taskTitle must be an object`}).nullable().optional();var LY={enabled:DY(`branchGc.enabled`),worktrees:DY(`branchGc.worktrees`),prefixes:A(D({error:`branchGc.prefixes must be an array of strings`}).min(1,{error:`branchGc.prefixes entries must be non-empty strings`}),{error:`branchGc.prefixes must be an array of strings`}).optional(),dryRun:DY(`branchGc.dryRun`),staleDays:AY(`branchGc.staleDays`,OD),deleteUnmerged:DY(`branchGc.deleteUnmerged`),intervalMs:AY(`branchGc.intervalMs`,kD)},RY=j(LY,{error:`branchGc must be an object`});NY(`branchGc`,LY),RY.omit({prefixes:!0,dryRun:!0,worktrees:!0}).nullable().optional(),Object.freeze([`enabled`,`deleteUnmerged`]),Object.freeze([`staleDays`,`intervalMs`]),NY(`postTurnChecks`,{mode:N(IY,{error:`postTurnChecks.mode must be one of report, fix`}).optional()}),NY(`visions`,{enabled:DY(`visions.enabled`),autoFix:DY(`visions.autoFix`),projects:A(D({error:`visions.projects must be an array of strings`}),{error:`visions.projects must be an array of strings`}).optional(),dispatch:NY(`visions.dispatch`,{enabled:DY(`visions.dispatch.enabled`),model:OY(`visions.dispatch.model`,!0),quietMs:jY(`visions.dispatch.quietMs`,AD),cooldownMs:jY(`visions.dispatch.cooldownMs`,jD),maxPerHour:jY(`visions.dispatch.maxPerHour`,MD),activityMaxPerHour:jY(`visions.dispatch.activityMaxPerHour`,ND),dispatchTimeoutSeconds:jY(`visions.dispatch.dispatchTimeoutSeconds`,PD)}),intent:NY(`visions.intent`,{threadTtlMs:jY(`visions.intent.threadTtlMs`,FD)})}),j({teams:A(D({error:`github.teams must be an array of org/slug strings`}).refine(e=>mc(e)!==null,{message:`github.teams entries must be org/slug with valid GitHub segments`}),{error:`github.teams must be an array of org/slug strings`}).optional()},{error:`github must be an object`}).nullable().optional(),NY(`teamReview`,{enabled:DY(`teamReview.enabled`),autoRebaseMyPrs:DY(`teamReview.autoRebaseMyPrs`),keepMergeableEnabled:DY(`teamReview.keepMergeableEnabled`),mergeQueueEnabled:DY(`teamReview.mergeQueueEnabled`),keepMergeableTimeoutMinutes:MY(`teamReview.keepMergeableTimeoutMinutes`,eO),org:OY(`teamReview.org`,!0),team:OY(`teamReview.team`,!0),skill:OY(`teamReview.skill`,!0),reReviewAfterHours:AY(`teamReview.reReviewAfterHours`),skipIdleAfterDays:AY(`teamReview.skipIdleAfterDays`)}),NY(`benchmarks`,{enabled:DY(`benchmarks.enabled`)}),j({enabled:DY(`factory.enabled`),maxRisk:Jc.optional(),maxLiveWorkers:O().int().min(xD.min).optional(),checks:A(D().trim().min(1)).optional(),protectedPaths:A(D().trim().min(1)).optional(),reviewerModel:D().trim().min(1).nullable().optional(),dailyBudgetUsd:O().finite().nonnegative().nullable().optional(),verifierModel:D().trim().min(1).nullable().optional(),mirrorHarnessRuns:DY(`factory.mirrorHarnessRuns`)}).nullable().optional(),NY(`knowledgeGraph`,{enabled:DY(`knowledgeGraph.enabled`)});var zY={intervalMinutes:ID,maxConcurrentInvestigations:LD,investigationTimeoutSeconds:RD,fixTimeoutSeconds:UD,minUsersToInvestigate:zD,userEscalationThreshold:BD,recurrenceWindowDays:VD,transientRecurrenceLimit:HD,trafficSpikeMultiplier:WD,trafficSpikeMinUsers:GD,trafficSpikeCooldownMinutes:KD,trafficSpikeBaselineDays:qD};NY(`posthog`,{enabled:DY(`posthog.enabled`),recurrenceDedupe:DY(`posthog.recurrenceDedupe`),trafficSpikeEnabled:DY(`posthog.trafficSpikeEnabled`),autoFix:DY(`posthog.autoFix`),host:OY(`posthog.host`,!0).refine(e=>e==null||!e||/^https?:\/\//i.test(e),{message:`posthog.host must be an http(s) URL`}),apiKey:OY(`posthog.apiKey`,!0),repoPath:OY(`posthog.repoPath`,!0),projects:Os([P(`all`),A(O({error:`posthog.projects must be "all" or an array of positive integer project ids`}).int({error:`posthog.projects must be "all" or an array of positive integer project ids`}).positive({error:`posthog.projects must be "all" or an array of positive integer project ids`}),{error:`posthog.projects must be "all" or an array of positive integer project ids`})],{error:`posthog.projects must be "all" or an array of positive integer project ids`}).optional(),projectMap:Ps(D(),xs(),{error:`posthog.projectMap must be an object`}).optional(),...Object.fromEntries(Object.entries(zY).map(([e,t])=>[e,Object.hasOwn(CY,e)?jY(`posthog.${e}`,t):AY(`posthog.${e}`,t)]))}),`${wY.join(`, `)}`,Object.fromEntries(TY.map(e=>[e,DY(`usage.vendors.${e}`)])),Object.fromEntries(EY.map(e=>[e,O({error:`usage.budget.${e} must be a positive number or null`}).positive({error:`usage.budget.${e} must be a positive number or null`}).nullable().optional()])),NY(`telegram`,{botToken:OY(`telegram.botToken`,!0),chatId:OY(`telegram.chatId`,!0)}),j({enabled:DY(`ingest.enabled`)},{error:`ingest must be an object`}).passthrough().optional(),j({enabled:DY(`trace.enabled`)},{error:`trace must be an object`}).optional(),j({enabled:DY(`planReview.enabled`)},{error:`planReview must be an object`}).optional();var BY={enabled:DY(`agentApi.enabled`)};j(BY,{error:`agentApi must be an object`}).strict().optional(),j(BY,{error:`agentApi must be an object`}).passthrough().optional();var VY=e=>A(D({error:`${e} must be an array of paths`}).trim().min(1,{error:`${e} must be an array of paths`}),{error:`${e} must be an array of paths`}).optional(),HY={unconfinedRepos:VY(`sandbox.unconfinedRepos`),writablePaths:VY(`sandbox.writablePaths`),unreadablePaths:VY(`sandbox.unreadablePaths`)};j(HY,{error:`sandbox must be an object`}).strict().optional(),j(HY,{error:`sandbox must be an object`}).passthrough().optional();var UY={enabled:DY(`telemetry.enabled`)};j(UY,{error:`telemetry must be an object`}).strict().optional(),j(UY,{error:`telemetry must be an object`}).passthrough().optional();function WY(e){return e.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))}var GY=Object.freeze({general:`machine-general`,updates:`machine-updates`,terminal:`machine-terminal`,repos:`machine-repositories`,repositories:`machine-repositories`,advanced:`machine-detection-sessions`,detection:`machine-detection-sessions`,telegram:`machine-telegram`,notifications:`machine-telegram`,"change-map":`lanes-change-map`,visions:`lanes-visions`,ingest:`lanes-ingest`,posthog:`lanes-posthog`,"team-review":`lanes-team-review`,reviews:`lanes-team-review`,benchmarks:`lanes-benchmarks`,factory:`lanes-factory`,"knowledge-graph":`lanes-knowledge-graph`,workflows:`lanes-workflows`,usage:`machine-usage`,privacy:`machine-privacy`,telemetry:`machine-privacy`,shortcuts:`browser-shortcuts`,animals:`browser-flying-animals`,"flying-animals":`browser-flying-animals`,unattended:`lanes-unattended`}),KY=Object.freeze({"browser-appearance":Object.freeze({"flying-animals":`browser-flying-animals`})}),qY=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance and alerts`,description:`Preferences stored only in this browser.`,settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`},{id:`compact-status`,path:`pref:compactStatusLabels`,title:`Hide status words in sidebar`,description:`Hide status words in the sidebar and on the phone Board while keeping the colored status mark and the phone Plan ready badge. Saved per browser, so turn it on in each one.`,control:`toggle`,keywords:[`sidebar`,`status`,`compact`],defaultValue:!1},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's transcript token count and CLI-reported cost when available, otherwise a calculated API list-price estimate.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1},{id:`alert-sounds-enabled`,path:`pref:soundEnabled`,title:`Alert sounds`,description:`Play sounds when a session needs attention and when a merge celebration plays. The same switch as the note button in the desktop header.`,control:`toggle`,keywords:[`audio`,`mute`,`sound`,`notification`],defaultValue:!0},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,description:`Sound played when a session needs attention. Your own .ogg, .mp3, .wav, .m4a or .webm files dropped into the sounds folder of the Glimmervoid home (~/.glimmervoid/sounds/, or $GLIMMERVOID_HOME/sounds/) are listed after the built-in sounds. Glimmervoid never creates that folder, so make it yourself; new files show up the next time Settings opens.`,control:`select`,optionsFrom:`sounds`,keywords:[`audio`,`notification`,`custom`],defaultValue:`chime`},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,description:`Raise a browser notification when a session needs attention while this dashboard is in the background.`,control:`toggle`,keywords:[`browser`,`attention`],defaultValue:!0}]},{id:`browser-flying-animals`,level:`browser`,title:`Flying animals`,description:`Choose your flying animals. Changes apply immediately in this browser.`,settings:[{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`],defaultValue:!1},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum (seconds)`,description:`Shortest pause between flights.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_GAP_RANGE`,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:aO.flyingAnimalsMinGapSeconds},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum (seconds)`,description:`Longest pause between flights.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_GAP_RANGE`,keywords:[`animals`,`frequency`],defaultValue:aO.flyingAnimalsMaxGapSeconds},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum (seconds)`,description:`Shortest flight, for faster animals.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_DURATION_RANGE`,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:aO.flyingAnimalsMinDurationSeconds},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum (seconds)`,description:`Longest flight, for slower animals.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_DURATION_RANGE`,keywords:[`animals`,`speed`],defaultValue:aO.flyingAnimalsMaxDurationSeconds},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_SCALE_RANGE`,keywords:[`animals`,`size`],defaultValue:aO.flyingAnimalsScale},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,advanced:!0,keywords:[`animals`,`mobile`],defaultValue:aO.flyingAnimalsOnPhone}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard reference and build information.`,settings:[]},{id:`machine-general`,level:`machine`,title:`General`,description:`Machine-wide session startup and diagnostics.`,settings:[{id:`auto-resume`,path:`autoResume`,title:`Auto-resume sessions on startup`,description:`Resume conversations that were live when Glimmervoid last shut down or crashed.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0},{id:`debug-mode`,path:`debugMode`,title:`Debug mode`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1},{id:`calm-layout`,path:`calmLayout`,title:`Calm layout (experimental)`,description:`Replace the Focus rail with a view that prioritizes sessions needing attention and also shows ready and working indicators. Applies to every browser on this machine.`,control:`toggle`,keywords:[`experimental`,`attention`,`priority`],defaultValue:!1}],unattendedLinks:[{settingId:`skip-permissions-by-default`,title:`Skip permission prompts by default`},{settingId:`rtk-compression`,title:`rtk output compression`}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,settings:[{id:`update-summary`,path:`status:update-summary`,title:`Status`,description:`Whether this install is up to date, and what an update would move it to.`,control:`readonly`,keywords:[`version`,`available`,`current`],status:`update-summary`},{id:`update-actions`,path:`status:update-actions`,title:`Actions`,description:`Update and restart stages the newest build, then restarts to run it. Update without restart stages it for a later restart.`,control:`readonly`,keywords:[`check`,`restart`],status:`update-actions`},{id:`update-installed`,path:`status:update-installed`,title:`Running version`,description:`The version loaded when the server started, alongside the commit, branch and state of the current disk checkout.`,control:`readonly`,keywords:[`version`,`commit`,`installed`],status:`update-installed`},{id:`update-latest`,path:`status:update-latest`,title:`Latest version`,description:`The newest target found on the selected update channel.`,control:`readonly`,keywords:[`release`,`commit`],status:`update-latest`},{id:`update-last-checked`,path:`status:update-last-checked`,title:`Last checked`,description:`The most recent update check, or why automatic checks are off.`,control:`readonly`,keywords:[`time`,`failure`],status:`update-last-checked`},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:WY(FY),keywords:[`release`,`branch`],defaultValue:`release`},{id:`check-updates`,path:`checkForUpdates`,title:`Check for updates automatically`,description:`Check for a newer Glimmervoid at launch, while a dashboard is connected, and when this page opens.`,control:`toggle`,keywords:[`release`,`github`],defaultValue:!0}]},{id:`machine-terminal`,level:`machine`,title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`,settings:[{id:`replay-buffer`,path:`replayBufferKB`,title:`Replay buffer (KB)`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:`REPLAY_BUFFER_KB_RANGE`,keywords:[`history`,`backfill`],defaultValue:512},{id:`cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1}]},{id:`machine-detection-sessions`,level:`machine`,title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`,settings:[{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,description:`Hold completion while tracked background work is active. Changes apply to newly created sessions; recreate existing sessions to apply them.`,control:`readonly`,keywords:[`subagents`,`completion`],fileOnly:!0},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,description:`Keep forensic status and hook recordings for newly created sessions. Full capture (capture.enabled) records these signals even when this is off. Recreate existing sessions to change recording.`,control:`readonly`,keywords:[`recordings`,`diagnostics`],fileOnly:!0},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,description:`Keep normalized Claude transcript traces for session debugging. Requires a server restart.`,control:`readonly`,keywords:[`transcripts`,`diagnostics`],fileOnly:!0},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,description:`Surface advisory wakeup timing for scheduled sessions. Requires a server restart to update the configuration, and newly created sessions use the change.`,control:`readonly`,keywords:[`schedule`,`sleep`],fileOnly:!0},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,description:`Rebase eligible session worktrees when the integration branch moves. Changes apply to newly created sessions; recreate existing sessions to apply them.`,control:`readonly`,keywords:[`git`,`branch`],fileOnly:!0},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,description:`Reuse recorded Git conflict resolutions. Requires a server restart.`,control:`readonly`,keywords:[`git`,`conflicts`],fileOnly:!0},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,description:`Base branch for session worktrees. Empty = each repo's default branch. Reload affects newly created sessions and does not retarget existing sessions.`,control:`readonly`,keywords:[`git`,`merge`],fileOnly:!0},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,description:`Directory that contains session worktrees. Changes apply to newly created sessions and do not relocate existing worktrees; recreate existing sessions to change where they create worktrees.`,control:`readonly`,keywords:[`git`,`directory`],fileOnly:!0},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,description:`Local paths copied or linked during worktree preparation. Changes apply to newly created sessions; recreate existing sessions to use a new share list.`,control:`readonly`,keywords:[`files`,`context`],fileOnly:!0},{id:`file-port`,path:`port`,title:`Local port`,description:`Port used by the local dashboard listener. Requires a server restart.`,control:`readonly`,keywords:[`server`,`listener`],fileOnly:!0},{id:`file-auto-recover-seconds`,path:`autoRecoverSeconds`,title:`Auto-recovery delay`,description:`Delay before an interrupted state can recover.`,control:`readonly`,keywords:[`timer`,`recovery`],fileOnly:!0},{id:`file-input-grace-seconds`,path:`inputGraceSeconds`,title:`Input grace period`,description:`Grace window around operator input.`,control:`readonly`,keywords:[`timer`,`prompt`],fileOnly:!0},{id:`file-prompt-detection-ms`,path:`promptDetectionMs`,title:`Prompt detection delay`,description:`Timing threshold used by prompt detection.`,control:`readonly`,keywords:[`timer`,`detection`],fileOnly:!0},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,description:`Delay used to coalesce notification state changes.`,control:`readonly`,keywords:[`timer`,`alerts`],fileOnly:!0},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,description:`Delay before off-dashboard escalation.`,control:`readonly`,keywords:[`timer`,`telegram`],fileOnly:!0},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,description:`Deterministic checks run after eligible turns. The global mode is a default; project and individual rule modes can select fixes even when the global mode is report.`,control:`readonly`,keywords:[`quality`,`fixes`],fileOnly:!0},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,description:`Enable cleanup of eligible session branches.`,control:`readonly`,keywords:[`git`,`cleanup`],fileOnly:!0},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,description:`Enable cleanup of eligible local worktrees.`,control:`readonly`,keywords:[`git`,`worktree`,`cleanup`],fileOnly:!0},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,description:`Branch prefixes that filter both remote branch cleanup and local worktree cleanup.`,control:`readonly`,keywords:[`git`,`branch`],fileOnly:!0},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,description:`Report planned cleanup without deleting remote branches.`,control:`readonly`,keywords:[`git`,`safety`],fileOnly:!0},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`readonly`,keywords:[`git`,`retention`],fileOnly:!0},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,description:`Delay between branch cleanup passes.`,control:`readonly`,keywords:[`git`,`schedule`],fileOnly:!0},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with.`,control:`readonly`,keywords:[`adapters`,`cli`],fileOnly:!0,status:`custom-agents`}]},{id:`machine-repositories`,level:`machine`,title:`Repositories`,description:`Project discovery roots for new sessions.`,settings:[{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[]}]},{id:`machine-telegram`,level:`machine`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot. When GLIMMERVOID_TELEGRAM_BOT_TOKEN supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Send session completion, input and failure alerts when no dashboard is open. Unacknowledged alerts also escalate after the phone escalation delay while a dashboard remains open.`,control:`toggle`,keywords:[`phone`,`off dashboard`],defaultValue:!1}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,settings:[{id:`usage-enabled`,path:`usage.enabled`,title:`Track token usage`,description:`Read local CLI transcripts and roll them into the Usage view and session chips.`,control:`toggle`,keywords:[`tokens`,`cost`],defaultValue:!0,status:`usage-last-report`},{id:`usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0},{id:`usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0},{id:`usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,description:`Load public model prices when usage tracking starts, using a cached table for up to one day. Falls back to cached or bundled prices if the fetch fails; no daily refresh runs while tracking continues.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0},{id:`usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval (minutes)`,description:`Periodic transcript polling interval. Session activity can also trigger scans between timer ticks.`,control:`number`,range:`USAGE_SCAN_INTERVAL_RANGE`,keywords:[`poll`,`refresh`],defaultValue:5},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail (days)`,description:`How long live transcript detail stays available. A monthly budget keeps detail from the start of the current month when that is longer.`,control:`number`,range:`USAGE_RETAIN_DAYS_RANGE`,keywords:[`history`,`retention`],defaultValue:90},{id:`usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:WY(wY),keywords:[`pricing`,`estimate`],defaultValue:`auto`},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget (USD)`,description:`Estimated daily spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:`USAGE_BUDGET_RANGE`,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget (USD)`,description:`Estimated monthly spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:`USAGE_BUDGET_RANGE`,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,settings:[{id:`telemetry-enabled`,path:`telemetry.enabled`,title:`Send anonymous usage and error data`,description:`Version, platform, app starts, daily activity, session starts and ends with agent kind, exit kind and duration, errors as their type, error code and scrubbed stack frames, per session token counts, models and estimated costs from the usage scan, and factory outcomes as the kind of decision, how it came out, its duration and attempt number, under a random install id. Never error messages, paths, repository or branch names, prompts, objectives or terminal output. GLIMMERVOID_TELEMETRY=0, DO_NOT_TRACK=1 or CI=true turn it off regardless.`,control:`toggle`,keywords:[`telemetry`,`analytics`,`tracking`,`opt out`],defaultValue:!0}]},{id:`lanes-change-map`,level:`lanes`,title:`Change map`,description:`Optional model narration for deterministic change facts.`,settings:[{id:`change-map-narrator-enabled`,path:`changeMap.narrator.enabled`,title:`Enable narration`,description:`Add cited model claims to the change map.`,control:`toggle`,keywords:[`review`,`claims`],defaultValue:!1},{id:`change-map-narrator-engine`,path:`changeMap.narrator.engine`,title:`Narrator engine`,description:`CLI used to generate change map claims.`,control:`select`,options:WY(PY),keywords:[`claude`,`codex`],defaultValue:`claude`},{id:`change-map-narrator-model`,path:`changeMap.narrator.model`,title:`Narrator model`,description:`Blank uses the engine default: haiku for Claude, the configured Codex model for Codex.`,control:`text`,keywords:[`claude`,`codex`,`haiku`],defaultValue:``},{id:`change-map-narrator-timeout`,path:`changeMap.narrator.timeoutSeconds`,title:`Narrator timeout (seconds)`,description:`Maximum time allowed for one narration.`,control:`number`,range:`CHANGE_MAP_NARRATOR_TIMEOUT_RANGE`,keywords:[`deadline`,`narration`],defaultValue:90}]},{id:`lanes-visions`,level:`lanes`,title:`Visions`,description:`Editor-buffer findings and bounded model comments.`,settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Set up supported editors detected on this machine, then show their buffer findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1},{id:`visions-dispatch-enabled`,path:`visions.dispatch.enabled`,title:`Enable model comments`,description:`Start bounded review sessions for local editor buffers.`,control:`toggle`,keywords:[`review`,`dispatch`],defaultValue:!1},{id:`visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay (ms)`,description:`Editor quiet time before a scheduled review. Saves and blank-line boundaries can dispatch immediately, subject to the other review limits.`,control:`number`,range:`VISIONS_QUIET_MS_RANGE`,keywords:[`debounce`,`idle`],defaultValue:3e4},{id:`visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown (ms)`,description:`Minimum delay between reviews of the same document. Initial orientation reviews bypass this delay.`,control:`number`,range:`VISIONS_COOLDOWN_MS_RANGE`,keywords:[`rate limit`,`delay`],defaultValue:3e5},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour.`,control:`number`,range:`VISIONS_MAX_PER_HOUR_RANGE`,keywords:[`rate limit`,`reviews`],defaultValue:6},{id:`visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,description:`Maximum activity-driven reviews dispatched per hour, capped at the overall hourly limit minus one to reserve an edit-review slot.`,control:`number`,range:`VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE`,status:`visions-activity-limit`,keywords:[`rate limit`,`events`],defaultValue:2},{id:`visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout (seconds)`,description:`Maximum time allowed for one review session.`,control:`number`,range:`VISIONS_DISPATCH_TIMEOUT_RANGE`,keywords:[`deadline`,`review`],defaultValue:180},{id:`visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime (ms)`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:`VISIONS_INTENT_THREAD_TTL_MS_RANGE`,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the opus model alias.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Clear every selection, including unavailable projects, to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[]},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit eligible open Markdown buffers, including inactive buffers, without asking.`,control:`toggle`,keywords:[`automatic`,`edits`],danger:!0,warning:`Enabling this control lets Visions edit eligible buffers without a carbon unit present.`,defaultValue:!1}]},{id:`lanes-ingest`,level:`lanes`,title:`Ingest`,description:`Machine-context ingest behind Visions.`,settings:[{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on enables ingest unless ingest.enabled is explicitly false.`,control:`toggle`,keywords:[`events`,`activity`],defaultValue:!1},{id:`ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1},{id:`ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1},{id:`ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1},{id:`ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1},{id:`ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1},{id:`ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1}]},{id:`lanes-posthog`,level:`lanes`,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,settings:[{id:`posthog-enabled`,path:`posthog.enabled`,title:`Enable PostHog monitoring`,description:`Poll PostHog error tracking and investigate issues that move.`,control:`toggle`,keywords:[`errors`,`monitoring`],defaultValue:!1},{id:`posthog-host`,path:`posthog.host`,title:`Host`,description:`PostHog cloud or self-hosted HTTP URL.`,control:`text`,keywords:[`url`,`server`],defaultValue:`https://us.posthog.com`},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects. When GLIMMERVOID_POSTHOG_API_KEY supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`Use all, none for an empty selection, or a comma-separated list of positive integer PostHog project ids. Blank means all.`,control:`text`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval (minutes)`,description:`Delay between PostHog polling passes.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`refresh`,`schedule`],defaultValue:15},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:`POSTHOG_MAX_CONCURRENT_RANGE`,keywords:[`parallel`,`workers`],defaultValue:2},{id:`posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout (seconds)`,description:`Maximum time allowed for one investigation.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_INVESTIGATION_TIMEOUT_RANGE`,keywords:[`deadline`,`session`],defaultValue:900},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users for a new issue investigation. Regressions, worsening issues and eligible error spikes bypass this minimum.`,control:`number`,range:`POSTHOG_MIN_USERS_RANGE`,keywords:[`threshold`,`affected`],defaultValue:1},{id:`posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold (users)`,description:`Affected-user count that escalates an issue.`,control:`number`,range:`POSTHOG_ESCALATION_RANGE`,keywords:[`threshold`,`severity`],defaultValue:25},{id:`posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout (seconds)`,description:`Maximum time allowed for one fix session.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_FIX_TIMEOUT_RANGE`,keywords:[`deadline`,`repair`],defaultValue:1800},{id:`posthog-traffic-enabled`,path:`posthog.trafficSpikeEnabled`,title:`Traffic spike alerts`,description:`Ping when recent unique users exceed a project baseline.`,control:`toggle`,keywords:[`analytics`,`alert`],defaultValue:!0},{id:`posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_TRAFFIC_MULTIPLIER_RANGE`,keywords:[`baseline`,`ratio`],defaultValue:3},{id:`posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,description:`Minimum recent unique users for an initial traffic-spike alert. Escalation and recovery alerts bypass this minimum.`,control:`number`,range:`POSTHOG_TRAFFIC_MIN_USERS_RANGE`,keywords:[`threshold`,`analytics`],defaultValue:10},{id:`posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown (minutes)`,description:`Cooldown for new traffic spikes. Escalation and recovery alerts bypass it. Zero removes the time delay; repeated active-spike alerts are still suppressed.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_TRAFFIC_COOLDOWN_RANGE`,keywords:[`silence`,`delay`],defaultValue:360},{id:`posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window (days)`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:`POSTHOG_TRAFFIC_BASELINE_RANGE`,keywords:[`history`,`analytics`],defaultValue:7},{id:`posthog-auto-fix`,path:`posthog.autoFix`,title:`Attempt fixes for major issues`,description:`Allow an isolated agent to fix an issue, push a branch and open a pull request.`,control:`toggle`,keywords:[`automatic`,`pull request`],danger:!0,warning:`Enabling this control lets PostHog fixes commit, push and open pull requests automatically.`,defaultValue:!1}]},{id:`lanes-team-review`,level:`lanes`,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,settings:[{id:`team-review-enabled`,path:`teamReview.enabled`,title:`Enable team review`,description:`Poll open pull requests from the team and draft a review of each one. Nothing is posted until you choose Approve or Comment.`,control:`toggle`,keywords:[`pull requests`,`github`],defaultValue:!1},{id:`github-teams`,path:`github.teams`,title:`GitHub teams`,description:`Teams to search for review requests and members, one org/slug per entry. Leave empty to use the organization and team below.`,control:`list`,keywords:[`github`,`teams`,`review requests`],defaultValue:[],listPlaceholder:`org/team-slug`,listEmptyText:`No GitHub teams configured.`},{id:`team-review-org`,path:`teamReview.org`,title:`GitHub organization`,description:`Organization login that owns the team, for example PostHog.`,control:`text`,keywords:[`github`,`owner`],defaultValue:``},{id:`team-review-team`,path:`teamReview.team`,title:`GitHub team`,description:`Team slug whose members and review requests are polled.`,control:`text`,keywords:[`github`,`slug`],defaultValue:``},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after (hours)`,description:`When a reviewed PR has a new head, review it again after this many hours since its last review. Queue review runs it at any time.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for (days)`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5},{id:`team-review-skill`,path:`teamReview.skill`,title:`Review skill`,description:`Name of a Claude Code skill installed for the review agent, for example your own PR review skill. Leave empty to let the agent review with whatever skills it has.`,control:`text`,keywords:[`skill`,`claude code`,`pr review`],defaultValue:``},{id:`team-review-auto-rebase-my-prs`,path:`teamReview.autoRebaseMyPrs`,title:`Keep my pull requests rebased`,description:`On each poll, rebase your open, non-draft pull requests that are behind their base branch. A pull request with conflicts or checks still running is left alone, and a failed rebase is not retried until you push again.`,control:`toggle`,keywords:[`rebase`,`update branch`,`behind`,`my prs`],danger:!0,warning:`Enabling this control rewrites your pull request branches on GitHub. Pull before you push from a local checkout of one.`,defaultValue:!1},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a sandboxed agent repairs conflicts and failing checks and pushes the repair. Off hides the control and starts no repair; the pull requests you chose stay chosen for when you turn it back on.`,control:`toggle`,keywords:[`repair`,`conflicts`,`my prs`],defaultValue:!0},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline (minutes)`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:`KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE`,keywords:[`timeout`,`repair`],defaultValue:30},{id:`team-review-merge-queue-enabled`,path:`teamReview.mergeQueueEnabled`,title:`Merge when ready`,description:`Offer Merge when ready on your pull requests: queued pull requests are rebased when behind and merged once ready, one per repository per poll. Off hides the control and merges nothing; the queue is kept for when you turn it back on.`,control:`toggle`,keywords:[`merge queue`,`auto merge`,`my prs`],defaultValue:!0}]},{id:`lanes-benchmarks`,level:`lanes`,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,settings:[{id:`benchmarks-enabled`,path:`benchmarks.enabled`,title:`Enable benchmarks`,description:`Show the Bench tab. Nothing runs until you choose Mine or Run there.`,control:`toggle`,keywords:[`eval`,`arms`,`recall`,`compare`],defaultValue:!1}]},{id:`lanes-factory`,level:`lanes`,title:`Factory`,description:`Read Coherence reports from repositories whose integration branch holds a coherence.config.json and show their status in the Factory tab.`,settings:[{id:`factory-enabled`,path:`factory.enabled`,title:`Enable the factory`,description:`Enable Coherence status polling and show the Factory tab. Off by default.`,control:`toggle`,keywords:[`orchestrator`,`intents`,`queue`,`coherence`,`guardrails`],defaultValue:!1},{id:`factory-max-risk`,path:`factory.maxRisk`,title:`Worker risk ceiling`,description:`Highest risk admitted for a ticket.`,control:`select`,defaultValue:`medium`,options:[`low`,`medium`,`high`,`critical`].map(e=>({value:e,label:e})),keywords:[`risk`,`admission`]},{id:`factory-max-live-workers`,path:`factory.maxLiveWorkers`,title:`Live worker cap`,description:`Most live workers per factory project.`,control:`number`,range:`FACTORY_MAX_LIVE_WORKERS_RANGE`,defaultValue:2,keywords:[`workers`,`parallel`]},{id:`factory-checks`,path:`factory.checks`,title:`Worker checks`,description:`Commands glimmervoid runs before merging worker commits.`,control:`list`,defaultValue:[`npm run typecheck`,`npm run lint`,`npm test`],keywords:[`tests`,`checks`]},{id:`factory-protected-paths`,path:`factory.protectedPaths`,title:`Protected paths`,description:`Repo-relative files, directory prefixes ending in /, or **/NAME basenames workers cannot change.`,control:`list`,defaultValue:[`coherence.config.json`,`.coherence/`,`package.json`,`package-lock.json`,`**/AGENTS.md`,`**/CLAUDE.md`,`**/CLAUDE.local.md`,`.claude/`,`.github/`],keywords:[`fence`,`scope`]},{id:`factory-reviewer-model`,path:`factory.reviewerModel`,title:`Reviewer model`,description:`Claude model for independent worker review. Blank uses the CLI default.`,control:`text`,defaultValue:null,nullable:!0,keywords:[`claude`,`review`]},{id:`factory-daily-budget`,path:`factory.dailyBudgetUsd`,title:`Factory daily budget (USD)`,description:`Factory lane spend ceiling. Blank means no ceiling. Needs usage tracking: with it off, dispatch refuses.`,control:`number`,range:`NON_NEGATIVE_NUMBER_RANGE`,integer:!1,nullable:!0,step:.01,defaultValue:null,keywords:[`spend`,`budget`]},{id:`factory-verifier-model`,path:`factory.verifierModel`,title:`Verifier model`,description:`Claude model for independent intent verification. Blank uses the CLI default.`,control:`text`,nullable:!0,defaultValue:null,keywords:[`claude`,`verification`]},{id:`factory-mirror-harness-runs`,path:`factory.mirrorHarnessRuns`,title:`Mirror harness runs`,description:`Show the latest factory harness run as a read-only project in the Factory tab while it runs and for a day after. Needs factory.enabled on; leave it off on a harness instance.`,control:`toggle`,defaultValue:!1,keywords:[`harness`,`test`,`read-only`]}]},{id:`lanes-knowledge-graph`,level:`lanes`,title:`Knowledge graph (experimental)`,description:`A typed local graph of projects, tasks, notes, references and questions, driven from the glimmervoid kg command. Its SQLite database defaults to the Glimmervoid home; --db selects another path.`,settings:[{id:`knowledge-graph-enabled`,path:`knowledgeGraph.enabled`,title:`Enable the knowledge graph`,description:`Allow the glimmervoid kg command. It reads Coherence ledgers to report where your tasks and the agents' tickets disagree, without modifying those ledgers. Graph writes go to the selected SQLite database, which can be inside a repository when --db names that path. Off by default.`,control:`toggle`,keywords:[`experimental`,`kg`,`tasks`,`notes`,`references`,`coherence`],defaultValue:!1}]},{id:`lanes-workflows`,level:`lanes`,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,settings:[{id:`workflows-enabled`,path:`workflows.enabled`,title:`Run workflows`,description:`Poll the repositories your enabled rules watch and run their actions. Off stops polling and every action, whatever each rule says.`,control:`toggle`,keywords:[`pull requests`,`automation`,`master switch`],defaultValue:!0},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Up to twenty later spawns wait for a free slot; additional spawns are dropped and logged.`,control:`number`,range:`WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE`,keywords:[`parallel`,`spawn`],defaultValue:2},{id:`workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:`WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE`,keywords:[`cap`,`rate limit`],defaultValue:20},{id:`workflows-rules`,path:`workflows`,title:`Workflow rules`,description:`Each rule watches repositories for one pull request event (opened, checks-failed, review-requested, approved, commented or merged), narrows it by author, labels, base branch, your own pull requests or a review request to your team, and then notifies you, labels or comments on the pull request, or starts a sandboxed agent session that pushes nothing. Rules start disabled. Turn each rule on or off here; everything else about a rule is set in config.json.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],fileOnly:!0,status:`workflows`}]},{id:`machine-sandbox`,level:`machine`,title:`Session sandbox`,description:`Claude Code sessions run inside the sandbox runtime on Linux and macOS. Changes apply to sessions started after the change.`,settings:[{id:`sandbox-unconfined-repos`,path:`sandbox.unconfinedRepos`,title:`Unconfined repositories`,description:`Folders whose sessions run outside the sandbox. A session started in one of these folders, or below it, is not confined. Applies to sessions created after the change.`,control:`list`,keywords:[`sandbox`,`opt out`,`dotfiles`],danger:!0,warning:`A session outside the sandbox can read credentials and write anywhere this account can.`,defaultValue:[]},{id:`sandbox-writable-paths`,path:`sandbox.writablePaths`,title:`Writable folders`,description:`Folders outside its checkout that a sandboxed session may write, such as package manager caches. A leading ~ means the home folder.`,control:`list`,keywords:[`sandbox`,`cache`,`npm`],defaultValue:[`~/.npm`,`~/.cache`]},{id:`sandbox-unreadable-paths`,path:`sandbox.unreadablePaths`,title:`Unreadable folders`,description:`Extra folders and files a sandboxed session cannot read, on top of the built-in credential list. A leading ~ means the home folder.`,control:`list`,keywords:[`sandbox`,`secrets`,`credentials`],defaultValue:[]}]},{id:`lanes-unattended`,level:`lanes`,title:`Unattended actions`,description:`Controls that let automated work change repositories or install executable tooling.`,settings:[{id:`skip-permissions-by-default`,path:`skipPermissionsByDefault`,title:`Skip permission prompts by default`,description:`Start sessions whose project sets no permission choice with the agent CLI permission bypass flag.`,control:`toggle`,keywords:[`permissions`,`yolo`,`dangerously`],danger:!0,warning:`Enabling this control lets agents edit files and run shell commands without asking, and restarts running sessions that inherit it.`,defaultValue:!1},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands in sessions that skip permission prompts when the cc-safety-net executable is available and trusted hooks are installed. Missing or untrusted hooks leave a session unprotected. Applies to sessions created after the change.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0},{id:`branch-gc-delete-unmerged`,path:`branchGc.deleteUnmerged`,title:`Delete unmerged branches`,description:`Also delete stale remote branches with no merge proof. Off keeps every unmerged branch.`,control:`toggle`,keywords:[`git`,`cleanup`,`orphan`],danger:!0,warning:`Enabling this control lets branch cleanup delete stale remote branches without merge proof.`,defaultValue:!1},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Default mode for post-turn checks. Project and individual rule modes override it, so Report can still allow file fixes.`,control:`select`,options:WY(IY),keywords:[`quality`,`fixes`],defaultValue:`report`},{id:`agent-api-enabled`,path:`agentApi.enabled`,title:`Agent API`,description:`Expose the per-session agent endpoint to running sessions.`,control:`toggle`,keywords:[`session`,`localhost`],danger:!0,warning:`Enabling this control lets a running session spawn sibling sessions, flag itself and read the board through a per-session token on localhost, and it applies to sessions spawned after the change.`,defaultValue:!1},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output for newly spawned or restarted sessions.`,control:`toggle`,keywords:[`bash`,`tokens`],danger:!0,status:`rtk-install`,warning:`Enabling this control permits Glimmervoid to install the pinned rtk executable automatically.`,defaultValue:!1}]}]);function JY(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function YY(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=vY.safeParse(e);return t.success?t.data.rules.length===0?[`No rules. Add workflows.rules to config.json.`]:t.data.rules.map(e=>[e.name,e.enabled?`enabled`:`disabled`,JY(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function XY(e){let t=vY.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:JY(e)})):[]}function ZY(e){let t=e.workflows;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,workflows:Object.fromEntries(Object.entries(t).filter(([e])=>e!==`rules`))}}function QY({checked:e=[],stored:t=[],rendered:n=[]}={}){let r=new Set(n),i=[...e];for(let e of t)typeof e==`string`&&e.trim()&&(r.has(e)||i.includes(e)||i.push(e));return i}function $Y(e,t){let n=new Set(e.map(e=>e.id)),r=[...new Set(t)].filter(e=>!n.has(e));return[...e,...r.map(e=>({id:e,name:`Unavailable project (${e})`}))]}function eX(e,t,n){return n?e.some(e=>e.toLowerCase()===t.toLowerCase()):e.includes(t)}var tX=new WeakMap,nX=`Configured`,rX=`•`.repeat(12);function iX(e,t){let n=t.secretSources;if(!n||typeof n!=`object`)return null;let r=n[e.path];return typeof r==`string`?r:null}function aX(e){let t=String(e??``).trim().toLowerCase();if(!t||t===`all`)return`all`;if(t===`none`)return[];let n=t.split(`,`).map(e=>e.trim());return n.every(e=>/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))&&Number(e)>0)?n.map(Number):null}function oX(e){let t=Number(e[`visions.dispatch.maxPerHour`]),n=Number(e[`visions.dispatch.activityMaxPerHour`]);return!Number.isSafeInteger(t)||t<1||!Number.isSafeInteger(n)||n<0?``:`Effective activity limit: ${Math.min(n,t-1)} per hour. One slot is reserved for edit reviews.`}function sX(e){let t=e.rtkInstall;return t?.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:e.rtkInstallSupported===!1?`No rtk binary found. Automatic installation is unavailable on this server platform; install a compatible binary manually.`:t?.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. A save can retry after the ten-minute failure cooldown; saves during the cooldown skip installation.`:`No rtk binary found. Saving requests installation into ~/.glimmervoid/bin on supported server platforms, subject to installer eligibility.`}function cX(e){return e.control===`password`}function lX(e){return`${e.path}${nX}`}function uX(e){return Array.isArray(e)?e.map(uX):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,uX(t)]))}function dX(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function fX(e,t){let n=t.split(`.`),r=e;for(let e of n.slice(0,-1)){if(!r||typeof r!=`object`)return;r=r[e]}r&&typeof r==`object`&&delete r[n.at(-1)]}function pX(e,t,n){let r=t.split(`.`),i=e;for(let e of r.slice(0,-1))(!i[e]||typeof i[e]!=`object`||Array.isArray(i[e]))&&(i[e]={}),i=i[e];i[r.at(-1)]=uX(n)}function mX(e){return e.flatMap(e=>e.settings||[])}function hX(e){return e.fileOnly||e.control===`readonly`}function gX(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}var _X=3,vX=2,yX=1,bX=3;function xX(e,t){return e===t?_X:e.startsWith(t)?vX:t.length>=bX&&e.includes(t)?yX:0}function SX(e,t,n){let r=0;for(let n of t){let t=Math.max(0,...e.map(e=>xX(e,n)));if(t===0)return 0;r+=t}return r*n}function CX(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>CX(e,t[n]));if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&CX(e[n],t[n]))}function wX(e,t){return e.valueKind===`posthog-projects`?Array.isArray(t)?t.length===0?`none`:t.join(`, `):t??`all`:uX(t)}function TX(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);return e.zeroIsNull&&n<=0?null:n}if(e.valueKind===`posthog-projects`)return aX(t);if(e.control===`text`||e.control===`password`){let n=String(t??``).trim();return e.nullable&&!n?null:n}return uX(t)}function EX(e){return tX.get(e)||null}function DX(e,t={}){let n={};for(let r of mX(e)){if(hX(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=wX(r,i??r.defaultValue);continue}if(cX(r)){let e=dX(t,lX(r))===!0;n[r.path]=e?rX:``;continue}let e=dX(t,r.path);n[r.path]=wX(r,e??r.defaultValue)}return tX.set(n,uX(t)),n}function OX(e,t,n,r,i={}){let{rehydrateSectionIds:a=[]}=i,o=DX(e,t),s=DX(e,t);if(!n||!r)return{original:o,edited:s};let c=new Set(a);for(let t of e)if(!c.has(t.id)&&t.settings.some(e=>!e.path.startsWith(`pref:`)&&!CX(n[e.path],r[e.path])))for(let e of t.settings)o[e.path]=uX(n[e.path]),s[e.path]=uX(r[e.path]);return{original:o,edited:s}}function kX(e,t,n){let r=mX(e).filter(e=>hX(e)||e.path.startsWith(`pref:`)||iX(e,EX(t)||{})||cX(e)&&n[e.path]===rX?!1:!CX(t[e.path],n[e.path]));if(r.length===0)return{};let i=EX(t)||{},a=(Array.isArray(i.projectChoices)?i.projectChoices:[]).map(e=>e.id).filter(e=>typeof e==`string`),o={},s=new Set;for(let e of r){let[r]=e.path.split(`.`);if(!e.path.includes(`.`)){o[r]=TX(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?uX(e):{},s.add(r)}let c=TX(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=QY({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:$Y(a.map(e=>({id:e,name:e})),Array.isArray(n)?n:[]).map(e=>e.id)})}pX(o,e.path,c)}for(let t of mX(e))cX(t)&&fX(o,lX(t));return delete o.secretSources,o}function AX(e,t){let n=t.integer===!1?`number`:`whole number`;return e.exclusiveMin?`Must be a positive ${n}.`:e.max==null?`Must be a ${n} of at least ${e.min}.`:`Must be a ${n} between ${e.min} and ${e.max}.`}function jX(e,t,n){if(e.nullable&&(t==null||String(t).trim()===``))return null;let r=Number(t),i=n[e.range??``];return i?!Number.isFinite(r)||e.integer!==!1&&!Number.isSafeInteger(r)?AX(i,e):i.exclusiveMin&&r<=i.min?e.zeroIsNull&&r<=0?null:AX(i,e):!i.exclusiveMin&&r<i.min||i.max!=null&&r>i.max?AX(i,e):null:`Allowed range is unavailable.`}function MX(e){return aX(e)===null?`Must be "all", "none", or a comma-separated list of positive safe integer ids without empty entries.`:null}function NX(e,t,n={}){let r={};for(let i of mX(e)){if(hX(i))continue;let e=null;i.control===`number`&&(e=jX(i,t[i.path],n)),i.valueKind===`posthog-projects`&&(e=MX(t[i.path])),i.control===`select`&&!i.options.some(e=>e.value===t[i.path])&&(e=`Choose one of the available options.`),e&&(r[i.id]=e)}return PX(mX(e),t,r),r}function PX(e,t,n){for(let r of e){let i=e.find(e=>e.id===r.maximumSettingId);if(!i||n[r.id]||n[i.id])continue;let a=Number(t[r.path]),o=Number(t[i.path]);a>o&&(n[r.id]=`Minimum must not exceed the maximum (${o}).`,n[i.id]=`Maximum must not be below the minimum (${a}).`)}}function FX(e,t){return mX(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function IX(e){let t={browser:[],machine:[],lanes:[],projects:[]};for(let n of e)t[n.level]||(t[n.level]=[]),t[n.level].push(n);return t}function LX(e,t){let n=gX(t);if(n.length===0)return[];let r=[];for(let t of e){let e=gX(t.title);for(let i of t.settings||[]){let a=SX(gX(i.title),n,1e3),o=SX(gX((i.keywords||[]).join(` `)),n,100),s=SX(e,n,10),c=SX(gX(i.description),n,1),l=a+o+s+c;l!==0&&r.push({section:t,setting:i,score:l})}}return r.sort((e,t)=>t.score-e.score||e.section.title.localeCompare(t.section.title)||e.setting.title.localeCompare(t.setting.title)).slice(0,30)}function RX(e,t,n={},r={}){let i=/^#settings\/([^/]+)(?:\/([^/]+))?$/.exec(String(e||``));if(!i)return null;let a,o;try{a=decodeURIComponent(i[1]),o=i[2]?decodeURIComponent(i[2]):null}catch{return null}let s=(o?r[a]?.[o]:void 0)||n[a]||a,c=t.find(e=>e.id===s);if(!c)return null;let l=o?(c.settings||[]).find(e=>e.id===o):null;return o&&!l?null:{sectionId:s,settingId:l?.id||null,hash:`#settings/${s}${l?`/${l.id}`:``}`}}function zX(e){let t=`lanes-unattended`,n=e.find(e=>e.id===t);if(!n)return[...e];let r=e.filter(e=>e.id!==t),i=r.findLastIndex(e=>e.level===`lanes`);return r.splice(i+1,0,n),r}function BX(e,t,n){return{id:`project-${e}-${t}`,projectId:e,...n}}function VX(e){return String(e||``).replace(/\s+\(\d+\)$/,``)}function HX(e){return String(e||``).replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||``}function UX(e){return HX(e?.path)||VX(e?.name)||e?.id}function WX(e=[]){return e.filter(e=>typeof e?.id==`string`&&e.id).map(e=>({id:`project-${e.id}`,level:`projects`,title:UX(e),description:`Settings scoped to this configured project.`,caption:(e.recordNames?.length??0)>1?`Cards: ${e.recordNames?.join(`, `)}`:``,project:e,settings:[BX(e.id,`agent`,{path:`project:${e.id}:agent`,title:`Agent`,description:`Agent configured for this project.`,control:`readonly`,keywords:[`cli`,`runtime`],value:e.agent||`Not available in the current dashboard payload`}),BX(e.id,`permission-mode`,{path:`project:${e.id}:permission-mode`,title:`Default permission mode`,description:`Permission mode used for newly spawned sessions.`,control:`readonly`,keywords:[`approval`,`sandbox`],value:e.permissionMode||`Not available in the current dashboard payload`}),BX(e.id,`codex-hook-trust`,{path:`projects.${e.id}.codexBypassHookTrust`,title:`Codex hook trust bypass`,description:`Configured only on this project record.`,control:`readonly`,keywords:[`hooks`,`codex`],fileOnly:!0})]}))}function GX(e=[]){let t=new Set;return e.filter(e=>typeof e?.id!=`string`||!e.id?!1:!e.path||!t.has(e.path)&&(t.add(e.path),!0))}function KX(e=[],t=[]){let n=new Map(t.filter(e=>typeof e?.id==`string`&&e.id).map(e=>[e.id,e]));return e.map(e=>{let r=n.get(e?.id),i=e?.path||r?.path,a=t.filter(e=>i&&e?.path===i).map(e=>e?.name).filter(e=>typeof e==`string`&&e!==``);return{...r,...e,path:i,recordNames:[...new Set(a)]}})}function qX(e,t){return e.danger===!0&&!!e.warning&&t===!0}function JX(e,t){return e.find(e=>e.id===t)||e[0]||null}var YX={ready:{label:`Ready`,meaning:`Ready to merge, or nothing left for you to do.`},passed:{label:`Passed`,meaning:`Checks passing, approved, or nothing open.`},failed:{label:`Failed`,meaning:`Checks failing, an automated review failed, or an auto-rebase failed.`},conflict:{label:`Conflict`,meaning:`Merge conflicts with the base branch.`},"your-turn":{label:`Your turn`,meaning:`Waiting on you: a review to give or a thread to answer.`},"changes-requested":{label:`Changes`,meaning:`A reviewer requested changes.`},thread:{label:`Threads`,meaning:`Unresolved review threads or comments.`},behind:{label:`Behind`,meaning:`The branch is behind its base.`},stale:{label:`Out of date`,meaning:`New commits landed since the automated review.`},fork:{label:`Fork`,meaning:`Opened from a fork, so it is reviewed by hand.`},running:{label:`Running`,meaning:`Checks or an automated review in progress.`},reviewer:{label:`Reviewer`,meaning:`Waiting on a reviewer.`},queued:{label:`Queued`,meaning:`Waiting for an automated review slot.`},draft:{label:`Draft`,meaning:`Still a draft.`},merged:{label:`Merged`,meaning:`Merged.`},discarded:{label:`Discarded`,meaning:`Review discarded or dismissed.`},unknown:{label:`Unknown`,meaning:`GitHub has not computed this yet.`},none:{label:`None`,meaning:`Nothing applies, such as no checks or no review requested.`}},XX={merged:`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`,draft:`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`,conflict:`M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,behind:`M13.03 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.47 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l2.97 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.97-2.97a.75.75 0 0 1 1.06 0Z`,failed:`M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z`,running:`M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z`,passed:`M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z`,ready:`M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z`,"changes-requested":`M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z`,thread:`M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z`,reviewer:`M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z`,"your-turn":`M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z`,queued:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z`,fork:`M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z`,discarded:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`,stale:`M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z`,unknown:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725 0 .448-.115.83-.329 1.15-.205.307-.47.513-.692.662-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16.952.952 0 0 0-.276.245.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,none:`M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z`};function ZX(e,t){let n=WL(16,16);return n.classList.add(`pr-status-icon`),t&&(n.dataset.tone=t),n.append(UL(`path`,{d:XX[e],fill:`currentColor`})),n}var QX=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:kc[e],meaning:t}),$X=Object.freeze([QX(F.DORMANT,`Not started yet.`),QX(F.INITIALIZING,`Setting up the worktree and launching the agent.`),QX(F.STARTING,`The agent is booting.`),QX(F.RUNNING,`The agent is mid-turn.`),QX(F.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),QX(F.WAITING,`Waiting on a permission prompt or your answer.`),QX(F.IDLE,`Ready for the next prompt.`),QX(F.COMPLETE,`Finished a turn you have not looked at yet.`),QX(F.DONE,`The agent process ended.`),QX(F.FAILED,`The agent failed to start or crashed.`)]);function eZ(e,t){let n=V(`section`,`status-legend`),r=V(`dl`,`status-legend-rows`);return r.append(...t),n.append(V(`h2`,`status-legend-title`,e),r),n}function tZ(e,t){let n=V(`div`,`status-legend-row`);return n.append(e,V(`dd`,`status-legend-meaning`,t)),n}function nZ(){return eZ(`Status colors`,$X.map(e=>{let t=V(`dt`,`status-legend-badge`),n=V(`span`,`status-legend-glyph`),r=V(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=tZ(t,e.meaning);return aU(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function rZ(){return eZ(`Pull request icons`,Object.keys(YX).map(e=>{let t=YX[e],n=V(`dt`,`status-legend-badge`);return n.append(ZX(e),V(`span`,`status-legend-name`,t.label)),tZ(n,t.meaning)}))}var iZ=2e4,Z=null,aZ=null,oZ=null,sZ=null,cZ=null,lZ=null,uZ=null,dZ=`all`,fZ=!1,pZ=null,mZ=DM,hZ=EM,gZ=TM,_Z=!1,vZ=null,yZ=`day`,bZ=new Set,xZ=AA({getAck:Ck,setAck:wk,signature:()=>xae(Z,oZ),isLooking:()=>!Ef(sZ)}),SZ=null,CZ=null,wZ=null,TZ=null,EZ=null,DZ=null,OZ=null,kZ=null,AZ=XP(()=>sZ),jZ=(e,t)=>Cf(`usage`,e,t);function MZ(e,t,n,r){let i=V(`div`,`usage-tile`);r&&r!==`ok`&&(i.dataset.tone=r);let a=V(`span`,`usage-tile-value`,t);i.append(a,V(`span`,`usage-tile-label`,e));let o=n?V(`span`,`usage-tile-sub`,n):null;return o&&i.append(o),{tile:i,valueEl:a,subEl:o}}function NZ(e){let t=Number(e);return Number.isFinite(t)?Math.min(Math.max(t,0),100):0}function PZ(e,t,n){let r=V(`div`,`usage-meter`);r.dataset.tone=String(t),r.setAttribute(`role`,`progressbar`),r.setAttribute(`aria-valuemin`,`0`),r.setAttribute(`aria-valuemax`,`100`),r.setAttribute(`aria-label`,n);let i=V(`span`,`usage-meter-fill`);return r.append(i),FZ(r,e),r}function FZ(e,t){if(!e)return;let n=NZ(t);e.setAttribute(`aria-valuenow`,String(Math.round(n)));let r=e.querySelector(`.usage-meter-fill`);r&&(r.style.width=`${n}%`)}function IZ(e,t,n,r){let i=V(`div`,`usage-table-scroll`);i.dataset.usageTable=r;let a=V(`table`,`usage-table`),o=V(`thead`),s=V(`tr`);for(let i of e){let e=V(`th`,i.numeric?`usage-num`:null);if(e.scope=`col`,!i.key){e.textContent=i.label,s.append(e);continue}let a=i.key;e.setAttribute(`aria-sort`,Fae(t,a));let o=V(`button`,`usage-sort`,i.label);o.type=`button`,o.dataset.sortKey=a,o.addEventListener(`click`,()=>{vZ={kind:`sort`,table:r,key:a},n(a)}),e.append(o),s.append(e)}o.append(s);let c=V(`tbody`);return a.append(o,c),i.append(a),{wrap:i,body:c}}function LZ(e,t){for(let n of t){let t=V(`td`,n.numeric?`usage-num`:n.className||null,n.node?null:n.text);n.node&&t.append(n.node),n.title&&(t.title=n.title),n.span&&(t.colSpan=n.span),e.append(t)}}function RZ(e){let t=V(`div`,`usage-share`);if(!Number.isFinite(e))return t.append(V(`span`,`usage-share-text`,jj(e))),t;let n=V(`span`,`usage-share-bar`),r=V(`span`,`usage-share-fill`);return r.style.width=`${NZ(e)}%`,n.append(r),t.append(n,V(`span`,`usage-share-text`,jj(e))),t}function zZ(){if(!SZ?.isConnected)return;let e=Number(Z?.ts);SZ.textContent=Number.isFinite(e)&&e>0?`Report ${JP(e)}`:``}function BZ(){if(!CZ?.isConnected)return;let e=Number(aZ?.ts);CZ.textContent=Number.isFinite(e)&&e>0?`Sessions ${JP(e)}`:``}function VZ(){let e=zj(Z?.activeBlock);e&&(TZ?.isConnected&&(TZ.textContent=`${e.pct}%`),EZ?.isConnected&&(EZ.textContent=`${Rj(e.remainingMinutes)} left`),DZ?.isConnected&&FZ(DZ,e.pct))}function HZ(e){let t=Cj.find(t=>t.value===e);return t?t.days:null}function UZ(){let e=V(`div`,`usage-controls`),t=V(`label`,`usage-control`);t.append(V(`span`,`usage-control-label`,`Range`));let n=V(`select`,`usage-select`);for(let e of Cj){let t=V(`option`,null,e.label);t.value=e.value,n.append(t)}n.value=dZ,n.addEventListener(`change`,()=>{dZ=n.value,EQ()}),t.append(n);let r=V(`button`,`usage-refresh`,`Refresh`);r.type=`button`,r.title=`Re-read every transcript from the start`,r.addEventListener(`click`,()=>EQ({force:!0}));let i=V(`span`,`usage-refresh-status`,``);return OZ=r,kZ=i,SQ(),e.append(t,r,i),e}function WZ(){let e=jZ(`Usage`,Tie(Z?.daily||[]));e.append(UZ()),SZ=V(`p`,`usage-meta`,``),e.append(SZ),zZ(),AZ.onTick(zZ);let t=jae(Z);t&&e.append(V(`p`,`usage-warning`,t));let n=Oae(Z?.pricing?.missing);return n&&e.append(V(`p`,`usage-warning`,n)),e}function GZ(){if(!yae(oZ))return null;let e=uM(Z?.totals),t=jZ(`Plan limits`,e?`${pM(`official`)}, ${e}`:pM(`official`)),n=Tae(oZ?.ts);if(n){let e=V(`p`,`usage-meta`,n);e.dataset.tone=`warn`,t.append(e)}let r=V(`div`,`usage-plan`);for(let e of dM){let t=fM(oZ,e.key);t&&r.append(KZ(e,t))}return t.append(r),wZ=V(`p`,`usage-meta`,``),t.append(wZ),qZ(),AZ.onTick(qZ),t}function KZ(e,t){let n=V(`div`,`usage-plan-window`),r=V(`div`,`usage-plan-head`);r.append(V(`span`,`usage-plan-label`,e.label)),r.append(V(`span`,`usage-plan-used`,Sae(t)));let i=V(`span`,`usage-plan-reset`,``);r.append(i),n.append(r),Number.isFinite(t.pct)&&n.append(PZ(t.pct,Bj(t.pct),`${e.label} plan limit used`));let a=()=>{i.isConnected&&(i.textContent=Cae(t.resetsAtMs))};return a(),AZ.onTick(a),n}function qZ(){if(!wZ?.isConnected)return;let e=hM(oZ?.ts);wZ.textContent=e?`Plan ${e}`:``}function JZ(){let e=Vie(Z,oZ),t=YZ();if(e.length===0&&!t)return null;let n=jZ(`Glimmervoid overhead`,e.length>0?Iie:null);if(e.length>0){let t=V(`div`,`usage-tiles`);for(let n of e){let e=[Hie(n),kj(n.costUSD)].filter(Boolean).join(`, `);t.append(MZ(`${n.label}, share of Claude use`,jj(n.sharePct),e).tile)}n.append(t);for(let t of e){let e=Uie(t);e&&n.append(V(`p`,`usage-meta`,`${t.label}: ${e}`))}}return t&&(n.append(V(`p`,`usage-meta`,`Selected range by lane. ${Fie}`)),n.append(t)),n}function YZ(){if(!Lie(Z))return null;let e=Kj(Z),t=e.reduce((e,t)=>e+(typeof t.costUSD==`number`&&Number.isFinite(t.costUSD)?t.costUSD:0),0),{wrap:n,body:r}=IZ([{label:`Lane`},{label:`Cost`,numeric:!0},{label:`Tokens`,numeric:!0},{label:`Sessions`,numeric:!0},{label:`Share`,numeric:!0}],null,()=>{},`lane`);for(let n of e){let e=V(`tr`,`usage-row`);n.lane===`other`&&(e.dataset.lane=`other`),LZ(e,[{text:Gj(n.lane),className:`usage-lane-cell`},{text:kj(n.costUSD),numeric:!0},{text:Aj(n.tokens),numeric:!0},{text:Yj(n.sessions),numeric:!0},{node:RZ(Pj(n.costUSD,t)),className:`usage-share-cell`}]),r.append(e)}return n}function XZ(){let e=Z?.activeBlock,t=Z?.blockHours,n=typeof t==`number`&&Number.isFinite(t)?t:5,r=uM(Z?.totals),i=jZ(`Current block`,r?`${n}h window, ${r}`:`${n}h window`);if(!e){i.append(V(`p`,`usage-empty`,`No active block.`));let e=ZZ();return e&&i.append(e),i}let a=mM(Z,oZ),o=V(`div`,`usage-tiles`);o.append(MZ(`block tokens`,Aj(e.tokens??0),kj(e.costUSD??0),a).tile);for(let t of kie(e.burn))o.append(MZ(t.label,t.value,t.sub,a).tile);let s=zj(e);if(s){let e=MZ(`elapsed`,`${s.pct}%`,`${Rj(s.remainingMinutes)} left`);TZ=e.valueEl,EZ=e.subEl,o.append(e.tile)}i.append(o),s&&(DZ=PZ(s.pct,`ok`,`Elapsed share of the current block window`),i.append(DZ),AZ.onTick(VZ));let c=Aie(e.projection);if(c){let e=V(`p`,`usage-projection`,c);e.dataset.tone=a,i.append(e)}let l=ZZ();l&&i.append(l);let u=jie(Z?.tokenLimit);if(!u)return i;let d=Hj(Z?.tokenLimit),f=mM(Z);i.append(PZ(d,f,`Share of the largest completed block seen, estimated`));let p=V(`p`,`usage-meta`,u);p.dataset.tone=f,i.append(p),i.append(V(`p`,`usage-provenance`,pM(`estimated`)));let m=Mie(e.projection,Z?.tokenLimit);if(m){let e=V(`p`,`usage-meta`,m);e.dataset.tone=f,i.append(e)}return i}function ZZ(){let e=Z?.anomaly;if(!mae(e))return null;let t=V(`p`,`usage-meta`,fae(e));return t.dataset.tone=pae(e),t}function QZ(){let e=Vae(Z?.blocks);if(e.length===0)return null;let t=uM(Z?.totals),n=jZ(`Recent blocks`,t?`newest first, ${t}`:`newest first`),r=V(`div`,`usage-blocks`),i=e.reduce((e,t)=>Math.max(e,t.tokens),0);for(let t of e){let e=V(`div`,`usage-block`);t.isActive&&(e.dataset.active=`true`),e.append(V(`span`,`usage-block-label`,Oie(t.startTs)));let n=V(`span`,`usage-block-bar`),a=V(`span`,`usage-block-fill`);a.style.width=`${NZ(Pj(t.tokens,i)??0)}%`,n.append(a),e.append(n),e.append(V(`span`,`usage-block-value`,`${Aj(t.tokens)} ${kj(t.costUSD)}`)),r.append(e)}return n.append(r),n}function $Z(){let e=Z?.totals||{},t=Bae(Z?.daily,Ij(Z)),n=jZ(`Totals`,[xie,Z?.tz?`TZ ${Z.tz}`:``].filter(Boolean).join(` `)),r=mM(Z,oZ),i=V(`div`,`usage-tiles`);i.append(MZ(`today`,Aj(t?.tokens??0),kj(t?.costUSD??0),r).tile),i.append(MZ(`range total`,Aj(e.tokens??0),kj(e.costUSD??0)).tile);let a=Wie(Z);a&&i.append(MZ(a.label,a.value,a.sub).tile),n.append(i);let o=eQ(e);o&&n.append(o);let s=lM(e)?gae(e):[];if(s.length>0){let e=V(`div`,`usage-tiles usage-vendor-tiles`);for(let t of s)e.append(MZ(t.label,Aj(t.tokens),kj(t.costUSD)).tile);n.append(e)}return CZ=V(`p`,`usage-meta`,``),n.append(CZ),BZ(),AZ.onTick(BZ),n}function eQ(e){let t=Pie(e);if(t.length===0)return null;let n=V(`div`,`usage-compo`),r=V(`div`,`usage-compo-bar`);r.setAttribute(`aria-hidden`,`true`);for(let e of t){if(e.pct<=0)continue;let t=V(`span`,`usage-compo-fill`);t.dataset.part=e.key,t.style.width=`${e.pct}%`,t.title=e.title,r.append(t)}let i=V(`div`,`usage-compo-legend`);for(let e of t){let t=V(`span`,`usage-compo-item`),n=V(`span`,`usage-compo-swatch`);n.dataset.part=e.key,t.append(n,V(`span`,`usage-compo-label`,e.label),V(`span`,`usage-compo-value`,e.value)),i.append(t)}return n.append(r,i),n}function tQ(){let e=Z?.savings;if(!Gie(e))return null;let t=jZ(`Savings`,``),n=V(`div`,`usage-tiles`),r=Kie(e);r&&n.append(MZ(`rtk compression`,r.value,r.sub).tile);let i=qie(e);return i&&n.append(MZ(`Prompt cache`,i.value,i.sub).tile),t.append(n),t}function nQ(){let e=Qj(Z);if(e.length===0)return null;let t=jZ(`Budgets`,`your own ceilings`),n=V(`div`,`usage-budgets`),r=pW(`machine-usage`,`usage-daily-budget`,`Budget settings`);n.appendChild(r);for(let t of e){let e=V(`div`,`usage-budget`),r=V(`div`,`usage-budget-head`);r.append(V(`span`,`usage-budget-label`,$j(t.scope))),r.append(V(`span`,`usage-budget-value`,Jie(t))),r.append(V(`span`,`usage-budget-pct`,jj(eM(t)))),e.append(r),e.append(PZ(eM(t),t.tone,Yie(t))),n.append(e)}return t.append(n),t}function rQ(){let e=Z?.daily||[],t=yZ,n=zae(nae(e,t),mZ),r=tM.find(e=>e.value===t)?.label||`Day`,i=jZ(`Over time`,[aae(e)].filter(Boolean).join(`, `));if(i.append(iQ()),n.length===0)return i.append(V(`p`,`usage-empty`,`No usage.`)),i;let a=oQ(e);a&&i.append(a);let{wrap:o,body:s}=IZ([{label:r,key:`day`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Models`}],mZ,e=>{mZ=wM(mZ,e),hQ()},`day`);for(let e of n){let n=String(e.day??``),r=V(`tr`,`usage-row`);e.source===`history`&&(r.dataset.source=`history`);let i=OM(e.models),a=`${t}:${n}`,o=sQ(a,i.length);LZ(r,[{node:aQ(e,t),title:n},{text:Aj(e.tokens),numeric:!0},{text:kj(e.costUSD),numeric:!0},{node:o,className:`usage-toggle-cell`}]),s.append(r),i.length!==0&&bZ.has(a)&&s.append(cQ(i))}return i.append(o),i}function iQ(){let e=V(`div`,`usage-period`);e.setAttribute(`role`,`group`),e.setAttribute(`aria-label`,`Period`);for(let t of tM){let n=V(`button`,`usage-period-button`,t.label);n.type=`button`,n.dataset.periodView=t.value,n.setAttribute(`aria-pressed`,t.value===yZ?`true`:`false`),n.addEventListener(`click`,()=>{yZ!==t.value&&(yZ=t.value,vZ={kind:`period`,view:t.value},hQ())}),e.append(n)}return e}function aQ(e,t){let n=V(`span`,`usage-period-cell`);return n.append(V(`span`,null,iae(e.day,t))),e.source===`history`&&n.append(V(`span`,`usage-history-tag`,`history`)),n}function oQ(e){let{cells:t,max:n}=cae(e,{today:Ij(Z)});if(t.length===0||n<=0)return null;let r=V(`div`,`usage-heatmap-scroll`),i=V(`div`,`usage-heatmap`);i.setAttribute(`role`,`img`),i.setAttribute(`aria-label`,`Daily usage for the trailing ${Math.max(...t.map(e=>e.week))+1} weeks`);let a=V(`div`,`usage-heatmap-days`);for(let e of oae)a.append(V(`span`,`usage-heatmap-day`,e));for(let e of t){let t=V(`span`,`usage-heatmap-cell`);t.dataset.tone=String(e.tone),e.noData&&(t.dataset.noData=`true`),e.source===`history`&&(t.dataset.source=`history`),t.style.gridColumn=String(e.week+1),t.style.gridRow=String(e.weekday+1),t.title=lae(e),i.append(t)}return r.append(a,i),r}function sQ(e,t){if(t===0)return null;let n=V(`button`,`usage-toggle`,`Models`);return n.type=`button`,n.dataset.usageDay=e,n.setAttribute(`aria-expanded`,bZ.has(e)?`true`:`false`),n.addEventListener(`click`,()=>{if(vZ={kind:`day`,day:e},bZ.has(e)){bZ.delete(e),hQ();return}bZ.add(e),hQ()}),n}function cQ(e){let t=V(`tr`,`usage-row-breakdown`),n=V(`td`,`usage-models`);n.colSpan=4;for(let t of e){let e=V(`span`,`usage-model-chip`);e.append(V(`span`,`usage-model-name`,bM(t)),V(`span`,`usage-model-value`,`${Aj(t.tokens)} ${kj(t.costUSD)}`)),n.append(e)}return t.append(n),t}function lQ(e,t){let n=V(`span`,`usage-model-name-wrap`),r=hae(e,t);return r&&n.append(V(`span`,`usage-vendor-tag`,r)),n.append(V(`span`,null,bM(e))),n}function uQ(){let e=OM(Z?.models,hZ),t=Z?.totals||{},n=Mj(t),r=jZ(`By model`,Nj(n));if(e.length===0)return r.append(V(`p`,`usage-empty`,`No models.`)),r;let{wrap:i,body:a}=IZ([{label:`Model`,key:`model`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Input`,numeric:!0,key:`input`},{label:`Output`,numeric:!0,key:`output`},{label:`Cache write`,numeric:!0,key:`cacheCreate`},{label:`Cache read`,numeric:!0,key:`cacheRead`}],hZ,e=>{hZ=wM(hZ,e),hQ()},`model`);for(let r of e){let e=V(`tr`,`usage-row`);LZ(e,[{node:lQ(r,t),className:`usage-model-cell`,title:bM(r)},{text:Aj(r.tokens),numeric:!0},{text:kj(r.costUSD),numeric:!0},{node:RZ(Pj(r[n],t[n])),className:`usage-share-cell`},{text:Aj(r.input),numeric:!0},{text:Aj(r.output),numeric:!0},{text:Aj(r.cacheCreate),numeric:!0},{text:Aj(r.cacheRead),numeric:!0}]),a.append(e)}return r.append(i),r}function dQ(){let e=Iae(Z?.sessions,gZ),t=Lae(e,_Z),n=Z?.totals||{},r=Mj(n),i=jZ(`By session`,Nj(r));if(e.length===0)return i.append(V(`p`,`usage-empty`,`No sessions.`)),i;let{wrap:a,body:o}=IZ([{label:`Session`,key:`label`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Last activity`,numeric:!0,key:`lastTs`}],gZ,e=>{gZ=wM(gZ,e),hQ()},`session`);for(let e of t.rows){let t=V(`tr`,`usage-row`);vM(e)&&(t.dataset.managed=`true`);let i=yM(e),a=V(`span`,`usage-ago`,``);LZ(t,[{text:i,className:`usage-session-cell`,title:e.project?String(e.project):i},{text:Aj(e.tokens),numeric:!0},{text:kj(e.costUSD),numeric:!0},{node:RZ(Pj(e[r],n[r])),className:`usage-share-cell`},{node:a,numeric:!0}]),AZ.track(a,Number(e.lastTs),JP),o.append(t)}return i.append(a),e.length>10&&i.append(fQ(t.hiddenCount)),i}function fQ(e){let t=V(`div`,`usage-overflow`),n=Rae(e);n&&t.append(V(`p`,`usage-meta`,n));let r=V(`button`,`usage-toggle`,`All sessions`);return r.type=`button`,r.dataset.usageSessionsToggle=`true`,r.setAttribute(`aria-expanded`,_Z?`true`:`false`),r.addEventListener(`click`,()=>{vZ={kind:`sessions-toggle`},_Z=!_Z,hQ()}),t.append(r),t}function pQ(){let e=jZ(`Not available`,``);return e.append(V(`p`,`usage-empty`,gM(Z))),e.append(V(`p`,`usage-empty`,Sie)),e}function mQ(){SZ=null,CZ=null,wZ=null,TZ=null,EZ=null,DZ=null,OZ=null,kZ=null}function hQ({force:e=!1}={}){if(!sZ||!e&&Ef(sZ))return;let t=sZ.parentElement,n=t?t.scrollTop:0;AZ.reset(),mQ(),sZ.textContent=``,vQ(),t&&(t.scrollTop=n),gQ()}function gQ(){let e=vZ;if(vZ=null,!e)return;let t=_Q(e);if(!t||!sZ)return;let n=sZ.querySelector(t);n instanceof HTMLElement&&n.focus()}function _Q(e){return e.kind===`day`?`.usage-toggle[data-usage-day="${CSS.escape(e.day)}"]`:e.kind===`period`?`.usage-period-button[data-period-view="${CSS.escape(e.view)}"]`:e.kind===`sessions-toggle`?`.usage-toggle[data-usage-sessions-toggle="true"]`:e.kind===`sort`?`[data-usage-table="${CSS.escape(e.table)}"] .usage-sort[data-sort-key="${CSS.escape(e.key)}"]`:null}function vQ(){if(!sZ)return;sZ.append(WZ());let e=GZ();if(_M(Z)){e&&sZ.append(e),sZ.append(pQ());return}if(!Z){e&&sZ.append(e),sZ.append(V(`p`,`usage-empty`,`Waiting for scan.`));return}let t=[e,nQ()].filter(e=>e!==null);sZ.append(yQ(`usage-band-now`,XZ(),t,{sideFirst:!0}));let n=[tQ()].filter(e=>e!==null);sZ.append(yQ(`usage-band-spend`,$Z(),n));let r=[QZ()].filter(e=>e!==null);sZ.append(yQ(`usage-band-trend`,rQ(),r));let i=JZ();i&&sZ.append(i),sZ.append(uQ(),dQ())}function yQ(e,t,n,{sideFirst:r=!1}={}){if(n.length===0)return t;let i=V(`div`,`usage-band ${e}`),a=V(`div`,`usage-band-col`);for(let e of n)a.append(e);return r?(i.append(a,t),i):(i.append(t,a),i)}function bQ(){cZ&&cZ(xZ.refresh())}function xQ(){xZ.acknowledge(),bQ()}function SQ(){OZ&&(OZ.disabled=fZ),kZ&&(kZ.textContent=fZ?`Refreshing`:``)}function CQ(e){fZ=e,SQ(),pZ&&=(clearTimeout(pZ),null),e&&(pZ=setTimeout(()=>{pZ=null,fZ=!1,SQ()},iZ))}function wQ(e){cZ=e,bQ()}function TQ(e){lZ=e}function EQ({force:e=!1}={}){if(!lZ)return;uZ=af(`usage`);let t={type:`request-usage-report`,requestId:uZ};e&&(t.force=!0);let n=HZ(dZ);n!==null&&(t.days=n),CQ(!0),lZ(t)}function DQ(e){if(sZ)return sZ;let t=V(`div`,`usage-content`);return e.appendChild(t),sZ=t,AZ.ensure(),hQ({force:!0}),t}function OQ(){hQ({force:!0})}function kQ(e){if(aZ=e,Z&&!_M(Z)&&CZ?.isConnected){BZ();return}hQ()}function AQ(e){oZ=e,hQ(),bQ()}function jQ(e){Mae(e,uZ)&&(CQ(!1),Z=e,hQ(),bQ())}function MQ(){let e=Z?.pricing||(aZ?{source:aZ.pricingSource}:null),t=Dae(e?.fetchedAt),n=[Eae(e,t!==null&&t>0?JP(t):``)],r=gM(Z);r&&n.push(r);let i=Aae(Z?.scan);return i&&n.push(i),n}var NQ=null,PQ=new Set;function FQ(){NQ?.setAttribute(`aria-pressed`,String(!LO()))}function IQ(e){RO(e),FQ();for(let t of PQ)t(e)}function LQ(e){PQ.add(e)}function RQ(e){NQ=e,FQ(),e.addEventListener(`click`,()=>IQ(!LO()))}var zQ=Object.freeze({fetch:`Fetch`,stage:`Stage`,install:`Install dependencies`,"link-deps":`Link dependencies`,build:`Build`}),BQ=Object.freeze({"branch-count-unavailable":`The last check could not compare the checked-out branch with its upstream.`,"branch-diverged":`The checked-out branch has diverged from its upstream.`,"fetch-failed":`The last update check could not fetch the upstream branch.`,"main-channel-requires-clone":`The main channel requires a clone install.`,"no-branch":`The last update check found no checked-out branch.`,"no-upstream":`The checked-out branch has no upstream.`,"release-already-checked-out":`The checkout already contains the latest release. Restart to run it.`,"release-check-failed":`The last release check failed.`,"remote-tip-unavailable":`The last update check could not resolve the upstream branch tip.`,"update-check-failed":`The last update check failed.`}),VQ=Object.freeze([`unsupported-flavor`,`unsupported-platform`]),HQ=`Not connected to the server. Reconnecting.`,UQ=Object.freeze({requested:!1,failure:null});function WQ(e,t){return t===`request-sent`?{requested:!0,failure:null}:t===`request-unsent`?{requested:!1,failure:HQ}:t===`progress-frame`?UQ:t===`error-frame`?e.requested?UQ:e:e.failure===null?e:{requested:e.requested,failure:null}}function GQ(e,t){return t?.state?t.state:e?.journalSummary?.state}function KQ(e){return{enabled:!1,reason:e}}function qQ(){return{enabled:!0,reason:null}}function JQ({status:e,journal:t,request:n=UQ}){let r=GQ(e,t)===`running`||n.requested,i=r?KQ(`Wait for update staging to finish.`):qQ();if(n.failure)return{update:KQ(n.failure),restart:i};if(r)return{update:KQ(`Wait for the current update to finish.`),restart:i};if(!e)return{update:KQ(`Update status unavailable. Check for updates.`),restart:i};let a=e.applyRefusal;return a?{update:KQ(a.message),restart:i}:{update:qQ(),restart:i}}function YQ(e){let t=e?.applyRefusal;return t===void 0?`command`:t===null?`link`:VQ.includes(t.reason)?`command`:`link`}function XQ(e){let t=OA(e,``);return t?`: ${t}`:``}function ZQ(e){return e.state===`staged`?`Update staged. Restart to hand it off${XQ(e.reason)}.`:e.state===`succeeded`?`Update succeeded at restart${XQ(e.reason)}.`:e.state===`failed`?`Update failed${XQ(e.reason)}.`:e.state===`discarded`?`Update discarded${XQ(e.reason)}.`:e.state===`interrupted`?`Update interrupted${XQ(e.reason)}.`:null}function QQ(e){return zQ[e]??e}function $Q(e){let t=e.steps.find(t=>t.id===e.activeStep);if(t&&t.outputTail.length>0)return{stepId:t.id,lines:t.outputTail};let n=e.steps.findLast(e=>e.outputTail.length>0);return n?{stepId:n.id,lines:n.outputTail}:{stepId:null,lines:[]}}function e$(e){if(!e||e.state===`idle`)return null;let t=$Q(e),n=t.stepId!==null&&t.stepId!==e.activeStep?t.stepId:null;return{state:e.state,terminalLine:ZQ(e),steps:e.steps.map(e=>({id:e.id,label:QQ(e.id),status:e.status})),outputTail:t.lines,outputStepId:t.stepId,outputStepLabel:n===null?null:QQ(n)}}var t$=6e5;function n$(e){return e.channel!==`main`||!Number.isInteger(e.behindCount)?``:`${e.behindCount} ${e.behindCount===1?`commit`:`commits`} behind`}function r$(e,t){let n=GQ(e,t),r=HA(t?.toVersion,t?.toSha)||HA(e?.latest,e?.latestSha)||`the update`;if(n===`running`)return{tone:`running`,headline:`Updating to ${r}. Glimmervoid keeps running until the restart.`};if(n===`staged`)return{tone:`staged`,headline:`${r} is staged. Restart to finish updating.`};if(!e)return{tone:`unknown`,headline:`No update check has run yet.`};let i=HA(e.current,e.currentSha)||`an unknown version`;if(e.updateAvailable){let t=HA(e.latest,e.latestSha)||`a newer build`,n=n$(e);return{tone:`available`,headline:`Update available: ${i} to ${t}${n?` (${n})`:``}.`}}return OA(e.reason,``)?{tone:`unknown`,headline:`Running ${i}. The last check did not finish.`}:{tone:`current`,headline:`Up to date. Running ${i}.`}}function i$(e){if(!e)return`Update status unavailable.`;let t=HA(e.current,null)||`Unknown version`,n=jl(e.currentSha,{validate:!0}),r=OA(e.installedBranch,``);return[t,[n?`commit ${n}`:``,r?`on ${r}`:``].filter(Boolean).join(` `),e.isTreeClean===!0?`clean checkout`:e.isTreeClean===!1?`uncommitted local changes`:``].filter(Boolean).join(`, `)}function a$(e){return e?{label:HA(e.latest,e.latestSha)||`Latest target unknown`,behind:n$(e),releaseUrl:OA(e.releaseUrl,``)}:{label:`Update status unavailable.`,behind:``,releaseUrl:``}}function o$({status:e,checkForUpdates:t,now:n,lastAutoCheckAt:r}){if(t===!1||r!==null&&n-r<t$)return!1;let i=typeof e?.lastCheckAt==`number`?e.lastCheckAt:null;return i===null||n-i>=t$}function s$({status:e,checkForUpdates:t,relativeTime:n}){if(t===!1)return`Update checks are off.`;if(!e)return`No update check has run.`;let r=OA(e.reason,``);return r?BQ[r]??`The last update check failed: ${r}.`:e.flavor===`unknown`?`The install flavor is unknown.`:n}var c$=rO,l$=Object.freeze({sounds:()=>bx(),themes:Hx});function u$(e){if(!e.optionsFrom)return e;let t=l$[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function d$(){return Object.freeze(qY.map(e=>({...e,settings:e.settings.map(u$)})))}var f$=d$(),p$=zX(f$),m$=Object.freeze({browser:`This browser`,machine:`Machine`,lanes:`Lanes`,projects:`Projects`}),h$=!1,g$=null,_$=null,v$=null,y$=null,b$=null,x$=null,S$=null,C$=null,w$=null,T$=null,E$=null,Q=p$[0],D$={},O$=[],k$=[],A$=new Map,j$=null,M$=null,N$=``,P$=``,F$=null,I$=null,L$=null,R$=null,z$=UQ,B$=()=>{},V$=e=>{e([])},H$=null,U$=!1,W$=new Set,G$=new Map;function K$(){return{themeId:qO(),flyingAnimalsEnabled:YO(),...zk(),soundEnabled:LO(),soundId:xx(zO()),notificationsEnabled:VO(),compactStatusLabels:UO(),sessionUsageChips:GO()}}function q$(e){let t={...e,prefs:K$()};j$=DX(p$,t),M$=DX(p$,t)}function J$(e){return e.control===`readonly`?e.value:M$?.[e.path]??e.defaultValue}function Y$(e){return e.settings.some(e=>!e.path.startsWith(`pref:`)&&JSON.stringify(j$?.[e.path])!==JSON.stringify(M$?.[e.path]))}function X$(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function Z$(e,t=null){history.replaceState(history.state,``,X$(e,t))}function soe(e){requestAnimationFrame(()=>{let t=document.getElementById(e),n=t?.closest(`.settings-view-advanced-panel`);n&&(h$=!0,n.hidden=!1,E$?.querySelector(`.settings-view-advanced-toggle`)?.setAttribute(`aria-expanded`,`true`));let r=t?.closest(`.settings-view-setting`);r&&(r.scrollIntoView({block:`center`}),r.classList.remove(`settings-view-setting-flash`),requestAnimationFrame(()=>r.classList.add(`settings-view-setting-flash`)))})}function Q$(){let e=WX(k$);p$=zX([...f$,...e]),Q=JX(p$,Q?.id)??Q}function $$(e){let t=Array.isArray(e)?e:[];for(let e of t)typeof e?.id==`string`&&e.id&&A$.set(e.id,{...A$.get(e.id),...e});k$=KX(GX(O$),[...A$.values()])}function e1(e){for(let t of qb(Jb)){let n=V(`div`,`shortcut-group`);n.appendChild(V(`div`,`shortcut-group-title`,t.title));let r=V(`dl`,`shortcut-rows`);for(let e of t.items){let t=V(`dt`,`shortcut-keys`);e.combos.forEach((e,n)=>{n>0&&t.appendChild(V(`span`,`shortcut-sep`,`/`)),Qb(t,e)}),r.append(t,V(`dd`,`shortcut-label`,e.label))}n.appendChild(r),e.appendChild(n)}}function t1(e){let t=V(`div`,`settings-about`),n=V(`span`,`settings-about-version`,`GLIMMERVOID `);n.appendChild(V(`span`,`settings-about-v`,`v0.33.0`));let r=V(`span`,`settings-about-links`),i=V(`a`,`settings-about-link`,`GitHub`);i.href=`https://github.com/${QJ}`,i.target=`_blank`,i.rel=`noopener`;let a=V(`a`,`settings-about-link`,`Changelog`);a.href=`https://github.com/${QJ}/blob/main/CHANGELOG.md`,a.target=`_blank`,a.rel=`noopener`,r.append(i,a),t.append(n,r),e.appendChild(t)}function n1(e){M$&&M$[`pref:soundEnabled`]!==e&&(M$[`pref:soundEnabled`]=e,j$&&(j$[`pref:soundEnabled`]=e),q1())}function r1(){for(let[e,t]of Object.entries(zk()))j$&&(j$[`pref:${e}`]=t),M$&&(M$[`pref:${e}`]=t)}var i1={"pref:flyingAnimalsMinGapSeconds":e=>jk(Number(e)),"pref:flyingAnimalsMaxGapSeconds":e=>Mk(Number(e)),"pref:flyingAnimalsMinDurationSeconds":e=>Nk(Number(e)),"pref:flyingAnimalsMaxDurationSeconds":e=>Pk(Number(e)),"pref:flyingAnimalsScale":e=>Fk(Number(e)),"pref:flyingAnimalsOnPhone":e=>Ik(e===!0)};function a1(e,t){if(e.path===`pref:compactStatusLabels`){WO(t===!0),zx(t===!0);return}if(e.path===`pref:sessionUsageChips`){KO(t===!0),Bx(t===!0);return}if(e.path===`pref:themeId`){JO(t),Rx(t);return}if(e.path===`pref:flyingAnimalsEnabled`){XO(t),XJ(t);return}let n=i1[e.path];if(n){let r=NX([Q],M$??{},c$);if(r[e.id])return;n(t);let i=FX([Q],e),a=i&&i1[i.path];i&&a&&!r[i.id]&&a(M$?.[i.path]),XJ(YO());return}if(e.path===`pref:soundEnabled`){IQ(t===!0);return}if(e.path===`pref:soundId`){BO(t),Mx(t);return}e.path===`pref:notificationsEnabled`&&(HO(t),t&&kJ().then(q1))}function o1(){if(!E$||!M$)return;E$.querySelector(`.settings-view-footer`)?.remove();let e=I1(NX([Q],M$,c$));e&&E$.appendChild(e)}function s1(e,t,{rerender:n=!0}={}){if(M$){if(M$[e.path]=t,N$=``,e.path.startsWith(`pref:`)&&j$&&(j$[e.path]=t,a1(e,t)),n){q1();return}o1(),m0()}}function c1(e,t){if(!t.exclusiveMin)return t.min;if(e.integer!==!1)return t.min+1}function l1(e){let t=V(`div`,`settings-view-toggle-wrap`),n=V(`label`,`settings-view-toggle`),r=V(`input`,`settings-view-checkbox`);return r.type=`checkbox`,r.checked=J$(e)===!0,e.id===`desktop-notifications`&&!DJ()&&(r.checked=!1,r.disabled=!0),r.setAttribute(`aria-labelledby`,e.id),r.addEventListener(`change`,()=>s1(e,r.checked)),n.append(r,V(`span`,`settings-view-toggle-state`,r.checked?`On`:`Off`)),t.appendChild(n),t}function u1(e){let t=V(`input`,`settings-view-input`);t.type=e.control??`text`,t.value=String(J$(e)??``),e.control===`password`&&(t.placeholder=`No credential stored`);let n=iX(e,D$);return n&&(t.disabled=!0,t.setAttribute(`aria-description`,`Supplied by ${n}`)),t.autocomplete=`off`,t.spellcheck=!1,t.setAttribute(`aria-labelledby`,e.id),t.addEventListener(`input`,()=>s1(e,t.value,{rerender:!1})),t}function d1(e){let t=V(`input`,`settings-view-input`),n=c$[e.range??``];t.type=`number`,t.value=String(J$(e)??``),t.step=String(e.step??1);let r=c1(e,n);return r!=null&&(t.min=String(r)),n.max!=null&&(t.max=String(n.max)),t.autocomplete=`off`,t.setAttribute(`aria-labelledby`,e.id),e.commitOnChange?(t.addEventListener(`change`,()=>s1(e,t.value.trim()===``?e.defaultValue:t.value)),t):(t.addEventListener(`input`,()=>s1(e,t.value,{rerender:!1})),t)}function f1(e){let t=V(`select`,`settings-view-input`);t.setAttribute(`aria-labelledby`,e.id);for(let n of e.options){let e=V(`option`,null,n.label);e.value=n.value,t.appendChild(e)}return t.value=String(J$(e)),t.addEventListener(`change`,()=>s1(e,t.value)),t}function p1(e){let t=V(`div`,`settings-view-list`),n=J$(e),r=Array.isArray(n)?n:[];r.length===0&&t.appendChild(V(`div`,`settings-empty`,e.listEmptyText??`No repository roots configured.`));for(let[n,i]of r.entries()){let a=V(`div`,`settings-root-item`),o=V(`span`,`settings-root-path`,i);o.title=i;let s=V(`button`,`btn-settings-remove`,`×`);s.type=`button`,s.title=`Remove`,s.setAttribute(`aria-label`,`Remove ${i}`),s.addEventListener(`click`,()=>{s1(e,r.filter((e,t)=>t!==n))}),a.append(o,s),t.appendChild(a)}let i=V(`div`,`settings-add-row`),a=V(`input`,`settings-view-input settings-root-input`);a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=e.listPlaceholder??`Repository root path`;let o=V(`button`,`btn-dialog btn-dialog-confirm btn-settings-add`,`Add`);o.type=`button`;let s=()=>{let t=a.value.trim();t&&(eX(r,t,D$.repositoryRootCaseInsensitive===!0)||s1(e,[...r,t]))};return o.addEventListener(`click`,s),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),i.append(a,o),t.appendChild(i),t}function m1(e){let t=V(`div`,`settings-view-projects`),n=J$(e),r=new Set(Array.isArray(n)?n:[]),i=Array.isArray(D$.projectChoices)?D$.projectChoices:[];i.length===0&&t.appendChild(V(`div`,`settings-empty`,`No configured projects are available.`));for(let n of $Y(i,[...r])){let i=V(`label`,`settings-view-project-choice`),a=V(`input`,`settings-view-checkbox`);a.type=`checkbox`,a.checked=r.has(n.id),a.addEventListener(`change`,()=>{let t=new Set(r);a.checked&&t.add(n.id),a.checked||t.delete(n.id),s1(e,[...t])}),i.append(a,document.createTextNode(n.name)),t.appendChild(i)}return t}function h1(e){let t=V(`div`,`settings-view-file-only`);return t.append(V(`code`,`settings-view-key-path`,e.path)),t.append(V(`span`,`settings-view-file-caption`,`Configured in config.json`)),t}function g1(){let e=r$(L$,R$),t=V(`div`,`settings-readonly settings-update-readout settings-update-summary`,e.headline);return t.dataset.tone=e.tone,t}function _1(){return V(`div`,`settings-readonly settings-update-readout`,i$(L$))}function v1(){let e=a$(L$),t=V(`div`,`settings-readonly settings-update-readout`);if(t.appendChild(V(`span`,`settings-update-latest-label`,e.label)),e.behind&&t.appendChild(V(`span`,`settings-update-behind`,e.behind)),!e.releaseUrl)return t;let n=V(`a`,`settings-link`,`View release`);return n.href=e.releaseUrl,n.target=`_blank`,n.rel=`noopener noreferrer`,t.appendChild(n),t}function y1(){let e=typeof L$?.lastCheckAt==`number`?L$.lastCheckAt:null,t=V(`div`,`settings-readonly settings-update-readout`,s$({status:L$,checkForUpdates:D$.checkForUpdates,relativeTime:JP(e)}));return e&&(t.title=new Date(e).toLocaleString()),t}function b1(e,t,{decision:n={enabled:!0,reason:null},isPrimary:r=!1}={}){let i=V(`button`,`btn-dialog ${r?`btn-dialog-confirm`:`btn-dialog-cancel`} settings-update-button`,e);return i.type=`button`,i.disabled=!n.enabled,i.addEventListener(`click`,t),i}function x1(e){let t=V(`span`,`settings-update-action-status`,e??``);return t.setAttribute(`role`,`status`),t}function S1(e){let t=WQ(z$,e);t!==z$&&(z$=t,h0())}function C1({restartWhenStaged:e,confirmedSessionIds:t}){S1(B({type:`update-apply`,restartWhenStaged:e,confirmedSessionIds:t})?`request-sent`:`request-unsent`)}function w1(){H$=Date.now(),B({type:`update-check`})}function T1(){if(!L$){U$=!0;return}U$=!1,o$({status:L$,checkForUpdates:D$.checkForUpdates,now:Date.now(),lastAutoCheckAt:H$})&&w1()}function E1(){let e=JQ({status:L$,journal:R$,request:z$}),t=V(`div`,`settings-update-actions settings-update-readout`),n=V(`div`,`settings-update-buttons`);return n.append(b1(`Update and restart`,()=>V$(e=>C1({restartWhenStaged:!0,confirmedSessionIds:e})),{decision:e.update,isPrimary:!0}),b1(`Update without restart`,()=>C1({restartWhenStaged:!1}),{decision:e.update}),b1(`Check for updates`,w1),b1(`Restart`,B$,{decision:e.restart})),t.append(n,x1(e.update.reason)),t}function D1(e){return e.status===`update-summary`?g1():e.status===`update-installed`?_1():e.status===`update-latest`?v1():e.status===`update-last-checked`?y1():e.status===`update-actions`?E1():V(`div`,`settings-readonly`,String(e.value||`Not configured`))}function O1(e){return e.fileOnly?h1(e):e.control===`readonly`?D1(e):e.control===`toggle`?l1(e):e.control===`number`?d1(e):e.control===`select`?f1(e):e.control===`list`?p1(e):e.control===`projects`?m1(e):u1(e)}function k1(e){let t=iX(e,D$);return t?`Supplied by ${t}. Change the server environment and restart to replace this credential.`:e.status===`visions-activity-limit`?oX(M$||{}):e.id===`desktop-notifications`&&!DJ()?`Desktop notifications are unavailable for this page.`:e.id===`desktop-notifications`&&J$(e)&&OJ()===`denied`?`Blocked by the browser. Allow notifications for this site to enable them.`:e.status!==`rtk-install`||!J$(e)||D$.rtkAvailable?``:sX(D$)}function A1(e){if(e.status===`custom-agents`)return z1();if(e.status===`workflows`)return U1();if(e.status===`usage-last-report`)return W1();if(e.status===`update-actions`)return j1();if(e.status?.startsWith(`update-`))return null;let t=k1(e);return t?V(`div`,`settings-view-warning settings-view-status-slot`,t):null}function j1(){let e=e$(R$);if(!e)return null;let t=V(`div`,`settings-update-progress settings-view-status-block settings-view-status-slot`);t.dataset.state=e.state,t.setAttribute(`role`,`status`),e.terminalLine&&t.appendChild(V(`div`,`settings-update-terminal`,e.terminalLine));let n=V(`ol`,`settings-update-steps`);for(let t of e.steps){let e=V(`li`,`settings-update-step`);e.dataset.status=t.status,e.append(V(`span`,`settings-update-step-state`,t.status),V(`span`,`settings-update-step-label`,t.label)),n.appendChild(e)}if(t.appendChild(n),e.outputTail.length===0)return t;let r=V(`pre`,`settings-update-output`,e.outputTail.join(`
|
|
247
|
-
`));if(e.outputStepId&&(r.dataset.step=e.outputStepId),!e.outputStepLabel)return t.appendChild(r),t;let i=`Output from ${e.outputStepLabel}`;return r.setAttribute(`aria-label`,i),t.append(V(`div`,`settings-update-output-label`,i),r),t}function M1(e){let t=V(`div`,`settings-view-setting-heading`),n=V(`h2`,`settings-view-setting-title`,e.title);n.id=e.id,n.addEventListener(`click`,()=>Z$(Q.id,e.id));let r=V(`button`,`settings-view-copy-link`,`#`);r.type=`button`,r.setAttribute(`aria-label`,`Copy link`);let i=V(`span`,`settings-view-copy-status`);return i.setAttribute(`role`,`status`),r.addEventListener(`click`,async()=>{let t=new URL(X$(Q.id,e.id),location.href).href;try{await navigator.clipboard.writeText(t),i.textContent=`Link copied`}catch{i.textContent=`Copy failed`}setTimeout(()=>{i.textContent=``},1600)}),t.append(n,r,i),t}function N1(e,t){let n=V(`article`,`settings-view-setting`);n.append(M1(e),V(`p`,`settings-view-setting-description`,e.description)),n.appendChild(O1(e)),e.id===`compact-status`&&n.appendChild(PJ()),qX(e,J$(e))&&n.appendChild(V(`div`,`settings-view-warning settings-warning`,e.warning));let r=A1(e);return r&&n.appendChild(r),t[e.id]&&n.appendChild(V(`div`,`settings-view-field-error`,t[e.id])),n}function P1(){if(M$&&j$){for(let e of Q.settings)M$[e.path]=structuredClone(j$[e.path]);N$=``,q1()}}async function F1(){let e=Q,t=[e],n=NX(t,M$??{},c$);if(Object.keys(n).length>0){N$=`Fix the highlighted settings before saving.`,q1();return}let r=ZY(kX(t,j$??{},M$??{}));if(Object.keys(r).length!==0)try{let t=await of(`update-settings`,{settings:r});if(t.type===`settings-error`){if(Q!==e)return;N$=String(t.message),q1();return}t.settings&&d0(t.settings,{rehydrateSectionIds:[e.id]})}catch(t){if(Q!==e)return;N$=t?.message||`Failed to save settings.`,q1()}}function I1(e){let t=Y$(Q);if(Q.level===`browser`||!t&&!N$)return null;let n=V(`footer`,`settings-view-footer`),r=V(`div`,`settings-view-footer-error`,N$);if(r.setAttribute(`role`,`status`),n.appendChild(r),!t)return n;let i=V(`div`,`settings-view-footer-actions`),a=V(`button`,`btn-dialog btn-dialog-cancel`,`Revert`);a.type=`button`,a.addEventListener(`click`,P1);let o=V(`button`,`btn-dialog btn-dialog-confirm`,`Save`);return o.type=`button`,o.disabled=Object.keys(e).length>0,o.addEventListener(`click`,F1),i.append(a,o),n.appendChild(i),n}function L1(e){return e===null?`not probed yet`:e?`resolved`:`not found on PATH`}function R1(){let e=Array.isArray(D$.customAgents)?D$.customAgents:[];return e.length===0?[`None declared. Add customAgents to config.json.`]:e.map(e=>{let t=e.args.length>0?`${e.command} ${e.args.join(` `)}`:e.command;return`${e.id} ${e.label} ${t} ${L1(e.resolvable)}`})}function z1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Declared agents`));for(let t of R1())e.appendChild(V(`div`,`settings-readonly`,t));return e}async function B1(e,t){W$.add(e.id),G$.delete(e.id),m0();try{let n=await of(`update-settings`,{settings:{workflows:{rules:[{id:e.id,enabled:t}]}}});if(n.type===`settings-error`&&G$.set(e.id,String(n.message)),W$.delete(e.id),n.type!==`settings-error`&&n.settings){d0(n.settings);return}}catch(t){G$.set(e.id,t?.message||`Failed to save the rule.`)}W$.delete(e.id),m0()}function V1(e){return W$.has(e.id)?`Saving`:G$.get(e.id)??``}function H1(e){let t=V(`div`,`settings-view-toggle-wrap`),n=V(`label`,`settings-view-toggle`),r=V(`input`,`settings-view-checkbox`);r.type=`checkbox`,r.checked=e.isEnabled,r.disabled=W$.has(e.id),r.setAttribute(`aria-label`,`Run rule ${e.name}`),r.addEventListener(`change`,()=>{B1(e,r.checked)}),n.append(r,V(`span`,`settings-view-toggle-state`,e.isEnabled?`On`:`Off`),V(`span`,`settings-readonly`,`${e.name} ${e.summary}`));let i=V(`span`,`settings-view-copy-status`,V1(e));return i.setAttribute(`role`,`status`),t.append(n,i),t}function U1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Rules`));let t=XY(D$.workflows);if(t.length>0){for(let n of t)e.appendChild(H1(n));return e}for(let t of YY(D$.workflows))e.appendChild(V(`div`,`settings-readonly`,t));return e}function W1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Last report`));let t=MQ();for(let n of t)e.appendChild(V(`div`,`settings-readonly`,n));return e}function G1(){let e=V(`button`,`btn-dialog btn-dialog-cancel`,`Reset to defaults`);return e.type=`button`,e.addEventListener(`click`,()=>{Bk(),r1(),XJ(YO()),q1()}),e}function K1(e,t){let n=V(`div`,`settings-view-advanced`),r=V(`button`,`dialog-advanced-toggle settings-view-advanced-toggle`,`Advanced`);r.type=`button`,r.setAttribute(`aria-expanded`,String(h$)),r.setAttribute(`aria-controls`,`settings-view-advanced-panel`);let i=V(`div`,`dialog-advanced-panel settings-view-advanced-panel`);i.id=`settings-view-advanced-panel`,i.hidden=!h$,r.addEventListener(`click`,()=>{h$=!h$,i.hidden=!h$,r.setAttribute(`aria-expanded`,String(h$))});for(let n of e)i.append(N1(n,t));return Q.id===`browser-flying-animals`&&i.append(G1()),n.append(r,i),n}function q1(){if(!E$||!M$)return;E$.textContent=``;let e=V(`header`,`settings-view-section-header`),t=V(`div`,`settings-view-title-row`),n=V(`h1`,`settings-view-section-title`,Q.title);if(n.tabIndex=-1,n.addEventListener(`click`,()=>Z$(Q.id)),t.append(n),t.append(V(`span`,`settings-view-level`,m$[Q.level]||Q.level)),e.append(t,V(`p`,`settings-view-section-description`,Q.description)),Q.caption&&e.appendChild(V(`p`,`settings-view-section-caption`,Q.caption)),E$.appendChild(e),Q.id===`browser-shortcuts`){let e=V(`div`,`shortcut-groups settings-view-shortcuts`);e1(e),E$.appendChild(e),E$.appendChild(nZ()),E$.appendChild(rZ()),t1(E$);return}let r=NX([Q],M$,c$),i=V(`div`,`settings-view-stack`);for(let e of Q.settings.filter(e=>!e.advanced))i.appendChild(N1(e,r));Q.id===`browser-flying-animals`&&i.append(ZJ());let a=Q.settings.filter(e=>e.advanced);a.length>0&&i.append(K1(a,r));for(let e of Q.unattendedLinks||[]){let t=V(`div`,`settings-view-unattended-link`);t.append(document.createTextNode(`${e.title}: `));let n=V(`a`,null,`Enabled in Unattended actions`);n.href=X$(`lanes-unattended`,e.settingId),t.appendChild(n),i.appendChild(t)}E$.appendChild(i);let o=I1(r);o&&E$.appendChild(o)}function J1(e,{focusContent:t=!1,settingId:n=null,updateHash:r=!0}={}){Q.id!==e&&(h$=!1),Q=JX(p$,e)??Q,N$=``,Y1(y$),Y1(w$),S$&&(S$.textContent=Q.title,x$&&(x$.title=Q.title)),C$&&(C$.textContent=m$[Q.level]||Q.level),q1(),o0(Q)&&a0(),Q.id===`machine-updates`&&T1(),r&&Z$(Q.id,n),n&&soe(n),t&&E$?.querySelector(`h1`)?.focus()}function Y1(e){for(let t of e?.querySelectorAll(`[data-settings-section]`)||[]){let e=t.dataset.settingsSection===Q.id;t.setAttribute(`aria-current`,e?`page`:`false`)}}function X1(e){t0(!1),b$&&(b$.value=``,P$=``,n0(),J1(e.section.id,{settingId:e.setting.id}))}function Z1(e,t){if(t.length===0){e.appendChild(V(`div`,`settings-empty settings-view-search-empty`,`No settings found.`));return}let n=new Map;for(let e of t)n.has(e.section.id)||n.set(e.section.id,[]),n.get(e.section.id)?.push(e);for(let t of n.values()){let n=t[0].section,r=V(`div`,`settings-view-nav-group`);r.appendChild(V(`div`,`settings-view-nav-label`,`${n.title} (${m$[n.level]})`));for(let e of t){let t=V(`button`,`settings-view-nav-item settings-view-search-result`,e.setting.title);t.type=`button`,t.addEventListener(`click`,()=>X1(e)),r.appendChild(t)}e.appendChild(r)}}function Q1(e,t,{groupClassName:n,headingClassName:r,createButton:i}){for(let a of[`browser`,`machine`,`lanes`,`projects`]){if(t[a].length===0)continue;let o=V(`div`,n);o.appendChild(V(`div`,r,m$[a]));for(let e of t[a])o.appendChild(i(e));e.appendChild(o)}}function $1(e){w$&&(w$.textContent=``,Q1(w$,e,{groupClassName:`settings-view-section-picker-group`,headingClassName:`settings-view-section-picker-heading`,createButton(e){let t=V(`button`,`settings-view-section-option`,e.title);return t.type=`button`,t.dataset.settingsSection=e.id,t.addEventListener(`click`,()=>{t0(!1),J1(e.id)}),t}}),Y1(w$))}function e0(){return!!w$&&!w$.hidden}function t0(e,{returnFocus:t=!0}={}){if(!w$||!x$)return;let n=e0();if(w$.hidden=!e,x$.setAttribute(`aria-expanded`,String(e)),e){$1(IX(p$)),requestAnimationFrame(()=>{let e=w$?.querySelector(`[aria-current="page"]`);e instanceof HTMLElement&&e.focus()});return}t&&n&&x$.focus()}function n0(){if(!y$||!T$||!v$)return;let e=IX(p$);if(y$.textContent=``,T$.textContent=``,v$.dataset.searching=String(!!P$),T$.hidden=!P$,P$){let e=LX(p$,P$);Z1(y$,e),Z1(T$,e);return}Q1(y$,e,{groupClassName:`settings-view-nav-group`,headingClassName:`settings-view-nav-label`,createButton(e){let t=V(`button`,`settings-view-nav-item`,e.title);return t.type=`button`,t.dataset.settingsSection=e.id,t.addEventListener(`click`,()=>J1(e.id)),t}}),$1(e),J1(Q.id,{updateHash:!1})}function r0(e){if(P$&&e.key===`Enter`){let t=LX(p$,P$)[0];if(!t)return;e.preventDefault(),X1(t);return}if(e.key===`Escape`&&P$){if(!b$)return;e.preventDefault(),b$.value=``,P$=``,n0(),b$.focus();return}if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`||!y$)return;let t=[...y$.querySelectorAll(`[data-settings-section]`)].filter(e=>e instanceof HTMLElement),n=document.activeElement;if(!(n instanceof HTMLElement))return;let r=t.indexOf(n);r<0||(e.preventDefault(),t[(r+(e.key===`ArrowDown`?1:-1)+t.length)%t.length].focus())}function i0(e,{onRestart:t=()=>{},onConfirmUpdateAndRestart:n=e=>{e([])}}={}){B$=t,V$=n,LQ(n1),g$=e,g$.textContent=``,v$=V(`div`,`settings-view-shell`);let r=V(`div`,`settings-view-sidebar`);b$=V(`input`,`settings-view-search`),b$.type=`search`,b$.placeholder=`Search settings`,b$.setAttribute(`aria-label`,`Search settings`),y$=V(`nav`,`settings-view-nav`),y$.setAttribute(`role`,`navigation`),y$.setAttribute(`aria-label`,`Settings sections`),x$=V(`button`,`settings-view-section-button`),x$.type=`button`,x$.setAttribute(`aria-expanded`,`false`),x$.setAttribute(`aria-controls`,`settings-section-picker`),S$=V(`span`,`settings-view-section-button-title`),C$=V(`span`,`settings-view-section-button-level`);let i=V(`span`,`settings-view-section-button-chevron`,`⌄`);i.setAttribute(`aria-hidden`,`true`),x$.append(S$,C$,i),w$=V(`div`,`settings-view-section-picker`),w$.id=`settings-section-picker`,w$.hidden=!0,w$.setAttribute(`role`,`dialog`),w$.setAttribute(`aria-label`,`Settings sections`),T$=V(`nav`,`settings-view-phone-results`),T$.hidden=!0,T$.setAttribute(`aria-label`,`Settings search results`),E$=V(`div`,`settings-view-content`),E$.setAttribute(`aria-live`,`polite`),b$.addEventListener(`input`,()=>{let e=b$;e&&(P$=e.value.trim(),n0())}),b$.addEventListener(`keydown`,r0),y$.addEventListener(`keydown`,r0),T$.addEventListener(`keydown`,r0),x$.addEventListener(`click`,()=>t0(!e0())),F$&&document.removeEventListener(`click`,F$),I$&&document.removeEventListener(`keydown`,I$),F$=e=>{e0()&&e.target instanceof Node&&(w$?.contains(e.target)||x$?.contains(e.target)||t0(!1))},I$=e=>{e.key===`Escape`&&e0()&&(e.preventDefault(),t0(!1))},document.addEventListener(`click`,F$),document.addEventListener(`keydown`,I$),r.append(b$,x$,y$,w$),v$.append(r,T$,E$),g$.appendChild(v$),q$(D$),n0(),a0(),_$?.disconnect(),_$=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&a0()}),_$.observe(g$)}function a0(){Sx().then(s0)}function o0(e){return e.settings.some(e=>e.path===`pref:soundId`)}function s0(){f$=d$(),Q$();let e=xx(zO());j$&&(j$[`pref:soundId`]=e),M$&&(M$[`pref:soundId`]=e),o0(Q)&&q1()}function c0({returnFocus:e=!0}={}){t0(!1,{returnFocus:e})}function l0(e=null,t=null){J1(e||Q.id,{settingId:t})}function u0(e){return RX(e,p$,GY,KY)}function d0(e,t={}){let{rehydrateSectionIds:n=[]}=t;if(!e)return;D$=e,O$=Array.isArray(D$.projectChoices)?D$.projectChoices:[],$$(D$.projectChoices),Q$();let r={...D$,prefs:K$()},i=OX(p$,r,j$,M$,{rehydrateSectionIds:n});j$=i.original,M$=i.edited,N$=``,y$&&n0(),q1()}function f0(e){return document.getElementById(e.id)?.closest(`.settings-view-setting`)??null}function p0(e,t){let n=t.querySelector(`.settings-view-status-slot`),r=A1(e);n&&r&&n.replaceWith(r),n&&!r&&n.remove(),!n&&r&&t.appendChild(r)}function m0(){for(let e of Q.settings||[]){if(!e.status)continue;let t=f0(e);t&&p0(e,t)}}function h0(){if(Q.id===`machine-updates`)for(let e of Q.settings||[]){if(!e.status?.startsWith(`update-`))continue;let t=f0(e);t&&(t.querySelector(`.settings-update-readout`)?.replaceWith(O1(e)),p0(e,t))}}function g0(e){L$=e,z$=WQ(z$,`status-frame`),h0(),U$&&Q.id===`machine-updates`&&T1()}function _0(e){R$=e,z$=WQ(z$,`progress-frame`),h0()}function v0(){S1(`error-frame`)}function y0(e){$$(e),Q$(),y$&&n0()}function b0(){Q.id===`browser-flying-animals`&&q1()}window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,b0),Gf(b0);function x0(e){return[...e||[]].map((e,t)=>({row:e,index:t})).sort((e,t)=>gj(e.row||{},`phone-triage`)-gj(t.row||{},`phone-triage`)||e.index-t.index).map(e=>e.row)}var S0=new Set;function C0(e,t,n){let r=nU(e,t,n),i=r.groups.map(e=>({...e,rows:x0(e.rows)})),a={...r,groups:i};return{...a,visibleIds:rU(a,S0)}}var w0=e=>e.ui.path;function T0({onSelectSession:e}){let t=V(`div`,`phone-board`),n=V(`header`,`phone-topbar`),r=V(`div`,`phone-attention`);r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`);let i=V(`div`,`phone-calm calm-view`);i.hidden=!0;let a=V(`div`,`phone-board-list`),o=V(`div`,`phone-empty`);o.append(V(`p`,`phone-empty-title`,`No sessions`),V(`p`,`phone-empty-desc`,`Spawn a session to start watching.`)),t.append(n,r,i,a,o);let s=new Map,c=new Map,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=0;Sf(n);function p(t){let n=V(`button`,`phone-row`);n.type=`button`,n.dataset.id=t,n.innerHTML=`<span class="phone-row-glyph" aria-hidden="true"></span><span class="phone-row-main"><span class="phone-row-name"></span><span class="phone-row-meta"><span class="phone-row-badge"></span><span class="phone-row-merge"></span></span></span><span class="phone-row-elapsed" aria-hidden="true"></span>`;let r={glyph:H(n,`.phone-row-glyph`,`span`),name:H(n,`.phone-row-name`,`span`),badge:H(n,`.phone-row-badge`,`span`),merge:H(n,`.phone-row-merge`,`span`),elapsed:H(n,`.phone-row-elapsed`,`span`)};n.addEventListener(`click`,()=>e?.(t));let i=V(`div`,`phone-row-item`);i.setAttribute(`role`,`listitem`);let a=V(`button`,`phone-row-remove`,`x`);return a.type=`button`,a.title=`Remove session`,a.setAttribute(`aria-label`,`Remove session`),a.addEventListener(`click`,e=>{e.stopPropagation(),OI(t)}),i.append(n,a),l.set(n,{refs:r,item:i}),n}function m(e){let t=V(`section`,`phone-board-group`);t.dataset.key=e;let n=V(`div`,`phone-board-group-header`),r=V(`span`,`phone-board-group-label`),i=V(`span`,`phone-board-group-count`),a=V(`button`,`phone-board-group-add`,`+`);a.type=`button`,a.addEventListener(`click`,()=>DI(t.dataset.path,t.dataset.label));let o=V(`button`,`phone-board-group-forget`,`x`);o.type=`button`,o.addEventListener(`click`,()=>{gI(t.dataset.path),b()});let s=V(`div`,`phone-board-group-rows`);return s.setAttribute(`role`,`list`),n.append(r,i,o,a),t.append(n,s),u.set(t,{header:n,label:r,count:i,addButton:a,forgetButton:o,rows:s}),t}function h(e,t){let n=l.get(e);if(!n)return;let{ui:r,state:i,unseen:a}=t,{glyph:o,label:s,isMonitoring:c}=xf(i,r.awaitingBackgroundTasks),u=r.pendingPromptKind===`plan`?`Plan ready`:s,d=t.name;e.dataset.state=i,e.toggleAttribute(`data-monitoring`,c),e.dataset.prompt=r.pendingPromptKind??``,e.toggleAttribute(`data-unseen`,a),n.refs.glyph.textContent=o,n.refs.name.textContent=d;let f=V(`span`,`session-list-task-title`,r.taskTitle??``);n.refs.name.append(f),n.refs.name.title=[d,r.taskTitle].filter(Boolean).join(` | `),n.refs.badge.textContent=u;let p=r.card?.dataset.merge||``;e.dataset.merge=p,n.refs.merge.textContent=yf[p]||``,n.refs.elapsed.textContent=Np(r),e.setAttribute(`aria-label`,`${d}, ${u}`)}function g(e,t){let n=u.get(e);if(!n)return;let{header:r,label:i,count:a,addButton:o,forgetButton:s,rows:c}=n,l=t.key===eU,d=t.rows.length===0;e.dataset.path=t.key,e.dataset.label=t.label,e.toggleAttribute(`data-empty`,d),r.title=t.title,i.textContent=t.label,a.textContent=String(t.rows.length),a.title=`${t.rows.length} ${t.rows.length===1?`session`:`sessions`}`,o.hidden=l,s.hidden=l||!d,l||(o.title=`Add a session to ${t.label}`,o.setAttribute(`aria-label`,`Add a session to ${t.label}`)),!l&&d&&(s.title=`Remove ${t.label} from the Board`,s.setAttribute(`aria-label`,`Remove ${t.label} from the Board`)),c.setAttribute(`aria-label`,`${t.label} sessions`)}let{noteStates:_,acknowledge:v,isUnseen:y}=oU();function ee(){let e=EI();_(e);for(let t of e)t.unseen=y(t.id);return _j(e)}function b(){let e=ee(),t=C0(e,w0,hI(e,w0));f=xj(e),r.textContent=Sj(f),r.toggleAttribute(`data-lit`,f>0);let n=new Set(t.order),i=t.order.join(`,`),_=d.get(a)===i&&a.childElementCount===t.groups.length;for(let e of t.groups){let t=c.get(e.key);t||(t=m(e.key),c.set(e.key,t)),g(t,e),_||a.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=u.get(t);if(!r)continue;let i=d.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=s.get(t.id);e||(e=p(t.id),s.set(t.id,e)),h(e,t);let n=l.get(e);n&&(i||r.rows.appendChild(n.item))}d.set(r.rows,n)}d.set(a,i);for(let[e,t]of[...c])n.has(e)||(t.remove(),c.delete(e));let v=new Set(t.visibleIds);for(let[e,t]of[...s]){if(v.has(e))continue;let n=l.get(t);n&&n.item.remove(),s.delete(e)}let y=t.groups.length>0;a.hidden=!y,o.hidden=y}Ip(()=>{for(let[e,t]of s){let n=U.get(e),r=l.get(t);n&&r&&(r.refs.elapsed.textContent=Np(n))}});function te(e){i.hidden=!e,t.toggleAttribute(`data-calm`,e)}return{el:t,topBarEl:n,calmEl:i,setCalmShown:te,refresh:b,acknowledge:v,getAttentionCount:()=>f}}var E0=`glimmervoidCalmSheet`,D0=Object.freeze({[E0]:!0});function O0(e){return typeof e!=`object`||!e?!1:E0 in e}function k0({poppedState:e,isCalmSheetOpen:t,isOwnSheetPopPending:n}){if(n)return`own-sheet-pop`;let r=O0(e);return r&&t?`adopt-sheet-entry`:r?`consume-stray-sheet-entry`:t?`close-sheet`:`navigate`}function A0({pushedEntry:e,isOwnSheetPopPending:t}){return e===`none`?t?`defer-until-own-pop`:`push-sheet-entry`:`keep-history`}function j0({pushedEntry:e,topState:t,isOwnSheetPopPending:n}){return!n&&e===`calm-sheet`&&O0(t)}var M0=`clipboard`,N0=`upload`,P0=Object.freeze([Object.freeze({id:`esc`,label:`Esc`,bytes:`\x1B`,title:`Send Escape`}),Object.freeze({id:`tab`,label:`Tab`,bytes:` `,title:`Send Tab`}),Object.freeze({id:`up`,label:`Up`,bytes:`\x1B[A`,title:`Arrow up`}),Object.freeze({id:`down`,label:`Down`,bytes:`\x1B[B`,title:`Arrow down`}),Object.freeze({id:`paste`,label:`Paste`,bytes:null,action:M0,title:`Paste from the clipboard`}),Object.freeze({id:`upload-image`,label:`Image`,bytes:null,action:N0,accept:`image/*`,title:`Upload an image to this session`}),Object.freeze({id:`upload-file`,label:`File`,bytes:null,action:N0,title:`Upload a file to this session`})]);function F0(e){let t=P0.find(t=>t.id===e);return t?t.bytes:null}function I0(e){return!!e&&e.action===`clipboard`}function L0(e){return!!e&&e.action===`upload`}function R0({send:e,getSessionId:t}){let n=V(`div`,`phone-key-strip`);n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Terminal keys`);let r=null,i=null;for(let e of P0){let t=V(`button`,`phone-key`,e.label);t.type=`button`,t.dataset.key=e.id,t.title=e.title,t.addEventListener(`pointerdown`,e=>e.preventDefault()),t.addEventListener(`click`,()=>a(e,t)),n.appendChild(t)}function a(t,n){if(L0(t)){o(t,n);return}if(I0(t)){B0(e);return}e(F0(t.id))}function o(e,t){i=t,r||(r=V(`input`,`phone-file-picker`),r.type=`file`,r.hidden=!0,r.addEventListener(`change`,s),n.appendChild(r)),e.accept&&(r.accept=e.accept),e.accept||r.removeAttribute(`accept`),r.click()}function s(){let e=r;if(!e)return;let n=e.files?e.files[0]:null;if(e.value=``,!n)return;let a=t?.();if(!a){WS(`No session is open to upload to`);return}c(a,n,i)}async function c(e,t,n){n&&(n.disabled=!0);let r={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(r[`content-type`]=t.type);try{let n=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:r});n.ok||WS(await z0(n))}catch{WS(`Upload failed`)}finally{n&&(n.disabled=!1)}}return n}async function z0(e){try{let t=await e.json();if(t&&typeof t.error==`string`)return`Upload failed: ${t.error}`}catch{}return`Upload failed`}function B0(e){let t=null;try{t=navigator.clipboard?.readText?.()}catch{WS(`Paste needs clipboard permission`);return}if(!t){WS(`Paste is unavailable in this browser`);return}t.then(t=>{t&&e(t)}).catch(()=>WS(`Paste needs clipboard permission`))}var V0=`‹`;function H0({onBack:e}){let t=V(`div`,`phone-terminal`),n=V(`header`,`phone-topbar phone-terminal-bar`),r=V(`button`,`phone-back`,V0);r.type=`button`,r.setAttribute(`aria-label`,`Back to board`),r.addEventListener(`click`,()=>e?.());let i=V(`div`,`phone-terminal-identity`),a=V(`span`,`phone-terminal-name`);a.title=`Tap to rename`,a.addEventListener(`click`,()=>b());let o=V(`span`,`session-task-title session-list-task-title`);LV(o,()=>te());let s=V(`span`,`phone-terminal-identity-line`),c=V(`span`,`phone-terminal-badge`);c.innerHTML=`<span class="phone-terminal-glyph" aria-hidden="true"></span><span class="phone-terminal-label"></span><span class="phone-terminal-elapsed" aria-hidden="true"></span>`;let l=H(c,`.phone-terminal-glyph`,`span`),u=H(c,`.phone-terminal-label`,`span`),d=H(c,`.phone-terminal-elapsed`,`span`);s.append(a,o),i.append(s,c);let f=V(`div`,`phone-terminal-actions`);n.append(r,i,f);let p=V(`div`,`phone-card-slot`),m=V(`div`,`phone-empty`);m.innerHTML=`<p class="phone-empty-title">No session selected</p><p class="phone-empty-desc">Select a session from the board to watch it here.</p>`;let h=R0({send:y,getSessionId:()=>g});t.append(n,p,m,h);let g=null,_=null,v=null;function y(e){let t=g?U.get(g):null;t&&(vA(t,e)||WS(`Session is not connected; key press was dropped`))}function ee(){let e=g?U.get(g):null;e?.term&&e.term.focus()}p.addEventListener(`click`,ee);function b(){let e=g?U.get(g):null;e&&g&&HV(e,g)}function te(){let e=g?U.get(g):null;e&&g&&zV(e,g)}function ne(){let e=g?U.get(g):null,t=!!e;if(m.hidden=t,p.hidden=!t,h.hidden=!t,i.hidden=!t,!t){n.removeAttribute(`data-state`),n.removeAttribute(`data-monitoring`);return}let r=e.currentState||F.DORMANT;n.dataset.state=r;let{glyph:s,label:c,isMonitoring:f}=xf(r,e.awaitingBackgroundTasks);n.toggleAttribute(`data-monitoring`,f),VV(a)||(a.textContent=e.card?.dataset.session||g),RV(o,e.taskTitle),l.textContent=s,u.textContent=c,d.textContent=Np(e)}function re(){v&&=(delete v.renameTargetEl,delete v.titleTargetEl,null),a.replaceChildren(),_&&=(kf(_),_.parentElement===f&&_.remove(),null)}function ie(e){let t=U.get(e);if(t){if(g===e&&DP()===e&&t.card.parentElement===p){ne();return}re(),g=e,OP(t,e,p,{className:`phone-centered`}),_=H(t.card,`.session-actions`,`div`),Of(_,f),t.renameTargetEl=a,t.titleTargetEl=o,v=t,ne()}}function ae(){re(),DP()===g&&kP(),g=null,ne()}function x(){if(!g){ne();return}let e=U.get(g);if(!e){ae();return}if(e.card.parentElement!==p){ie(g);return}ne()}function oe(){let e=g;e&&TA(U.get(e),e,!1)}function se(){x();let e=g;if(!e)return;let t=U.get(e);t&&TA(t,e,!0)}return Ip(()=>{let e=g?U.get(g):null;e&&(d.textContent=Np(e))}),ne(),{el:t,show:ie,clear:ae,refresh:x,reveal:se,unview:oe,getSessionId:()=>g}}var U0=`board`,W0=Object.freeze([{id:U0,label:`Board`,glyph:`▤`},{id:`terminal`,label:`Terminal`,glyph:`▸`},{id:`review`,label:`Review`,glyph:`◫`}]),G0=[],K0=new Map,q0=null,J0=new Map,Y0=new Map,X0=new Map,Z0=null,Q0=null,$0=null,e2=null,t2=null,n2=new Map,r2=new Set,i2={},a2=!1,o2=120,s2=0,c2=0,l2=`none`,u2=!1,d2=!1,f2=!1,p2={openTerminal:E2,openPlan:e=>{W2(e)},onSheetOpenChange:M2};function m2(){s2=0,c2=0}function h2(){let e=window.visualViewport;if(q0){if(!a2||!e){q0.removeAttribute(`data-keyboard`);return}if(q0.style.setProperty(`--phone-vh`,`${e.height}px`),q0.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==c2&&(c2=e.width,s2=0),s2=Math.max(s2,e.height),s2-e.height>o2){q0.dataset.keyboard=`open`;return}q0.removeAttribute(`data-keyboard`)}}function g2(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=V(`button`,n);i.type=`button`;let a=V(`span`,`phone-nav-glyph`,t);a.setAttribute(`aria-hidden`,`true`),i.append(a,V(`span`,`phone-nav-label`,e));let o=V(`span`,r);return o.setAttribute(`aria-hidden`,`true`),o.hidden=!0,i.appendChild(o),i}function _2(e){return e?.querySelector(`.phone-nav-dot`)||null}function v2(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function y2(){let e=[];for(let t of G0){if(r2.has(t.id))continue;let n=X0.get(t.id)||!1;e.push(n),v2(_2(n2.get(t.id)),n)}v2(_2(e2),bie(e))}function b2(){let e=V(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of G0){let n=g2(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=r2.has(t.id),n.addEventListener(`click`,()=>{x2(!1),R2(t.id)}),n2.set(t.id,n),e.appendChild(n)}return e}function x2(e){t2&&e2&&(t2.hidden=!e,e2.setAttribute(`aria-expanded`,String(e)))}function S2(){return!!t2&&!t2.hidden}function C2(){let e=V(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of W0){let n=g2(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>R2(t.id)),J0.set(t.id,n),e.appendChild(n)}return e2=g2(`More`,`⋯`),e2.setAttribute(`aria-expanded`,`false`),e2.addEventListener(`click`,()=>x2(!S2())),e.appendChild(e2),t2=b2(),e.appendChild(t2),e}function w2(e,t,n){let r=V(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),Y0.set(e,r),r}function T2(){if(q0)return;Z0=T0({onSelectSession:E2}),Z0.setCalmShown(f2),Q0=H0({onBack:()=>R2(U0)}),$0=V(`div`,`phone-review`);let e=V(`div`,`phone-screens`),t={[U0]:Z0.el,terminal:Q0.el,review:$0};for(let n of W0)e.appendChild(w2(n.id,n.label,t[n.id]));for(let t of G0){let n=V(`div`,`phone-panel phone-${t.id}`);K0.set(t.id,n),e.appendChild(w2(t.id,t.label,n))}q0=V(`div`,`phone-shell`),q0.id=`phone-shell`,q0.append(e,C2()),document.body.appendChild(q0),y2(),window.visualViewport?.addEventListener(`resize`,h2),window.visualViewport?.addEventListener(`scroll`,h2),window.addEventListener(`popstate`,P2),document.addEventListener(`click`,e=>{S2()&&t2&&e2&&e.target instanceof Node&&(t2.contains(e.target)||e2.contains(e.target)||x2(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&S2()&&x2(!1)})}function E2(e){if(U.has(e)){if(!Z0||!Q0)throw Error(`Phone shell is not built`);CI(e,`dormant-fallback`),Z0.acknowledge(e),wI(e),Q0.show(e),R2(`terminal`)}}function D2(e){if(e===U0){k2();return}let t={glimmervoidScreen:e};if(l2!==`none`){history.replaceState(t,``),l2=`screen`;return}history.pushState(t,``),l2=`screen`}function O2(){if(O0(history.state))return l2=`calm-sheet`,j2(),U0;let e=N2(history.state);return e&&L2(e)?(l2=`screen`,e):(e&&history.replaceState(null,``),l2=`none`,U0)}function k2(){l2!==`none`&&(l2=`none`,history.back())}function A2(){A0({pushedEntry:l2,isOwnSheetPopPending:d2})===`push-sheet-entry`&&(history.pushState(D0,``),l2=`calm-sheet`)}function j2(){j0({pushedEntry:l2,topState:history.state,isOwnSheetPopPending:d2})&&(l2=`none`,d2=!0,history.back())}function M2(e){if(u2=e,e){A2();return}j2()}function N2(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function P2(e){let t=d2;if(d2=!1,!a2)return;let n=k0({poppedState:e.state,isCalmSheetOpen:u2,isOwnSheetPopPending:t});if(n===`own-sheet-pop`){u2&&A2();return}if(n===`adopt-sheet-entry`){l2=`calm-sheet`;return}if(n===`consume-stray-sheet-entry`){l2=`calm-sheet`,j2();return}if(n===`close-sheet`){l2=`none`,bP();return}let r=N2(e.state);l2=r?`screen`:`none`,I2(r&&L2(r)?r:U0)}function F2(e,t){for(let[n,r]of e){if(n===t){r.setAttribute(`aria-current`,`page`);continue}r.removeAttribute(`aria-current`)}}function I2(e){if(!e2||!Q0)throw Error(`Phone shell is not built`);Lf.dispatch(`setPhoneScreen`,e),x2(!1);for(let[t,n]of Y0)n.hidden=t!==e;i2.onScreenShown?.(e),H2(),F2(J0,e);let t=n2.has(e);if(t&&e2.setAttribute(`aria-current`,`page`),t||e2.removeAttribute(`aria-current`),F2(n2,e),e===`terminal`){Q0.reveal();return}Q0.unview()}function L2(e){return Y0.has(e)&&!r2.has(e)}function R2(e){q0&&L2(e)&&(e!==Lf.snapshot().phoneScreen&&D2(e),I2(e))}function z2(e){i2=e||{},G0=i2.panels||[]}function B2({sessionId:e}={}){if(a2)return;if(T2(),!q0||!Z0||!Q0)throw Error(`Phone shell is not built`);a2=!0,q0.hidden=!1;for(let e of i2.headerControls||[])Of(e,Z0.topBarEl);az($0);for(let e of G0)Of(e.el,K0.get(e.id)),e.el.hidden=!1;h2(),e&&Q0.show(e);let t=O2();if(q2(),e&&t===U0){Lf.dispatch(`setPhoneScreen`,U0),R2(`terminal`);return}I2(t)}function V2(){if(a2){if(!q0||!Q0)throw Error(`Phone shell is not built`);a2=!1,H2(),c0({returnFocus:!1}),Q0.clear(),az(null);for(let e of G0)kf(e.el);for(let e of i2.headerControls||[])kf(e);x2(!1),q0.hidden=!0,q0.removeAttribute(`data-keyboard`),m2(),k2()}}function H2(){if(Z0){if(!(a2&&f2&&Lf.snapshot().phoneScreen===U0)){xP();return}yP(Z0.calmEl,p2)}}function U2(e){f2=e,Z0?.setCalmShown(e),H2()}function W2(e){return!a2||!Z0||!Q0||!U.has(e)?!1:(E2(e),EH(e))}function G2(){return a2}function K2(){return a2&&Q0?Q0.getSessionId():null}function q2(){if(!a2)return;if(!Z0||!Q0)throw Error(`Phone shell is not built`);Z2(),Z0.refresh(),Q0.refresh(),Lf.snapshot().phoneScreen===`terminal`&&!Q0.getSessionId()&&R2(U0);let e=_2(J0.get(U0));e&&(e.hidden=Z0.getAttentionCount()===0)}function J2(e){return!a2||!L2(e)?!1:(R2(e),!0)}function Y2(e,t){t&&r2.delete(e),t||r2.add(e);let n=n2.get(e);n&&(n.hidden=!t);let r=Y0.get(e);r&&!t&&(r.hidden=!0),y2(),!t&&a2&&Lf.snapshot().phoneScreen===e&&R2(U0)}function X2(e,t){X0.set(e,typeof t==`string`&&t?t:t===!0),y2()}function Z2(){if(!Q0)throw Error(`Phone shell is not built`);if(Q0.getSessionId())return;let e=TI();e&&(Q0.show(e),wI(e,{rememberFocus:!1}))}function Q2(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function $2(e,t){if(!e?.error)return null;let n=`Could not reach GitHub: ${e.error.trim().replace(/[.!]+$/,``)}.`;if(e.isRefreshing)return`${n} Refreshing.`;if(typeof e.nextAttemptAt!=`number`)return n;let r=Math.max(0,Math.ceil((e.nextAttemptAt-t)/1e3));return r===0?`${n} Retrying now.`:e.retry?`${n} Retrying in ${r}s (${e.retry.attempt} of ${e.retry.limit}).`:`${n} Next try in ${r>=60?`${Math.ceil(r/60)} min`:`${r}s`}.`}function e4(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing.`:n||e?.refreshNotice||``}var t4={minPx:220,maxPx:720},n4=16,r4=new Set,i4=0;function a4(e){let t=sk();e.toggleAttribute(`data-queue-collapsed`,t),e.querySelector(`.pr-queue-toggle`)?.setAttribute(`aria-expanded`,String(!t));let n=ak();if(n===null){e.style.removeProperty(`--pr-queue-width`);return}e.style.setProperty(`--pr-queue-width`,`${n}px`)}function o4(){for(let e of r4){if(!e.isConnected){r4.delete(e);continue}a4(e)}}function s4(e,t){let n=V(`div`,`pr-queue-head`);return e&&n.append(e),t&&n.append(t),n}function c4(e){let t=V(`div`,`pr-queue-foot`);return e&&t.append(e),t}function l4({queueLabel:e,scopeTabs:t,resizerLabel:n}){let r=V(`div`,`pr-columns`),i=V(`div`,`pr-queue-pane`),a=V(`nav`,`pr-queue`);a.id=`pr-queue-${++i4}`,a.setAttribute(`aria-label`,e);let o=V(`button`,`pr-queue-toggle`);o.type=`button`,o.setAttribute(`aria-label`,`Review queue`),o.setAttribute(`aria-controls`,a.id),o.title=`Collapse or expand the review queue`;let s=WL(16,16);s.append(UL(`rect`,{x:`1.5`,y:`2`,width:`13`,height:`12`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),s.append(UL(`path`,{d:`M5.5 2V14`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`}));let c=UL(`path`,{d:`M11 6L9 8L11 10`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`,"stroke-linejoin":`round`});c.classList.add(`pr-queue-chevron`),s.append(c),o.append(s),o.addEventListener(`click`,()=>{ck(!sk()),o4()});let l=c4(null);i.append(s4(t,o),a,l);let u=V(`div`,`pr-queue-resizer`);u.setAttribute(`role`,`separator`),u.setAttribute(`aria-orientation`,`vertical`),u.setAttribute(`aria-label`,n),u.tabIndex=0;let d=V(`main`,`pr-detail-host`);return r.append(i,u,d),a4(r),r4.add(r),dI({resizer:u,column:i,widthHost:r,widthProperty:`--pr-queue-width`,bounds:t4,keyStepPx:n4,getStoredWidth:ak,setStoredWidth:ok}),{columns:r,queue:a,foot:l,detail:d}}var u4=1.2,d4=1.55,f4=.12,p4=523.25,m4=2,h4=8,$=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),g4={melody:[$(7,4,.5),$(11,4.5,.5),$(12,5,3)],bass:[$(-5,4,1),$(-12,5,3)]},_4=[{melody:[$(0,0,1),$(4,1,1),$(7,2,1),$(9,3,1)],bass:[$(-12,0,2),$(-8,2,2)]},{melody:[$(7,0,.67),$(7,.67,.67),$(7,1.33,.67),$(9,2,1),$(5,3,1)],bass:[$(-12,0,2),$(-7,2,2)]},{melody:[$(5,0,1),$(9,1,1),$(7,2,1),$(4,3,1)],bass:[$(-7,0,2),$(-12,2,2)]},{melody:[$(12,0,.5),$(7,.5,.5),$(12,1,.5),$(16,1.5,.5),$(16,2,1),$(14,3,1)],bass:[$(-12,0,2),$(-3,2,2)]},{melody:[$(4,0,1),$(7,1,1),$(4,2,.5),$(5,2.5,.5),$(7,3,.5),$(4,3.5,.5)],bass:[$(-8,0,2),$(-12,2,2)]}].map(e=>({melody:[...e.melody,...g4.melody],bass:[...e.bass,...g4.bass]}));function v4(e,t){return p4*2**((e+t)/12)}function y4(e,t){let n=(e,n,r)=>e.map(e=>({frequency:v4(e.semitone,t),startSeconds:d4+e.startBeat*f4,durationSeconds:e.beats*f4,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var b4=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:u4,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:u4,durationSeconds:.06,waveform:`square`,gain:.12}];function x4(e){let t=_4[e%_4.length],n=Math.min(e*m4,h4);return{peakGain:.1,tones:[...b4,...y4(t,n)]}}function S4(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function C4(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function w4(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var T4=.6,E4=.25,D4=1.6;function O4(e){return Math.min(T4+e*E4,D4)}var k4=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function A4(e,t=Math.random){let n=C4(320,520,t),r=C4(1800,2800,t);return[[`--confetti-start-x`,`${C4(4,96,t)}%`],[`--confetti-x`,`${C4(-140,140,t)}px`],[`--confetti-rise`,`${-C4(20,55,t)}px`],[`--confetti-fall`,`${C4(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${C4(0,180,t)}deg`],[`--confetti-spin`,`${C4(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${C4(160,340,t)}ms`],[`--confetti-delay`,`${C4(0,160,t)}ms`],[`--confetti-color`,k4[e%k4.length]]]}var j4=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,M4=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function N4(){let e=pf(`div`,`merge-bullseye-target`,j4);return e.append(V(`span`,`merge-bullseye-ripple`)),e}function P4(){let e=V(`div`,`merge-bullseye-dart-drift`),t=V(`div`,`merge-bullseye-dart-arc`),n=V(`div`,`merge-bullseye-dart-aim`);return n.append(pf(`div`,`merge-bullseye-dart`,M4)),t.append(n),e.append(t),e}function F4(){let e=V(`div`,`merge-bullseye-range`),t=V(`div`,`merge-bullseye-track`);return t.append(P4()),e.append(N4(),t),e}var I4={title:`BULLSEYE!`,buildScene:F4},L4=6,R4=30,z4=-14,B4=16;function V4(e=Math.random){return[[`--crosshair-start-left`,`${C4(L4,R4,e)}%`],[`--crosshair-start-offset-y`,`${C4(z4,B4,e)}px`]]}var H4=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,U4=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,W4=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function G4(){let e=V(`div`,`merge-headshot-sweep`);mf(e,V4());let t=V(`div`,`merge-headshot-aim`);t.append(pf(`div`,`merge-headshot-crosshair`,U4));let n=V(`div`,`merge-headshot-bob`);return n.append(t,pf(`div`,`merge-headshot-hitmarker`,W4)),e.append(n),e}function K4(){let e=V(`div`,`merge-headshot-range`),t=V(`div`,`merge-headshot-track`);return t.append(G4()),e.append(pf(`div`,`merge-headshot-target`,H4),t),e}var q4={title:`HEADSHOT!`,buildScene:K4},J4=[`10`,`J`,`Q`,`K`,`A`],Y4=19,X4=5,Z4=9,Q4=780,$4=70,e3=70,t3=35;function n3(e){let t=J4.length-1,n=e-t/2;return{offsetPx:n*Y4,titleSpreadFraction:n/t,tiltDegrees:n*X4,bottomPx:Z4-n**2,dealLeadMs:Q4-e*$4,flipLeadMs:160+(t-e)*e3,waveDelayMs:e*t3}}function coe(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function loe(){return[[`--card-flip-ms`,`160ms`]]}var uoe=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function doe(e,t){let n=V(`div`,`merge-flush-deal`);mf(n,coe(n3(t)));let r=V(`div`,`merge-flush-hop`),i=V(`div`,`merge-flush-card`),a=V(`div`,`merge-flush-face`);return a.append(V(`span`,`merge-flush-rank`,e)),a.insertAdjacentHTML(`beforeend`,uoe),i.append(V(`div`,`merge-flush-back`),a),r.append(i),n.append(r),n}function foe(){let e=V(`div`,`merge-flush-table`);return mf(e,loe()),e.append(...J4.map(doe)),e}var poe={title:`ROYAL FLUSH!`,buildScene:foe},moe=[1,2,3,4],hoe=14,goe=3,_oe=3,r3=10,voe=20,yoe=2,i3=28,a3=18,boe=.01,xoe=1.5,Soe=2200,Coe=1,o3=120,s3=.35,woe=4,Toe=65,Eoe=145;function Doe(e){return Math.round(e/(Math.PI*a3)*360)}function c3(e){return voe-e*yoe}function l3(e){return e.rowIndex*hoe+e.depthIndex*goe}function u3(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function d3(){return moe.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function Ooe(e,t){let n=w4(u3(15,105,e),t),r=w4(u3(Toe,Eoe,e),t);return n.map((e,n)=>({angleDegrees:e+C4(-4,woe,t),depthScalePercent:Math.round(r[n])}))}function koe(e,t,n){let r=C4(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=C4(15,45,n),c=S4(o),l=S4(o+s),u=c+l,d=C4(540,1080,n),f=a>=0?1:-1,p=l3(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:c3(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/s3)}}function Aoe(e=Math.random){let t=d3(),n=Ooe(t.length,e);return t.map((t,r)=>koe(t,n[r],e))}function joe(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*_oe}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function Moe(){return c3(xoe)}function Noe(){return Math.max(...d3().map(l3))+r3}function Poe(){let e=Noe(),t=i3+e+a3-Coe;return[[`--ball-follow-px`,`${o3}px`],[`--ball-follow-ms`,`${Math.round(o3/s3)}ms`],[`--ball-follow-spin`,`${Doe(o3)}deg`],[`--ball-size`,`${a3}px`],[`--ball-approach-spin`,`${Soe}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(Moe())],[`--rack-right`,`${i3}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${r3}px`]]}function Foe(e=Math.random){return e()>=boe?null:iO[Math.floor(e()*iO.length)].sprite}var Ioe=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function Loe(e){let t=V(`span`,`merge-strike-pin`);return t.append(pf(`span`,`merge-strike-pin-arc`,Ioe)),mf(t,joe(e)),t}function Roe(){let e=Foe();if(!e)return V(`span`,`merge-strike-ball`);let t=V(`span`,`merge-strike-ball is-animal`);return t.append(V(`span`,`nyan-sprite ${e}`)),t}function zoe(){let e=V(`div`,`merge-strike-lane`);mf(e,Poe());let t=V(`div`,`merge-strike-rack`);t.append(...Aoe().map(Loe));let n=V(`div`,`merge-strike-track`);return n.append(Roe()),e.append(t,n),e}var Boe={title:`STRIKE!`,buildScene:zoe},Voe=20,Hoe=92,Uoe=23,Woe=7,Goe=-40;function Koe(){let e=S4(72),t=S4(69),n=780*t/1e3;return{launchHeightPx:Voe,peakHeightPx:Hoe,heightThroughRimPx:Uoe,heightLeavingNetPx:Woe,heightOutOfCardPx:Goe,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:S4(47)}}function qoe(e=Koe()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var Joe=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,Yoe=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function Xoe(){let e=V(`div`,`merge-swish-ball-drift`),t=V(`div`,`merge-swish-ball-arc`);return t.append(V(`span`,`merge-swish-ball`)),e.append(t),e}function Zoe(){let e=V(`div`,`merge-swish-court`);mf(e,qoe());let t=V(`div`,`merge-swish-track`);return t.append(Xoe()),e.append(pf(`div`,`merge-swish-hoop-back`,Joe),t,pf(`div`,`merge-swish-hoop-front`,Yoe)),e}var f3=[Boe,{title:`SWISH!`,buildScene:Zoe},I4,q4,poe],Qoe=48,p3=5600,$oe=20,m3=null,h3=[],g3=null,_3=!1,v3=0;function ese(e){let t=V(`span`,`merge-confetti-piece`),n=V(`span`,`merge-confetti-arc`);return n.append(V(`span`,`merge-confetti-paper`)),t.append(n),mf(t,A4(e)),t}function tse(e){let t=V(`p`,`merge-celebration-title`);return t.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,n)=>{let r=V(`span`,`merge-celebration-letter`,e);r.style.setProperty(`--letter-delay`,`${n*45}ms`),t.append(r)}),t}function nse(e,t){let n=t.firstElementChild,r=t.lastElementChild;n instanceof HTMLElement&&r instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${r.offsetLeft+r.offsetWidth-n.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2}px`))}function rse(e){let t=V(`div`,`merge-celebration-scene`);return t.setAttribute(`aria-hidden`,`true`),t.append(e.buildScene()),t}function ise(){return f3[Math.floor(Math.random()*f3.length)]}function ase(e){if(LO())try{Ex(x4(e))}catch{}}function ose(e,t,n){m3?.remove(),ase(n);let r=V(`div`,`merge-celebration`);r.setAttribute(`role`,`status`);let i=V(`div`,`merge-celebration-card`),a=V(`div`,`merge-celebration-stage`),o=tse(t.title);a.append(o,V(`p`,`merge-celebration-message`,e),rse(t));let s=V(`div`,`merge-confetti`);s.style.setProperty(`--confetti-scale`,String(O4(n)));for(let e=0;e<Qoe;e+=1)s.append(ese(e));i.append(s,a),r.append(i),document.body.append(r),nse(a,o),m3=r,window.setTimeout(()=>{r.remove(),m3===r&&(m3=null)},p3)}function sse(e){return _3?`playing`:e?`queued`:`empty`}function y3(){if(!g3)return;let e=h3.length>0;g3.tray.dataset.state=sse(e),g3.count.textContent=e?String(h3.length):``,g3.button.disabled=_3||!e}function b3(){let e=h3.shift();_3=e!==void 0,y3(),e&&(ose(e.message,e.scene,v3),v3+=1,window.setTimeout(b3,p3))}function cse(e,t,n){g3={tray:e,button:t,count:n},t.addEventListener(`click`,()=>{v3=0,b3()}),y3()}function lse(e,t=ise()){h3.push({message:e,scene:t}),h3.length>$oe&&h3.shift(),y3()}var use={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},dse=new Set([`FAILURE`,`ERROR`]);function x3(e){return use[e]}function fse(e){return e.state===`MERGED`?`Already merged`:e.state===`OPEN`?e.isDraft?`Drafts cannot be merged`:e.isInMergeQueue?`Already in the merge queue`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`Resolve the merge conflicts first`:e.checks.failing.length>0||e.checks.state!==null&&dse.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function S3(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving...`:i)}}function pse(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=C3(e,!1,``,!0,n).statusText;if(e.isKeepMergeableFixInFlight)return{text:`Repairing`,tone:`warn`,title:r};let i=e.keepMergeableAttempt;return!i||i.outcome===`pushed`||i.outcome===`stopped`?null:{text:`Repair failed`,tone:`danger`,title:r}}function C3(e,t,n=``,r=!0,i=``){let a=e.keepMergeableAttempt,o=e.keepMergeable?`On`:`Off`;if(e.keepMergeable&&a&&a.outcome!==`pushed`&&a.outcome!==`stopped`){let e=i?` (${i})`:``;o=`Keep mergeable failed: ${a.reason??`The attempt produced no repair`}${e}`}return e.isKeepMergeableFixInFlight&&(o=`Keep mergeable is running`),S3(e,!!e.keepMergeable,t,n,o,r)}function mse(e){return e?.isKeepMergeableEnabled!==!1}function hse(e){return e?.isMergeQueueEnabled!==!1}var gse={one:`st`,two:`nd`,few:`rd`,other:`th`},_se=new Intl.PluralRules(`en-US`,{type:`ordinal`});function vse(e){return`${e}${gse[_se.select(e)]??`th`}`}function yse(e,t){return e===null?`Not queued`:t?`Repair pushed, waiting for you`:`Queued, ${vse(e)} in line for this repository`}function bse(e,t,n=``,r=!0){let i=e.mergeQueuePosition??null;return S3(e,i!==null,t,n,yse(i,!!e.isMergeQueueHeldForRepairPush),r)}var w3=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],xse=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],Sse={conflicts:`Needs you`,behind:`Needs you`,"checks-failing":`Needs you`,"changes-requested":`Needs you`,"unresolved-threads":`Needs you`,"checks-pending":`Waiting`,"needs-approval":`Waiting`,unknown:`Waiting`,ready:`Ready to merge`,draft:`Drafts`,merged:`Merged today`},Cse={merged:`Merged`,draft:`Draft`,conflicts:`Merge conflicts`,behind:`Behind base`,"checks-failing":`Checks failing`,"changes-requested":`Changes requested`,"unresolved-threads":`Unresolved threads`,"checks-pending":`Checks running`,"needs-approval":`Needs approval`,ready:`Ready to merge`,unknown:`Status unknown`},wse={merged:`muted`,draft:`muted`,conflicts:`danger`,behind:`warn`,"checks-failing":`danger`,"changes-requested":`warn`,"unresolved-threads":`warn`,"checks-pending":`wait`,"needs-approval":`wait`,ready:`ok`,unknown:`muted`},Tse={merged:`merged`,draft:`draft`,conflicts:`conflict`,behind:`behind`,"checks-failing":`failed`,"changes-requested":`changes-requested`,"unresolved-threads":`thread`,"checks-pending":`running`,"needs-approval":`reviewer`,ready:`ready`,unknown:`unknown`};function Ese(e){let t=Mu.safeParse(e);return t.success?t.data:null}function Dse(e){let t=e.filter(e=>e.state===`OPEN`&&!e.isCrossRepository),n=new Map(t.map(e=>[JSON.stringify([e.repo.toLowerCase(),e.headRefName]),e])),r=new Map,i=[];for(let t of e){let e=t.state===`OPEN`?n.get(JSON.stringify([t.repo.toLowerCase(),t.baseRefName])):void 0;if(!e||e.key===t.key){i.push(t);continue}let a=r.get(e.key)??[];a.push(t),r.set(e.key,a)}let a=[],o=new Set;for(let t of[...i,...e]){if(o.has(t.key))continue;let e=[],n=[{pr:t,parentKey:null,depth:0}];for(;n.length>0;){let t=n.pop();if(!t||o.has(t.pr.key))continue;o.add(t.pr.key),e.push(t);let i=r.get(t.pr.key)??[];for(let e=i.length-1;e>=0;--e)n.push({pr:i[e],parentKey:t.pr.key,depth:t.depth+1})}a.push({root:t,rows:e})}return a}function Ose(e){return w3[e.rows.reduce((e,{pr:t})=>Math.min(e,w3.indexOf(Sse[t.stage])),w3.length-1)]}function kse(e){let t=new Map(w3.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Dse(e)){let e=t.get(Ose(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return xse.flatMap(e=>t.get(e)??[])}function T3(e){return Cse[e]}function E3(e){return wse[e]}function D3(e){return Tse[e]}function Ase(e){if(e.checks.failing.length>0){let t=e.checks.failing.length-3;return{label:`Checks`,tone:`danger`,icon:`failed`,text:`${e.checks.failing.length} failing: ${e.checks.failing.slice(0,3).join(`, `)}${t>0?` and ${t} more`:``}`}}return e.checks.state===`FAILURE`||e.checks.state===`ERROR`?{label:`Checks`,tone:`danger`,icon:`failed`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,icon:`running`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,icon:`running`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,icon:`passed`,text:`Passing`}:{label:`Checks`,tone:`muted`,icon:`none`,text:`No checks`}}function O3(e){return`${e} ${e===1?`approval`:`approvals`}`}function k3(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function jse(e){let t=e.reviewRequests.length>0?`Requested: ${k3(e)}`:`Approval required`;return e.approvals>0?`${t}, ${O3(e.approvals)}`:t}function Mse(e){let t=e.approvals>0?O3(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,icon:`passed`,text:t}}function Nse(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,icon:`changes-requested`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?Mse(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:jse(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`Requested: ${k3(e)}`}:{label:`Review`,tone:`muted`,icon:`none`,text:`No review requested`}}function A3(e,t){return t?e.lastAuthor!==t:null}function Pse(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function Fse(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function Ise(e,t){let n=A3(e,t);return n===null?null:n?{tone:`warn`,icon:`your-turn`,text:`Waiting on you`}:{tone:`wait`,icon:`reviewer`,text:`Waiting on reviewer`}}function Lse(e,t){return[...e.threads].sort((e,n)=>{let r=Number(A3(n,t)===!0)-Number(A3(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:Pse(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:Fse(e),lastActivityAt:e.lastActivityAt,waiting:Ise(e,t)}))}function Rse(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,icon:`passed`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,icon:`thread`,text:n};let r=e.threads.filter(e=>A3(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,icon:`thread`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,icon:`your-turn`,text:`${n}, ${r} waiting on you`}}function zse(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,icon:`conflict`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,icon:`passed`,text:`None`}:{label:`Conflicts`,tone:`muted`,icon:`unknown`,text:`Not computed yet`}}function Bse(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,icon:`behind`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,icon:`unknown`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,icon:`behind`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,icon:`passed`,text:`Up to date with ${e.baseRefName}`}}var Vse={APPROVED:{text:`Approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`,icon:`changes-requested`},COMMENTED:{text:`Commented`,tone:`muted`,icon:`thread`},DISMISSED:{text:`Dismissed`,tone:`muted`,icon:`discarded`},PENDING:{text:`Pending`,tone:`wait`,icon:`running`}};function Hse(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=Vse[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`,icon:`unknown`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,icon:t.icon,submittedAt:e.submittedAt}})}function Use(e,t=null){if(e.state===`MERGED`)return[];let n=[Ase(e),Nse(e),Rse(e,t),zse(e),Bse(e)];return e.autoRebase?[...n,e.autoRebase.outcome===`rebased`?{label:`Auto-rebase`,tone:`ok`,icon:`passed`,text:e.autoRebase.message}:{label:`Auto-rebase`,tone:`danger`,icon:`failed`,text:e.autoRebase.message}]:n}function j3(e){return e?e.configured?e.error&&e.prs.length===0?`Pull requests will show here once GitHub answers.`:`No open or recently merged pull requests found.`:`Enable Team review and set its GitHub organization in settings to see your pull requests.`:`Waiting for your pull requests.`}function Wse(e,t=0){if(!e)return[];let n=$2(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function Gse(e,t){let n=e.flatMap(e=>e.prs);return t&&n.some(e=>e.key===t)?t:n[0]?.key??null}function Kse(e,t){if(!e)return[];let n=new Set(e.filter(e=>e.state===`OPEN`).map(e=>e.key));return t.filter(e=>e.state===`MERGED`&&n.has(e.key))}function qse(e){return e.length===1?`Merged ${e[0].key}`:`Merged ${e.length} pull requests`}var Jse={isVisible:!1,isDisabled:!0,statusText:``,tone:null},Yse={merged:{statusText:`Merged on GitHub. Refreshing the list.`,tone:`ok`},queued:{statusText:`Added to the merge queue. Refreshing the list.`,tone:`ok`},"auto-merge":{statusText:`Auto-merge enabled. GitHub merges it once its requirements pass.`,tone:`ok`},unconfirmed:{statusText:`GitHub accepted the request but did not confirm a merge. Check GitHub.`,tone:null}};function Xse(e,t){if(e.state!==`OPEN`)return Jse;let n=t?.head===e.headRefOid?t:void 0;if(n?.phase===`pending`)return{isVisible:!0,isDisabled:!0,statusText:`Merging on GitHub`,tone:`busy`};if(n&&n.phase!==`failed`)return{isVisible:!0,isDisabled:!0,...Yse[n.phase]};let r=fse(e);return r?{isVisible:!0,isDisabled:!0,statusText:r,tone:null}:n?.phase===`failed`?{isVisible:!0,isDisabled:!1,statusText:n.text,tone:`error`}:{isVisible:!0,isDisabled:!1,statusText:`Merges into ${e.baseRefName} with ${x3(e.mergeMethod)}`,tone:null}}function Zse(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${x3(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function Qse(e){let t=Fu.safeParse(e);if(!t.success)return null;let n=e&&typeof e==`object`&&`requestId`in e?e.requestId:null;return typeof n==`string`?{...t.data,requestId:n}:null}var M3=null,N3=null,P3=null,F3=null,I3=null,L3=null,R3=null,z3=new Map,B3=new Set,V3=new Map,H3={label:`Keep mergeable`,pendingKeys:new Set,errorsByKey:new Map,controlState:(e,t,n,r)=>C3(e,t,n,r,JP(e.keepMergeableAttempt?.at)),isFeatureEnabled:mse,save:async(e,t)=>{let n=await of(`my-pr-keep-mergeable`,{repo:e.repo,number:e.number,keepMergeable:t});if(n.type!==`my-pr-keep-mergeable-result`||n.key!==e.key)throw Error(`Unexpected keep mergeable reply.`);return n.ok?null:n.error??`Could not save Keep mergeable.`}},$se={label:`Merge when ready`,pendingKeys:new Set,errorsByKey:new Map,controlState:bse,isFeatureEnabled:hse,save:async(e,t)=>{let n=await of(`my-pr-merge-when-ready`,{repo:e.repo,number:e.number,mergeWhenReady:t});if(n.type!==`my-pr-merge-when-ready-result`||n.key!==e.key)throw Error(`Unexpected merge when ready reply.`);return n.ok?null:n.error??`Could not save Merge when ready.`}},ece=6e4,tce=`No reply from the server. Check GitHub before trying again.`;function U3(e,t){let n=V(`div`,`reviews-refresh-control`),r=V(`button`,`pr-action reviews-refresh-button`,`Refresh`);r.type=`button`;let i=V(`span`,`reviews-refresh-status`);i.setAttribute(`role`,`status`);let a=V(`p`,`my-pr-error reviews-retry-notice`);n.append(r,i);let o=null,s=!1,c=``,l=null;function u(){a.textContent=$2(o,Date.now()),a.hidden!==!o?.error&&(a.hidden=!o?.error);let e=a.isConnected&&!Ef(t)&&!document.hidden&&a.getClientRects().length>0&&Q2(o,Date.now());!e&&l!==null&&(window.clearInterval(l),l=null),e&&l===null&&(l=window.setInterval(u,1e3))}function d(e){e!==o&&(c=``),o=e,r.disabled=s||!!e?.isRefreshing||!e?.configured,i.textContent=e4(e,s,c),i.hidden=!i.textContent,u()}r.addEventListener(`click`,async()=>{if(!s){s=!0,c=``,d(o);try{let t=await of(`reviews-refresh`,{lane:e});t.type===`reviews-refresh-result`&&(c=t.ok?`Refreshed.`:t.error??`Could not refresh from GitHub.`)}catch(e){c=nH(e)}finally{s=!1,d(o)}}});let f=new MutationObserver(u);f.observe(t,{attributes:!0,subtree:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});for(let e=t.parentElement;e;e=e.parentElement)f.observe(e,{attributes:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});return document.addEventListener(`visibilitychange`,u),{control:n,notice:a,update:d}}function W3(e,t,n,r){z3.set(e,{head:t,phase:n,text:r}),q3()}function nce(e){if(V3.has(e.key))return;let t=af(`my-pr-merge`);if(!B({type:`my-pr-merge`,requestId:t,repo:e.repo,number:e.number,headRefOid:e.headRefOid})){W3(e.key,e.headRefOid,`failed`,`Not connected to the server.`);return}let n=window.setTimeout(()=>{V3.delete(e.key),W3(e.key,e.headRefOid,`failed`,tce)},ece);V3.set(e.key,{requestId:t,head:e.headRefOid,timer:n}),z3.set(e.key,{head:e.headRefOid,phase:`pending`,text:``}),q3()}function rce(e){let t=Xse(e,z3.get(e.key));if(!t.isVisible)return null;let n=V(`div`,`my-pr-merge`),r=V(`button`,`pr-action`,`Merge`);r.type=`button`,r.disabled=t.isDisabled;let i=V(`span`,`pr-action-status`,t.statusText);return i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`),t.tone&&(i.dataset.tone=t.tone),r.addEventListener(`click`,()=>{tp({title:`Merge pull request`,message:Zse(e),confirmLabel:`Merge`,onConfirm:()=>nce(e)})}),n.append(r,i),n}function ice(e,t){let n=t.controlState(e,t.pendingKeys.has(e.key),t.errorsByKey.get(e.key),t.isFeatureEnabled(I3));if(!n.isVisible)return null;let r=V(`div`,`my-pr-merge`),i=V(`button`,`pr-action`,t.label);i.type=`button`,i.disabled=n.isDisabled,i.setAttribute(`aria-pressed`,String(n.isPressed));let a=V(`span`,`pr-action-status`,n.statusText);return a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),i.addEventListener(`click`,async()=>{if(!t.pendingKeys.has(e.key)){t.pendingKeys.add(e.key),t.errorsByKey.delete(e.key),q3();try{let r=await t.save(e,!n.isPressed);r&&t.errorsByKey.set(e.key,r)}catch(n){t.errorsByKey.set(e.key,nH(n))}finally{t.pendingKeys.delete(e.key),q3()}}}),r.append(i,a),r}function G3(e,{hasGlyph:t}){let n=V(`span`,`my-pr-stage`);return n.dataset.tone=E3(e.stage),t&&n.append(ZX(D3(e.stage),E3(e.stage))),n.append(T3(e.stage)),n}function ace(e,t){let n=V(`span`,`my-pr-requested`);n.append(V(`span`,null,`Requested`));let r=V(`span`,`avatar-stack`);for(let t of e.reviewRequests){let e=hf({login:t.name,url:t.isTeam?t.avatarUrl:void 0,cssPx:16});e.title=t.name,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.name),r.append(e)}return n.append(r,V(`span`,`my-pr-requested-names`,t.slice(11))),n}function oce(){if(!M3||!N3||P3?.isConnected)return;let e=l4({queueLabel:`My pull requests`,scopeTabs:N3,resizerLabel:`Resize pull request list`});P3=e.queue,F3=e.detail,M3.replaceChildren(e.columns),R3&&e.foot.append(R3.control)}function K3(e){if(!F3)return;if(!e){F3.replaceChildren(V(`p`,`pr-empty`,j3(I3)));return}let t=V(`article`,`pr-detail`),n=V(`div`,`pr-detail-heading`),r=V(`div`,`pr-detail-title`);r.append(vf(`pr-link`,e.key,e.url),V(`h2`,null,e.title)),n.append(r,G3(e,{hasGlyph:!0})),t.append(n);for(let n of[H3,$se]){let r=ice(e,n);r&&t.append(r)}let i=Use(e,I3?.viewer??null);if(i.length>0){let n=V(`section`,`pr-readiness-section`);n.append(V(`h3`,`pr-section-heading`,`Merge readiness`));let r=V(`ul`,`pr-readiness`);for(let t of i){let n=V(`li`,`pr-readiness-row`),i=V(`span`,`pr-readiness-value`);t.label===`Review`&&t.text.startsWith(`Requested: `)&&i.append(ace(e,t.text)),i.childNodes.length===0&&(i.textContent=t.text),n.append(ZX(t.icon,t.tone),V(`span`,`pr-readiness-label`,t.label),i),r.append(n)}n.append(r);let a=rce(e);a&&n.append(a),t.append(n)}if(e.checks.failing.length>0){let n=V(`section`,`my-pr-failures`);n.append(V(`h3`,`pr-section-heading`,`Failing checks`));let r=V(`ul`,`my-pr-facts`);for(let t of e.checks.failing)r.append(V(`li`,null,t));n.append(r),t.append(n)}let a=Hse(e);if(a.length>0){let e=V(`section`,`pr-readiness-section`);e.append(V(`h3`,`pr-section-heading`,`Reviews`));let n=V(`ul`,`pr-readiness`);for(let e of a){let t=V(`li`,`pr-readiness-row`),r=Date.parse(e.submittedAt??``),i=Number.isFinite(r)?`${e.text} ${JP(r)}`:e.text,a=V(`span`,`my-pr-reviewer`);a.append(gf([{login:e.reviewer,tone:e.tone,title:e.reviewer,url:e.reviewer===`a deleted account`?null:void 0}],16),V(`span`,null,e.reviewer)),t.append(ZX(e.icon,e.tone),a,V(`span`,`pr-readiness-value`,i)),n.append(t)}e.append(n),t.append(e)}let o=Lse(e,I3?.viewer??null);if(o.length>0){let e=V(`section`,`my-pr-threads-section`);e.append(V(`h3`,`pr-section-heading`,`Unresolved threads`));let n=V(`ul`,`my-pr-threads`);for(let e of o){let t=V(`li`,`my-pr-thread`),r=V(`div`,`my-pr-thread-heading`);if(r.append(vf(`my-pr-thread-location`,e.location,e.url)),e.waiting){let t=V(`span`,`my-pr-stage`);t.dataset.tone=e.waiting.tone,t.append(ZX(e.waiting.icon,e.waiting.tone),e.waiting.text),r.append(t)}let i=V(`p`,`my-pr-thread-excerpt`);i.append(V(`strong`,null,e.author),` ${e.excerpt}`);let a=Date.parse(e.lastActivityAt),o=V(`p`,`my-pr-thread-meta`,Number.isFinite(a)?`${e.replySummary}, ${JP(a)}`:e.replySummary);t.append(r,i,o),n.append(t)}e.append(n),t.append(e)}let s=V(`p`,`pr-detail-meta`);s.append(V(`span`,null,`Opened ${JP(Date.parse(e.createdAt))}`),V(`span`,null,`${e.state===`MERGED`?`Merged`:`Updated`} ${JP(Date.parse(e.state===`MERGED`?e.mergedAt??``:e.updatedAt))}`)),t.append(s),F3.replaceChildren(t)}function q3(){if(oce(),!P3)return;let e=I3?.prs??[],t=kse(e);L3=Gse(t,L3);let n=document.activeElement instanceof HTMLElement&&P3.contains(document.activeElement)?document.activeElement.dataset.prKey:null,r=t.filter(e=>e.rows.length>0).map(e=>{let t=V(`section`,`pr-queue-section`);t.append(V(`h3`,`pr-section-heading`,`${e.title} ${e.rows.length}`));for(let{pr:n,parentKey:r,depth:i}of e.rows){let e=V(`button`,`pr-queue-row`);e.type=`button`,e.dataset.prKey=n.key,r&&(e.style.paddingInlineStart=`${12+Math.min(i,6)*16}px`),e.setAttribute(`aria-current`,String(n.key===L3)),e.title=`${n.key}: ${T3(n.stage)}`;let a=V(`span`,`pr-queue-glyph`);a.append(ZX(D3(n.stage),E3(n.stage)));let o=V(`span`,`pr-queue-top`);o.append(V(`strong`,`pr-queue-ref`,n.key),V(`span`,`pr-queue-title`,n.title));let s=V(`span`,`pr-queue-bottom`);r&&s.append(V(`span`,`my-pr-stage`,`Stacked on ${r}`)),s.append(G3(n,{hasGlyph:!1}),V(`span`,`pr-queue-elapsed`,`opened ${JP(Date.parse(n.createdAt))}`));let c=pse(n,H3.isFeatureEnabled(I3),JP(n.keepMergeableAttempt?.at));if(c){let e=V(`span`,`my-pr-stage`,c.text);e.dataset.tone=c.tone,e.title=c.title,s.append(e)}e.append(a,o,s),e.addEventListener(`click`,()=>{L3=n.key;for(let e of P3?.querySelectorAll(`button[data-pr-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.prKey===L3));K3(n),document.documentElement.dataset.layout===`phone`&&F3?.scrollIntoView({block:`start`,behavior:`smooth`})}),t.append(e)}return t});if(r.length===0&&P3.replaceChildren(V(`p`,`pr-empty`,j3(I3))),r.length>0){let e=Wse(I3,Date.now()).filter(e=>e.tone!==`error`).map(e=>V(`p`,e.tone===`error`?`my-pr-error`:`my-pr-note`,e.text));P3.replaceChildren(...e,...r)}R3&&(P3.prepend(R3.notice),R3.update(I3)),n&&[...P3.querySelectorAll(`button[data-pr-key]`)].find(e=>e.dataset.prKey===n)?.focus({preventScroll:!0}),K3(e.find(e=>e.key===L3))}function sce(e,t){return M3||(N3=t,M3=V(`div`,`pr-content`),e.append(M3),R3=U3(`my-prs`,M3),q3(),M3)}function cce(e){let t=Ese(e);if(!t)return;let n=Kse(I3?.prs??null,t.prs);I3=t,q3(),J3(n)}function J3(e){let t=e.filter(e=>!B3.has(e.key));if(t.length!==0){for(let e of t)B3.add(e.key);lse(qse(t))}}function lce(e){let t=Qse(e);if(!t)return;let n=V3.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),V3.delete(t.key),!t.ok){W3(t.key,n.head,`failed`,t.error||`The merge failed.`);return}if(W3(t.key,n.head,t.kind??`unconfirmed`,``),t.kind!==`merged`)return;let r=I3?.prs.find(e=>e.key===t.key);r&&J3([r])}var uce=Ll.options.join(`|`),Y3=String.raw`\*\*(?:\[([^\]\n]+)\]\s+)?(${uce})\*\*`;function dce(e){return[...e.matchAll(new RegExp(Y3,`g`))].flatMap(e=>{let t=Ll.safeParse(e[2]);return t.success?[t.data]:[]})}function fce(e){let t=new RegExp(String.raw`^${Y3}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=Ll.safeParse(t[2]);return n.success?{reviewer:t[1]??null,severity:n.data,length:t[0].length}:null}function X3(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
|
|
248
|
-
> Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}var
|
|
249
|
-
`);let a=s6(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${
|
|
250
|
-
`)}function l6(e){if(e.ready.length+e.attention.length+e.handReview.length>0)return null;let t=e.inReview.length+e.queued.length;return t===0?`Nothing needs you right now.`:`Nothing needs you right now. ${t} ${t===1?`review is`:`reviews are`} still running.`}function
|
|
251
|
-
`).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/
|
|
246
|
+
`;function KW(e){let t=2166136261,n=3266489909;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619)>>>0,n=Math.imul(n^i,2246822507)>>>0}return`${t.toString(36).padStart(7,`0`)}${n.toString(36).padStart(7,`0`)}`}function qW(e,t){return KW(JSON.stringify([e,...t]))}function JW(e,t){return qW(`finding`,[e,jW(t),String(t.code??``),String(t.message??``)])}function YW(e,t){return qW(`comment`,[e,eG(t),String(t.message??``)])}function XW(e){return qW(`fix`,[e.uri,dG(e),e.code,e.message,fG(e)])}function ZW(e){return qW(`intent`,[e.key,e.text,e.active])}function QW(e,t,n,r=[],i=null){let a=[...n].map(([e,t])=>qW(`hand`,[e,t])).sort(),o=new Set;for(let r of[...e.keys(),...t.keys(),...n.keys()])o.add(qW(`document`,[r]));for(let[t,n]of e)for(let e of n)o.add(JW(t,e));for(let[e,n]of t)for(let t of n)o.add(YW(e,t));for(let e of r)o.add(XW(e));for(let e of DW(i,null,0))e.hasText&&o.add(ZW(e));let s=[...o].sort();return{signature:[...a,...s].join(GW),handEntries:a,contentEntries:s}}function $W(e,t){let n=new Set(t.split(GW));return e.handEntries.some(e=>!n.has(e))?UW:e.contentEntries.some(e=>!n.has(e))?WW:null}function eG(e){let t=Number(e?.line);return!Number.isFinite(t)||t<1?`L?`:`L${Math.floor(t)}`}function tG(e){return Array.isArray(e?.diagnostics)?e.diagnostics:[]}function nG(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=tG(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function rG(e){return Array.isArray(e?.comments)?e.comments:[]}function iG(e,t){let n=new Map(e),r=typeof t?.uri==`string`?t.uri:``;if(!r)return n;let i=rG(t);return i.length===0?(n.delete(r),n):(n.set(r,i),n)}function aG(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.diagnostics)?e.diagnostics:[];n&&r.length!==0&&t.set(n,r)}return t}function oG(e){let t=new Map,n=Array.isArray(e?.documents)?e.documents:[];for(let e of n){let n=typeof e?.uri==`string`?e.uri:``,r=Array.isArray(e?.comments)?e.comments:[];n&&r.length!==0&&t.set(n,r)}return t}function sG(e,t=new Map,n=new Map){let r=[],i=new Set([...e.keys(),...t.keys(),...n.keys()]);for(let a of i){let i=e.get(a),o=t.get(a),s=n.get(a)||null,c=Array.isArray(i)?i:[],l=Array.isArray(o)?o:[];(c.length!==0||l.length!==0||s)&&r.push({uri:a,name:PW(a)||a,hand:s,findings:[...c].sort((e,t)=>NW(e)-NW(t)||MW(e)-MW(t)),comments:[...l].sort((e,t)=>(Number(e?.line)||0)-(Number(t?.line)||0))})}return r.sort((e,t)=>cG(e.name,t.name)||cG(e.uri,t.uri)),r}function cG(e,t){return e<t?-1:+(e>t)}var lG=`No fixes yet. Silent fixes appear here once the lane applies or is refused one.`;function uG(e){let t=FW(e);return t===1?`1 fix`:`${t} fixes`}function dG(e){let t=Number(e?.line);return!Number.isFinite(t)||t<0?`L?`:`L${Math.floor(t)+1}`}function fG(e){return e?.applied===!0?`applied`:`refused`}function pG(e,{uri:t=``,ts:n=0}={}){if(!e||typeof e!=`object`)return null;let r=e,i=typeof r.message==`string`?r.message.trim():``;if(!i)return null;let a=Number(r.line),o=Number(r.ts??n);return{uri:typeof r.uri==`string`&&r.uri?r.uri:t,code:typeof r.code==`string`?r.code:``,line:Number.isFinite(a)&&a>0?Math.floor(a):0,message:i,applied:r.applied===!0,ts:Number.isFinite(o)&&o>0?o:0}}function mG(e){let t=typeof e?.uri==`string`?e.uri:``,n=Number(e?.ts);return pG(e?.fix,{uri:t,ts:Number.isFinite(n)?n:0})}function hG(e,t,{max:n=20}={}){let r=mG(t);return r?[r,...e].slice(0,Math.max(0,Math.floor(n))):[...e]}function gG(e,{max:t=20}={}){let n=Array.isArray(e?.fixes)?e.fixes:[],r=[];for(let e of n){let t=pG(e);t&&r.push(t)}return r.slice(0,Math.max(0,Math.floor(t)))}var _G=`No activity yet. The ingest lane reports what your sessions and tools are doing.`,vG={terminal:`terminal`,agentLogs:`agent`,git:`git`,fs:`files`,shellHistory:`shell`,editor:`editor`};function yG(e){let t=typeof e==`string`?e:``;return vG[t]||t||`source`}function bG(e,t=Date.now()){let n=Number(e);return!Number.isFinite(n)||n<=0?``:_p(Number(t)-n,pp)}function xG(e){if(!e||typeof e!=`object`)return null;let t=e,n=Number(t.seq);if(!Number.isFinite(n))return null;let r=typeof t.summary==`string`?t.summary.trim():``;if(!r)return null;let i=Number(t.ts),a=t.scope&&typeof t.scope==`object`?t.scope:{};return{seq:Math.floor(n),source:typeof t.source==`string`?t.source:``,kind:typeof t.kind==`string`?t.kind:``,ts:Number.isFinite(i)&&i>0?i:0,summary:r,root:typeof a.root==`string`&&a.root?a.root:null,sessionId:typeof a.sessionId==`string`&&a.sessionId?a.sessionId:null}}function SG(e){let t=Array.isArray(e?.events)?e.events:[],n=[];for(let e of t){let t=xG(e);t&&n.push(t)}return n}function CG(e){let t=Number(e?.overflow);return!Number.isFinite(t)||t<=0?0:Math.floor(t)}function wG(e){let t=FW(e);return t<=0?``:t===1?`1 more event not shown`:`${t} more events not shown`}function TG(e,t){return[...e].sort((e,t)=>t.seq-e.seq).slice(0,Math.max(0,Math.floor(t)))}function EG(e,t,{max:n=100}={}){let r=SG(t);if(r.length===0)return TG(e,n);let i=new Map;for(let t of e)i.set(t.seq,t);for(let e of r)i.set(e.seq,e);return TG([...i.values()],n)}function DG(e,{max:t=100}={}){return TG(SG(e),t)}function OG(e){let t=FW(e);return t===1?`1 event`:`${t} events`}function kG(e){if(!e?.root)return`machine`;let t=e.root.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var AG=new Map,jG=new Map,MG=new Map,NG=yW(),PG=new Map,FG=null,IG=null,LG=null,RG=null,zG=null,BG=[],VG=0,HG=null,UG=[],WG=null,GG=QW(AG,jG,MG,UG,NG),KG=Tk(),qG=AA({getAck:()=>KG,setAck:e=>{KG=e,Ek(e)},signature:()=>GG.signature,isLooking:()=>!Ef(FG)});function JG(){let e=V(`section`,`visions-intent`);e.append(V(`h2`,`visions-intent-title`,`Intent`));let t=V(`div`,`visions-intent-list`);return e.append(t),LG={list:t},e}function YG(e){let t=V(`div`,`visions-intent-item`),n=V(`div`,`visions-intent-head`);n.append(V(`span`,`visions-intent-scope`,e.label),V(`span`,`visions-intent-meta`,e.meta));let r=V(`p`,`visions-intent-text`,e.text);return r.classList.toggle(`visions-intent-none`,!e.hasText),t.classList.toggle(`visions-intent-active`,e.active===!0),t.append(n,r),t}function XG(){LG&&LG.list.replaceChildren(...DW(NG,PG).map(YG))}function ZG(e){PG=e instanceof Map?e:new Map,XG()}function QG(e){let t=V(`section`,`visions-doc`),n=V(`div`,`visions-doc-head`),r=V(`h2`,`visions-doc-name`);if(r.textContent=e.name,r.title=e.uri,n.append(r,V(`span`,`visions-doc-count`,RW(e))),t.append(n),e.hand&&t.append($G(e.hand)),e.findings.length>0){let n=V(`div`,`visions-findings`);for(let t of e.findings)n.append(tK(t));t.append(n)}if(e.comments.length>0){let n=V(`div`,`visions-comments`);for(let t of e.comments)n.append(eK(t));t.append(n)}return t}function $G(e){let t=V(`div`,`visions-hand`);return t.textContent=zW(e),t}function eK(e){let t=V(`div`,`visions-comment`),n=V(`div`,`visions-comment-head`);n.append(V(`span`,`visions-comment-chip`,`visions`)),n.append(V(`span`,`visions-comment-line`,eG(e))),t.append(n);let r=V(`p`,`visions-comment-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function tK(e){let t=V(`div`,`visions-finding`);t.append(V(`span`,`visions-finding-line`,jW(e)));let n=e?.code==null?``:String(e.code);n&&t.append(V(`span`,`visions-finding-code`,n));let r=V(`span`,`visions-finding-message`);return r.textContent=e?.message==null?``:String(e.message),t.append(r),t}function nK({force:e=!1}={}){if(!IG||!e&&Ef(FG))return;IG.textContent=``;let t=sG(AG,jG,MG);if(t.length===0){let e=V(`p`,`visions-empty`,hW);if(zG===!1){let t=pW(`lanes-visions`,`visions-enabled`,`Enable Visions`);e.append(document.createTextNode(` `),t)}IG.append(e);return}for(let e of t)IG.append(QG(e))}function rK(e){zG=e?.visions?.enabled===!0,nK()}function iK(){let e=V(`section`,`visions-activity`),t=V(`div`,`visions-activity-head`);t.append(V(`h2`,`visions-activity-title`,`Activity`));let n=V(`span`,`visions-activity-count`);t.append(n),e.append(t);let r=V(`div`,`visions-activity-list`);e.append(r);let i=V(`p`,`visions-activity-overflow`);return e.append(i),HG={count:n,list:r,overflow:i},e}function aK(e,t){let n=V(`div`,`visions-activity-row`);n.append(V(`span`,`visions-activity-source`,yG(e.source))),n.append(V(`span`,`visions-activity-age`,bG(e.ts,t))),n.append(V(`span`,`visions-activity-scope`,kG(e)));let r=V(`span`,`visions-activity-summary`);return r.textContent=e.summary,n.append(r),n}function oK({force:e=!1}={}){if(!HG||!e&&Ef(FG))return;let{count:t,list:n,overflow:r}=HG;if(t.textContent=OG(BG.length),n.textContent=``,BG.length===0){n.append(V(`p`,`visions-empty`,_G)),r.textContent=``;return}let i=Date.now();for(let e of BG)n.append(aK(e,i));r.textContent=wG(VG)}function sK(){let e=V(`section`,`visions-fixes`),t=V(`div`,`visions-fixes-head`);t.append(V(`h2`,`visions-fixes-title`,`Fixes`));let n=V(`span`,`visions-fixes-count`);t.append(n),e.append(t);let r=V(`div`,`visions-fixes-list`);return e.append(r),WG={count:n,list:r},e}function cK(e){let t=V(`div`,`visions-fix-row`);t.dataset.applied=e.applied?`yes`:`no`;let n=V(`span`,`visions-fix-file`);n.textContent=PW(e.uri)||e.uri,n.title=e.uri,t.append(n),t.append(V(`span`,`visions-fix-line`,dG(e))),t.append(V(`span`,`visions-fix-outcome`,fG(e))),t.append(V(`span`,`visions-fix-code`,e.code||``));let r=V(`span`,`visions-fix-message`);return r.textContent=e.message,t.append(r),t}function lK({force:e=!1}={}){if(!WG||!e&&Ef(FG))return;let{count:t,list:n}=WG;if(t.textContent=uG(UG.length),n.textContent=``,UG.length===0){n.append(V(`p`,`visions-empty`,lG));return}for(let e of UG)n.append(cK(e))}function uK(){GG=QW(AG,jG,MG,UG,NG),GG.signature!==``&&qG.refresh(),RG&&RG($W(GG,KG))}function dK(e){RG=e,uK()}function fK(e){if(FG)return FG;let t=V(`div`,`visions-content`);t.append(JG());let n=V(`div`,`visions-feed`);return t.append(n),t.append(sK()),t.append(iK()),e.appendChild(t),FG=t,IG=n,XG(),nK({force:!0}),lK({force:!0}),oK({force:!0}),t}function pK(){XG(),nK({force:!0}),lK({force:!0}),oK({force:!0})}function mK(){GG.signature!==``&&qG.acknowledge(),uK()}function hK(e){UG=hG(UG,e),lK(),uK()}function gK(e){AG=nG(AG,e),nK(),uK()}function _K(e){jG=iG(jG,e),nK(),uK()}function vK(e){MG=VW(MG,e),nK(),uK()}function yK(e){NG=wW(NG,e),XG(),uK()}function bK(e){BG=EG(BG,e),VG=CG(e),oK(),uK()}function xK(e){BG=DG(e),VG=0,oK(),uK()}function SK(e){AG=aG(e),jG=oG(e),MG=HW(e),NG=SW(e),UG=gG(e),XG(),nK(),lK(),uK()}var CK=Ps(D(),xs());j({glimmervoidId:D().min(1),event:D().min(1),token:D().nullable().optional(),payload:CK}),j({id:D().min(1),name:D().min(1),event:D().min(1),matcher:D().optional(),type:N([`command`,`http`]),command:D().optional(),url:D().optional(),timeout:O().int().positive().optional(),enabled:k(),projects:A(D()).optional()}).passthrough();var wK=`Claude Code hooks injected into every session Glimmervoid spawns.`,TK=`Loading hooks`,EK=`No hooks yet. A hook runs a command, or calls a URL, when a Claude Code event fires in a Glimmervoid session. Start from one of these, or add your own.`,DK=`Start from`,OK=`Filter by name, event or command`,kK=`Nothing matches that filter.`,AK=`Preview`,jK=`The entry this becomes in the per-session settings file.`,MK=`Duplicate`,NK=`Discard changes`,PK=`Close the editor and lose the unsaved changes?`,FK=`Esc cancels. Ctrl+Enter saves.`,IK=`A change reaches a session at its next start or restart. Claude Code sessions only; Codex and Grok sessions do not read this file.`,LK=`Glimmervoid's own hooks`,RK=`Always present, read-only. Status detection depends on them.`,zK=`Your hooks`,BK=`New hook`,VK=`Edit hook`,HK=`Saved to config.json.`,UK=`All projects`,WK=`This event takes no matcher.`,GK=`Blank uses Claude Code's default for the event.`,KK=Object.freeze([{value:`command`,label:`Command`,hint:`Run a shell command. It receives the event JSON on stdin.`},{value:`http`,label:`HTTP`,hint:`POST the event JSON to a URL.`}]),qK=Object.freeze([{id:`lint`,label:`Lint after edits`,summary:`PostToolUse on Edit|Write`,draft:{name:`Lint after edits`,event:`PostToolUse`,matcher:`Edit|Write`,type:`command`,command:`npx biome check --write "$(jq -r .tool_input.file_path)"`}},{id:`notify`,label:`Notify on Stop`,summary:`Stop, command`,draft:{name:`Notify on Stop`,event:`Stop`,matcher:``,type:`command`,command:`command -v notify-send >/dev/null 2>&1 && notify-send "Claude finished a turn" || { command -v osascript >/dev/null 2>&1 && osascript -e 'display notification "Claude finished a turn" with title "Claude Code"'; }`}},{id:`guard`,label:`Guard destructive Bash`,summary:`PreToolUse on Bash, exit 2 blocks`,draft:{name:`Guard destructive Bash`,event:`PreToolUse`,matcher:`Bash`,type:`command`,command:`jq -r .tool_input.command | grep -Eq "rm -rf|git push --force" && exit 2 || exit 0`}},{id:`log`,label:`Log every prompt`,summary:`UserPromptSubmit, appends JSON`,draft:{name:`Log every prompt`,event:`UserPromptSubmit`,matcher:``,type:`command`,command:`cat >> ~/.claude/prompts.jsonl`}}]),JK=Object.freeze({hooks:[],builtin:[],events:[]});function YK(e){return!e||typeof e.error==`string`}function XK(e){return!e||typeof e.error!=`string`?``:e.error}function ZK(e,t){let n=e?.[t];return Array.isArray(n)?n:JK[t]}var QK=e=>ZK(e,`hooks`),$K=e=>ZK(e,`builtin`),eq=e=>ZK(e,`events`);function tq(e){let t=e?.limits?.maxTimeoutSec;return typeof t==`number`&&Number.isInteger(t)&&t>0?t:600}function nq(e,t){if(!e||typeof e!=`object`)return!1;let n=e.requestId;return typeof n!=`string`||!t||n===t}function rq(e){let t=QK(e),n=t.filter(e=>e.enabled!==!1).length;return[{label:`yours`,value:String(t.length),tone:null},{label:`enabled`,value:String(n),tone:t.length>0&&n===0?`warn`:null},{label:`built in`,value:String($K(e).length),tone:null}]}function iq(e,t){let n=new Map(t.map((e,t)=>[e.name,t])),r=e=>n.get(e.event)??t.length;return[...e].sort((e,t)=>{let n=r(e)-r(t);return n===0?String(e.name).localeCompare(String(t.name)):n})}function aq(e,t){let n=String(t||``).trim().toLowerCase();return n?e.filter(e=>[e.name,e.event,e.matcher,e.command,e.url].some(e=>typeof e==`string`&&e.toLowerCase().includes(n))):e}function oq(e){return e.length>=4}function sq(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.event===n.event){e.hooks.push(n);continue}t.push({event:n.event,hooks:[n]})}return t}function cq(e){let t=e.type===`http`?{type:`http`,url:e.url||``}:{type:`command`,command:e.command||``};Number.isInteger(e.timeout)&&Number(e.timeout)>0&&(t.timeout=e.timeout);let n=e.matcher?{matcher:e.matcher,hooks:[t]}:{hooks:[t]};return JSON.stringify({hooks:{[e.event]:[n]}},null,2)}function lq(e){return`${e} copy`}function uq(e,t){return e.find(e=>e.name===t)||null}function dq(e,t){let n=uq(e,t);return n?n.matcher?`Matches ${n.matcher}. Blank matches every ${n.name}.`:WK:``}function fq(e){return e.type===`http`?e.url||``:e.command||``}function pq(e){let t=KK.find(t=>t.value===e);return t?t.label:String(e||``)}function mq(e){return!Number.isInteger(e.timeout)||Number(e.timeout)<=0?``:`${e.timeout}s timeout`}function hq(e,t){let n=Array.isArray(e.projects)?e.projects:[];return n.length===0?UK:n.map(e=>{let n=t.find(t=>t.id===e);return n?n.name:e}).join(`, `)}function gq(e){return e.matcher?`${e.event} / ${e.matcher}`:e.event}function _q(e){return gq(e)}function vq(e,t){let n=Array.isArray(e.projects)?e.projects:[],r=new Set(t.map(e=>e.id));return n.filter(e=>!r.has(e))}function yq(e){let t=e[0];return{id:null,name:``,event:t?t.name:``,matcher:``,type:`command`,command:``,url:``,timeout:``,enabled:!0,projects:[]}}function bq(e){return{id:e.id??null,name:e.name||``,event:e.event||``,matcher:e.matcher||``,type:e.type===`http`?`http`:`command`,command:e.command||``,url:e.url||``,timeout:Number.isInteger(e.timeout)?String(e.timeout):``,enabled:e.enabled!==!1,projects:Array.isArray(e.projects)?[...e.projects]:[]}}function xq(e,t,n=600){if(!e.name.trim())return`Give the hook a name.`;let r=uq(t,e.event);if(!r)return`Pick an event.`;if(e.matcher.trim()&&!r.matcher)return`${r.name} takes no matcher.`;if(e.type===`http`&&r.http===!1)return`${r.name} does not support HTTP hooks.`;if(e.type===`command`&&!e.command.trim())return`Enter the command to run.`;if(e.type===`http`&&!/^https?:\/\/\S+$/i.test(e.url.trim()))return`Enter a URL starting with http:// or https://.`;if(e.timeout.trim()!==``){let t=Number(e.timeout);if(!Number.isInteger(t)||t<1||t>n)return`Timeout must be a whole number of seconds from 1 to ${n}.`}return null}function Sq(e){let t={name:e.name.trim(),event:e.event,type:e.type,enabled:e.enabled!==!1};return e.id&&(t.id=e.id),e.matcher.trim()&&(t.matcher=e.matcher.trim()),e.type===`command`&&(t.command=e.command.trim()),e.type===`http`&&(t.url=e.url.trim()),e.timeout.trim()!==``&&(t.timeout=Number(e.timeout)),e.projects.length>0&&(t.projects=[...e.projects]),t}function Cq(e,t){let n={...yq(t),...e.draft};return uq(t,n.event)||(n.event=yq(t).event),n}function wq(e,t){return JSON.stringify(Sq(e))!==JSON.stringify(t)}function Tq(e){return{...e,enabled:e.enabled===!1}}function Eq(e){return`Delete the hook "${e.name}"? Sessions already running keep it until they restart.`}var Dq=null,Oq=null,kq=null,Aq=null,jq=null,Mq=null,Nq=null,Pq=null,Fq=!1,Iq=null,Lq=``,Rq=new Set,zq=new Set,Bq=!1,Vq=(e,t)=>Cf(`hooks`,e,t);function Hq(e,t,n){let r=V(`p`,e,t);return n&&(r.dataset.tone=n),r}function Uq(e,t,n,r){let i=V(`button`,e,t);return i.type=`button`,r&&i.setAttribute(`aria-label`,r),i.addEventListener(`click`,n),i}function Wq(e){if(!kq)return null;let t=af(`hooks`);return kq({requestId:t,...e}),t}function Gq(e,t,n){let r=V(`label`,`hooks-field`);return r.append(V(`span`,`hooks-field-label`,e),t),n&&r.append(V(`span`,`hooks-field-hint`,n)),r}function Kq(e,t,n){let r=V(`input`,`settings-view-input`);return r.type=`text`,r.value=e,r.autocomplete=`off`,r.spellcheck=!1,t&&(r.placeholder=t),r.addEventListener(`input`,()=>n(r.value)),r}function qq(e,t){let n=V(`textarea`,`settings-view-input hooks-command`);return n.rows=3,n.value=e,n.spellcheck=!1,n.addEventListener(`input`,()=>t(n.value)),n}function Jq(e,t,n){let r=V(`select`,`settings-view-input hooks-select`);for(let n of t){let t=V(`option`,null,n.name);t.value=n.name,t.title=n.description,n.name===e.event&&(t.selected=!0),r.append(t)}return r.addEventListener(`change`,()=>n(r.value)),r}function Yq(e,t){let n=V(`div`,`hooks-type-row`);n.setAttribute(`role`,`radiogroup`);for(let r of KK){let i=V(`label`,`settings-view-toggle hooks-choice`),a=V(`input`,`settings-view-checkbox`);a.type=`radio`,a.name=`hooks-type`,a.value=r.value,a.checked=e.type===r.value,a.title=r.hint,a.addEventListener(`change`,()=>{a.checked&&t(r.value)}),i.append(a,V(`span`,null,r.label)),n.append(i)}return n}function Xq(e,t){let n=V(`div`,`hooks-projects`);if(t.length===0)return n.append(V(`span`,`hooks-field-hint`,UK)),n;let r=V(`label`,`settings-view-project-choice hooks-choice`),i=V(`input`,`settings-view-checkbox`);i.type=`checkbox`,i.checked=e.projects.length===0,r.append(i,V(`span`,null,UK)),n.append(r);let a=[];for(let r of t){let t=V(`label`,`settings-view-project-choice hooks-choice`),o=V(`input`,`settings-view-checkbox`);o.type=`checkbox`,o.value=r.id,o.checked=e.projects.includes(r.id),o.addEventListener(`change`,()=>{e.projects=a.filter(e=>e.checked).map(e=>e.value),i.checked=e.projects.length===0}),a.push(o),t.append(o,V(`span`,null,r.name)),r.agent!==`claude-code`&&(t.append(V(`span`,`hooks-choice-note`,r.agent)),t.title=`Not a Claude Code project: this hook will not reach its sessions.`),n.append(t)}return i.addEventListener(`change`,()=>{if(!i.checked){i.checked=e.projects.length===0;return}for(let e of a)e.checked=!1;e.projects=[]}),n}function Zq(e){let t=V(`div`,`hooks-templates`);t.append(V(`span`,`hooks-templates-label`,DK));for(let n of qK){let r=Uq(`hooks-chip`,n.label,()=>eJ(null,Cq(n,e)));r.title=n.summary,t.append(r)}return t}function Qq(e){Pq&&(Pq.textContent=e||``,Pq.hidden=!e)}function $q(e){let t=eq(Dq),n=Tf(Dq),r=Vq(e.id?VK:BK,HK);r.classList.add(`hooks-editor`);let i=V(`form`,`hooks-form`);i.addEventListener(`submit`,e=>{e.preventDefault(),rJ()}),i.addEventListener(`keydown`,e=>{if(e.key===`Escape`){e.preventDefault(),nJ();return}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),rJ())}),e.id||i.append(Zq(t));let a=V(`span`,`hooks-field-hint`,dq(t,e.event)),o=Kq(e.matcher,``,t=>{e.matcher=t}),s=Gq(`Command`,qq(e.command,t=>{e.command=t}),`Runs through the shell with the event JSON on stdin. Exit 2 blocks the action where the event allows it.`),c=Gq(`URL`,Kq(e.url,`http://127.0.0.1:8080/hook`,t=>{e.url=t}),`Claude Code POSTs the event JSON to it.`),l=()=>{s.hidden=e.type!==`command`,c.hidden=e.type!==`http`};l();let u=Gq(`Matcher`,o,null);u.append(a);let d=()=>{let n=t.find(t=>t.name===e.event);a.textContent=dq(t,e.event),o.disabled=!!n&&!n.matcher,o.disabled&&(o.value=``,e.matcher=``)};d();let f=V(`input`,`settings-view-input hooks-timeout`);f.type=`number`,f.inputMode=`numeric`,f.min=`1`,f.max=String(tq(Dq)),f.value=e.timeout,f.addEventListener(`input`,()=>{e.timeout=f.value});let p=V(`label`,`settings-view-toggle hooks-choice`),m=V(`input`,`settings-view-checkbox`);m.type=`checkbox`,m.checked=e.enabled,m.addEventListener(`change`,()=>{e.enabled=m.checked}),p.append(m,V(`span`,null,`Enabled`)),i.append(Gq(`Name`,Kq(e.name,`Lint after edits`,t=>{e.name=t}),null),Gq(`Event`,Jq(e,t,t=>{e.event=t,d()}),null),u,Gq(`Type`,Yq(e,t=>{e.type=t,l()}),null),s,c,Gq(`Timeout (seconds)`,f,GK),Gq(`Projects`,Xq(e,n),null),Gq(``,p,null)),Pq=V(`p`,`hooks-editor-error`),Pq.setAttribute(`role`,`alert`),Pq.hidden=!0;let h=V(`div`,`hooks-editor-footer`),g=V(`span`,`hooks-editor-shortcut`,FK),_=Uq(`btn-dialog btn-dialog-cancel`,`Cancel`,nJ),v=V(`button`,`btn-dialog btn-dialog-confirm`,e.id?`Save changes`:`Add hook`);return v.type=`submit`,h.append(Pq,g,_,v),i.append(h),r.append(i),r}function eJ(e,t=null){jq=t||(e?bq(e):yq(eq(Dq))),Mq=Sq(e?bq(e):yq(eq(Dq))),Nq=$q(jq),mJ({force:!0}),Nq.scrollIntoView({block:`nearest`});let n=Nq.querySelector(`input[type=text]`);n instanceof HTMLInputElement&&n.focus()}function tJ(){jq=null,Mq=null,Nq=null,Pq=null,Fq=!1,Iq=null,Bq=!0,mJ({force:!0})}function nJ(){if(!jq||!Mq||!wq(jq,Mq)){tJ();return}tp({title:NK,message:PK,confirmLabel:`Discard`,danger:!0,onConfirm:tJ})}function rJ(){if(!jq||Fq)return;let e=xq(jq,eq(Dq),tq(Dq));if(e){Qq(e);return}Fq=!0,Qq(``),Iq=Wq({type:`save-hook`,hook:Sq(jq)}),Iq||(Fq=!1)}function iJ(e){let t=V(`details`,`hooks-preview`);t.open=Rq.has(e.id),t.addEventListener(`toggle`,()=>{if(t.open){Rq.add(e.id);return}Rq.delete(e.id)});let n=V(`summary`,`hooks-preview-summary`,AK);n.title=jK;let r=V(`pre`,`hooks-preview-code`,cq(e));return t.append(n,r),t}function aJ(e,{grouped:t=!1}={}){let n=Tf(Dq),r=V(`article`,`hooks-row`);r.setAttribute(`aria-label`,e.name),e.enabled===!1&&(r.dataset.state=`off`);let i=V(`div`,`hooks-row-main`),a=V(`div`,`hooks-row-head`);a.append(V(`span`,`hooks-row-name`,e.name));let o=t?e.matcher||``:gq(e);o&&a.append(V(`span`,`hooks-row-event`,o));let s=V(`code`,`hooks-row-target`,fq(e));s.title=fq(e);let c=V(`p`,`hooks-row-meta`,[pq(e.type),mq(e),hq(e,n)].filter(Boolean).join(` / `));i.append(a,s,c);let l=vq(e,n);l.length>0&&i.append(Hq(`hooks-row-meta`,`Scoped to a project no longer in config: ${l.join(`, `)}`,`warn`)),i.append(iJ(e));let u=V(`div`,`hooks-row-actions`),d=V(`label`,`settings-view-toggle hooks-choice`),f=V(`input`,`settings-view-checkbox`);f.type=`checkbox`,f.checked=e.enabled!==!1,f.disabled=zq.has(e.id),f.setAttribute(`aria-label`,`${e.name} enabled`),f.addEventListener(`change`,()=>{zq.add(e.id),f.disabled=!0,Wq({type:`save-hook`,hook:Tq(e)})}),d.append(f,V(`span`,null,`On`));let p=Uq(`hooks-btn`,`Edit`,()=>eJ(e),`Edit ${e.name}`),m=Uq(`hooks-btn`,MK,()=>{let t=bq({...e,name:lq(e.name)});t.id=null,eJ(null,t)},`Duplicate ${e.name}`),h=Uq(`hooks-btn hooks-btn-danger`,`Delete`,()=>{tp({title:`Delete hook`,message:Eq(e),confirmLabel:`Delete`,danger:!0,onConfirm:()=>{zq.add(e.id),Wq({type:`delete-hook`,id:e.id}),mJ({force:!0})}})},`Delete ${e.name}`);return h.disabled=zq.has(e.id),u.append(d,p,m,h),r.append(i,u),r}function oJ(e){let t=V(`article`,`hooks-row hooks-row-builtin`),n=V(`div`,`hooks-row-main`);return n.append(V(`span`,`hooks-row-event`,_q(e)),V(`p`,`hooks-row-meta`,e.purpose)),t.append(n),t}function sJ(){let e=Vq(`Hooks`,wK),t=V(`div`,`hooks-stats`);for(let e of rq(Dq))t.append(wf(`hooks`,e.label,e.value,e.tone));return e.append(t,Hq(`hooks-meta`,IK)),e}function cJ(){let e=V(`input`,`settings-view-input hooks-filter`);return e.type=`search`,e.value=Lq,e.placeholder=OK,e.setAttribute(`aria-label`,OK),e.addEventListener(`input`,()=>{Lq=e.value;let t=Oq?.querySelector(`.hooks-list-yours`);t&&t.replaceWith(uJ())}),e}function lJ(){let e=V(`div`,`hooks-empty-state`);return e.append(Hq(`hooks-empty`,EK),Zq(eq(Dq))),e}function uJ(){let e=V(`div`,`hooks-list-yours`),t=QK(Dq);if(t.length===0)return e.append(lJ()),e;let n=aq(iq(t,eq(Dq)),Lq);if(n.length===0)return e.append(Hq(`hooks-empty`,kK)),e;for(let t of sq(n)){let n=V(`div`,`hooks-group`);n.append(V(`h3`,`hooks-group-title`,t.event));let r=V(`div`,`hooks-list`);for(let e of t.hooks)r.append(aJ(e,{grouped:!0}));n.append(r),e.append(n)}return e}function dJ(){let e=Vq(zK,null),t=Uq(`hooks-btn hooks-btn-add`,`+ New hook`,()=>eJ(null));t.disabled=!!jq;let n=e.querySelector(`.hooks-section-head`);return n&&n.append(t),oq(QK(Dq))&&e.append(cJ()),e.append(uJ()),e}function fJ(){let e=V(`details`,`hooks-builtin`),t=V(`summary`,`hooks-builtin-summary`);t.append(V(`span`,`hooks-section-title`,`${LK} (${$K(Dq).length})`),V(`span`,`hooks-section-hint`,RK));let n=V(`div`,`hooks-list`);for(let e of $K(Dq))n.append(oJ(e));return e.append(t,n),e}function pJ(){let e=V(`div`,`hooks-content`);return Dq?YK(Dq)?(e.append(Hq(`hooks-warning`,XK(Dq))),e):(e.append(sJ()),Nq&&e.append(Nq),e.append(dJ(),fJ()),e):(e.append(Hq(`hooks-empty`,TK)),e)}function mJ({force:e=!1}={}){if(!Oq||!e&&Ef(Oq)||(Oq.replaceChildren(pJ()),!Bq))return;Bq=!1;let t=Oq.querySelector(`.hooks-btn-add`);t instanceof HTMLButtonElement&&t.focus()}function hJ(e){kq=e}function gJ(){kq&&(Aq=af(`hooks-report`),kq({type:`request-hooks-report`,requestId:Aq}))}function _J(e){Oq||(Oq=V(`div`,`hooks-panel`),e.append(Oq),mJ({force:!0}))}function vJ(){mJ({force:!0})}function yJ(e){nq(e,Aq)&&(Dq=e,zq.clear(),Fq=!1,mJ())}function bJ(e){let t=Iq!==null&&e.requestId===Iq;if(t&&(Iq=null,Fq=!1),e.ok){t&&tJ(),gJ();return}let n=typeof e.error==`string`&&e.error?e.error:`Could not save the hook`;if(t){Qq(n);return}WS(n,{persist:!0}),gJ()}function xJ(e){e.ok||WS(typeof e.error==`string`&&e.error?e.error:`Could not delete the hook`,{persist:!0}),gJ()}function SJ(e,t,n){return{body:String(n||`Session needs attention`),tag:`glimmervoid-${e||``}-${t||``}`,renotify:!0,silent:!0}}var CJ=4e3;function wJ(e,t){return`glimmervoid-notify-claim-${e||``}-${t||``}`}function TJ(e,t,n,r=CJ){try{let i=e.getItem(t);if(i){let e=Number(i);if(Number.isFinite(e)&&n-e<r)return!1}return e.setItem(t,String(n)),!0}catch{return!0}}function EJ(){return typeof Notification>`u`?null:Notification}function DJ(){return EJ()!==null}function OJ(){let e=EJ();return e?e.permission:`unavailable`}async function kJ(){let e=EJ();if(!e)return`denied`;if(e.permission!=="default")return e.permission;try{return await e.requestPermission()}catch{return e.permission}}function AJ(){let e=EJ();e&&VO()&&e.permission==="default"&&kJ()}function jJ({session:e,category:t,message:n,kind:r,ignoreFocus:i=!1}={}){let a=EJ();if(a&&VO()&&a.permission===`granted`&&(i||typeof document>`u`||typeof document.hasFocus!=`function`||!document.hasFocus())&&TJ(window.localStorage,wJ(e,t),Date.now()))try{let i=new a(`Glimmervoid`,SJ(e,t,n));i.onclick=()=>{window.focus(),r===`plan`&&typeof e==`string`&&(window.location.hash=BL(e)),i.close()}}catch{}}function MJ(e){return e.filter(e=>!e.hasOwnPhoneScreen).map(e=>{let t=e.label.trim();return{id:e.view,label:t,glyph:e.glyph||t.charAt(0).toUpperCase(),el:e.el}})}var NJ=[{name:`glimmervoid`,state:F.RUNNING,awaitingBackgroundTasks:!1},{name:`glimmervoid (2)`,state:F.RUNNING,awaitingBackgroundTasks:!0},{name:`api`,state:F.WAITING,awaitingBackgroundTasks:!1},{name:`docs-site`,state:F.IDLE,awaitingBackgroundTasks:!1}];function PJ(){let e=V(`div`,`compact-status-preview`);e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,`Example sidebar sessions showing how status appears with this setting`);for(let t of NJ){let{pill:n,refs:r}=iU(`div`,`focus-pill compact-status-preview-pill`);r.name.textContent=t.name,aU(n,r,t.state,t.awaitingBackgroundTasks),e.append(n)}return e}var FJ=null,IJ=null,LJ=null,RJ=null,zJ=-1,BJ=null,VJ=1;function HJ(){if(!FJ||BJ===null)return;let e=bO({viewportWidthPx:document.documentElement.clientWidth,viewportHeightPx:document.documentElement.clientHeight,verticalProgress:BJ});mf(FJ,xO(e,VJ))}function UJ(){RJ!==null&&(clearTimeout(RJ),RJ=null)}function WJ(e=YO()){return fO({isEnabled:e,hasReducedMotion:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,isPhone:Wf(),options:Rk()})}function GJ(e,t){if(!FJ||!IJ||!LJ||WJ())return;let n=Rk();UJ();let r=dO(n,zJ,Math.random,t);if(FJ.onanimationend=null,FJ.style.animation=`none`,!r){RJ=setTimeout(()=>GJ(!1),1e3);return}BJ=r.verticalProgress,VJ=n.flyingAnimalsScale,HJ();let i=iO[r.animalIndex];IJ.className=`nyan-sprite ${i.sprite}`,LJ.className=`nyan-trail ${i.trail}`,zJ=r.animalIndex,FJ.offsetWidth,FJ.style.animation=`nyan-fly ${r.durationSeconds}s linear`,e&&(FJ.style.animationDelay=`-${r.firstDelaySeconds}s`),FJ.onanimationend=e=>{FJ&&e.target===FJ&&(FJ.onanimationend=null,FJ.style.animation=`none`,RJ=setTimeout(()=>GJ(!1),r.gapMs))}}function KJ(){FJ||WJ()||(FJ=document.createElement(`div`),FJ.className=`nyan-flight`,FJ.setAttribute(`aria-hidden`,`true`),LJ=document.createElement(`div`),IJ=document.createElement(`div`),FJ.append(LJ,IJ),document.body.appendChild(FJ),window.addEventListener(`resize`,HJ),window.addEventListener(`orientationchange`,HJ),GJ(!0))}function qJ(e){KJ(),GJ(!1,e)}function JJ(){UJ(),window.removeEventListener(`resize`,HJ),window.removeEventListener(`orientationchange`,HJ),FJ?.remove(),FJ=null,IJ=null,LJ=null,zJ=-1,BJ=null}var YJ=!1;function XJ(e){let t=document.documentElement;if(YJ||(YJ=!0,Gf(()=>XJ(YO())),window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,()=>XJ(YO()))),e){if(t.dataset.flyingAnimals=`true`,WJ(e)){JJ();return}KJ();return}delete t.dataset.flyingAnimals,JJ()}function ZJ(){let e=V(`div`),t=V(`p`,`flying-animals-status`);t.id=`flying-animals-gallery-status`,t.setAttribute(`role`,`status`);let n=V(`div`,`flying-animals-gallery`);n.setAttribute(`aria-label`,`Animal gallery`);let r=[],i=()=>{let e=WJ(),n=lO(Rk().flyingAnimalsExcludedSprites);t.textContent=[e,n?``:`No animals are included, so automatic flights are paused.`].filter(Boolean).join(` `);for(let t of r)t.disabled=e!==null},a=Rk();for(let e of iO){let o=V(`article`,`flying-animal-tile`),s=Hk(e),c=V(`label`,`flying-animal-include`),l=V(`input`,`settings-view-checkbox`);l.type=`checkbox`,l.checked=!a.flyingAnimalsExcludedSprites.includes(e.sprite),l.setAttribute(`aria-label`,`Include ${e.name}`),l.addEventListener(`change`,()=>{let t=new Set(Rk().flyingAnimalsExcludedSprites);l.checked&&t.delete(e.sprite),l.checked||t.add(e.sprite),Lk([...t]),XJ(YO()),i()}),c.append(l,document.createTextNode(`Include`));let u=V(`button`,`btn-dialog btn-dialog-cancel`,`Fly now`);u.type=`button`,u.setAttribute(`aria-describedby`,t.id),u.addEventListener(`click`,()=>qJ(e.sprite)),r.push(u),o.append(s,V(`h2`,`flying-animal-name`,e.name),c,u),n.append(o)}return i(),e.append(t,n),e}var QJ=`johncwaters/glimmervoid`,$J=Object.freeze([`opened`,`checks-failed`,`review-requested`,`approved`,`commented`,`merged`]),eY=Object.freeze([`notify`,`spawn`,`label`,`comment`]),tY=2e4,nY=65536,rY=/^[a-z0-9][a-z0-9-]{0,63}$/,iY=/[\x00-\x1f\x7f,]|^-/,aY=(e,t)=>{let n=`${e} must be an integer between ${t.min} and ${t.max}`;return O({error:n}).int({error:n}).min(t.min,{error:n}).max(t.max,{error:n})},oY=k({error:`workflows.enabled must be a boolean`}),sY=aY(`workflows.maxConcurrentSessions`,tO),cY=aY(`workflows.maxActionsPerPoll`,nO),lY=(e,t)=>A(t,{error:`${e} must be an array`}).min(1,{error:`${e} must list at least one entry when present`}),uY=D({error:`a workflow label name must be a string`}).trim().min(1,{error:`a workflow label name must not be empty`}).max(50,{error:`a workflow label name must be at most 50 characters`}).refine(e=>!iY.test(e),{error:`a workflow label name must not start with a dash or hold a comma or control character`}),dY=D({error:`a workflow comment body must be a string`}).min(1,{error:`a workflow comment body must not be empty`}).max(nY,{error:`a workflow comment body must be at most ${nY} characters`}).refine(e=>e.trim().length>0,{error:`a workflow comment body must not be blank`}),fY=N($J,{error:`workflows.rules[].trigger must be one of ${$J.join(`, `)}`}),pY=As(`type`,[M({type:P(`notify`)}),M({type:P(`spawn`),promptTemplate:D({error:`a spawn action needs a promptTemplate string`}).min(1,{error:`a spawn action promptTemplate must not be empty`}).max(tY,{error:`a spawn action promptTemplate must be at most ${tY} characters`}).refine(e=>e.trim().length>0,{error:`a spawn action promptTemplate must not be blank`})}),M({type:P(`label`),name:uY}),M({type:P(`comment`),body:dY})],{error:`workflows.rules[].actions[].type must be one of ${eY.join(`, `)}`}),mY=M({mine:k({error:`workflows.rules[].filters.mine must be a boolean`}).optional(),teamReviewRequested:k({error:`workflows.rules[].filters.teamReviewRequested must be a boolean`}).optional(),authors:lY(`workflows.rules[].filters.authors`,D({error:`workflows.rules[].filters.authors must hold GitHub logins`}).regex(dc,{error:`workflows.rules[].filters.authors must hold GitHub logins`})).optional(),labels:lY(`workflows.rules[].filters.labels`,uY).optional(),baseBranches:lY(`workflows.rules[].filters.baseBranches`,D({error:`workflows.rules[].filters.baseBranches must hold branch names`}).min(1,{error:`workflows.rules[].filters.baseBranches must hold branch names`})).optional()},{error:`workflows.rules[].filters must be an object`}),hY=D({error:`workflows.rules[].id must be a string`}).regex(rY,{error:`workflows.rules[].id must be 1 to 64 lowercase letters, digits and dashes, starting with a letter or digit`}),gY=k({error:`workflows.rules[].enabled must be a boolean`}),_Y=M({id:hY,name:D({error:`workflows.rules[].name must be a string`}).trim().min(1,{error:`workflows.rules[].name must not be empty`}).max(80,{error:`workflows.rules[].name must be at most 80 characters`}),enabled:gY.default(!1),repos:lY(`workflows.rules[].repos`,hu),filters:mY.default({}),trigger:fY,actions:lY(`workflows.rules[].actions`,pY)},{error:`workflows.rules[] must be an object`}),vY=M({enabled:oY.default(!0),maxConcurrentSessions:sY.default(2),maxActionsPerPoll:cY.default(20),rules:A(_Y,{error:`workflows.rules must be an array`}).default([])},{error:`workflows must be an object`}).superRefine((e,t)=>{let n=new Set;for(let[r,i]of e.rules.entries()){if(!n.has(i.id)){n.add(i.id);continue}t.addIssue({code:`custom`,path:[`rules`,r,`id`],message:`workflows.rules[${r}].id "${i.id}" is declared more than once`})}}),yY=M({id:hY,enabled:gY},{error:`a dashboard update of workflows.rules[] carries only id and enabled`});M({enabled:oY.optional(),maxConcurrentSessions:sY.optional(),maxActionsPerPoll:cY.optional(),rules:A(yY,{error:`workflows.rules must be an array`}).optional()},{error:`a dashboard update of workflows carries only enabled, maxConcurrentSessions, maxActionsPerPoll and rule toggles`});var bY=O().int().nonnegative(),xY=N([`SUCCESS`,`FAILURE`,`PENDING`,`ERROR`,`EXPECTED`]).nullable();Ru.extend({author:j({login:D()}).nullable(),labels:j({nodes:A(j({name:D()}))}),comments:j({totalCount:bY})});var SY=M({polledAtMs:bY,prs:A(M({repo:hu,number:O().int().positive(),title:D(),url:Zo(),author:D().nullable(),state:N([`OPEN`,`MERGED`,`CLOSED`]),createdAt:D(),mergedAt:D().nullable(),isDraft:k(),isCrossRepository:k(),baseRefName:D(),headRefName:D().min(1),headRefOid:I,labels:A(D()),commentCount:bY,reviewRequests:A(D()),checksState:xY,reviewDecision:N([`APPROVED`,`CHANGES_REQUESTED`,`REVIEW_REQUIRED`]).nullable()}))});M({repos:Ps(D().regex(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/),SY)});var CY={maxConcurrentInvestigations:Math.ceil,minUsersToInvestigate:Math.ceil,userEscalationThreshold:Math.ceil,trafficSpikeMinUsers:Math.ceil,trafficSpikeBaselineDays:Math.floor};[...Object.entries(CY).map(([e,t])=>({path:[`posthog`,e],min:1,round:t}))];var wY=Object.freeze([`auto`,`calculate`,`display`]),TY=Object.freeze([`codex`,`grok`]),EY=Object.freeze([`dailyUsd`,`monthlyUsd`]),DY=e=>k({error:`${e} must be a boolean`}).optional(),OY=(e,t=!1)=>{let n=D({error:`${e} must be a string`});return(t?n.transform(e=>e.trim()):n).optional()},kY=e=>e.label?e.label:e.max==null?e.exclusiveMin?`greater than ${e.min}`:`at least ${e.min}`:`between ${e.min} and ${e.max}`,AY=(e,t=SD)=>O({error:`${e} must be ${kY(t)}`}).finite().refine(e=>!t.exclusiveMin||e>t.min,{message:`${e} must be ${kY(t)}`}).refine(e=>t.exclusiveMin||e>=t.min,{message:`${e} must be ${kY(t)}`}).refine(e=>t.max==null||e<=t.max,{message:`${e} must be ${kY(t)}`}).optional(),jY=(e,t)=>AY(e,t).unwrap().int({error:`${e} must be a whole number ${kY(t)}`}).optional(),MY=(e,t)=>O({error:`${e} must be an integer between ${t.min} and ${t.max}`}).int({error:`${e} must be an integer between ${t.min} and ${t.max}`}).min(t.min,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).max(t.max,{error:`${e} must be an integer between ${t.min} and ${t.max}`}).optional(),NY=(e,t)=>j(t,{error:`${e} must be an object`}).nullable().optional(),PY=Object.freeze([`claude`,`codex`]),FY=Object.freeze([`release`,`main`]),IY=Object.freeze([`report`,`fix`]);NY(`changeMap`,{narrator:NY(`changeMap.narrator`,{enabled:DY(`changeMap.narrator.enabled`),engine:N(PY,{error:`changeMap.narrator.engine must be one of ${PY.join(`, `)}`}).optional(),model:OY(`changeMap.narrator.model`,!0),timeoutSeconds:MY(`changeMap.narrator.timeoutSeconds`,$D)})}),j({refiner:j({enabled:DY(`taskTitle.refiner.enabled`),model:OY(`taskTitle.refiner.model`,!0),minIntervalSeconds:AY(`taskTitle.refiner.minIntervalSeconds`,{min:0}),timeoutSeconds:AY(`taskTitle.refiner.timeoutSeconds`,{min:0,exclusiveMin:!0,max:2147483647/1e3})},{error:`taskTitle.refiner must be an object`}).nullable().optional()},{error:`taskTitle must be an object`}).nullable().optional();var LY={enabled:DY(`branchGc.enabled`),worktrees:DY(`branchGc.worktrees`),prefixes:A(D({error:`branchGc.prefixes must be an array of strings`}).min(1,{error:`branchGc.prefixes entries must be non-empty strings`}),{error:`branchGc.prefixes must be an array of strings`}).optional(),dryRun:DY(`branchGc.dryRun`),staleDays:AY(`branchGc.staleDays`,OD),deleteUnmerged:DY(`branchGc.deleteUnmerged`),intervalMs:AY(`branchGc.intervalMs`,kD)},RY=j(LY,{error:`branchGc must be an object`});NY(`branchGc`,LY),RY.omit({prefixes:!0,dryRun:!0,worktrees:!0}).nullable().optional(),Object.freeze([`enabled`,`deleteUnmerged`]),Object.freeze([`staleDays`,`intervalMs`]),NY(`postTurnChecks`,{mode:N(IY,{error:`postTurnChecks.mode must be one of report, fix`}).optional()}),NY(`visions`,{enabled:DY(`visions.enabled`),autoFix:DY(`visions.autoFix`),projects:A(D({error:`visions.projects must be an array of strings`}),{error:`visions.projects must be an array of strings`}).optional(),dispatch:NY(`visions.dispatch`,{enabled:DY(`visions.dispatch.enabled`),model:OY(`visions.dispatch.model`,!0),quietMs:jY(`visions.dispatch.quietMs`,AD),cooldownMs:jY(`visions.dispatch.cooldownMs`,jD),maxPerHour:jY(`visions.dispatch.maxPerHour`,MD),activityMaxPerHour:jY(`visions.dispatch.activityMaxPerHour`,ND),dispatchTimeoutSeconds:jY(`visions.dispatch.dispatchTimeoutSeconds`,PD)}),intent:NY(`visions.intent`,{threadTtlMs:jY(`visions.intent.threadTtlMs`,FD)})}),j({teams:A(D({error:`github.teams must be an array of org/slug strings`}).refine(e=>mc(e)!==null,{message:`github.teams entries must be org/slug with valid GitHub segments`}),{error:`github.teams must be an array of org/slug strings`}).optional()},{error:`github must be an object`}).nullable().optional(),NY(`teamReview`,{enabled:DY(`teamReview.enabled`),autoRebaseMyPrs:DY(`teamReview.autoRebaseMyPrs`),keepMergeableEnabled:DY(`teamReview.keepMergeableEnabled`),mergeQueueEnabled:DY(`teamReview.mergeQueueEnabled`),keepMergeableTimeoutMinutes:MY(`teamReview.keepMergeableTimeoutMinutes`,eO),org:OY(`teamReview.org`,!0),team:OY(`teamReview.team`,!0),skill:OY(`teamReview.skill`,!0),reReviewAfterHours:AY(`teamReview.reReviewAfterHours`),skipIdleAfterDays:AY(`teamReview.skipIdleAfterDays`)}),NY(`benchmarks`,{enabled:DY(`benchmarks.enabled`)}),j({enabled:DY(`factory.enabled`),maxRisk:Jc.optional(),maxLiveWorkers:O().int().min(xD.min).optional(),checks:A(D().trim().min(1)).optional(),protectedPaths:A(D().trim().min(1)).optional(),reviewerModel:D().trim().min(1).nullable().optional(),dailyBudgetUsd:O().finite().nonnegative().nullable().optional(),verifierModel:D().trim().min(1).nullable().optional(),mirrorHarnessRuns:DY(`factory.mirrorHarnessRuns`)}).nullable().optional(),NY(`knowledgeGraph`,{enabled:DY(`knowledgeGraph.enabled`)});var zY={intervalMinutes:ID,maxConcurrentInvestigations:LD,investigationTimeoutSeconds:RD,fixTimeoutSeconds:UD,minUsersToInvestigate:zD,userEscalationThreshold:BD,recurrenceWindowDays:VD,transientRecurrenceLimit:HD,trafficSpikeMultiplier:WD,trafficSpikeMinUsers:GD,trafficSpikeCooldownMinutes:KD,trafficSpikeBaselineDays:qD};NY(`posthog`,{enabled:DY(`posthog.enabled`),recurrenceDedupe:DY(`posthog.recurrenceDedupe`),trafficSpikeEnabled:DY(`posthog.trafficSpikeEnabled`),autoFix:DY(`posthog.autoFix`),host:OY(`posthog.host`,!0).refine(e=>e==null||!e||/^https?:\/\//i.test(e),{message:`posthog.host must be an http(s) URL`}),apiKey:OY(`posthog.apiKey`,!0),repoPath:OY(`posthog.repoPath`,!0),projects:Os([P(`all`),A(O({error:`posthog.projects must be "all" or an array of positive integer project ids`}).int({error:`posthog.projects must be "all" or an array of positive integer project ids`}).positive({error:`posthog.projects must be "all" or an array of positive integer project ids`}),{error:`posthog.projects must be "all" or an array of positive integer project ids`})],{error:`posthog.projects must be "all" or an array of positive integer project ids`}).optional(),projectMap:Ps(D(),xs(),{error:`posthog.projectMap must be an object`}).optional(),...Object.fromEntries(Object.entries(zY).map(([e,t])=>[e,Object.hasOwn(CY,e)?jY(`posthog.${e}`,t):AY(`posthog.${e}`,t)]))}),`${wY.join(`, `)}`,Object.fromEntries(TY.map(e=>[e,DY(`usage.vendors.${e}`)])),Object.fromEntries(EY.map(e=>[e,O({error:`usage.budget.${e} must be a positive number or null`}).positive({error:`usage.budget.${e} must be a positive number or null`}).nullable().optional()])),NY(`telegram`,{botToken:OY(`telegram.botToken`,!0),chatId:OY(`telegram.chatId`,!0)}),j({enabled:DY(`ingest.enabled`)},{error:`ingest must be an object`}).passthrough().optional(),j({enabled:DY(`trace.enabled`)},{error:`trace must be an object`}).optional(),j({enabled:DY(`planReview.enabled`)},{error:`planReview must be an object`}).optional();var BY={enabled:DY(`agentApi.enabled`)};j(BY,{error:`agentApi must be an object`}).strict().optional(),j(BY,{error:`agentApi must be an object`}).passthrough().optional();var VY=e=>A(D({error:`${e} must be an array of paths`}).trim().min(1,{error:`${e} must be an array of paths`}),{error:`${e} must be an array of paths`}).optional();j({unguardedRepos:VY(`guardrails.unguardedRepos`),blockedPaths:VY(`guardrails.blockedPaths`),unreadablePaths:VY(`guardrails.unreadablePaths`)},{error:`guardrails must be an object`}).passthrough().optional();var HY={enabled:DY(`telemetry.enabled`)};j(HY,{error:`telemetry must be an object`}).strict().optional(),j(HY,{error:`telemetry must be an object`}).passthrough().optional();function UY(e){return e.map(e=>({value:e,label:e[0].toUpperCase()+e.slice(1)}))}var WY=Object.freeze({general:`machine-general`,updates:`machine-updates`,terminal:`machine-terminal`,repos:`machine-repositories`,repositories:`machine-repositories`,advanced:`machine-detection-sessions`,detection:`machine-detection-sessions`,telegram:`machine-telegram`,notifications:`machine-telegram`,"change-map":`lanes-change-map`,visions:`lanes-visions`,ingest:`lanes-ingest`,posthog:`lanes-posthog`,"team-review":`lanes-team-review`,reviews:`lanes-team-review`,benchmarks:`lanes-benchmarks`,factory:`lanes-factory`,"knowledge-graph":`lanes-knowledge-graph`,workflows:`lanes-workflows`,usage:`machine-usage`,privacy:`machine-privacy`,telemetry:`machine-privacy`,shortcuts:`browser-shortcuts`,animals:`browser-flying-animals`,"flying-animals":`browser-flying-animals`,unattended:`lanes-unattended`}),GY=Object.freeze({"browser-appearance":Object.freeze({"flying-animals":`browser-flying-animals`})}),KY=Object.freeze([{id:`browser-appearance`,level:`browser`,title:`Appearance and alerts`,description:`Preferences stored only in this browser.`,settings:[{id:`theme`,path:`pref:themeId`,title:`Theme`,description:`Color scheme for the dashboard.`,control:`select`,optionsFrom:`themes`,keywords:[`color`,`palette`],defaultValue:`phyrexian`},{id:`compact-status`,path:`pref:compactStatusLabels`,title:`Hide status words in sidebar`,description:`Hide status words in the sidebar and on the phone Board while keeping the colored status mark and the phone Plan ready badge. Saved per browser, so turn it on in each one.`,control:`toggle`,keywords:[`sidebar`,`status`,`compact`],defaultValue:!1},{id:`session-usage-chips`,path:`pref:sessionUsageChips`,title:`Show usage on session cards`,description:`Shows each card's transcript token count and CLI-reported cost when available, otherwise a calculated API list-price estimate.`,control:`toggle`,keywords:[`usage`,`cost`,`tokens`,`card`,`price`],defaultValue:!1},{id:`alert-sounds-enabled`,path:`pref:soundEnabled`,title:`Alert sounds`,description:`Play sounds when a session needs attention and when a merge celebration plays. The same switch as the note button in the desktop header.`,control:`toggle`,keywords:[`audio`,`mute`,`sound`,`notification`],defaultValue:!0},{id:`alert-sound`,path:`pref:soundId`,title:`Alert sound`,description:`Sound played when a session needs attention. Your own .ogg, .mp3, .wav, .m4a or .webm files dropped into the sounds folder of the Glimmervoid home (~/.glimmervoid/sounds/, or $GLIMMERVOID_HOME/sounds/) are listed after the built-in sounds. Glimmervoid never creates that folder, so make it yourself; new files show up the next time Settings opens.`,control:`select`,optionsFrom:`sounds`,keywords:[`audio`,`notification`,`custom`],defaultValue:`chime`},{id:`desktop-notifications`,path:`pref:notificationsEnabled`,title:`Desktop notifications`,description:`Raise a browser notification when a session needs attention while this dashboard is in the background.`,control:`toggle`,keywords:[`browser`,`attention`],defaultValue:!0}]},{id:`browser-flying-animals`,level:`browser`,title:`Flying animals`,description:`Choose your flying animals. Changes apply immediately in this browser.`,settings:[{id:`flying-animals`,path:`pref:flyingAnimalsEnabled`,title:`Flying animals`,description:`Show animated animals flying across the dashboard.`,control:`toggle`,keywords:[`animation`,`motion`],defaultValue:!1},{id:`animals-min-gap`,path:`pref:flyingAnimalsMinGapSeconds`,title:`Time between flights: minimum (seconds)`,description:`Shortest pause between flights.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_GAP_RANGE`,maximumSettingId:`animals-max-gap`,keywords:[`animals`,`frequency`],defaultValue:aO.flyingAnimalsMinGapSeconds},{id:`animals-max-gap`,path:`pref:flyingAnimalsMaxGapSeconds`,title:`Time between flights: maximum (seconds)`,description:`Longest pause between flights.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_GAP_RANGE`,keywords:[`animals`,`frequency`],defaultValue:aO.flyingAnimalsMaxGapSeconds},{id:`animals-min-duration`,path:`pref:flyingAnimalsMinDurationSeconds`,title:`Flight duration: minimum (seconds)`,description:`Shortest flight, for faster animals.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_DURATION_RANGE`,maximumSettingId:`animals-max-duration`,keywords:[`animals`,`speed`],defaultValue:aO.flyingAnimalsMinDurationSeconds},{id:`animals-max-duration`,path:`pref:flyingAnimalsMaxDurationSeconds`,title:`Flight duration: maximum (seconds)`,description:`Longest flight, for slower animals.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_DURATION_RANGE`,keywords:[`animals`,`speed`],defaultValue:aO.flyingAnimalsMaxDurationSeconds},{id:`animals-scale`,path:`pref:flyingAnimalsScale`,title:`Size multiplier`,description:`Scale applied on top of the viewport size.`,control:`number`,advanced:!0,commitOnChange:!0,integer:!1,step:.1,range:`FLYING_ANIMALS_SCALE_RANGE`,keywords:[`animals`,`size`],defaultValue:aO.flyingAnimalsScale},{id:`animals-on-phone`,path:`pref:flyingAnimalsOnPhone`,title:`Show on phone layout`,description:`Allow flights on the phone layout.`,control:`toggle`,advanced:!0,keywords:[`animals`,`mobile`],defaultValue:aO.flyingAnimalsOnPhone}]},{id:`browser-shortcuts`,level:`browser`,title:`Shortcuts and about`,description:`Keyboard reference and build information.`,settings:[]},{id:`machine-general`,level:`machine`,title:`General`,description:`Machine-wide session startup and diagnostics.`,settings:[{id:`auto-resume`,path:`autoResume`,title:`Auto-resume sessions on startup`,description:`Resume conversations that were live when Glimmervoid last shut down or crashed.`,control:`toggle`,keywords:[`startup`,`conversation`],defaultValue:!0},{id:`debug-mode`,path:`debugMode`,title:`Debug mode`,description:`Show session-card diagnostics for state, transitions and detection signals.`,control:`toggle`,keywords:[`diagnostics`,`state`],defaultValue:!1},{id:`calm-layout`,path:`calmLayout`,title:`Calm layout (experimental)`,description:`Replace the Focus rail with a view that prioritizes sessions needing attention and also shows ready and working indicators. Applies to every browser on this machine.`,control:`toggle`,keywords:[`experimental`,`attention`,`priority`],defaultValue:!1}],unattendedLinks:[{settingId:`skip-permissions-by-default`,title:`Skip permission prompts by default`},{settingId:`rtk-compression`,title:`rtk output compression`}]},{id:`machine-updates`,level:`machine`,title:`Updates`,description:`See which Glimmervoid version is running, which one is newest, and update in one step.`,settings:[{id:`update-summary`,path:`status:update-summary`,title:`Status`,description:`Whether this install is up to date, and what an update would move it to.`,control:`readonly`,keywords:[`version`,`available`,`current`],status:`update-summary`},{id:`update-actions`,path:`status:update-actions`,title:`Actions`,description:`Update and restart stages the newest build, then restarts to run it. Update without restart stages it for a later restart.`,control:`readonly`,keywords:[`check`,`restart`],status:`update-actions`},{id:`update-installed`,path:`status:update-installed`,title:`Running version`,description:`The version loaded when the server started, alongside the commit, branch and state of the current disk checkout.`,control:`readonly`,keywords:[`version`,`commit`,`installed`],status:`update-installed`},{id:`update-latest`,path:`status:update-latest`,title:`Latest version`,description:`The newest target found on the selected update channel.`,control:`readonly`,keywords:[`release`,`commit`],status:`update-latest`},{id:`update-last-checked`,path:`status:update-last-checked`,title:`Last checked`,description:`The most recent update check, or why automatic checks are off.`,control:`readonly`,keywords:[`time`,`failure`],status:`update-last-checked`},{id:`update-channel`,path:`updateChannel`,title:`Channel`,description:`Track tagged releases or the upstream of the checked-out branch.`,control:`select`,options:UY(FY),keywords:[`release`,`branch`],defaultValue:`release`},{id:`check-updates`,path:`checkForUpdates`,title:`Check for updates automatically`,description:`Check for a newer Glimmervoid at launch, while a dashboard is connected, and when this page opens.`,control:`toggle`,keywords:[`release`,`github`],defaultValue:!0}]},{id:`machine-terminal`,level:`machine`,title:`Terminal`,description:`Terminal behavior shared by dashboard clients.`,settings:[{id:`replay-buffer`,path:`replayBufferKB`,title:`Replay buffer (KB)`,description:`PTY output retained for clients that reconnect or join late.`,control:`number`,range:`REPLAY_BUFFER_KB_RANGE`,keywords:[`history`,`backfill`],defaultValue:512},{id:`cursor-blink`,path:`cursorBlink`,title:`Cursor blink`,description:`Blink the cursor in every terminal.`,control:`toggle`,keywords:[`caret`,`terminal`],defaultValue:!1}]},{id:`machine-detection-sessions`,level:`machine`,title:`Detection and sessions`,description:`Config-file-only detection, timing, worktree and process settings.`,settings:[{id:`file-detect-background-agents`,path:`detectBackgroundAgents`,title:`Detect background agents`,description:`Hold completion while tracked background work is active. Changes apply to newly created sessions; recreate existing sessions to apply them.`,control:`readonly`,keywords:[`subagents`,`completion`],fileOnly:!0},{id:`file-record-signals`,path:`recordSignals`,title:`Record structural signals`,description:`Keep forensic status and hook recordings for newly created sessions. Full capture (capture.enabled) records these signals even when this is off. Recreate existing sessions to change recording.`,control:`readonly`,keywords:[`recordings`,`diagnostics`],fileOnly:!0},{id:`file-trace-enabled`,path:`trace.enabled`,title:`Capture session traces`,description:`Keep normalized Claude transcript traces for session debugging. Requires a server restart.`,control:`readonly`,keywords:[`transcripts`,`diagnostics`],fileOnly:!0},{id:`file-detect-scheduled-wakeups`,path:`detectScheduledWakeups`,title:`Detect scheduled wakeups`,description:`Surface advisory wakeup timing for scheduled sessions. Requires a server restart to update the configuration, and newly created sessions use the change.`,control:`readonly`,keywords:[`schedule`,`sleep`],fileOnly:!0},{id:`file-worktree-auto-rebase`,path:`worktreeAutoRebase`,title:`Worktree auto-rebase`,description:`Rebase eligible session worktrees when the integration branch moves. Changes apply to newly created sessions; recreate existing sessions to apply them.`,control:`readonly`,keywords:[`git`,`branch`],fileOnly:!0},{id:`file-worktree-rerere`,path:`worktreeRerere`,title:`Worktree rerere`,description:`Reuse recorded Git conflict resolutions. Requires a server restart.`,control:`readonly`,keywords:[`git`,`conflicts`],fileOnly:!0},{id:`file-integration-branch`,path:`integrationBranch`,title:`Integration branch`,description:`Base branch for session worktrees. Empty = each repo's default branch. Reload affects newly created sessions and does not retarget existing sessions.`,control:`readonly`,keywords:[`git`,`merge`],fileOnly:!0},{id:`file-worktree-root`,path:`worktreeRoot`,title:`Worktree root`,description:`Directory that contains session worktrees. Changes apply to newly created sessions and do not relocate existing worktrees; recreate existing sessions to change where they create worktrees.`,control:`readonly`,keywords:[`git`,`directory`],fileOnly:!0},{id:`file-worktree-share`,path:`worktreeShare`,title:`Shared worktree paths`,description:`Local paths copied or linked during worktree preparation. Changes apply to newly created sessions; recreate existing sessions to use a new share list.`,control:`readonly`,keywords:[`files`,`context`],fileOnly:!0},{id:`file-port`,path:`port`,title:`Local port`,description:`Port used by the local dashboard listener. Requires a server restart.`,control:`readonly`,keywords:[`server`,`listener`],fileOnly:!0},{id:`file-auto-recover-seconds`,path:`autoRecoverSeconds`,title:`Auto-recovery delay`,description:`Delay before an interrupted state can recover.`,control:`readonly`,keywords:[`timer`,`recovery`],fileOnly:!0},{id:`file-input-grace-seconds`,path:`inputGraceSeconds`,title:`Input grace period`,description:`Grace window around operator input.`,control:`readonly`,keywords:[`timer`,`prompt`],fileOnly:!0},{id:`file-prompt-detection-ms`,path:`promptDetectionMs`,title:`Prompt detection delay`,description:`Timing threshold used by prompt detection.`,control:`readonly`,keywords:[`timer`,`detection`],fileOnly:!0},{id:`file-notify-debounce-ms`,path:`notifyDebounceMs`,title:`Notification debounce`,description:`Delay used to coalesce notification state changes.`,control:`readonly`,keywords:[`timer`,`alerts`],fileOnly:!0},{id:`file-phone-escalation-ms`,path:`phoneEscalationMs`,title:`Phone escalation delay`,description:`Delay before off-dashboard escalation.`,control:`readonly`,keywords:[`timer`,`telegram`],fileOnly:!0},{id:`file-post-turn-checks`,path:`postTurnChecks`,title:`Post-turn checks`,description:`Deterministic checks run after eligible turns. The global mode is a default; project and individual rule modes can select fixes even when the global mode is report.`,control:`readonly`,keywords:[`quality`,`fixes`],fileOnly:!0},{id:`file-branch-gc-enabled`,path:`branchGc.enabled`,title:`Branch cleanup`,description:`Enable cleanup of eligible session branches.`,control:`readonly`,keywords:[`git`,`cleanup`],fileOnly:!0},{id:`file-branch-gc-worktrees`,path:`branchGc.worktrees`,title:`Local worktree cleanup`,description:`Enable cleanup of eligible local worktrees.`,control:`readonly`,keywords:[`git`,`worktree`,`cleanup`],fileOnly:!0},{id:`file-branch-gc-prefixes`,path:`branchGc.prefixes`,title:`Branch cleanup prefixes`,description:`Branch prefixes that filter both remote branch cleanup and local worktree cleanup.`,control:`readonly`,keywords:[`git`,`branch`],fileOnly:!0},{id:`file-branch-gc-dry-run`,path:`branchGc.dryRun`,title:`Branch cleanup dry run`,description:`Report planned cleanup without deleting remote branches.`,control:`readonly`,keywords:[`git`,`safety`],fileOnly:!0},{id:`file-branch-gc-stale-days`,path:`branchGc.staleDays`,title:`Branch stale days`,description:`Age threshold for orphan branch cleanup when unmerged deletion is on.`,control:`readonly`,keywords:[`git`,`retention`],fileOnly:!0},{id:`file-branch-gc-interval-ms`,path:`branchGc.intervalMs`,title:`Branch cleanup interval`,description:`Delay between branch cleanup passes.`,control:`readonly`,keywords:[`git`,`schedule`],fileOnly:!0},{id:`file-custom-agents`,path:`customAgents`,title:`Custom agents`,description:`Extra agent CLIs a session can be spawned with.`,control:`readonly`,keywords:[`adapters`,`cli`],fileOnly:!0,status:`custom-agents`}]},{id:`machine-repositories`,level:`machine`,title:`Repositories`,description:`Project discovery roots for new sessions.`,settings:[{id:`repository-roots`,path:`repoRoots`,title:`Repository roots`,description:`Directories scanned for projects when adding sessions.`,control:`list`,keywords:[`folders`,`project discovery`],defaultValue:[]}]},{id:`machine-telegram`,level:`machine`,title:`Telegram`,description:`One bot shared by session, PR review and PostHog notifications.`,settings:[{id:`telegram-bot-token`,path:`telegram.botToken`,title:`Bot token`,description:`Credential used by the shared Telegram bot. When GLIMMERVOID_TELEGRAM_BOT_TOKEN supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`api`],defaultValue:``},{id:`telegram-chat-id`,path:`telegram.chatId`,title:`Chat id`,description:`Destination chat for enabled Telegram lanes.`,control:`text`,keywords:[`destination`,`channel`],defaultValue:``},{id:`telegram-session-notifications`,path:`telegramNotifications`,title:`Send session notifications`,description:`Send session completion, input and failure alerts when no dashboard is open. Unacknowledged alerts also escalate after the phone escalation delay while a dashboard remains open.`,control:`toggle`,keywords:[`phone`,`off dashboard`],defaultValue:!1}]},{id:`machine-usage`,level:`machine`,title:`Usage`,description:`Local transcript accounting and estimated-cost budgets.`,settings:[{id:`usage-enabled`,path:`usage.enabled`,title:`Track token usage`,description:`Read local CLI transcripts and roll them into the Usage view and session chips.`,control:`toggle`,keywords:[`tokens`,`cost`],defaultValue:!0,status:`usage-last-report`},{id:`usage-codex`,path:`usage.vendors.codex`,title:`Track Codex usage`,description:`Include local Codex CLI transcripts in usage reports.`,control:`toggle`,keywords:[`openai`,`vendor`],defaultValue:!0},{id:`usage-grok`,path:`usage.vendors.grok`,title:`Track Grok usage`,description:`Include local Grok CLI transcripts in usage reports.`,control:`toggle`,keywords:[`xai`,`vendor`],defaultValue:!0},{id:`usage-fetch-pricing`,path:`usage.fetchPricing`,title:`Fetch current model prices`,description:`Load public model prices when usage tracking starts, using a cached table for up to one day. Falls back to cached or bundled prices if the fetch fails; no daily refresh runs while tracking continues.`,control:`toggle`,keywords:[`rates`,`models`],defaultValue:!0},{id:`usage-scan-interval`,path:`usage.scanIntervalMinutes`,title:`Scan interval (minutes)`,description:`Periodic transcript polling interval. Session activity can also trigger scans between timer ticks.`,control:`number`,range:`USAGE_SCAN_INTERVAL_RANGE`,keywords:[`poll`,`refresh`],defaultValue:5},{id:`usage-retain-days`,path:`usage.retainDays`,title:`Retain transcript detail (days)`,description:`How long live transcript detail stays available. A monthly budget keeps detail from the start of the current month when that is longer.`,control:`number`,range:`USAGE_RETAIN_DAYS_RANGE`,keywords:[`history`,`retention`],defaultValue:90},{id:`usage-cost-mode`,path:`usage.costMode`,title:`Cost mode`,description:`Choose whether recorded costs, calculated costs or both can appear.`,control:`select`,options:UY(wY),keywords:[`pricing`,`estimate`],defaultValue:`auto`},{id:`usage-daily-budget`,path:`usage.budget.dailyUsd`,title:`Daily budget (USD)`,description:`Estimated daily spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:`USAGE_BUDGET_RANGE`,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01},{id:`usage-monthly-budget`,path:`usage.budget.monthlyUsd`,title:`Monthly budget (USD)`,description:`Estimated monthly spend alert threshold. Alerts at 50%, 75% and 100% do not stop spending. Zero or below disables the threshold.`,control:`number`,range:`USAGE_BUDGET_RANGE`,keywords:[`spend`,`alert`],defaultValue:null,integer:!1,nullable:!0,zeroIsNull:!0,step:.01}]},{id:`machine-privacy`,level:`machine`,title:`Privacy`,description:`What Glimmervoid sends about itself.`,settings:[{id:`telemetry-enabled`,path:`telemetry.enabled`,title:`Send anonymous usage and error data`,description:`Version, platform, app starts, daily activity, session starts and ends with agent kind, exit kind and duration, errors as their type, error code and scrubbed stack frames, per session token counts, models and estimated costs from the usage scan, and factory outcomes as the kind of decision, how it came out, its duration and attempt number, under a random install id. Never error messages, paths, repository or branch names, prompts, objectives or terminal output. GLIMMERVOID_TELEMETRY=0, DO_NOT_TRACK=1 or CI=true turn it off regardless.`,control:`toggle`,keywords:[`telemetry`,`analytics`,`tracking`,`opt out`],defaultValue:!0}]},{id:`lanes-change-map`,level:`lanes`,title:`Change map`,description:`Optional model narration for deterministic change facts.`,settings:[{id:`change-map-narrator-enabled`,path:`changeMap.narrator.enabled`,title:`Enable narration`,description:`Add cited model claims to the change map.`,control:`toggle`,keywords:[`review`,`claims`],defaultValue:!1},{id:`change-map-narrator-engine`,path:`changeMap.narrator.engine`,title:`Narrator engine`,description:`CLI used to generate change map claims.`,control:`select`,options:UY(PY),keywords:[`claude`,`codex`],defaultValue:`claude`},{id:`change-map-narrator-model`,path:`changeMap.narrator.model`,title:`Narrator model`,description:`Blank uses the engine default: haiku for Claude, the configured Codex model for Codex.`,control:`text`,keywords:[`claude`,`codex`,`haiku`],defaultValue:``},{id:`change-map-narrator-timeout`,path:`changeMap.narrator.timeoutSeconds`,title:`Narrator timeout (seconds)`,description:`Maximum time allowed for one narration.`,control:`number`,range:`CHANGE_MAP_NARRATOR_TIMEOUT_RANGE`,keywords:[`deadline`,`narration`],defaultValue:90}]},{id:`lanes-visions`,level:`lanes`,title:`Visions`,description:`Editor-buffer findings and bounded model comments.`,settings:[{id:`visions-enabled`,path:`visions.enabled`,title:`Enable Visions`,description:`Set up supported editors detected on this machine, then show their buffer findings in the Visions view.`,control:`toggle`,keywords:[`editor`,`findings`,`lsp`],defaultValue:!1},{id:`visions-dispatch-enabled`,path:`visions.dispatch.enabled`,title:`Enable model comments`,description:`Start bounded review sessions for local editor buffers.`,control:`toggle`,keywords:[`review`,`dispatch`],defaultValue:!1},{id:`visions-quiet-delay`,path:`visions.dispatch.quietMs`,title:`Quiet delay (ms)`,description:`Editor quiet time before a scheduled review. Saves and blank-line boundaries can dispatch immediately, subject to the other review limits.`,control:`number`,range:`VISIONS_QUIET_MS_RANGE`,keywords:[`debounce`,`idle`],defaultValue:3e4},{id:`visions-cooldown`,path:`visions.dispatch.cooldownMs`,title:`Cooldown (ms)`,description:`Minimum delay between reviews of the same document. Initial orientation reviews bypass this delay.`,control:`number`,range:`VISIONS_COOLDOWN_MS_RANGE`,keywords:[`rate limit`,`delay`],defaultValue:3e5},{id:`visions-max-per-hour`,path:`visions.dispatch.maxPerHour`,title:`Max per hour`,description:`Maximum review sessions dispatched per hour.`,control:`number`,range:`VISIONS_MAX_PER_HOUR_RANGE`,keywords:[`rate limit`,`reviews`],defaultValue:6},{id:`visions-activity-max-per-hour`,path:`visions.dispatch.activityMaxPerHour`,title:`Activity max per hour`,description:`Maximum activity-driven reviews dispatched per hour, capped at the overall hourly limit minus one to reserve an edit-review slot.`,control:`number`,range:`VISIONS_ACTIVITY_MAX_PER_HOUR_RANGE`,status:`visions-activity-limit`,keywords:[`rate limit`,`events`],defaultValue:2},{id:`visions-dispatch-timeout`,path:`visions.dispatch.dispatchTimeoutSeconds`,title:`Dispatch timeout (seconds)`,description:`Maximum time allowed for one review session.`,control:`number`,range:`VISIONS_DISPATCH_TIMEOUT_RANGE`,keywords:[`deadline`,`review`],defaultValue:180},{id:`visions-intent-thread-ttl`,path:`visions.intent.threadTtlMs`,title:`Intent thread lifetime (ms)`,description:`How long an intent thread nobody advanced stays live before it retires.`,control:`number`,range:`VISIONS_INTENT_THREAD_TTL_MS_RANGE`,keywords:[`intent`,`decay`,`thread`],defaultValue:2592e5},{id:`visions-model`,path:`visions.dispatch.model`,title:`Model override`,description:`Leave blank to use the opus model alias.`,control:`text`,keywords:[`claude`,`override`],defaultValue:``},{id:`visions-projects`,path:`visions.projects`,title:`Projects`,description:`Clear every selection, including unavailable projects, to accept buffers from every configured project.`,control:`projects`,keywords:[`repositories`,`filter`],defaultValue:[]},{id:`visions-auto-fix`,path:`visions.autoFix`,title:`Apply tier 1 fixes`,description:`Allow Visions to edit eligible open Markdown buffers, including inactive buffers, without asking.`,control:`toggle`,keywords:[`automatic`,`edits`],danger:!0,warning:`Enabling this control lets Visions edit eligible buffers without a carbon unit present.`,defaultValue:!1}]},{id:`lanes-ingest`,level:`lanes`,title:`Ingest`,description:`Machine-context ingest behind Visions.`,settings:[{id:`ingest-enabled`,path:`ingest.enabled`,title:`Enable machine context ingest`,description:`Enable the local activity feed behind Visions. Turning Visions on enables ingest unless ingest.enabled is explicitly false.`,control:`toggle`,keywords:[`events`,`activity`],defaultValue:!1},{id:`ingest-terminal`,path:`ingest.sources.terminal.enabled`,title:`Terminal output source`,description:`Include terminal output in the ingest feed.`,control:`toggle`,keywords:[`pty`,`source`],defaultValue:!1},{id:`ingest-agent-logs`,path:`ingest.sources.agentLogs.enabled`,title:`Agent logs source`,description:`Include local agent logs in the ingest feed.`,control:`toggle`,keywords:[`transcript`,`source`],defaultValue:!1},{id:`ingest-git`,path:`ingest.sources.git.enabled`,title:`Git activity source`,description:`Include local Git activity in the ingest feed.`,control:`toggle`,keywords:[`commits`,`source`],defaultValue:!1},{id:`ingest-fs`,path:`ingest.sources.fs.enabled`,title:`File changes source`,description:`Include watched file changes in the ingest feed.`,control:`toggle`,keywords:[`filesystem`,`source`],defaultValue:!1},{id:`ingest-shell-history`,path:`ingest.sources.shellHistory.enabled`,title:`Shell history source`,description:`Include local shell history in the ingest feed.`,control:`toggle`,keywords:[`commands`,`source`],defaultValue:!1},{id:`ingest-editor`,path:`ingest.sources.editor.enabled`,title:`Editor events source`,description:`Include local editor events in the ingest feed.`,control:`toggle`,keywords:[`buffers`,`source`],defaultValue:!1}]},{id:`lanes-posthog`,level:`lanes`,title:`PostHog`,description:`Error monitoring, investigations and traffic-spike alerts.`,settings:[{id:`posthog-enabled`,path:`posthog.enabled`,title:`Enable PostHog monitoring`,description:`Poll PostHog error tracking and investigate issues that move.`,control:`toggle`,keywords:[`errors`,`monitoring`],defaultValue:!1},{id:`posthog-host`,path:`posthog.host`,title:`Host`,description:`PostHog cloud or self-hosted HTTP URL.`,control:`text`,keywords:[`url`,`server`],defaultValue:`https://us.posthog.com`},{id:`posthog-api-key`,path:`posthog.apiKey`,title:`Personal API key`,description:`Credential with read access to PostHog projects. When GLIMMERVOID_POSTHOG_API_KEY supplies it, this field is read-only.`,control:`password`,keywords:[`credential`,`token`],defaultValue:``},{id:`posthog-projects`,path:`posthog.projects`,title:`Projects`,description:`Use all, none for an empty selection, or a comma-separated list of positive integer PostHog project ids. Blank means all.`,control:`text`,keywords:[`project ids`,`filter`],defaultValue:`all`,valueKind:`posthog-projects`},{id:`posthog-interval`,path:`posthog.intervalMinutes`,title:`Poll interval (minutes)`,description:`Delay between PostHog polling passes.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`refresh`,`schedule`],defaultValue:15},{id:`posthog-max-investigations`,path:`posthog.maxConcurrentInvestigations`,title:`Max concurrent investigations`,description:`Maximum investigation sessions running together.`,control:`number`,range:`POSTHOG_MAX_CONCURRENT_RANGE`,keywords:[`parallel`,`workers`],defaultValue:2},{id:`posthog-investigation-timeout`,path:`posthog.investigationTimeoutSeconds`,title:`Investigation timeout (seconds)`,description:`Maximum time allowed for one investigation.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_INVESTIGATION_TIMEOUT_RANGE`,keywords:[`deadline`,`session`],defaultValue:900},{id:`posthog-min-users`,path:`posthog.minUsersToInvestigate`,title:`Min users to investigate`,description:`Minimum affected users for a new issue investigation. Regressions, worsening issues and eligible error spikes bypass this minimum.`,control:`number`,range:`POSTHOG_MIN_USERS_RANGE`,keywords:[`threshold`,`affected`],defaultValue:1},{id:`posthog-escalation`,path:`posthog.userEscalationThreshold`,title:`Escalation threshold (users)`,description:`Affected-user count that escalates an issue.`,control:`number`,range:`POSTHOG_ESCALATION_RANGE`,keywords:[`threshold`,`severity`],defaultValue:25},{id:`posthog-fix-timeout`,path:`posthog.fixTimeoutSeconds`,title:`Fix timeout (seconds)`,description:`Maximum time allowed for one fix session.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_FIX_TIMEOUT_RANGE`,keywords:[`deadline`,`repair`],defaultValue:1800},{id:`posthog-traffic-enabled`,path:`posthog.trafficSpikeEnabled`,title:`Traffic spike alerts`,description:`Ping when recent unique users exceed a project baseline.`,control:`toggle`,keywords:[`analytics`,`alert`],defaultValue:!0},{id:`posthog-traffic-multiplier`,path:`posthog.trafficSpikeMultiplier`,title:`Spike multiplier`,description:`Baseline multiplier required to classify a traffic spike.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_TRAFFIC_MULTIPLIER_RANGE`,keywords:[`baseline`,`ratio`],defaultValue:3},{id:`posthog-traffic-min-users`,path:`posthog.trafficSpikeMinUsers`,title:`Min users to alert`,description:`Minimum recent unique users for an initial traffic-spike alert. Escalation and recovery alerts bypass this minimum.`,control:`number`,range:`POSTHOG_TRAFFIC_MIN_USERS_RANGE`,keywords:[`threshold`,`analytics`],defaultValue:10},{id:`posthog-traffic-cooldown`,path:`posthog.trafficSpikeCooldownMinutes`,title:`Spike cooldown (minutes)`,description:`Cooldown for new traffic spikes. Escalation and recovery alerts bypass it. Zero removes the time delay; repeated active-spike alerts are still suppressed.`,control:`number`,integer:!1,step:`any`,range:`POSTHOG_TRAFFIC_COOLDOWN_RANGE`,keywords:[`silence`,`delay`],defaultValue:360},{id:`posthog-traffic-baseline`,path:`posthog.trafficSpikeBaselineDays`,title:`Baseline window (days)`,description:`Historical window used to calculate normal hourly traffic.`,control:`number`,range:`POSTHOG_TRAFFIC_BASELINE_RANGE`,keywords:[`history`,`analytics`],defaultValue:7},{id:`posthog-auto-fix`,path:`posthog.autoFix`,title:`Attempt fixes for major issues`,description:`Allow an isolated agent to fix an issue, push a branch and open a pull request.`,control:`toggle`,keywords:[`automatic`,`pull request`],danger:!0,warning:`Enabling this control lets PostHog fixes commit, push and open pull requests automatically.`,defaultValue:!1}]},{id:`lanes-team-review`,level:`lanes`,title:`Team review`,description:`Draft reviews of teammates' pull requests for you to post from the Reviews tab.`,settings:[{id:`team-review-enabled`,path:`teamReview.enabled`,title:`Enable team review`,description:`Poll open pull requests from the team and draft a review of each one. Nothing is posted until you choose Approve or Comment.`,control:`toggle`,keywords:[`pull requests`,`github`],defaultValue:!1},{id:`github-teams`,path:`github.teams`,title:`GitHub teams`,description:`Teams to search for review requests and members, one org/slug per entry. Leave empty to use the organization and team below.`,control:`list`,keywords:[`github`,`teams`,`review requests`],defaultValue:[],listPlaceholder:`org/team-slug`,listEmptyText:`No GitHub teams configured.`},{id:`team-review-org`,path:`teamReview.org`,title:`GitHub organization`,description:`Organization login that owns the team, for example PostHog.`,control:`text`,keywords:[`github`,`owner`],defaultValue:``},{id:`team-review-team`,path:`teamReview.team`,title:`GitHub team`,description:`Team slug whose members and review requests are polled.`,control:`text`,keywords:[`github`,`slug`],defaultValue:``},{id:`team-review-re-review-after-hours`,path:`teamReview.reReviewAfterHours`,title:`Re-review after (hours)`,description:`When a reviewed PR has a new head, review it again after this many hours since its last review. Queue review runs it at any time.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`review`,`delay`],defaultValue:24,integer:!1,step:.5},{id:`team-review-skip-idle-after-days`,path:`teamReview.skipIdleAfterDays`,title:`Skip PRs idle for (days)`,description:`Leave pull requests without GitHub activity for this long out of automatic review.`,control:`number`,range:`POSTHOG_INTERVAL_RANGE`,keywords:[`idle`,`activity`],defaultValue:14,integer:!1,step:.5},{id:`team-review-skill`,path:`teamReview.skill`,title:`Review skill`,description:`Name of a Claude Code skill installed for the review agent, for example your own PR review skill. Leave empty to let the agent review with whatever skills it has.`,control:`text`,keywords:[`skill`,`claude code`,`pr review`],defaultValue:``},{id:`team-review-auto-rebase-my-prs`,path:`teamReview.autoRebaseMyPrs`,title:`Keep my pull requests rebased`,description:`On each poll, rebase your open, non-draft pull requests that are behind their base branch. A pull request with conflicts or checks still running is left alone, and a failed rebase is not retried until you push again.`,control:`toggle`,keywords:[`rebase`,`update branch`,`behind`,`my prs`],danger:!0,warning:`Enabling this control rewrites your pull request branches on GitHub. Pull before you push from a local checkout of one.`,defaultValue:!1},{id:`team-review-keep-mergeable-enabled`,path:`teamReview.keepMergeableEnabled`,title:`Keep mergeable`,description:`Offer Keep mergeable on your pull requests: a sandboxed agent repairs conflicts and failing checks and pushes the repair. Off hides the control and starts no repair; the pull requests you chose stay chosen for when you turn it back on.`,control:`toggle`,keywords:[`repair`,`conflicts`,`my prs`],defaultValue:!0},{id:`team-review-keep-mergeable-timeout`,path:`teamReview.keepMergeableTimeoutMinutes`,title:`Keep mergeable deadline (minutes)`,description:`Longest a Keep mergeable repair session may run before it is stopped and nothing is pushed.`,control:`number`,range:`KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE`,keywords:[`timeout`,`repair`],defaultValue:30},{id:`team-review-merge-queue-enabled`,path:`teamReview.mergeQueueEnabled`,title:`Merge when ready`,description:`Offer Merge when ready on your pull requests: queued pull requests are rebased when behind and merged once ready, one per repository per poll. Off hides the control and merges nothing; the queue is kept for when you turn it back on.`,control:`toggle`,keywords:[`merge queue`,`auto merge`,`my prs`],defaultValue:!0}]},{id:`lanes-benchmarks`,level:`lanes`,title:`Benchmarks`,description:`Compare agent setups on frozen cases from the suites in the benchmarks folder of the Glimmervoid home.`,settings:[{id:`benchmarks-enabled`,path:`benchmarks.enabled`,title:`Enable benchmarks`,description:`Show the Bench tab. Nothing runs until you choose Mine or Run there.`,control:`toggle`,keywords:[`eval`,`arms`,`recall`,`compare`],defaultValue:!1}]},{id:`lanes-factory`,level:`lanes`,title:`Factory`,description:`Read Coherence reports from repositories whose integration branch holds a coherence.config.json and show their status in the Factory tab.`,settings:[{id:`factory-enabled`,path:`factory.enabled`,title:`Enable the factory`,description:`Enable Coherence status polling and show the Factory tab. Off by default.`,control:`toggle`,keywords:[`orchestrator`,`intents`,`queue`,`coherence`,`guardrails`],defaultValue:!1},{id:`factory-max-risk`,path:`factory.maxRisk`,title:`Worker risk ceiling`,description:`Highest risk admitted for a ticket.`,control:`select`,defaultValue:`medium`,options:[`low`,`medium`,`high`,`critical`].map(e=>({value:e,label:e})),keywords:[`risk`,`admission`]},{id:`factory-max-live-workers`,path:`factory.maxLiveWorkers`,title:`Live worker cap`,description:`Most live workers per factory project.`,control:`number`,range:`FACTORY_MAX_LIVE_WORKERS_RANGE`,defaultValue:2,keywords:[`workers`,`parallel`]},{id:`factory-checks`,path:`factory.checks`,title:`Worker checks`,description:`Commands glimmervoid runs before merging worker commits.`,control:`list`,defaultValue:[`npm run typecheck`,`npm run lint`,`npm test`],keywords:[`tests`,`checks`]},{id:`factory-protected-paths`,path:`factory.protectedPaths`,title:`Protected paths`,description:`Repo-relative files, directory prefixes ending in /, or **/NAME basenames workers cannot change.`,control:`list`,defaultValue:[`coherence.config.json`,`.coherence/`,`package.json`,`package-lock.json`,`**/AGENTS.md`,`**/CLAUDE.md`,`**/CLAUDE.local.md`,`.claude/`,`.github/`],keywords:[`fence`,`scope`]},{id:`factory-reviewer-model`,path:`factory.reviewerModel`,title:`Reviewer model`,description:`Claude model for independent worker review. Blank uses the CLI default.`,control:`text`,defaultValue:null,nullable:!0,keywords:[`claude`,`review`]},{id:`factory-daily-budget`,path:`factory.dailyBudgetUsd`,title:`Factory daily budget (USD)`,description:`Factory lane spend ceiling. Blank means no ceiling. Needs usage tracking: with it off, dispatch refuses.`,control:`number`,range:`NON_NEGATIVE_NUMBER_RANGE`,integer:!1,nullable:!0,step:.01,defaultValue:null,keywords:[`spend`,`budget`]},{id:`factory-verifier-model`,path:`factory.verifierModel`,title:`Verifier model`,description:`Claude model for independent intent verification. Blank uses the CLI default.`,control:`text`,nullable:!0,defaultValue:null,keywords:[`claude`,`verification`]},{id:`factory-mirror-harness-runs`,path:`factory.mirrorHarnessRuns`,title:`Mirror harness runs`,description:`Show the latest factory harness run as a read-only project in the Factory tab while it runs and for a day after. Needs factory.enabled on; leave it off on a harness instance.`,control:`toggle`,defaultValue:!1,keywords:[`harness`,`test`,`read-only`]}]},{id:`lanes-knowledge-graph`,level:`lanes`,title:`Knowledge graph (experimental)`,description:`A typed local graph of projects, tasks, notes, references and questions, driven from the glimmervoid kg command. Its SQLite database defaults to the Glimmervoid home; --db selects another path.`,settings:[{id:`knowledge-graph-enabled`,path:`knowledgeGraph.enabled`,title:`Enable the knowledge graph`,description:`Allow the glimmervoid kg command. It reads Coherence ledgers to report where your tasks and the agents' tickets disagree, without modifying those ledgers. Graph writes go to the selected SQLite database, which can be inside a repository when --db names that path. Off by default.`,control:`toggle`,keywords:[`experimental`,`kg`,`tasks`,`notes`,`references`,`coherence`],defaultValue:!1}]},{id:`lanes-workflows`,level:`lanes`,title:`Workflows`,description:`Rules that act on pull request events in the repositories you choose.`,settings:[{id:`workflows-enabled`,path:`workflows.enabled`,title:`Run workflows`,description:`Poll the repositories your enabled rules watch and run their actions. Off stops polling and every action, whatever each rule says.`,control:`toggle`,keywords:[`pull requests`,`automation`,`master switch`],defaultValue:!0},{id:`workflows-max-concurrent-sessions`,path:`workflows.maxConcurrentSessions`,title:`Concurrent agent sessions`,description:`Most workflow agent sessions running at once. Up to twenty later spawns wait for a free slot; additional spawns are dropped and logged.`,control:`number`,range:`WORKFLOWS_MAX_CONCURRENT_SESSIONS_RANGE`,keywords:[`parallel`,`spawn`],defaultValue:2},{id:`workflows-max-actions-per-poll`,path:`workflows.maxActionsPerPoll`,title:`Actions per poll`,description:`Most actions run in one poll. The rest are dropped and logged.`,control:`number`,range:`WORKFLOWS_MAX_ACTIONS_PER_POLL_RANGE`,keywords:[`cap`,`rate limit`],defaultValue:20},{id:`workflows-rules`,path:`workflows`,title:`Workflow rules`,description:`Each rule watches repositories for one pull request event (opened, checks-failed, review-requested, approved, commented or merged), narrows it by author, labels, base branch, your own pull requests or a review request to your team, and then notifies you, labels or comments on the pull request, or starts a sandboxed agent session that pushes nothing. Rules start disabled. Turn each rule on or off here; everything else about a rule is set in config.json.`,control:`readonly`,keywords:[`pull requests`,`automation`,`github`,`rules`],fileOnly:!0,status:`workflows`}]},{id:`machine-guardrails`,level:`machine`,title:`Session guardrails`,description:`Claude Code sessions on Linux and macOS write anywhere this account can, except credentials, Glimmervoid's own state and the blocked folders below. Changes apply to sessions started after the change.`,settings:[{id:`guardrails-unguarded-repos`,path:`guardrails.unguardedRepos`,title:`Unguarded repositories`,description:`Folders whose sessions run without guardrails. A session started in one of these folders, or below it, is not guarded. Applies to sessions created after the change.`,control:`list`,keywords:[`guardrails`,`opt out`,`dotfiles`],danger:!0,warning:`A session without guardrails can read credentials and write anywhere this account can.`,defaultValue:[]},{id:`guardrails-blocked-paths`,path:`guardrails.blockedPaths`,title:`Blocked folders`,description:`Extra folders and files a guarded session cannot write, on top of credentials and Glimmervoid's own state. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`block`,`protect`],defaultValue:[]},{id:`guardrails-unreadable-paths`,path:`guardrails.unreadablePaths`,title:`Unreadable folders`,description:`Extra folders and files a guarded session cannot read, on top of the built-in credential list. A leading ~ means the home folder.`,control:`list`,keywords:[`guardrails`,`secrets`,`credentials`],defaultValue:[]}]},{id:`lanes-unattended`,level:`lanes`,title:`Unattended actions`,description:`Controls that let automated work change repositories or install executable tooling.`,settings:[{id:`skip-permissions-by-default`,path:`skipPermissionsByDefault`,title:`Skip permission prompts by default`,description:`Start sessions whose project sets no permission choice with the agent CLI permission bypass flag.`,control:`toggle`,keywords:[`permissions`,`yolo`,`dangerously`],danger:!0,warning:`Enabling this control lets agents edit files and run shell commands without asking, and restarts running sessions that inherit it.`,defaultValue:!1},{id:`sane-yolo`,path:`saneYolo`,title:`Sane YOLO`,description:`Block catastrophic commands in sessions that skip permission prompts when the cc-safety-net executable is available and trusted hooks are installed. Missing or untrusted hooks leave a session unprotected. Applies to sessions created after the change.`,control:`toggle`,keywords:[`permissions`,`yolo`,`safety`],defaultValue:!0},{id:`branch-gc-delete-unmerged`,path:`branchGc.deleteUnmerged`,title:`Delete unmerged branches`,description:`Also delete stale remote branches with no merge proof. Off keeps every unmerged branch.`,control:`toggle`,keywords:[`git`,`cleanup`,`orphan`],danger:!0,warning:`Enabling this control lets branch cleanup delete stale remote branches without merge proof.`,defaultValue:!1},{id:`post-turn-checks-mode`,path:`postTurnChecks.mode`,title:`Post-turn checks mode`,description:`Default mode for post-turn checks. Project and individual rule modes override it, so Report can still allow file fixes.`,control:`select`,options:UY(IY),keywords:[`quality`,`fixes`],defaultValue:`report`},{id:`agent-api-enabled`,path:`agentApi.enabled`,title:`Agent API`,description:`Expose the per-session agent endpoint to running sessions.`,control:`toggle`,keywords:[`session`,`localhost`],danger:!0,warning:`Enabling this control lets a running session spawn sibling sessions, flag itself and read the board through a per-session token on localhost, and it applies to sessions spawned after the change.`,defaultValue:!1},{id:`rtk-compression`,path:`rtk`,title:`rtk output compression`,description:`Compress Bash output for newly spawned or restarted sessions.`,control:`toggle`,keywords:[`bash`,`tokens`],danger:!0,status:`rtk-install`,warning:`Enabling this control permits Glimmervoid to install the pinned rtk executable automatically.`,defaultValue:!1}]}]);function qY(e){return[e.repos.join(`, `),e.trigger,e.actions.map(e=>e.type).join(`, `)].join(` `)}function JY(e){if(e==null)return[`No rules. Add workflows.rules to config.json.`];let t=vY.safeParse(e);return t.success?t.data.rules.length===0?[`No rules. Add workflows.rules to config.json.`]:t.data.rules.map(e=>[e.name,e.enabled?`enabled`:`disabled`,qY(e)].join(` `)):[`The workflows block is invalid, so no rule runs: ${t.error.issues[0]?.message??`unknown problem`}`]}function YY(e){let t=vY.safeParse(e??{});return t.success?t.data.rules.map(e=>({id:e.id,name:e.name,isEnabled:e.enabled,summary:qY(e)})):[]}function XY(e){let t=e.workflows;return typeof t!=`object`||!t||Array.isArray(t)?e:{...e,workflows:Object.fromEntries(Object.entries(t).filter(([e])=>e!==`rules`))}}function ZY({checked:e=[],stored:t=[],rendered:n=[]}={}){let r=new Set(n),i=[...e];for(let e of t)typeof e==`string`&&e.trim()&&(r.has(e)||i.includes(e)||i.push(e));return i}function QY(e,t){let n=new Set(e.map(e=>e.id)),r=[...new Set(t)].filter(e=>!n.has(e));return[...e,...r.map(e=>({id:e,name:`Unavailable project (${e})`}))]}function $Y(e,t,n){return n?e.some(e=>e.toLowerCase()===t.toLowerCase()):e.includes(t)}var eX=new WeakMap,tX=`Configured`,nX=`•`.repeat(12);function rX(e,t){let n=t.secretSources;if(!n||typeof n!=`object`)return null;let r=n[e.path];return typeof r==`string`?r:null}function iX(e){let t=String(e??``).trim().toLowerCase();if(!t||t===`all`)return`all`;if(t===`none`)return[];let n=t.split(`,`).map(e=>e.trim());return n.every(e=>/^\d+$/.test(e)&&Number.isSafeInteger(Number(e))&&Number(e)>0)?n.map(Number):null}function aX(e){let t=Number(e[`visions.dispatch.maxPerHour`]),n=Number(e[`visions.dispatch.activityMaxPerHour`]);return!Number.isSafeInteger(t)||t<1||!Number.isSafeInteger(n)||n<0?``:`Effective activity limit: ${Math.min(n,t-1)} per hour. One slot is reserved for edit reviews.`}function oX(e){let t=e.rtkInstall;return t?.status===`installing`?`No rtk binary found. Glimmervoid is installing it into ~/.glimmervoid/bin now.`:e.rtkInstallSupported===!1?`No rtk binary found. Automatic installation is unavailable on this server platform; install a compatible binary manually.`:t?.status===`failed`?`No rtk binary found. The last install attempt failed: ${t.reason||`unknown reason`}. A save can retry after the ten-minute failure cooldown; saves during the cooldown skip installation.`:`No rtk binary found. Saving requests installation into ~/.glimmervoid/bin on supported server platforms, subject to installer eligibility.`}function sX(e){return e.control===`password`}function cX(e){return`${e.path}${tX}`}function lX(e){return Array.isArray(e)?e.map(lX):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,lX(t)]))}function uX(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function dX(e,t){let n=t.split(`.`),r=e;for(let e of n.slice(0,-1)){if(!r||typeof r!=`object`)return;r=r[e]}r&&typeof r==`object`&&delete r[n.at(-1)]}function fX(e,t,n){let r=t.split(`.`),i=e;for(let e of r.slice(0,-1))(!i[e]||typeof i[e]!=`object`||Array.isArray(i[e]))&&(i[e]={}),i=i[e];i[r.at(-1)]=lX(n)}function pX(e){return e.flatMap(e=>e.settings||[])}function mX(e){return e.fileOnly||e.control===`readonly`}function hX(e){return String(e||``).toLowerCase().match(/[a-z0-9]+/g)||[]}var gX=3,_X=2,vX=1,yX=3;function bX(e,t){return e===t?gX:e.startsWith(t)?_X:t.length>=yX&&e.includes(t)?vX:0}function xX(e,t,n){let r=0;for(let n of t){let t=Math.max(0,...e.map(e=>bX(e,n)));if(t===0)return 0;r+=t}return r*n}function SX(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>SX(e,t[n]));if(!e||!t||typeof e!=`object`||typeof t!=`object`)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&SX(e[n],t[n]))}function CX(e,t){return e.valueKind===`posthog-projects`?Array.isArray(t)?t.length===0?`none`:t.join(`, `):t??`all`:lX(t)}function wX(e,t){if(e.control===`number`){if(e.nullable&&(t==null||String(t).trim()===``))return null;let n=Number(t);return e.zeroIsNull&&n<=0?null:n}if(e.valueKind===`posthog-projects`)return iX(t);if(e.control===`text`||e.control===`password`){let n=String(t??``).trim();return e.nullable&&!n?null:n}return lX(t)}function TX(e){return eX.get(e)||null}function EX(e,t={}){let n={};for(let r of pX(e)){if(mX(r))continue;if(r.path.startsWith(`pref:`)){let e=r.path.slice(5),i=t.prefs?.[e]??t[r.path];n[r.path]=CX(r,i??r.defaultValue);continue}if(sX(r)){let e=uX(t,cX(r))===!0;n[r.path]=e?nX:``;continue}let e=uX(t,r.path);n[r.path]=CX(r,e??r.defaultValue)}return eX.set(n,lX(t)),n}function DX(e,t,n,r,i={}){let{rehydrateSectionIds:a=[]}=i,o=EX(e,t),s=EX(e,t);if(!n||!r)return{original:o,edited:s};let c=new Set(a);for(let t of e)if(!c.has(t.id)&&t.settings.some(e=>!e.path.startsWith(`pref:`)&&!SX(n[e.path],r[e.path])))for(let e of t.settings)o[e.path]=lX(n[e.path]),s[e.path]=lX(r[e.path]);return{original:o,edited:s}}function OX(e,t,n){let r=pX(e).filter(e=>mX(e)||e.path.startsWith(`pref:`)||rX(e,TX(t)||{})||sX(e)&&n[e.path]===nX?!1:!SX(t[e.path],n[e.path]));if(r.length===0)return{};let i=TX(t)||{},a=(Array.isArray(i.projectChoices)?i.projectChoices:[]).map(e=>e.id).filter(e=>typeof e==`string`),o={},s=new Set;for(let e of r){let[r]=e.path.split(`.`);if(!e.path.includes(`.`)){o[r]=wX(e,n[e.path]);continue}if(!s.has(r)){let e=i[r];o[r]=e&&typeof e==`object`&&!Array.isArray(e)?lX(e):{},s.add(r)}let c=wX(e,n[e.path]);if(e.control===`projects`){let n=t[e.path];c=ZY({checked:Array.isArray(c)?c:[],stored:Array.isArray(n)?n:[],rendered:QY(a.map(e=>({id:e,name:e})),Array.isArray(n)?n:[]).map(e=>e.id)})}fX(o,e.path,c)}for(let t of pX(e))sX(t)&&dX(o,cX(t));return delete o.secretSources,o}function kX(e,t){let n=t.integer===!1?`number`:`whole number`;return e.exclusiveMin?`Must be a positive ${n}.`:e.max==null?`Must be a ${n} of at least ${e.min}.`:`Must be a ${n} between ${e.min} and ${e.max}.`}function AX(e,t,n){if(e.nullable&&(t==null||String(t).trim()===``))return null;let r=Number(t),i=n[e.range??``];return i?!Number.isFinite(r)||e.integer!==!1&&!Number.isSafeInteger(r)?kX(i,e):i.exclusiveMin&&r<=i.min?e.zeroIsNull&&r<=0?null:kX(i,e):!i.exclusiveMin&&r<i.min||i.max!=null&&r>i.max?kX(i,e):null:`Allowed range is unavailable.`}function jX(e){return iX(e)===null?`Must be "all", "none", or a comma-separated list of positive safe integer ids without empty entries.`:null}function MX(e,t,n={}){let r={};for(let i of pX(e)){if(mX(i))continue;let e=null;i.control===`number`&&(e=AX(i,t[i.path],n)),i.valueKind===`posthog-projects`&&(e=jX(t[i.path])),i.control===`select`&&!i.options.some(e=>e.value===t[i.path])&&(e=`Choose one of the available options.`),e&&(r[i.id]=e)}return NX(pX(e),t,r),r}function NX(e,t,n){for(let r of e){let i=e.find(e=>e.id===r.maximumSettingId);if(!i||n[r.id]||n[i.id])continue;let a=Number(t[r.path]),o=Number(t[i.path]);a>o&&(n[r.id]=`Minimum must not exceed the maximum (${o}).`,n[i.id]=`Maximum must not be below the minimum (${a}).`)}}function PX(e,t){return pX(e).find(e=>e.id===t.maximumSettingId||e.maximumSettingId===t.id)}function FX(e){let t={browser:[],machine:[],lanes:[],projects:[]};for(let n of e)t[n.level]||(t[n.level]=[]),t[n.level].push(n);return t}function IX(e,t){let n=hX(t);if(n.length===0)return[];let r=[];for(let t of e){let e=hX(t.title);for(let i of t.settings||[]){let a=xX(hX(i.title),n,1e3),o=xX(hX((i.keywords||[]).join(` `)),n,100),s=xX(e,n,10),c=xX(hX(i.description),n,1),l=a+o+s+c;l!==0&&r.push({section:t,setting:i,score:l})}}return r.sort((e,t)=>t.score-e.score||e.section.title.localeCompare(t.section.title)||e.setting.title.localeCompare(t.setting.title)).slice(0,30)}function LX(e,t,n={},r={}){let i=/^#settings\/([^/]+)(?:\/([^/]+))?$/.exec(String(e||``));if(!i)return null;let a,o;try{a=decodeURIComponent(i[1]),o=i[2]?decodeURIComponent(i[2]):null}catch{return null}let s=(o?r[a]?.[o]:void 0)||n[a]||a,c=t.find(e=>e.id===s);if(!c)return null;let l=o?(c.settings||[]).find(e=>e.id===o):null;return o&&!l?null:{sectionId:s,settingId:l?.id||null,hash:`#settings/${s}${l?`/${l.id}`:``}`}}function RX(e){let t=`lanes-unattended`,n=e.find(e=>e.id===t);if(!n)return[...e];let r=e.filter(e=>e.id!==t),i=r.findLastIndex(e=>e.level===`lanes`);return r.splice(i+1,0,n),r}function zX(e,t,n){return{id:`project-${e}-${t}`,projectId:e,...n}}function BX(e){return String(e||``).replace(/\s+\(\d+\)$/,``)}function VX(e){return String(e||``).replace(/[\\/]+$/,``).split(/[\\/]/).at(-1)||``}function HX(e){return VX(e?.path)||BX(e?.name)||e?.id}function UX(e=[]){return e.filter(e=>typeof e?.id==`string`&&e.id).map(e=>({id:`project-${e.id}`,level:`projects`,title:HX(e),description:`Settings scoped to this configured project.`,caption:(e.recordNames?.length??0)>1?`Cards: ${e.recordNames?.join(`, `)}`:``,project:e,settings:[zX(e.id,`agent`,{path:`project:${e.id}:agent`,title:`Agent`,description:`Agent configured for this project.`,control:`readonly`,keywords:[`cli`,`runtime`],value:e.agent||`Not available in the current dashboard payload`}),zX(e.id,`permission-mode`,{path:`project:${e.id}:permission-mode`,title:`Default permission mode`,description:`Permission mode used for newly spawned sessions.`,control:`readonly`,keywords:[`approval`,`sandbox`],value:e.permissionMode||`Not available in the current dashboard payload`}),zX(e.id,`codex-hook-trust`,{path:`projects.${e.id}.codexBypassHookTrust`,title:`Codex hook trust bypass`,description:`Configured only on this project record.`,control:`readonly`,keywords:[`hooks`,`codex`],fileOnly:!0})]}))}function WX(e=[]){let t=new Set;return e.filter(e=>typeof e?.id!=`string`||!e.id?!1:!e.path||!t.has(e.path)&&(t.add(e.path),!0))}function GX(e=[],t=[]){let n=new Map(t.filter(e=>typeof e?.id==`string`&&e.id).map(e=>[e.id,e]));return e.map(e=>{let r=n.get(e?.id),i=e?.path||r?.path,a=t.filter(e=>i&&e?.path===i).map(e=>e?.name).filter(e=>typeof e==`string`&&e!==``);return{...r,...e,path:i,recordNames:[...new Set(a)]}})}function KX(e,t){return e.danger===!0&&!!e.warning&&t===!0}function qX(e,t){return e.find(e=>e.id===t)||e[0]||null}var JX={ready:{label:`Ready`,meaning:`Ready to merge, or nothing left for you to do.`},passed:{label:`Passed`,meaning:`Checks passing, approved, or nothing open.`},failed:{label:`Failed`,meaning:`Checks failing, an automated review failed, or an auto-rebase failed.`},conflict:{label:`Conflict`,meaning:`Merge conflicts with the base branch.`},"your-turn":{label:`Your turn`,meaning:`Waiting on you: a review to give or a thread to answer.`},"changes-requested":{label:`Changes`,meaning:`A reviewer requested changes.`},thread:{label:`Threads`,meaning:`Unresolved review threads or comments.`},behind:{label:`Behind`,meaning:`The branch is behind its base.`},stale:{label:`Out of date`,meaning:`New commits landed since the automated review.`},fork:{label:`Fork`,meaning:`Opened from a fork, so it is reviewed by hand.`},running:{label:`Running`,meaning:`Checks or an automated review in progress.`},reviewer:{label:`Reviewer`,meaning:`Waiting on a reviewer.`},queued:{label:`Queued`,meaning:`Waiting for an automated review slot.`},draft:{label:`Draft`,meaning:`Still a draft.`},merged:{label:`Merged`,meaning:`Merged.`},discarded:{label:`Discarded`,meaning:`Review discarded or dismissed.`},unknown:{label:`Unknown`,meaning:`GitHub has not computed this yet.`},none:{label:`None`,meaning:`Nothing applies, such as no checks or no review requested.`}},YX={merged:`M5.45 5.154A4.25 4.25 0 0 0 9.25 7.5h1.378a2.251 2.251 0 1 1 0 1.5H9.25A5.734 5.734 0 0 1 5 7.123v3.505a2.25 2.25 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.95-.218ZM4.25 13.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm8.5-4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0 .005V3.25Z`,draft:`M3.25 1A2.25 2.25 0 0 1 4 5.372v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.251 2.251 0 0 1 3.25 1Zm9.5 14a2.25 2.25 0 1 1 0-4.5 2.25 2.25 0 0 1 0 4.5ZM2.5 3.25a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0ZM3.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm9.5 0a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM14 7.5a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Zm0-4.25a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0Z`,conflict:`M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,behind:`M13.03 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.47 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018l2.97 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.97-2.97a.75.75 0 0 1 1.06 0Z`,failed:`M2.343 13.657A8 8 0 1 1 13.658 2.343 8 8 0 0 1 2.343 13.657ZM6.03 4.97a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042L6.94 8 4.97 9.97a.749.749 0 0 0 .326 1.275.749.749 0 0 0 .734-.215L8 9.06l1.97 1.97a.749.749 0 0 0 1.275-.326.749.749 0 0 0-.215-.734L9.06 8l1.97-1.97a.749.749 0 0 0-.326-1.275.749.749 0 0 0-.734.215L8 6.94Z`,running:`M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z`,passed:`M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z`,ready:`M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z`,"changes-requested":`M1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16H2.75A1.75 1.75 0 0 1 1 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177l-2.914-2.914a.25.25 0 0 0-.177-.073ZM8 3.25a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0V7h-1.5a.75.75 0 0 1 0-1.5h1.5V4A.75.75 0 0 1 8 3.25Zm-3 8a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75Z`,thread:`M1 2.75C1 1.784 1.784 1 2.75 1h10.5c.966 0 1.75.784 1.75 1.75v7.5A1.75 1.75 0 0 1 13.25 12H9.06l-2.573 2.573A1.458 1.458 0 0 1 4 13.543V12H2.75A1.75 1.75 0 0 1 1 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h4.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z`,reviewer:`M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 13H8.061l-2.574 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25v-8.5C0 1.784.784 1 1.75 1ZM1.5 2.75v8.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-8.5a.25.25 0 0 0-.25-.25H1.75a.25.25 0 0 0-.25.25Zm5.28 1.72a.75.75 0 0 1 0 1.06L5.31 7l1.47 1.47a.751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018l-2-2a.75.75 0 0 1 0-1.06l2-2a.75.75 0 0 1 1.06 0Zm2.44 0a.75.75 0 0 1 1.06 0l2 2a.75.75 0 0 1 0 1.06l-2 2a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.69 7 9.22 5.53a.75.75 0 0 1 0-1.06Z`,"your-turn":`M8 16a2 2 0 0 0 1.985-1.75c.017-.137-.097-.25-.235-.25h-3.5c-.138 0-.252.113-.235.25A2 2 0 0 0 8 16ZM3 5a5 5 0 0 1 10 0v2.947c0 .05.015.098.042.139l1.703 2.555A1.519 1.519 0 0 1 13.482 13H2.518a1.516 1.516 0 0 1-1.263-2.36l1.703-2.554A.255.255 0 0 0 3 7.947Zm5-3.5A3.5 3.5 0 0 0 4.5 5v2.947c0 .346-.102.683-.294.97l-1.703 2.556a.017.017 0 0 0-.003.01l.001.006c0 .002.002.004.004.006l.006.004.007.001h10.964l.007-.001.006-.004.004-.006.001-.007a.017.017 0 0 0-.003-.01l-1.703-2.554a1.745 1.745 0 0 1-.294-.97V5A3.5 3.5 0 0 0 8 1.5Z`,queued:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z`,fork:`M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z`,discarded:`M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm9.78-2.22-5.5 5.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l5.5-5.5a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z`,stale:`M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z`,unknown:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67c.169-.339.436-.701.849-.977C6.845 4.16 7.369 4 8 4a2.756 2.756 0 0 1 1.637.525c.503.377.863.965.863 1.725 0 .448-.115.83-.329 1.15-.205.307-.47.513-.692.662-.109.072-.22.138-.313.195l-.006.004a6.24 6.24 0 0 0-.26.16.952.952 0 0 0-.276.245.75.75 0 0 1-1.248-.832c.184-.264.42-.489.692-.661.103-.067.207-.132.313-.195l.007-.004c.1-.061.182-.11.258-.161a.969.969 0 0 0 .277-.245C8.96 6.514 9 6.427 9 6.25a.612.612 0 0 0-.262-.525A1.27 1.27 0 0 0 8 5.5c-.369 0-.595.09-.74.187a1.01 1.01 0 0 0-.34.398ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z`,none:`M2 7.75A.75.75 0 0 1 2.75 7h10a.75.75 0 0 1 0 1.5h-10A.75.75 0 0 1 2 7.75Z`};function XX(e,t){let n=WL(16,16);return n.classList.add(`pr-status-icon`),t&&(n.dataset.tone=t),n.append(UL(`path`,{d:YX[e],fill:`currentColor`})),n}var ZX=(e,t,n=!1)=>({state:e,awaitingBackgroundTasks:n,label:n?`Monitoring`:kc[e],meaning:t}),QX=Object.freeze([ZX(F.DORMANT,`Not started yet.`),ZX(F.INITIALIZING,`Setting up the worktree and launching the agent.`),ZX(F.STARTING,`The agent is booting.`),ZX(F.RUNNING,`The agent is mid-turn.`),ZX(F.RUNNING,`The turn ended but background tasks or sub-agents are still running.`,!0),ZX(F.WAITING,`Waiting on a permission prompt or your answer.`),ZX(F.IDLE,`Ready for the next prompt.`),ZX(F.COMPLETE,`Finished a turn you have not looked at yet.`),ZX(F.DONE,`The agent process ended.`),ZX(F.FAILED,`The agent failed to start or crashed.`)]);function $X(e,t){let n=V(`section`,`status-legend`),r=V(`dl`,`status-legend-rows`);return r.append(...t),n.append(V(`h2`,`status-legend-title`,e),r),n}function eZ(e,t){let n=V(`div`,`status-legend-row`);return n.append(e,V(`dd`,`status-legend-meaning`,t)),n}function tZ(){return $X(`Status colors`,QX.map(e=>{let t=V(`dt`,`status-legend-badge`),n=V(`span`,`status-legend-glyph`),r=V(`span`,`status-legend-name`);n.setAttribute(`aria-hidden`,`true`),t.append(n,r);let i=eZ(t,e.meaning);return aU(i,{glyph:n,label:r},e.state,e.awaitingBackgroundTasks),i}))}function nZ(){return $X(`Pull request icons`,Object.keys(JX).map(e=>{let t=JX[e],n=V(`dt`,`status-legend-badge`);return n.append(XX(e),V(`span`,`status-legend-name`,t.label)),eZ(n,t.meaning)}))}var rZ=2e4,Z=null,iZ=null,aZ=null,oZ=null,sZ=null,cZ=null,lZ=null,uZ=`all`,dZ=!1,fZ=null,pZ=DM,mZ=EM,hZ=TM,gZ=!1,_Z=null,vZ=`day`,yZ=new Set,bZ=AA({getAck:Ck,setAck:wk,signature:()=>xae(Z,aZ),isLooking:()=>!Ef(oZ)}),xZ=null,SZ=null,CZ=null,wZ=null,TZ=null,EZ=null,DZ=null,OZ=null,kZ=XP(()=>oZ),AZ=(e,t)=>Cf(`usage`,e,t);function jZ(e,t,n,r){let i=V(`div`,`usage-tile`);r&&r!==`ok`&&(i.dataset.tone=r);let a=V(`span`,`usage-tile-value`,t);i.append(a,V(`span`,`usage-tile-label`,e));let o=n?V(`span`,`usage-tile-sub`,n):null;return o&&i.append(o),{tile:i,valueEl:a,subEl:o}}function MZ(e){let t=Number(e);return Number.isFinite(t)?Math.min(Math.max(t,0),100):0}function NZ(e,t,n){let r=V(`div`,`usage-meter`);r.dataset.tone=String(t),r.setAttribute(`role`,`progressbar`),r.setAttribute(`aria-valuemin`,`0`),r.setAttribute(`aria-valuemax`,`100`),r.setAttribute(`aria-label`,n);let i=V(`span`,`usage-meter-fill`);return r.append(i),PZ(r,e),r}function PZ(e,t){if(!e)return;let n=MZ(t);e.setAttribute(`aria-valuenow`,String(Math.round(n)));let r=e.querySelector(`.usage-meter-fill`);r&&(r.style.width=`${n}%`)}function FZ(e,t,n,r){let i=V(`div`,`usage-table-scroll`);i.dataset.usageTable=r;let a=V(`table`,`usage-table`),o=V(`thead`),s=V(`tr`);for(let i of e){let e=V(`th`,i.numeric?`usage-num`:null);if(e.scope=`col`,!i.key){e.textContent=i.label,s.append(e);continue}let a=i.key;e.setAttribute(`aria-sort`,Fae(t,a));let o=V(`button`,`usage-sort`,i.label);o.type=`button`,o.dataset.sortKey=a,o.addEventListener(`click`,()=>{_Z={kind:`sort`,table:r,key:a},n(a)}),e.append(o),s.append(e)}o.append(s);let c=V(`tbody`);return a.append(o,c),i.append(a),{wrap:i,body:c}}function IZ(e,t){for(let n of t){let t=V(`td`,n.numeric?`usage-num`:n.className||null,n.node?null:n.text);n.node&&t.append(n.node),n.title&&(t.title=n.title),n.span&&(t.colSpan=n.span),e.append(t)}}function LZ(e){let t=V(`div`,`usage-share`);if(!Number.isFinite(e))return t.append(V(`span`,`usage-share-text`,jj(e))),t;let n=V(`span`,`usage-share-bar`),r=V(`span`,`usage-share-fill`);return r.style.width=`${MZ(e)}%`,n.append(r),t.append(n,V(`span`,`usage-share-text`,jj(e))),t}function RZ(){if(!xZ?.isConnected)return;let e=Number(Z?.ts);xZ.textContent=Number.isFinite(e)&&e>0?`Report ${JP(e)}`:``}function zZ(){if(!SZ?.isConnected)return;let e=Number(iZ?.ts);SZ.textContent=Number.isFinite(e)&&e>0?`Sessions ${JP(e)}`:``}function BZ(){let e=zj(Z?.activeBlock);e&&(wZ?.isConnected&&(wZ.textContent=`${e.pct}%`),TZ?.isConnected&&(TZ.textContent=`${Rj(e.remainingMinutes)} left`),EZ?.isConnected&&PZ(EZ,e.pct))}function VZ(e){let t=Cj.find(t=>t.value===e);return t?t.days:null}function HZ(){let e=V(`div`,`usage-controls`),t=V(`label`,`usage-control`);t.append(V(`span`,`usage-control-label`,`Range`));let n=V(`select`,`usage-select`);for(let e of Cj){let t=V(`option`,null,e.label);t.value=e.value,n.append(t)}n.value=uZ,n.addEventListener(`change`,()=>{uZ=n.value,TQ()}),t.append(n);let r=V(`button`,`usage-refresh`,`Refresh`);r.type=`button`,r.title=`Re-read every transcript from the start`,r.addEventListener(`click`,()=>TQ({force:!0}));let i=V(`span`,`usage-refresh-status`,``);return DZ=r,OZ=i,xQ(),e.append(t,r,i),e}function UZ(){let e=AZ(`Usage`,Tie(Z?.daily||[]));e.append(HZ()),xZ=V(`p`,`usage-meta`,``),e.append(xZ),RZ(),kZ.onTick(RZ);let t=jae(Z);t&&e.append(V(`p`,`usage-warning`,t));let n=Oae(Z?.pricing?.missing);return n&&e.append(V(`p`,`usage-warning`,n)),e}function WZ(){if(!yae(aZ))return null;let e=uM(Z?.totals),t=AZ(`Plan limits`,e?`${pM(`official`)}, ${e}`:pM(`official`)),n=Tae(aZ?.ts);if(n){let e=V(`p`,`usage-meta`,n);e.dataset.tone=`warn`,t.append(e)}let r=V(`div`,`usage-plan`);for(let e of dM){let t=fM(aZ,e.key);t&&r.append(GZ(e,t))}return t.append(r),CZ=V(`p`,`usage-meta`,``),t.append(CZ),KZ(),kZ.onTick(KZ),t}function GZ(e,t){let n=V(`div`,`usage-plan-window`),r=V(`div`,`usage-plan-head`);r.append(V(`span`,`usage-plan-label`,e.label)),r.append(V(`span`,`usage-plan-used`,Sae(t)));let i=V(`span`,`usage-plan-reset`,``);r.append(i),n.append(r),Number.isFinite(t.pct)&&n.append(NZ(t.pct,Bj(t.pct),`${e.label} plan limit used`));let a=()=>{i.isConnected&&(i.textContent=Cae(t.resetsAtMs))};return a(),kZ.onTick(a),n}function KZ(){if(!CZ?.isConnected)return;let e=hM(aZ?.ts);CZ.textContent=e?`Plan ${e}`:``}function qZ(){let e=Vie(Z,aZ),t=JZ();if(e.length===0&&!t)return null;let n=AZ(`Glimmervoid overhead`,e.length>0?Iie:null);if(e.length>0){let t=V(`div`,`usage-tiles`);for(let n of e){let e=[Hie(n),kj(n.costUSD)].filter(Boolean).join(`, `);t.append(jZ(`${n.label}, share of Claude use`,jj(n.sharePct),e).tile)}n.append(t);for(let t of e){let e=Uie(t);e&&n.append(V(`p`,`usage-meta`,`${t.label}: ${e}`))}}return t&&(n.append(V(`p`,`usage-meta`,`Selected range by lane. ${Fie}`)),n.append(t)),n}function JZ(){if(!Lie(Z))return null;let e=Kj(Z),t=e.reduce((e,t)=>e+(typeof t.costUSD==`number`&&Number.isFinite(t.costUSD)?t.costUSD:0),0),{wrap:n,body:r}=FZ([{label:`Lane`},{label:`Cost`,numeric:!0},{label:`Tokens`,numeric:!0},{label:`Sessions`,numeric:!0},{label:`Share`,numeric:!0}],null,()=>{},`lane`);for(let n of e){let e=V(`tr`,`usage-row`);n.lane===`other`&&(e.dataset.lane=`other`),IZ(e,[{text:Gj(n.lane),className:`usage-lane-cell`},{text:kj(n.costUSD),numeric:!0},{text:Aj(n.tokens),numeric:!0},{text:Yj(n.sessions),numeric:!0},{node:LZ(Pj(n.costUSD,t)),className:`usage-share-cell`}]),r.append(e)}return n}function YZ(){let e=Z?.activeBlock,t=Z?.blockHours,n=typeof t==`number`&&Number.isFinite(t)?t:5,r=uM(Z?.totals),i=AZ(`Current block`,r?`${n}h window, ${r}`:`${n}h window`);if(!e){i.append(V(`p`,`usage-empty`,`No active block.`));let e=XZ();return e&&i.append(e),i}let a=mM(Z,aZ),o=V(`div`,`usage-tiles`);o.append(jZ(`block tokens`,Aj(e.tokens??0),kj(e.costUSD??0),a).tile);for(let t of kie(e.burn))o.append(jZ(t.label,t.value,t.sub,a).tile);let s=zj(e);if(s){let e=jZ(`elapsed`,`${s.pct}%`,`${Rj(s.remainingMinutes)} left`);wZ=e.valueEl,TZ=e.subEl,o.append(e.tile)}i.append(o),s&&(EZ=NZ(s.pct,`ok`,`Elapsed share of the current block window`),i.append(EZ),kZ.onTick(BZ));let c=Aie(e.projection);if(c){let e=V(`p`,`usage-projection`,c);e.dataset.tone=a,i.append(e)}let l=XZ();l&&i.append(l);let u=jie(Z?.tokenLimit);if(!u)return i;let d=Hj(Z?.tokenLimit),f=mM(Z);i.append(NZ(d,f,`Share of the largest completed block seen, estimated`));let p=V(`p`,`usage-meta`,u);p.dataset.tone=f,i.append(p),i.append(V(`p`,`usage-provenance`,pM(`estimated`)));let m=Mie(e.projection,Z?.tokenLimit);if(m){let e=V(`p`,`usage-meta`,m);e.dataset.tone=f,i.append(e)}return i}function XZ(){let e=Z?.anomaly;if(!mae(e))return null;let t=V(`p`,`usage-meta`,fae(e));return t.dataset.tone=pae(e),t}function ZZ(){let e=Vae(Z?.blocks);if(e.length===0)return null;let t=uM(Z?.totals),n=AZ(`Recent blocks`,t?`newest first, ${t}`:`newest first`),r=V(`div`,`usage-blocks`),i=e.reduce((e,t)=>Math.max(e,t.tokens),0);for(let t of e){let e=V(`div`,`usage-block`);t.isActive&&(e.dataset.active=`true`),e.append(V(`span`,`usage-block-label`,Oie(t.startTs)));let n=V(`span`,`usage-block-bar`),a=V(`span`,`usage-block-fill`);a.style.width=`${MZ(Pj(t.tokens,i)??0)}%`,n.append(a),e.append(n),e.append(V(`span`,`usage-block-value`,`${Aj(t.tokens)} ${kj(t.costUSD)}`)),r.append(e)}return n.append(r),n}function QZ(){let e=Z?.totals||{},t=Bae(Z?.daily,Ij(Z)),n=AZ(`Totals`,[xie,Z?.tz?`TZ ${Z.tz}`:``].filter(Boolean).join(` `)),r=mM(Z,aZ),i=V(`div`,`usage-tiles`);i.append(jZ(`today`,Aj(t?.tokens??0),kj(t?.costUSD??0),r).tile),i.append(jZ(`range total`,Aj(e.tokens??0),kj(e.costUSD??0)).tile);let a=Wie(Z);a&&i.append(jZ(a.label,a.value,a.sub).tile),n.append(i);let o=$Z(e);o&&n.append(o);let s=lM(e)?gae(e):[];if(s.length>0){let e=V(`div`,`usage-tiles usage-vendor-tiles`);for(let t of s)e.append(jZ(t.label,Aj(t.tokens),kj(t.costUSD)).tile);n.append(e)}return SZ=V(`p`,`usage-meta`,``),n.append(SZ),zZ(),kZ.onTick(zZ),n}function $Z(e){let t=Pie(e);if(t.length===0)return null;let n=V(`div`,`usage-compo`),r=V(`div`,`usage-compo-bar`);r.setAttribute(`aria-hidden`,`true`);for(let e of t){if(e.pct<=0)continue;let t=V(`span`,`usage-compo-fill`);t.dataset.part=e.key,t.style.width=`${e.pct}%`,t.title=e.title,r.append(t)}let i=V(`div`,`usage-compo-legend`);for(let e of t){let t=V(`span`,`usage-compo-item`),n=V(`span`,`usage-compo-swatch`);n.dataset.part=e.key,t.append(n,V(`span`,`usage-compo-label`,e.label),V(`span`,`usage-compo-value`,e.value)),i.append(t)}return n.append(r,i),n}function eQ(){let e=Z?.savings;if(!Gie(e))return null;let t=AZ(`Savings`,``),n=V(`div`,`usage-tiles`),r=Kie(e);r&&n.append(jZ(`rtk compression`,r.value,r.sub).tile);let i=qie(e);return i&&n.append(jZ(`Prompt cache`,i.value,i.sub).tile),t.append(n),t}function tQ(){let e=Qj(Z);if(e.length===0)return null;let t=AZ(`Budgets`,`your own ceilings`),n=V(`div`,`usage-budgets`),r=pW(`machine-usage`,`usage-daily-budget`,`Budget settings`);n.appendChild(r);for(let t of e){let e=V(`div`,`usage-budget`),r=V(`div`,`usage-budget-head`);r.append(V(`span`,`usage-budget-label`,$j(t.scope))),r.append(V(`span`,`usage-budget-value`,Jie(t))),r.append(V(`span`,`usage-budget-pct`,jj(eM(t)))),e.append(r),e.append(NZ(eM(t),t.tone,Yie(t))),n.append(e)}return t.append(n),t}function nQ(){let e=Z?.daily||[],t=vZ,n=zae(nae(e,t),pZ),r=tM.find(e=>e.value===t)?.label||`Day`,i=AZ(`Over time`,[aae(e)].filter(Boolean).join(`, `));if(i.append(rQ()),n.length===0)return i.append(V(`p`,`usage-empty`,`No usage.`)),i;let a=aQ(e);a&&i.append(a);let{wrap:o,body:s}=FZ([{label:r,key:`day`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Models`}],pZ,e=>{pZ=wM(pZ,e),mQ()},`day`);for(let e of n){let n=String(e.day??``),r=V(`tr`,`usage-row`);e.source===`history`&&(r.dataset.source=`history`);let i=OM(e.models),a=`${t}:${n}`,o=oQ(a,i.length);IZ(r,[{node:iQ(e,t),title:n},{text:Aj(e.tokens),numeric:!0},{text:kj(e.costUSD),numeric:!0},{node:o,className:`usage-toggle-cell`}]),s.append(r),i.length!==0&&yZ.has(a)&&s.append(sQ(i))}return i.append(o),i}function rQ(){let e=V(`div`,`usage-period`);e.setAttribute(`role`,`group`),e.setAttribute(`aria-label`,`Period`);for(let t of tM){let n=V(`button`,`usage-period-button`,t.label);n.type=`button`,n.dataset.periodView=t.value,n.setAttribute(`aria-pressed`,t.value===vZ?`true`:`false`),n.addEventListener(`click`,()=>{vZ!==t.value&&(vZ=t.value,_Z={kind:`period`,view:t.value},mQ())}),e.append(n)}return e}function iQ(e,t){let n=V(`span`,`usage-period-cell`);return n.append(V(`span`,null,iae(e.day,t))),e.source===`history`&&n.append(V(`span`,`usage-history-tag`,`history`)),n}function aQ(e){let{cells:t,max:n}=cae(e,{today:Ij(Z)});if(t.length===0||n<=0)return null;let r=V(`div`,`usage-heatmap-scroll`),i=V(`div`,`usage-heatmap`);i.setAttribute(`role`,`img`),i.setAttribute(`aria-label`,`Daily usage for the trailing ${Math.max(...t.map(e=>e.week))+1} weeks`);let a=V(`div`,`usage-heatmap-days`);for(let e of oae)a.append(V(`span`,`usage-heatmap-day`,e));for(let e of t){let t=V(`span`,`usage-heatmap-cell`);t.dataset.tone=String(e.tone),e.noData&&(t.dataset.noData=`true`),e.source===`history`&&(t.dataset.source=`history`),t.style.gridColumn=String(e.week+1),t.style.gridRow=String(e.weekday+1),t.title=lae(e),i.append(t)}return r.append(a,i),r}function oQ(e,t){if(t===0)return null;let n=V(`button`,`usage-toggle`,`Models`);return n.type=`button`,n.dataset.usageDay=e,n.setAttribute(`aria-expanded`,yZ.has(e)?`true`:`false`),n.addEventListener(`click`,()=>{if(_Z={kind:`day`,day:e},yZ.has(e)){yZ.delete(e),mQ();return}yZ.add(e),mQ()}),n}function sQ(e){let t=V(`tr`,`usage-row-breakdown`),n=V(`td`,`usage-models`);n.colSpan=4;for(let t of e){let e=V(`span`,`usage-model-chip`);e.append(V(`span`,`usage-model-name`,bM(t)),V(`span`,`usage-model-value`,`${Aj(t.tokens)} ${kj(t.costUSD)}`)),n.append(e)}return t.append(n),t}function cQ(e,t){let n=V(`span`,`usage-model-name-wrap`),r=hae(e,t);return r&&n.append(V(`span`,`usage-vendor-tag`,r)),n.append(V(`span`,null,bM(e))),n}function lQ(){let e=OM(Z?.models,mZ),t=Z?.totals||{},n=Mj(t),r=AZ(`By model`,Nj(n));if(e.length===0)return r.append(V(`p`,`usage-empty`,`No models.`)),r;let{wrap:i,body:a}=FZ([{label:`Model`,key:`model`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Input`,numeric:!0,key:`input`},{label:`Output`,numeric:!0,key:`output`},{label:`Cache write`,numeric:!0,key:`cacheCreate`},{label:`Cache read`,numeric:!0,key:`cacheRead`}],mZ,e=>{mZ=wM(mZ,e),mQ()},`model`);for(let r of e){let e=V(`tr`,`usage-row`);IZ(e,[{node:cQ(r,t),className:`usage-model-cell`,title:bM(r)},{text:Aj(r.tokens),numeric:!0},{text:kj(r.costUSD),numeric:!0},{node:LZ(Pj(r[n],t[n])),className:`usage-share-cell`},{text:Aj(r.input),numeric:!0},{text:Aj(r.output),numeric:!0},{text:Aj(r.cacheCreate),numeric:!0},{text:Aj(r.cacheRead),numeric:!0}]),a.append(e)}return r.append(i),r}function uQ(){let e=Iae(Z?.sessions,hZ),t=Lae(e,gZ),n=Z?.totals||{},r=Mj(n),i=AZ(`By session`,Nj(r));if(e.length===0)return i.append(V(`p`,`usage-empty`,`No sessions.`)),i;let{wrap:a,body:o}=FZ([{label:`Session`,key:`label`},{label:`Tokens`,numeric:!0,key:`tokens`},{label:`Cost`,numeric:!0,key:`costUSD`},{label:`Share`,numeric:!0},{label:`Last activity`,numeric:!0,key:`lastTs`}],hZ,e=>{hZ=wM(hZ,e),mQ()},`session`);for(let e of t.rows){let t=V(`tr`,`usage-row`);vM(e)&&(t.dataset.managed=`true`);let i=yM(e),a=V(`span`,`usage-ago`,``);IZ(t,[{text:i,className:`usage-session-cell`,title:e.project?String(e.project):i},{text:Aj(e.tokens),numeric:!0},{text:kj(e.costUSD),numeric:!0},{node:LZ(Pj(e[r],n[r])),className:`usage-share-cell`},{node:a,numeric:!0}]),kZ.track(a,Number(e.lastTs),JP),o.append(t)}return i.append(a),e.length>10&&i.append(dQ(t.hiddenCount)),i}function dQ(e){let t=V(`div`,`usage-overflow`),n=Rae(e);n&&t.append(V(`p`,`usage-meta`,n));let r=V(`button`,`usage-toggle`,`All sessions`);return r.type=`button`,r.dataset.usageSessionsToggle=`true`,r.setAttribute(`aria-expanded`,gZ?`true`:`false`),r.addEventListener(`click`,()=>{_Z={kind:`sessions-toggle`},gZ=!gZ,mQ()}),t.append(r),t}function fQ(){let e=AZ(`Not available`,``);return e.append(V(`p`,`usage-empty`,gM(Z))),e.append(V(`p`,`usage-empty`,Sie)),e}function pQ(){xZ=null,SZ=null,CZ=null,wZ=null,TZ=null,EZ=null,DZ=null,OZ=null}function mQ({force:e=!1}={}){if(!oZ||!e&&Ef(oZ))return;let t=oZ.parentElement,n=t?t.scrollTop:0;kZ.reset(),pQ(),oZ.textContent=``,_Q(),t&&(t.scrollTop=n),hQ()}function hQ(){let e=_Z;if(_Z=null,!e)return;let t=gQ(e);if(!t||!oZ)return;let n=oZ.querySelector(t);n instanceof HTMLElement&&n.focus()}function gQ(e){return e.kind===`day`?`.usage-toggle[data-usage-day="${CSS.escape(e.day)}"]`:e.kind===`period`?`.usage-period-button[data-period-view="${CSS.escape(e.view)}"]`:e.kind===`sessions-toggle`?`.usage-toggle[data-usage-sessions-toggle="true"]`:e.kind===`sort`?`[data-usage-table="${CSS.escape(e.table)}"] .usage-sort[data-sort-key="${CSS.escape(e.key)}"]`:null}function _Q(){if(!oZ)return;oZ.append(UZ());let e=WZ();if(_M(Z)){e&&oZ.append(e),oZ.append(fQ());return}if(!Z){e&&oZ.append(e),oZ.append(V(`p`,`usage-empty`,`Waiting for scan.`));return}let t=[e,tQ()].filter(e=>e!==null);oZ.append(vQ(`usage-band-now`,YZ(),t,{sideFirst:!0}));let n=[eQ()].filter(e=>e!==null);oZ.append(vQ(`usage-band-spend`,QZ(),n));let r=[ZZ()].filter(e=>e!==null);oZ.append(vQ(`usage-band-trend`,nQ(),r));let i=qZ();i&&oZ.append(i),oZ.append(lQ(),uQ())}function vQ(e,t,n,{sideFirst:r=!1}={}){if(n.length===0)return t;let i=V(`div`,`usage-band ${e}`),a=V(`div`,`usage-band-col`);for(let e of n)a.append(e);return r?(i.append(a,t),i):(i.append(t,a),i)}function yQ(){sZ&&sZ(bZ.refresh())}function bQ(){bZ.acknowledge(),yQ()}function xQ(){DZ&&(DZ.disabled=dZ),OZ&&(OZ.textContent=dZ?`Refreshing`:``)}function SQ(e){dZ=e,xQ(),fZ&&=(clearTimeout(fZ),null),e&&(fZ=setTimeout(()=>{fZ=null,dZ=!1,xQ()},rZ))}function CQ(e){sZ=e,yQ()}function wQ(e){cZ=e}function TQ({force:e=!1}={}){if(!cZ)return;lZ=af(`usage`);let t={type:`request-usage-report`,requestId:lZ};e&&(t.force=!0);let n=VZ(uZ);n!==null&&(t.days=n),SQ(!0),cZ(t)}function EQ(e){if(oZ)return oZ;let t=V(`div`,`usage-content`);return e.appendChild(t),oZ=t,kZ.ensure(),mQ({force:!0}),t}function DQ(){mQ({force:!0})}function OQ(e){if(iZ=e,Z&&!_M(Z)&&SZ?.isConnected){zZ();return}mQ()}function kQ(e){aZ=e,mQ(),yQ()}function AQ(e){Mae(e,lZ)&&(SQ(!1),Z=e,mQ(),yQ())}function jQ(){let e=Z?.pricing||(iZ?{source:iZ.pricingSource}:null),t=Dae(e?.fetchedAt),n=[Eae(e,t!==null&&t>0?JP(t):``)],r=gM(Z);r&&n.push(r);let i=Aae(Z?.scan);return i&&n.push(i),n}var MQ=null,NQ=new Set;function PQ(){MQ?.setAttribute(`aria-pressed`,String(!LO()))}function FQ(e){RO(e),PQ();for(let t of NQ)t(e)}function IQ(e){NQ.add(e)}function LQ(e){MQ=e,PQ(),e.addEventListener(`click`,()=>FQ(!LO()))}var RQ=Object.freeze({fetch:`Fetch`,stage:`Stage`,install:`Install dependencies`,"link-deps":`Link dependencies`,build:`Build`}),zQ=Object.freeze({"branch-count-unavailable":`The last check could not compare the checked-out branch with its upstream.`,"branch-diverged":`The checked-out branch has diverged from its upstream.`,"fetch-failed":`The last update check could not fetch the upstream branch.`,"main-channel-requires-clone":`The main channel requires a clone install.`,"no-branch":`The last update check found no checked-out branch.`,"no-upstream":`The checked-out branch has no upstream.`,"release-already-checked-out":`The checkout already contains the latest release. Restart to run it.`,"release-check-failed":`The last release check failed.`,"remote-tip-unavailable":`The last update check could not resolve the upstream branch tip.`,"update-check-failed":`The last update check failed.`}),BQ=Object.freeze([`unsupported-flavor`,`unsupported-platform`]),VQ=`Not connected to the server. Reconnecting.`,HQ=Object.freeze({requested:!1,failure:null});function UQ(e,t){return t===`request-sent`?{requested:!0,failure:null}:t===`request-unsent`?{requested:!1,failure:VQ}:t===`progress-frame`?HQ:t===`error-frame`?e.requested?HQ:e:e.failure===null?e:{requested:e.requested,failure:null}}function WQ(e,t){return t?.state?t.state:e?.journalSummary?.state}function GQ(e){return{enabled:!1,reason:e}}function KQ(){return{enabled:!0,reason:null}}function qQ({status:e,journal:t,request:n=HQ}){let r=WQ(e,t)===`running`||n.requested,i=r?GQ(`Wait for update staging to finish.`):KQ();if(n.failure)return{update:GQ(n.failure),restart:i};if(r)return{update:GQ(`Wait for the current update to finish.`),restart:i};if(!e)return{update:GQ(`Update status unavailable. Check for updates.`),restart:i};let a=e.applyRefusal;return a?{update:GQ(a.message),restart:i}:{update:KQ(),restart:i}}function JQ(e){let t=e?.applyRefusal;return t===void 0?`command`:t===null?`link`:BQ.includes(t.reason)?`command`:`link`}function YQ(e){let t=OA(e,``);return t?`: ${t}`:``}function XQ(e){return e.state===`staged`?`Update staged. Restart to hand it off${YQ(e.reason)}.`:e.state===`succeeded`?`Update succeeded at restart${YQ(e.reason)}.`:e.state===`failed`?`Update failed${YQ(e.reason)}.`:e.state===`discarded`?`Update discarded${YQ(e.reason)}.`:e.state===`interrupted`?`Update interrupted${YQ(e.reason)}.`:null}function ZQ(e){return RQ[e]??e}function QQ(e){let t=e.steps.find(t=>t.id===e.activeStep);if(t&&t.outputTail.length>0)return{stepId:t.id,lines:t.outputTail};let n=e.steps.findLast(e=>e.outputTail.length>0);return n?{stepId:n.id,lines:n.outputTail}:{stepId:null,lines:[]}}function $Q(e){if(!e||e.state===`idle`)return null;let t=QQ(e),n=t.stepId!==null&&t.stepId!==e.activeStep?t.stepId:null;return{state:e.state,terminalLine:XQ(e),steps:e.steps.map(e=>({id:e.id,label:ZQ(e.id),status:e.status})),outputTail:t.lines,outputStepId:t.stepId,outputStepLabel:n===null?null:ZQ(n)}}var e$=6e5;function t$(e){return e.channel!==`main`||!Number.isInteger(e.behindCount)?``:`${e.behindCount} ${e.behindCount===1?`commit`:`commits`} behind`}function n$(e,t){let n=WQ(e,t),r=HA(t?.toVersion,t?.toSha)||HA(e?.latest,e?.latestSha)||`the update`;if(n===`running`)return{tone:`running`,headline:`Updating to ${r}. Glimmervoid keeps running until the restart.`};if(n===`staged`)return{tone:`staged`,headline:`${r} is staged. Restart to finish updating.`};if(!e)return{tone:`unknown`,headline:`No update check has run yet.`};let i=HA(e.current,e.currentSha)||`an unknown version`;if(e.updateAvailable){let t=HA(e.latest,e.latestSha)||`a newer build`,n=t$(e);return{tone:`available`,headline:`Update available: ${i} to ${t}${n?` (${n})`:``}.`}}return OA(e.reason,``)?{tone:`unknown`,headline:`Running ${i}. The last check did not finish.`}:{tone:`current`,headline:`Up to date. Running ${i}.`}}function r$(e){if(!e)return`Update status unavailable.`;let t=HA(e.current,null)||`Unknown version`,n=jl(e.currentSha,{validate:!0}),r=OA(e.installedBranch,``);return[t,[n?`commit ${n}`:``,r?`on ${r}`:``].filter(Boolean).join(` `),e.isTreeClean===!0?`clean checkout`:e.isTreeClean===!1?`uncommitted local changes`:``].filter(Boolean).join(`, `)}function i$(e){return e?{label:HA(e.latest,e.latestSha)||`Latest target unknown`,behind:t$(e),releaseUrl:OA(e.releaseUrl,``)}:{label:`Update status unavailable.`,behind:``,releaseUrl:``}}function a$({status:e,checkForUpdates:t,now:n,lastAutoCheckAt:r}){if(t===!1||r!==null&&n-r<e$)return!1;let i=typeof e?.lastCheckAt==`number`?e.lastCheckAt:null;return i===null||n-i>=e$}function o$({status:e,checkForUpdates:t,relativeTime:n}){if(t===!1)return`Update checks are off.`;if(!e)return`No update check has run.`;let r=OA(e.reason,``);return r?zQ[r]??`The last update check failed: ${r}.`:e.flavor===`unknown`?`The install flavor is unknown.`:n}var s$=rO,c$=Object.freeze({sounds:()=>bx(),themes:Hx});function l$(e){if(!e.optionsFrom)return e;let t=c$[e.optionsFrom]?.()??[];return{...e,options:t.map(e=>({value:e.id,label:e.label}))}}function u$(){return Object.freeze(KY.map(e=>({...e,settings:e.settings.map(l$)})))}var d$=u$(),f$=RX(d$),p$=Object.freeze({browser:`This browser`,machine:`Machine`,lanes:`Lanes`,projects:`Projects`}),m$=!1,h$=null,g$=null,_$=null,v$=null,y$=null,b$=null,x$=null,S$=null,C$=null,w$=null,T$=null,Q=f$[0],E$={},D$=[],O$=[],k$=new Map,A$=null,j$=null,M$=``,N$=``,P$=null,F$=null,I$=null,L$=null,R$=HQ,z$=()=>{},B$=e=>{e([])},V$=null,H$=!1,U$=new Set,W$=new Map;function G$(){return{themeId:qO(),flyingAnimalsEnabled:YO(),...zk(),soundEnabled:LO(),soundId:xx(zO()),notificationsEnabled:VO(),compactStatusLabels:UO(),sessionUsageChips:GO()}}function K$(e){let t={...e,prefs:G$()};A$=EX(f$,t),j$=EX(f$,t)}function q$(e){return e.control===`readonly`?e.value:j$?.[e.path]??e.defaultValue}function J$(e){return e.settings.some(e=>!e.path.startsWith(`pref:`)&&JSON.stringify(A$?.[e.path])!==JSON.stringify(j$?.[e.path]))}function Y$(e,t=null){return`#settings/${encodeURIComponent(e)}${t?`/${encodeURIComponent(t)}`:``}`}function X$(e,t=null){history.replaceState(history.state,``,Y$(e,t))}function soe(e){requestAnimationFrame(()=>{let t=document.getElementById(e),n=t?.closest(`.settings-view-advanced-panel`);n&&(m$=!0,n.hidden=!1,T$?.querySelector(`.settings-view-advanced-toggle`)?.setAttribute(`aria-expanded`,`true`));let r=t?.closest(`.settings-view-setting`);r&&(r.scrollIntoView({block:`center`}),r.classList.remove(`settings-view-setting-flash`),requestAnimationFrame(()=>r.classList.add(`settings-view-setting-flash`)))})}function Z$(){let e=UX(O$);f$=RX([...d$,...e]),Q=qX(f$,Q?.id)??Q}function Q$(e){let t=Array.isArray(e)?e:[];for(let e of t)typeof e?.id==`string`&&e.id&&k$.set(e.id,{...k$.get(e.id),...e});O$=GX(WX(D$),[...k$.values()])}function $$(e){for(let t of qb(Jb)){let n=V(`div`,`shortcut-group`);n.appendChild(V(`div`,`shortcut-group-title`,t.title));let r=V(`dl`,`shortcut-rows`);for(let e of t.items){let t=V(`dt`,`shortcut-keys`);e.combos.forEach((e,n)=>{n>0&&t.appendChild(V(`span`,`shortcut-sep`,`/`)),Qb(t,e)}),r.append(t,V(`dd`,`shortcut-label`,e.label))}n.appendChild(r),e.appendChild(n)}}function e1(e){let t=V(`div`,`settings-about`),n=V(`span`,`settings-about-version`,`GLIMMERVOID `);n.appendChild(V(`span`,`settings-about-v`,`v0.34.0`));let r=V(`span`,`settings-about-links`),i=V(`a`,`settings-about-link`,`GitHub`);i.href=`https://github.com/${QJ}`,i.target=`_blank`,i.rel=`noopener`;let a=V(`a`,`settings-about-link`,`Changelog`);a.href=`https://github.com/${QJ}/blob/main/CHANGELOG.md`,a.target=`_blank`,a.rel=`noopener`,r.append(i,a),t.append(n,r),e.appendChild(t)}function t1(e){j$&&j$[`pref:soundEnabled`]!==e&&(j$[`pref:soundEnabled`]=e,A$&&(A$[`pref:soundEnabled`]=e),K1())}function n1(){for(let[e,t]of Object.entries(zk()))A$&&(A$[`pref:${e}`]=t),j$&&(j$[`pref:${e}`]=t)}var r1={"pref:flyingAnimalsMinGapSeconds":e=>jk(Number(e)),"pref:flyingAnimalsMaxGapSeconds":e=>Mk(Number(e)),"pref:flyingAnimalsMinDurationSeconds":e=>Nk(Number(e)),"pref:flyingAnimalsMaxDurationSeconds":e=>Pk(Number(e)),"pref:flyingAnimalsScale":e=>Fk(Number(e)),"pref:flyingAnimalsOnPhone":e=>Ik(e===!0)};function i1(e,t){if(e.path===`pref:compactStatusLabels`){WO(t===!0),zx(t===!0);return}if(e.path===`pref:sessionUsageChips`){KO(t===!0),Bx(t===!0);return}if(e.path===`pref:themeId`){JO(t),Rx(t);return}if(e.path===`pref:flyingAnimalsEnabled`){XO(t),XJ(t);return}let n=r1[e.path];if(n){let r=MX([Q],j$??{},s$);if(r[e.id])return;n(t);let i=PX([Q],e),a=i&&r1[i.path];i&&a&&!r[i.id]&&a(j$?.[i.path]),XJ(YO());return}if(e.path===`pref:soundEnabled`){FQ(t===!0);return}if(e.path===`pref:soundId`){BO(t),Mx(t);return}e.path===`pref:notificationsEnabled`&&(HO(t),t&&kJ().then(K1))}function a1(){if(!T$||!j$)return;T$.querySelector(`.settings-view-footer`)?.remove();let e=F1(MX([Q],j$,s$));e&&T$.appendChild(e)}function o1(e,t,{rerender:n=!0}={}){if(j$){if(j$[e.path]=t,M$=``,e.path.startsWith(`pref:`)&&A$&&(A$[e.path]=t,i1(e,t)),n){K1();return}a1(),p0()}}function s1(e,t){if(!t.exclusiveMin)return t.min;if(e.integer!==!1)return t.min+1}function c1(e){let t=V(`div`,`settings-view-toggle-wrap`),n=V(`label`,`settings-view-toggle`),r=V(`input`,`settings-view-checkbox`);return r.type=`checkbox`,r.checked=q$(e)===!0,e.id===`desktop-notifications`&&!DJ()&&(r.checked=!1,r.disabled=!0),r.setAttribute(`aria-labelledby`,e.id),r.addEventListener(`change`,()=>o1(e,r.checked)),n.append(r,V(`span`,`settings-view-toggle-state`,r.checked?`On`:`Off`)),t.appendChild(n),t}function l1(e){let t=V(`input`,`settings-view-input`);t.type=e.control??`text`,t.value=String(q$(e)??``),e.control===`password`&&(t.placeholder=`No credential stored`);let n=rX(e,E$);return n&&(t.disabled=!0,t.setAttribute(`aria-description`,`Supplied by ${n}`)),t.autocomplete=`off`,t.spellcheck=!1,t.setAttribute(`aria-labelledby`,e.id),t.addEventListener(`input`,()=>o1(e,t.value,{rerender:!1})),t}function u1(e){let t=V(`input`,`settings-view-input`),n=s$[e.range??``];t.type=`number`,t.value=String(q$(e)??``),t.step=String(e.step??1);let r=s1(e,n);return r!=null&&(t.min=String(r)),n.max!=null&&(t.max=String(n.max)),t.autocomplete=`off`,t.setAttribute(`aria-labelledby`,e.id),e.commitOnChange?(t.addEventListener(`change`,()=>o1(e,t.value.trim()===``?e.defaultValue:t.value)),t):(t.addEventListener(`input`,()=>o1(e,t.value,{rerender:!1})),t)}function d1(e){let t=V(`select`,`settings-view-input`);t.setAttribute(`aria-labelledby`,e.id);for(let n of e.options){let e=V(`option`,null,n.label);e.value=n.value,t.appendChild(e)}return t.value=String(q$(e)),t.addEventListener(`change`,()=>o1(e,t.value)),t}function f1(e){let t=V(`div`,`settings-view-list`),n=q$(e),r=Array.isArray(n)?n:[];r.length===0&&t.appendChild(V(`div`,`settings-empty`,e.listEmptyText??`No repository roots configured.`));for(let[n,i]of r.entries()){let a=V(`div`,`settings-root-item`),o=V(`span`,`settings-root-path`,i);o.title=i;let s=V(`button`,`btn-settings-remove`,`×`);s.type=`button`,s.title=`Remove`,s.setAttribute(`aria-label`,`Remove ${i}`),s.addEventListener(`click`,()=>{o1(e,r.filter((e,t)=>t!==n))}),a.append(o,s),t.appendChild(a)}let i=V(`div`,`settings-add-row`),a=V(`input`,`settings-view-input settings-root-input`);a.type=`text`,a.autocomplete=`off`,a.spellcheck=!1,a.placeholder=e.listPlaceholder??`Repository root path`;let o=V(`button`,`btn-dialog btn-dialog-confirm btn-settings-add`,`Add`);o.type=`button`;let s=()=>{let t=a.value.trim();t&&($Y(r,t,E$.repositoryRootCaseInsensitive===!0)||o1(e,[...r,t]))};return o.addEventListener(`click`,s),a.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),s())}),i.append(a,o),t.appendChild(i),t}function p1(e){let t=V(`div`,`settings-view-projects`),n=q$(e),r=new Set(Array.isArray(n)?n:[]),i=Array.isArray(E$.projectChoices)?E$.projectChoices:[];i.length===0&&t.appendChild(V(`div`,`settings-empty`,`No configured projects are available.`));for(let n of QY(i,[...r])){let i=V(`label`,`settings-view-project-choice`),a=V(`input`,`settings-view-checkbox`);a.type=`checkbox`,a.checked=r.has(n.id),a.addEventListener(`change`,()=>{let t=new Set(r);a.checked&&t.add(n.id),a.checked||t.delete(n.id),o1(e,[...t])}),i.append(a,document.createTextNode(n.name)),t.appendChild(i)}return t}function m1(e){let t=V(`div`,`settings-view-file-only`);return t.append(V(`code`,`settings-view-key-path`,e.path)),t.append(V(`span`,`settings-view-file-caption`,`Configured in config.json`)),t}function h1(){let e=n$(I$,L$),t=V(`div`,`settings-readonly settings-update-readout settings-update-summary`,e.headline);return t.dataset.tone=e.tone,t}function g1(){return V(`div`,`settings-readonly settings-update-readout`,r$(I$))}function _1(){let e=i$(I$),t=V(`div`,`settings-readonly settings-update-readout`);if(t.appendChild(V(`span`,`settings-update-latest-label`,e.label)),e.behind&&t.appendChild(V(`span`,`settings-update-behind`,e.behind)),!e.releaseUrl)return t;let n=V(`a`,`settings-link`,`View release`);return n.href=e.releaseUrl,n.target=`_blank`,n.rel=`noopener noreferrer`,t.appendChild(n),t}function v1(){let e=typeof I$?.lastCheckAt==`number`?I$.lastCheckAt:null,t=V(`div`,`settings-readonly settings-update-readout`,o$({status:I$,checkForUpdates:E$.checkForUpdates,relativeTime:JP(e)}));return e&&(t.title=new Date(e).toLocaleString()),t}function y1(e,t,{decision:n={enabled:!0,reason:null},isPrimary:r=!1}={}){let i=V(`button`,`btn-dialog ${r?`btn-dialog-confirm`:`btn-dialog-cancel`} settings-update-button`,e);return i.type=`button`,i.disabled=!n.enabled,i.addEventListener(`click`,t),i}function b1(e){let t=V(`span`,`settings-update-action-status`,e??``);return t.setAttribute(`role`,`status`),t}function x1(e){let t=UQ(R$,e);t!==R$&&(R$=t,m0())}function S1({restartWhenStaged:e,confirmedSessionIds:t}){x1(B({type:`update-apply`,restartWhenStaged:e,confirmedSessionIds:t})?`request-sent`:`request-unsent`)}function C1(){V$=Date.now(),B({type:`update-check`})}function w1(){if(!I$){H$=!0;return}H$=!1,a$({status:I$,checkForUpdates:E$.checkForUpdates,now:Date.now(),lastAutoCheckAt:V$})&&C1()}function T1(){let e=qQ({status:I$,journal:L$,request:R$}),t=V(`div`,`settings-update-actions settings-update-readout`),n=V(`div`,`settings-update-buttons`);return n.append(y1(`Update and restart`,()=>B$(e=>S1({restartWhenStaged:!0,confirmedSessionIds:e})),{decision:e.update,isPrimary:!0}),y1(`Update without restart`,()=>S1({restartWhenStaged:!1}),{decision:e.update}),y1(`Check for updates`,C1),y1(`Restart`,z$,{decision:e.restart})),t.append(n,b1(e.update.reason)),t}function E1(e){return e.status===`update-summary`?h1():e.status===`update-installed`?g1():e.status===`update-latest`?_1():e.status===`update-last-checked`?v1():e.status===`update-actions`?T1():V(`div`,`settings-readonly`,String(e.value||`Not configured`))}function D1(e){return e.fileOnly?m1(e):e.control===`readonly`?E1(e):e.control===`toggle`?c1(e):e.control===`number`?u1(e):e.control===`select`?d1(e):e.control===`list`?f1(e):e.control===`projects`?p1(e):l1(e)}function O1(e){let t=rX(e,E$);return t?`Supplied by ${t}. Change the server environment and restart to replace this credential.`:e.status===`visions-activity-limit`?aX(j$||{}):e.id===`desktop-notifications`&&!DJ()?`Desktop notifications are unavailable for this page.`:e.id===`desktop-notifications`&&q$(e)&&OJ()===`denied`?`Blocked by the browser. Allow notifications for this site to enable them.`:e.status!==`rtk-install`||!q$(e)||E$.rtkAvailable?``:oX(E$)}function k1(e){if(e.status===`custom-agents`)return R1();if(e.status===`workflows`)return H1();if(e.status===`usage-last-report`)return U1();if(e.status===`update-actions`)return A1();if(e.status?.startsWith(`update-`))return null;let t=O1(e);return t?V(`div`,`settings-view-warning settings-view-status-slot`,t):null}function A1(){let e=$Q(L$);if(!e)return null;let t=V(`div`,`settings-update-progress settings-view-status-block settings-view-status-slot`);t.dataset.state=e.state,t.setAttribute(`role`,`status`),e.terminalLine&&t.appendChild(V(`div`,`settings-update-terminal`,e.terminalLine));let n=V(`ol`,`settings-update-steps`);for(let t of e.steps){let e=V(`li`,`settings-update-step`);e.dataset.status=t.status,e.append(V(`span`,`settings-update-step-state`,t.status),V(`span`,`settings-update-step-label`,t.label)),n.appendChild(e)}if(t.appendChild(n),e.outputTail.length===0)return t;let r=V(`pre`,`settings-update-output`,e.outputTail.join(`
|
|
247
|
+
`));if(e.outputStepId&&(r.dataset.step=e.outputStepId),!e.outputStepLabel)return t.appendChild(r),t;let i=`Output from ${e.outputStepLabel}`;return r.setAttribute(`aria-label`,i),t.append(V(`div`,`settings-update-output-label`,i),r),t}function j1(e){let t=V(`div`,`settings-view-setting-heading`),n=V(`h2`,`settings-view-setting-title`,e.title);n.id=e.id,n.addEventListener(`click`,()=>X$(Q.id,e.id));let r=V(`button`,`settings-view-copy-link`,`#`);r.type=`button`,r.setAttribute(`aria-label`,`Copy link`);let i=V(`span`,`settings-view-copy-status`);return i.setAttribute(`role`,`status`),r.addEventListener(`click`,async()=>{let t=new URL(Y$(Q.id,e.id),location.href).href;try{await navigator.clipboard.writeText(t),i.textContent=`Link copied`}catch{i.textContent=`Copy failed`}setTimeout(()=>{i.textContent=``},1600)}),t.append(n,r,i),t}function M1(e,t){let n=V(`article`,`settings-view-setting`);n.append(j1(e),V(`p`,`settings-view-setting-description`,e.description)),n.appendChild(D1(e)),e.id===`compact-status`&&n.appendChild(PJ()),KX(e,q$(e))&&n.appendChild(V(`div`,`settings-view-warning settings-warning`,e.warning));let r=k1(e);return r&&n.appendChild(r),t[e.id]&&n.appendChild(V(`div`,`settings-view-field-error`,t[e.id])),n}function N1(){if(j$&&A$){for(let e of Q.settings)j$[e.path]=structuredClone(A$[e.path]);M$=``,K1()}}async function P1(){let e=Q,t=[e],n=MX(t,j$??{},s$);if(Object.keys(n).length>0){M$=`Fix the highlighted settings before saving.`,K1();return}let r=XY(OX(t,A$??{},j$??{}));if(Object.keys(r).length!==0)try{let t=await of(`update-settings`,{settings:r});if(t.type===`settings-error`){if(Q!==e)return;M$=String(t.message),K1();return}t.settings&&u0(t.settings,{rehydrateSectionIds:[e.id]})}catch(t){if(Q!==e)return;M$=t?.message||`Failed to save settings.`,K1()}}function F1(e){let t=J$(Q);if(Q.level===`browser`||!t&&!M$)return null;let n=V(`footer`,`settings-view-footer`),r=V(`div`,`settings-view-footer-error`,M$);if(r.setAttribute(`role`,`status`),n.appendChild(r),!t)return n;let i=V(`div`,`settings-view-footer-actions`),a=V(`button`,`btn-dialog btn-dialog-cancel`,`Revert`);a.type=`button`,a.addEventListener(`click`,N1);let o=V(`button`,`btn-dialog btn-dialog-confirm`,`Save`);return o.type=`button`,o.disabled=Object.keys(e).length>0,o.addEventListener(`click`,P1),i.append(a,o),n.appendChild(i),n}function I1(e){return e===null?`not probed yet`:e?`resolved`:`not found on PATH`}function L1(){let e=Array.isArray(E$.customAgents)?E$.customAgents:[];return e.length===0?[`None declared. Add customAgents to config.json.`]:e.map(e=>{let t=e.args.length>0?`${e.command} ${e.args.join(` `)}`:e.command;return`${e.id} ${e.label} ${t} ${I1(e.resolvable)}`})}function R1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Declared agents`));for(let t of L1())e.appendChild(V(`div`,`settings-readonly`,t));return e}async function z1(e,t){U$.add(e.id),W$.delete(e.id),p0();try{let n=await of(`update-settings`,{settings:{workflows:{rules:[{id:e.id,enabled:t}]}}});if(n.type===`settings-error`&&W$.set(e.id,String(n.message)),U$.delete(e.id),n.type!==`settings-error`&&n.settings){u0(n.settings);return}}catch(t){W$.set(e.id,t?.message||`Failed to save the rule.`)}U$.delete(e.id),p0()}function B1(e){return U$.has(e.id)?`Saving`:W$.get(e.id)??``}function V1(e){let t=V(`div`,`settings-view-toggle-wrap`),n=V(`label`,`settings-view-toggle`),r=V(`input`,`settings-view-checkbox`);r.type=`checkbox`,r.checked=e.isEnabled,r.disabled=U$.has(e.id),r.setAttribute(`aria-label`,`Run rule ${e.name}`),r.addEventListener(`change`,()=>{z1(e,r.checked)}),n.append(r,V(`span`,`settings-view-toggle-state`,e.isEnabled?`On`:`Off`),V(`span`,`settings-readonly`,`${e.name} ${e.summary}`));let i=V(`span`,`settings-view-copy-status`,B1(e));return i.setAttribute(`role`,`status`),t.append(n,i),t}function H1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Rules`));let t=YY(E$.workflows);if(t.length>0){for(let n of t)e.appendChild(V1(n));return e}for(let t of JY(E$.workflows))e.appendChild(V(`div`,`settings-readonly`,t));return e}function U1(){let e=V(`div`,`settings-view-status-block settings-view-status-slot`);e.appendChild(V(`div`,`settings-section-title`,`Last report`));let t=jQ();for(let n of t)e.appendChild(V(`div`,`settings-readonly`,n));return e}function W1(){let e=V(`button`,`btn-dialog btn-dialog-cancel`,`Reset to defaults`);return e.type=`button`,e.addEventListener(`click`,()=>{Bk(),n1(),XJ(YO()),K1()}),e}function G1(e,t){let n=V(`div`,`settings-view-advanced`),r=V(`button`,`dialog-advanced-toggle settings-view-advanced-toggle`,`Advanced`);r.type=`button`,r.setAttribute(`aria-expanded`,String(m$)),r.setAttribute(`aria-controls`,`settings-view-advanced-panel`);let i=V(`div`,`dialog-advanced-panel settings-view-advanced-panel`);i.id=`settings-view-advanced-panel`,i.hidden=!m$,r.addEventListener(`click`,()=>{m$=!m$,i.hidden=!m$,r.setAttribute(`aria-expanded`,String(m$))});for(let n of e)i.append(M1(n,t));return Q.id===`browser-flying-animals`&&i.append(W1()),n.append(r,i),n}function K1(){if(!T$||!j$)return;T$.textContent=``;let e=V(`header`,`settings-view-section-header`),t=V(`div`,`settings-view-title-row`),n=V(`h1`,`settings-view-section-title`,Q.title);if(n.tabIndex=-1,n.addEventListener(`click`,()=>X$(Q.id)),t.append(n),t.append(V(`span`,`settings-view-level`,p$[Q.level]||Q.level)),e.append(t,V(`p`,`settings-view-section-description`,Q.description)),Q.caption&&e.appendChild(V(`p`,`settings-view-section-caption`,Q.caption)),T$.appendChild(e),Q.id===`browser-shortcuts`){let e=V(`div`,`shortcut-groups settings-view-shortcuts`);$$(e),T$.appendChild(e),T$.appendChild(tZ()),T$.appendChild(nZ()),e1(T$);return}let r=MX([Q],j$,s$),i=V(`div`,`settings-view-stack`);for(let e of Q.settings.filter(e=>!e.advanced))i.appendChild(M1(e,r));Q.id===`browser-flying-animals`&&i.append(ZJ());let a=Q.settings.filter(e=>e.advanced);a.length>0&&i.append(G1(a,r));for(let e of Q.unattendedLinks||[]){let t=V(`div`,`settings-view-unattended-link`);t.append(document.createTextNode(`${e.title}: `));let n=V(`a`,null,`Enabled in Unattended actions`);n.href=Y$(`lanes-unattended`,e.settingId),t.appendChild(n),i.appendChild(t)}T$.appendChild(i);let o=F1(r);o&&T$.appendChild(o)}function q1(e,{focusContent:t=!1,settingId:n=null,updateHash:r=!0}={}){Q.id!==e&&(m$=!1),Q=qX(f$,e)??Q,M$=``,J1(v$),J1(C$),x$&&(x$.textContent=Q.title,b$&&(b$.title=Q.title)),S$&&(S$.textContent=p$[Q.level]||Q.level),K1(),a0(Q)&&i0(),Q.id===`machine-updates`&&w1(),r&&X$(Q.id,n),n&&soe(n),t&&T$?.querySelector(`h1`)?.focus()}function J1(e){for(let t of e?.querySelectorAll(`[data-settings-section]`)||[]){let e=t.dataset.settingsSection===Q.id;t.setAttribute(`aria-current`,e?`page`:`false`)}}function Y1(e){e0(!1),y$&&(y$.value=``,N$=``,t0(),q1(e.section.id,{settingId:e.setting.id}))}function X1(e,t){if(t.length===0){e.appendChild(V(`div`,`settings-empty settings-view-search-empty`,`No settings found.`));return}let n=new Map;for(let e of t)n.has(e.section.id)||n.set(e.section.id,[]),n.get(e.section.id)?.push(e);for(let t of n.values()){let n=t[0].section,r=V(`div`,`settings-view-nav-group`);r.appendChild(V(`div`,`settings-view-nav-label`,`${n.title} (${p$[n.level]})`));for(let e of t){let t=V(`button`,`settings-view-nav-item settings-view-search-result`,e.setting.title);t.type=`button`,t.addEventListener(`click`,()=>Y1(e)),r.appendChild(t)}e.appendChild(r)}}function Z1(e,t,{groupClassName:n,headingClassName:r,createButton:i}){for(let a of[`browser`,`machine`,`lanes`,`projects`]){if(t[a].length===0)continue;let o=V(`div`,n);o.appendChild(V(`div`,r,p$[a]));for(let e of t[a])o.appendChild(i(e));e.appendChild(o)}}function Q1(e){C$&&(C$.textContent=``,Z1(C$,e,{groupClassName:`settings-view-section-picker-group`,headingClassName:`settings-view-section-picker-heading`,createButton(e){let t=V(`button`,`settings-view-section-option`,e.title);return t.type=`button`,t.dataset.settingsSection=e.id,t.addEventListener(`click`,()=>{e0(!1),q1(e.id)}),t}}),J1(C$))}function $1(){return!!C$&&!C$.hidden}function e0(e,{returnFocus:t=!0}={}){if(!C$||!b$)return;let n=$1();if(C$.hidden=!e,b$.setAttribute(`aria-expanded`,String(e)),e){Q1(FX(f$)),requestAnimationFrame(()=>{let e=C$?.querySelector(`[aria-current="page"]`);e instanceof HTMLElement&&e.focus()});return}t&&n&&b$.focus()}function t0(){if(!v$||!w$||!_$)return;let e=FX(f$);if(v$.textContent=``,w$.textContent=``,_$.dataset.searching=String(!!N$),w$.hidden=!N$,N$){let e=IX(f$,N$);X1(v$,e),X1(w$,e);return}Z1(v$,e,{groupClassName:`settings-view-nav-group`,headingClassName:`settings-view-nav-label`,createButton(e){let t=V(`button`,`settings-view-nav-item`,e.title);return t.type=`button`,t.dataset.settingsSection=e.id,t.addEventListener(`click`,()=>q1(e.id)),t}}),Q1(e),q1(Q.id,{updateHash:!1})}function n0(e){if(N$&&e.key===`Enter`){let t=IX(f$,N$)[0];if(!t)return;e.preventDefault(),Y1(t);return}if(e.key===`Escape`&&N$){if(!y$)return;e.preventDefault(),y$.value=``,N$=``,t0(),y$.focus();return}if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`||!v$)return;let t=[...v$.querySelectorAll(`[data-settings-section]`)].filter(e=>e instanceof HTMLElement),n=document.activeElement;if(!(n instanceof HTMLElement))return;let r=t.indexOf(n);r<0||(e.preventDefault(),t[(r+(e.key===`ArrowDown`?1:-1)+t.length)%t.length].focus())}function r0(e,{onRestart:t=()=>{},onConfirmUpdateAndRestart:n=e=>{e([])}}={}){z$=t,B$=n,IQ(t1),h$=e,h$.textContent=``,_$=V(`div`,`settings-view-shell`);let r=V(`div`,`settings-view-sidebar`);y$=V(`input`,`settings-view-search`),y$.type=`search`,y$.placeholder=`Search settings`,y$.setAttribute(`aria-label`,`Search settings`),v$=V(`nav`,`settings-view-nav`),v$.setAttribute(`role`,`navigation`),v$.setAttribute(`aria-label`,`Settings sections`),b$=V(`button`,`settings-view-section-button`),b$.type=`button`,b$.setAttribute(`aria-expanded`,`false`),b$.setAttribute(`aria-controls`,`settings-section-picker`),x$=V(`span`,`settings-view-section-button-title`),S$=V(`span`,`settings-view-section-button-level`);let i=V(`span`,`settings-view-section-button-chevron`,`⌄`);i.setAttribute(`aria-hidden`,`true`),b$.append(x$,S$,i),C$=V(`div`,`settings-view-section-picker`),C$.id=`settings-section-picker`,C$.hidden=!0,C$.setAttribute(`role`,`dialog`),C$.setAttribute(`aria-label`,`Settings sections`),w$=V(`nav`,`settings-view-phone-results`),w$.hidden=!0,w$.setAttribute(`aria-label`,`Settings search results`),T$=V(`div`,`settings-view-content`),T$.setAttribute(`aria-live`,`polite`),y$.addEventListener(`input`,()=>{let e=y$;e&&(N$=e.value.trim(),t0())}),y$.addEventListener(`keydown`,n0),v$.addEventListener(`keydown`,n0),w$.addEventListener(`keydown`,n0),b$.addEventListener(`click`,()=>e0(!$1())),P$&&document.removeEventListener(`click`,P$),F$&&document.removeEventListener(`keydown`,F$),P$=e=>{$1()&&e.target instanceof Node&&(C$?.contains(e.target)||b$?.contains(e.target)||e0(!1))},F$=e=>{e.key===`Escape`&&$1()&&(e.preventDefault(),e0(!1))},document.addEventListener(`click`,P$),document.addEventListener(`keydown`,F$),r.append(y$,b$,v$,C$),_$.append(r,w$,T$),h$.appendChild(_$),K$(E$),t0(),i0(),g$?.disconnect(),g$=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&i0()}),g$.observe(h$)}function i0(){Sx().then(o0)}function a0(e){return e.settings.some(e=>e.path===`pref:soundId`)}function o0(){d$=u$(),Z$();let e=xx(zO());A$&&(A$[`pref:soundId`]=e),j$&&(j$[`pref:soundId`]=e),a0(Q)&&K1()}function s0({returnFocus:e=!0}={}){e0(!1,{returnFocus:e})}function c0(e=null,t=null){q1(e||Q.id,{settingId:t})}function l0(e){return LX(e,f$,WY,GY)}function u0(e,t={}){let{rehydrateSectionIds:n=[]}=t;if(!e)return;E$=e,D$=Array.isArray(E$.projectChoices)?E$.projectChoices:[],Q$(E$.projectChoices),Z$();let r={...E$,prefs:G$()},i=DX(f$,r,A$,j$,{rehydrateSectionIds:n});A$=i.original,j$=i.edited,M$=``,v$&&t0(),K1()}function d0(e){return document.getElementById(e.id)?.closest(`.settings-view-setting`)??null}function f0(e,t){let n=t.querySelector(`.settings-view-status-slot`),r=k1(e);n&&r&&n.replaceWith(r),n&&!r&&n.remove(),!n&&r&&t.appendChild(r)}function p0(){for(let e of Q.settings||[]){if(!e.status)continue;let t=d0(e);t&&f0(e,t)}}function m0(){if(Q.id===`machine-updates`)for(let e of Q.settings||[]){if(!e.status?.startsWith(`update-`))continue;let t=d0(e);t&&(t.querySelector(`.settings-update-readout`)?.replaceWith(D1(e)),f0(e,t))}}function h0(e){I$=e,R$=UQ(R$,`status-frame`),m0(),H$&&Q.id===`machine-updates`&&w1()}function g0(e){L$=e,R$=UQ(R$,`progress-frame`),m0()}function _0(){x1(`error-frame`)}function v0(e){Q$(e),Z$(),v$&&t0()}function y0(){Q.id===`browser-flying-animals`&&K1()}window.matchMedia(`(prefers-reduced-motion: reduce)`).addEventListener(`change`,y0),Gf(y0);function b0(e){return[...e||[]].map((e,t)=>({row:e,index:t})).sort((e,t)=>gj(e.row||{},`phone-triage`)-gj(t.row||{},`phone-triage`)||e.index-t.index).map(e=>e.row)}var x0=new Set;function S0(e,t,n){let r=nU(e,t,n),i=r.groups.map(e=>({...e,rows:b0(e.rows)})),a={...r,groups:i};return{...a,visibleIds:rU(a,x0)}}var C0=e=>e.ui.path;function w0({onSelectSession:e}){let t=V(`div`,`phone-board`),n=V(`header`,`phone-topbar`),r=V(`div`,`phone-attention`);r.setAttribute(`role`,`status`),r.setAttribute(`aria-live`,`polite`);let i=V(`div`,`phone-calm calm-view`);i.hidden=!0;let a=V(`div`,`phone-board-list`),o=V(`div`,`phone-empty`);o.append(V(`p`,`phone-empty-title`,`No sessions`),V(`p`,`phone-empty-desc`,`Spawn a session to start watching.`)),t.append(n,r,i,a,o);let s=new Map,c=new Map,l=new WeakMap,u=new WeakMap,d=new WeakMap,f=0;Sf(n);function p(t){let n=V(`button`,`phone-row`);n.type=`button`,n.dataset.id=t,n.innerHTML=`<span class="phone-row-glyph" aria-hidden="true"></span><span class="phone-row-main"><span class="phone-row-name"></span><span class="phone-row-meta"><span class="phone-row-badge"></span><span class="phone-row-merge"></span></span></span><span class="phone-row-elapsed" aria-hidden="true"></span>`;let r={glyph:H(n,`.phone-row-glyph`,`span`),name:H(n,`.phone-row-name`,`span`),badge:H(n,`.phone-row-badge`,`span`),merge:H(n,`.phone-row-merge`,`span`),elapsed:H(n,`.phone-row-elapsed`,`span`)};n.addEventListener(`click`,()=>e?.(t));let i=V(`div`,`phone-row-item`);i.setAttribute(`role`,`listitem`);let a=V(`button`,`phone-row-remove`,`x`);return a.type=`button`,a.title=`Remove session`,a.setAttribute(`aria-label`,`Remove session`),a.addEventListener(`click`,e=>{e.stopPropagation(),OI(t)}),i.append(n,a),l.set(n,{refs:r,item:i}),n}function m(e){let t=V(`section`,`phone-board-group`);t.dataset.key=e;let n=V(`div`,`phone-board-group-header`),r=V(`span`,`phone-board-group-label`),i=V(`span`,`phone-board-group-count`),a=V(`button`,`phone-board-group-add`,`+`);a.type=`button`,a.addEventListener(`click`,()=>DI(t.dataset.path,t.dataset.label));let o=V(`button`,`phone-board-group-forget`,`x`);o.type=`button`,o.addEventListener(`click`,()=>{gI(t.dataset.path),b()});let s=V(`div`,`phone-board-group-rows`);return s.setAttribute(`role`,`list`),n.append(r,i,o,a),t.append(n,s),u.set(t,{header:n,label:r,count:i,addButton:a,forgetButton:o,rows:s}),t}function h(e,t){let n=l.get(e);if(!n)return;let{ui:r,state:i,unseen:a}=t,{glyph:o,label:s,isMonitoring:c}=xf(i,r.awaitingBackgroundTasks),u=r.pendingPromptKind===`plan`?`Plan ready`:s,d=t.name;e.dataset.state=i,e.toggleAttribute(`data-monitoring`,c),e.dataset.prompt=r.pendingPromptKind??``,e.toggleAttribute(`data-unseen`,a),n.refs.glyph.textContent=o,n.refs.name.textContent=d;let f=V(`span`,`session-list-task-title`,r.taskTitle??``);n.refs.name.append(f),n.refs.name.title=[d,r.taskTitle].filter(Boolean).join(` | `),n.refs.badge.textContent=u;let p=r.card?.dataset.merge||``;e.dataset.merge=p,n.refs.merge.textContent=yf[p]||``,n.refs.elapsed.textContent=Np(r),e.setAttribute(`aria-label`,`${d}, ${u}`)}function g(e,t){let n=u.get(e);if(!n)return;let{header:r,label:i,count:a,addButton:o,forgetButton:s,rows:c}=n,l=t.key===eU,d=t.rows.length===0;e.dataset.path=t.key,e.dataset.label=t.label,e.toggleAttribute(`data-empty`,d),r.title=t.title,i.textContent=t.label,a.textContent=String(t.rows.length),a.title=`${t.rows.length} ${t.rows.length===1?`session`:`sessions`}`,o.hidden=l,s.hidden=l||!d,l||(o.title=`Add a session to ${t.label}`,o.setAttribute(`aria-label`,`Add a session to ${t.label}`)),!l&&d&&(s.title=`Remove ${t.label} from the Board`,s.setAttribute(`aria-label`,`Remove ${t.label} from the Board`)),c.setAttribute(`aria-label`,`${t.label} sessions`)}let{noteStates:_,acknowledge:v,isUnseen:y}=oU();function ee(){let e=EI();_(e);for(let t of e)t.unseen=y(t.id);return _j(e)}function b(){let e=ee(),t=S0(e,C0,hI(e,C0));f=xj(e),r.textContent=Sj(f),r.toggleAttribute(`data-lit`,f>0);let n=new Set(t.order),i=t.order.join(`,`),_=d.get(a)===i&&a.childElementCount===t.groups.length;for(let e of t.groups){let t=c.get(e.key);t||(t=m(e.key),c.set(e.key,t)),g(t,e),_||a.appendChild(t);let n=e.rows.map(e=>e.id).join(`,`),r=u.get(t);if(!r)continue;let i=d.get(r.rows)===n&&r.rows.childElementCount===e.rows.length;for(let t of e.rows){let e=s.get(t.id);e||(e=p(t.id),s.set(t.id,e)),h(e,t);let n=l.get(e);n&&(i||r.rows.appendChild(n.item))}d.set(r.rows,n)}d.set(a,i);for(let[e,t]of[...c])n.has(e)||(t.remove(),c.delete(e));let v=new Set(t.visibleIds);for(let[e,t]of[...s]){if(v.has(e))continue;let n=l.get(t);n&&n.item.remove(),s.delete(e)}let y=t.groups.length>0;a.hidden=!y,o.hidden=y}Ip(()=>{for(let[e,t]of s){let n=U.get(e),r=l.get(t);n&&r&&(r.refs.elapsed.textContent=Np(n))}});function te(e){i.hidden=!e,t.toggleAttribute(`data-calm`,e)}return{el:t,topBarEl:n,calmEl:i,setCalmShown:te,refresh:b,acknowledge:v,getAttentionCount:()=>f}}var T0=`glimmervoidCalmSheet`,E0=Object.freeze({[T0]:!0});function D0(e){return typeof e!=`object`||!e?!1:T0 in e}function O0({poppedState:e,isCalmSheetOpen:t,isOwnSheetPopPending:n}){if(n)return`own-sheet-pop`;let r=D0(e);return r&&t?`adopt-sheet-entry`:r?`consume-stray-sheet-entry`:t?`close-sheet`:`navigate`}function k0({pushedEntry:e,isOwnSheetPopPending:t}){return e===`none`?t?`defer-until-own-pop`:`push-sheet-entry`:`keep-history`}function A0({pushedEntry:e,topState:t,isOwnSheetPopPending:n}){return!n&&e===`calm-sheet`&&D0(t)}var j0=`clipboard`,M0=`upload`,N0=Object.freeze([Object.freeze({id:`esc`,label:`Esc`,bytes:`\x1B`,title:`Send Escape`}),Object.freeze({id:`tab`,label:`Tab`,bytes:` `,title:`Send Tab`}),Object.freeze({id:`up`,label:`Up`,bytes:`\x1B[A`,title:`Arrow up`}),Object.freeze({id:`down`,label:`Down`,bytes:`\x1B[B`,title:`Arrow down`}),Object.freeze({id:`paste`,label:`Paste`,bytes:null,action:j0,title:`Paste from the clipboard`}),Object.freeze({id:`upload-image`,label:`Image`,bytes:null,action:M0,accept:`image/*`,title:`Upload an image to this session`}),Object.freeze({id:`upload-file`,label:`File`,bytes:null,action:M0,title:`Upload a file to this session`})]);function P0(e){let t=N0.find(t=>t.id===e);return t?t.bytes:null}function F0(e){return!!e&&e.action===`clipboard`}function I0(e){return!!e&&e.action===`upload`}function L0({send:e,getSessionId:t}){let n=V(`div`,`phone-key-strip`);n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Terminal keys`);let r=null,i=null;for(let e of N0){let t=V(`button`,`phone-key`,e.label);t.type=`button`,t.dataset.key=e.id,t.title=e.title,t.addEventListener(`pointerdown`,e=>e.preventDefault()),t.addEventListener(`click`,()=>a(e,t)),n.appendChild(t)}function a(t,n){if(I0(t)){o(t,n);return}if(F0(t)){z0(e);return}e(P0(t.id))}function o(e,t){i=t,r||(r=V(`input`,`phone-file-picker`),r.type=`file`,r.hidden=!0,r.addEventListener(`change`,s),n.appendChild(r)),e.accept&&(r.accept=e.accept),e.accept||r.removeAttribute(`accept`),r.click()}function s(){let e=r;if(!e)return;let n=e.files?e.files[0]:null;if(e.value=``,!n)return;let a=t?.();if(!a){WS(`No session is open to upload to`);return}c(a,n,i)}async function c(e,t,n){n&&(n.disabled=!0);let r={"x-glimmervoid-upload-name":encodeURIComponent(t.name)};t.type&&(r[`content-type`]=t.type);try{let n=await fetch(`/upload/${encodeURIComponent(e)}`,{method:`POST`,body:t,headers:r});n.ok||WS(await R0(n))}catch{WS(`Upload failed`)}finally{n&&(n.disabled=!1)}}return n}async function R0(e){try{let t=await e.json();if(t&&typeof t.error==`string`)return`Upload failed: ${t.error}`}catch{}return`Upload failed`}function z0(e){let t=null;try{t=navigator.clipboard?.readText?.()}catch{WS(`Paste needs clipboard permission`);return}if(!t){WS(`Paste is unavailable in this browser`);return}t.then(t=>{t&&e(t)}).catch(()=>WS(`Paste needs clipboard permission`))}var B0=`‹`;function V0({onBack:e}){let t=V(`div`,`phone-terminal`),n=V(`header`,`phone-topbar phone-terminal-bar`),r=V(`button`,`phone-back`,B0);r.type=`button`,r.setAttribute(`aria-label`,`Back to board`),r.addEventListener(`click`,()=>e?.());let i=V(`div`,`phone-terminal-identity`),a=V(`span`,`phone-terminal-name`);a.title=`Tap to rename`,a.addEventListener(`click`,()=>b());let o=V(`span`,`session-task-title session-list-task-title`);LV(o,()=>te());let s=V(`span`,`phone-terminal-identity-line`),c=V(`span`,`phone-terminal-badge`);c.innerHTML=`<span class="phone-terminal-glyph" aria-hidden="true"></span><span class="phone-terminal-label"></span><span class="phone-terminal-elapsed" aria-hidden="true"></span>`;let l=H(c,`.phone-terminal-glyph`,`span`),u=H(c,`.phone-terminal-label`,`span`),d=H(c,`.phone-terminal-elapsed`,`span`);s.append(a,o),i.append(s,c);let f=V(`div`,`phone-terminal-actions`);n.append(r,i,f);let p=V(`div`,`phone-card-slot`),m=V(`div`,`phone-empty`);m.innerHTML=`<p class="phone-empty-title">No session selected</p><p class="phone-empty-desc">Select a session from the board to watch it here.</p>`;let h=L0({send:y,getSessionId:()=>g});t.append(n,p,m,h);let g=null,_=null,v=null;function y(e){let t=g?U.get(g):null;t&&(vA(t,e)||WS(`Session is not connected; key press was dropped`))}function ee(){let e=g?U.get(g):null;e?.term&&e.term.focus()}p.addEventListener(`click`,ee);function b(){let e=g?U.get(g):null;e&&g&&HV(e,g)}function te(){let e=g?U.get(g):null;e&&g&&zV(e,g)}function ne(){let e=g?U.get(g):null,t=!!e;if(m.hidden=t,p.hidden=!t,h.hidden=!t,i.hidden=!t,!t){n.removeAttribute(`data-state`),n.removeAttribute(`data-monitoring`);return}let r=e.currentState||F.DORMANT;n.dataset.state=r;let{glyph:s,label:c,isMonitoring:f}=xf(r,e.awaitingBackgroundTasks);n.toggleAttribute(`data-monitoring`,f),VV(a)||(a.textContent=e.card?.dataset.session||g),RV(o,e.taskTitle),l.textContent=s,u.textContent=c,d.textContent=Np(e)}function re(){v&&=(delete v.renameTargetEl,delete v.titleTargetEl,null),a.replaceChildren(),_&&=(kf(_),_.parentElement===f&&_.remove(),null)}function ie(e){let t=U.get(e);if(t){if(g===e&&DP()===e&&t.card.parentElement===p){ne();return}re(),g=e,OP(t,e,p,{className:`phone-centered`}),_=H(t.card,`.session-actions`,`div`),Of(_,f),t.renameTargetEl=a,t.titleTargetEl=o,v=t,ne()}}function ae(){re(),DP()===g&&kP(),g=null,ne()}function x(){if(!g){ne();return}let e=U.get(g);if(!e){ae();return}if(e.card.parentElement!==p){ie(g);return}ne()}function oe(){let e=g;e&&TA(U.get(e),e,!1)}function se(){x();let e=g;if(!e)return;let t=U.get(e);t&&TA(t,e,!0)}return Ip(()=>{let e=g?U.get(g):null;e&&(d.textContent=Np(e))}),ne(),{el:t,show:ie,clear:ae,refresh:x,reveal:se,unview:oe,getSessionId:()=>g}}var H0=`board`,U0=Object.freeze([{id:H0,label:`Board`,glyph:`▤`},{id:`terminal`,label:`Terminal`,glyph:`▸`},{id:`review`,label:`Review`,glyph:`◫`}]),W0=[],G0=new Map,K0=null,q0=new Map,J0=new Map,Y0=new Map,X0=null,Z0=null,Q0=null,$0=null,e2=null,t2=new Map,n2=new Set,r2={},i2=!1,a2=120,o2=0,s2=0,c2=`none`,l2=!1,u2=!1,d2=!1,f2={openTerminal:T2,openPlan:e=>{U2(e)},onSheetOpenChange:j2};function p2(){o2=0,s2=0}function m2(){let e=window.visualViewport;if(K0){if(!i2||!e){K0.removeAttribute(`data-keyboard`);return}if(K0.style.setProperty(`--phone-vh`,`${e.height}px`),K0.style.setProperty(`--phone-vv-top`,`${e.offsetTop}px`),e.width!==s2&&(s2=e.width,o2=0),o2=Math.max(o2,e.height),o2-e.height>a2){K0.dataset.keyboard=`open`;return}K0.removeAttribute(`data-keyboard`)}}function h2(e,t,n=`phone-nav-item`,r=`phone-nav-dot`){let i=V(`button`,n);i.type=`button`;let a=V(`span`,`phone-nav-glyph`,t);a.setAttribute(`aria-hidden`,`true`),i.append(a,V(`span`,`phone-nav-label`,e));let o=V(`span`,r);return o.setAttribute(`aria-hidden`,`true`),o.hidden=!0,i.appendChild(o),i}function g2(e){return e?.querySelector(`.phone-nav-dot`)||null}function _2(e,t){e&&(e.hidden=!t,typeof t==`string`&&(e.dataset.attention=t),typeof t!=`string`&&delete e.dataset.attention)}function v2(){let e=[];for(let t of W0){if(n2.has(t.id))continue;let n=Y0.get(t.id)||!1;e.push(n),_2(g2(t2.get(t.id)),n)}_2(g2($0),bie(e))}function y2(){let e=V(`div`,`phone-nav-more-menu`);e.hidden=!0;for(let t of W0){let n=h2(t.label,t.glyph,`phone-nav-menu-item`,`phone-nav-dot phone-nav-menu-dot`);n.dataset.screen=t.id,n.hidden=n2.has(t.id),n.addEventListener(`click`,()=>{b2(!1),L2(t.id)}),t2.set(t.id,n),e.appendChild(n)}return e}function b2(e){e2&&$0&&(e2.hidden=!e,$0.setAttribute(`aria-expanded`,String(e)))}function x2(){return!!e2&&!e2.hidden}function S2(){let e=V(`nav`,`phone-nav`);e.setAttribute(`aria-label`,`Screens`);for(let t of U0){let n=h2(t.label,t.glyph);n.dataset.screen=t.id,n.addEventListener(`click`,()=>L2(t.id)),q0.set(t.id,n),e.appendChild(n)}return $0=h2(`More`,`⋯`),$0.setAttribute(`aria-expanded`,`false`),$0.addEventListener(`click`,()=>b2(!x2())),e.appendChild($0),e2=y2(),e.appendChild(e2),e}function C2(e,t,n){let r=V(`section`,`phone-screen`);return r.dataset.screen=e,r.setAttribute(`aria-label`,t),r.hidden=!0,n&&r.appendChild(n),J0.set(e,r),r}function w2(){if(K0)return;X0=w0({onSelectSession:T2}),X0.setCalmShown(d2),Z0=V0({onBack:()=>L2(H0)}),Q0=V(`div`,`phone-review`);let e=V(`div`,`phone-screens`),t={[H0]:X0.el,terminal:Z0.el,review:Q0};for(let n of U0)e.appendChild(C2(n.id,n.label,t[n.id]));for(let t of W0){let n=V(`div`,`phone-panel phone-${t.id}`);G0.set(t.id,n),e.appendChild(C2(t.id,t.label,n))}K0=V(`div`,`phone-shell`),K0.id=`phone-shell`,K0.append(e,S2()),document.body.appendChild(K0),v2(),window.visualViewport?.addEventListener(`resize`,m2),window.visualViewport?.addEventListener(`scroll`,m2),window.addEventListener(`popstate`,N2),document.addEventListener(`click`,e=>{x2()&&e2&&$0&&e.target instanceof Node&&(e2.contains(e.target)||$0.contains(e.target)||b2(!1))}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&x2()&&b2(!1)})}function T2(e){if(U.has(e)){if(!X0||!Z0)throw Error(`Phone shell is not built`);CI(e,`dormant-fallback`),X0.acknowledge(e),wI(e),Z0.show(e),L2(`terminal`)}}function E2(e){if(e===H0){O2();return}let t={glimmervoidScreen:e};if(c2!==`none`){history.replaceState(t,``),c2=`screen`;return}history.pushState(t,``),c2=`screen`}function D2(){if(D0(history.state))return c2=`calm-sheet`,A2(),H0;let e=M2(history.state);return e&&I2(e)?(c2=`screen`,e):(e&&history.replaceState(null,``),c2=`none`,H0)}function O2(){c2!==`none`&&(c2=`none`,history.back())}function k2(){k0({pushedEntry:c2,isOwnSheetPopPending:u2})===`push-sheet-entry`&&(history.pushState(E0,``),c2=`calm-sheet`)}function A2(){A0({pushedEntry:c2,topState:history.state,isOwnSheetPopPending:u2})&&(c2=`none`,u2=!0,history.back())}function j2(e){if(l2=e,e){k2();return}A2()}function M2(e){let t=e?.glimmervoidScreen;return typeof t==`string`?t:null}function N2(e){let t=u2;if(u2=!1,!i2)return;let n=O0({poppedState:e.state,isCalmSheetOpen:l2,isOwnSheetPopPending:t});if(n===`own-sheet-pop`){l2&&k2();return}if(n===`adopt-sheet-entry`){c2=`calm-sheet`;return}if(n===`consume-stray-sheet-entry`){c2=`calm-sheet`,A2();return}if(n===`close-sheet`){c2=`none`,bP();return}let r=M2(e.state);c2=r?`screen`:`none`,F2(r&&I2(r)?r:H0)}function P2(e,t){for(let[n,r]of e){if(n===t){r.setAttribute(`aria-current`,`page`);continue}r.removeAttribute(`aria-current`)}}function F2(e){if(!$0||!Z0)throw Error(`Phone shell is not built`);Lf.dispatch(`setPhoneScreen`,e),b2(!1);for(let[t,n]of J0)n.hidden=t!==e;r2.onScreenShown?.(e),V2(),P2(q0,e);let t=t2.has(e);if(t&&$0.setAttribute(`aria-current`,`page`),t||$0.removeAttribute(`aria-current`),P2(t2,e),e===`terminal`){Z0.reveal();return}Z0.unview()}function I2(e){return J0.has(e)&&!n2.has(e)}function L2(e){K0&&I2(e)&&(e!==Lf.snapshot().phoneScreen&&E2(e),F2(e))}function R2(e){r2=e||{},W0=r2.panels||[]}function z2({sessionId:e}={}){if(i2)return;if(w2(),!K0||!X0||!Z0)throw Error(`Phone shell is not built`);i2=!0,K0.hidden=!1;for(let e of r2.headerControls||[])Of(e,X0.topBarEl);az(Q0);for(let e of W0)Of(e.el,G0.get(e.id)),e.el.hidden=!1;m2(),e&&Z0.show(e);let t=D2();if(K2(),e&&t===H0){Lf.dispatch(`setPhoneScreen`,H0),L2(`terminal`);return}F2(t)}function B2(){if(i2){if(!K0||!Z0)throw Error(`Phone shell is not built`);i2=!1,V2(),s0({returnFocus:!1}),Z0.clear(),az(null);for(let e of W0)kf(e.el);for(let e of r2.headerControls||[])kf(e);b2(!1),K0.hidden=!0,K0.removeAttribute(`data-keyboard`),p2(),O2()}}function V2(){if(X0){if(!(i2&&d2&&Lf.snapshot().phoneScreen===H0)){xP();return}yP(X0.calmEl,f2)}}function H2(e){d2=e,X0?.setCalmShown(e),V2()}function U2(e){return!i2||!X0||!Z0||!U.has(e)?!1:(T2(e),EH(e))}function W2(){return i2}function G2(){return i2&&Z0?Z0.getSessionId():null}function K2(){if(!i2)return;if(!X0||!Z0)throw Error(`Phone shell is not built`);X2(),X0.refresh(),Z0.refresh(),Lf.snapshot().phoneScreen===`terminal`&&!Z0.getSessionId()&&L2(H0);let e=g2(q0.get(H0));e&&(e.hidden=X0.getAttentionCount()===0)}function q2(e){return!i2||!I2(e)?!1:(L2(e),!0)}function J2(e,t){t&&n2.delete(e),t||n2.add(e);let n=t2.get(e);n&&(n.hidden=!t);let r=J0.get(e);r&&!t&&(r.hidden=!0),v2(),!t&&i2&&Lf.snapshot().phoneScreen===e&&L2(H0)}function Y2(e,t){Y0.set(e,typeof t==`string`&&t?t:t===!0),v2()}function X2(){if(!Z0)throw Error(`Phone shell is not built`);if(Z0.getSessionId())return;let e=TI();e&&(Z0.show(e),wI(e,{rememberFocus:!1}))}function Z2(e,t){return!!e?.error&&!e.isRefreshing&&typeof e.nextAttemptAt==`number`&&e.nextAttemptAt>t}function Q2(e,t){if(!e?.error)return null;let n=`Could not reach GitHub: ${e.error.trim().replace(/[.!]+$/,``)}.`;if(e.isRefreshing)return`${n} Refreshing.`;if(typeof e.nextAttemptAt!=`number`)return n;let r=Math.max(0,Math.ceil((e.nextAttemptAt-t)/1e3));return r===0?`${n} Retrying now.`:e.retry?`${n} Retrying in ${r}s (${e.retry.attempt} of ${e.retry.limit}).`:`${n} Next try in ${r>=60?`${Math.ceil(r/60)} min`:`${r}s`}.`}function $2(e,t,n){return e?.refreshNotice&&e.isRefreshing?e.refreshNotice:t||e?.isRefreshing?`Refreshing.`:n||e?.refreshNotice||``}var e4={minPx:220,maxPx:720},t4=16,n4=new Set,r4=0;function i4(e){let t=sk();e.toggleAttribute(`data-queue-collapsed`,t),e.querySelector(`.pr-queue-toggle`)?.setAttribute(`aria-expanded`,String(!t));let n=ak();if(n===null){e.style.removeProperty(`--pr-queue-width`);return}e.style.setProperty(`--pr-queue-width`,`${n}px`)}function a4(){for(let e of n4){if(!e.isConnected){n4.delete(e);continue}i4(e)}}function o4(e,t){let n=V(`div`,`pr-queue-head`);return e&&n.append(e),t&&n.append(t),n}function s4(e){let t=V(`div`,`pr-queue-foot`);return e&&t.append(e),t}function c4({queueLabel:e,scopeTabs:t,resizerLabel:n}){let r=V(`div`,`pr-columns`),i=V(`div`,`pr-queue-pane`),a=V(`nav`,`pr-queue`);a.id=`pr-queue-${++r4}`,a.setAttribute(`aria-label`,e);let o=V(`button`,`pr-queue-toggle`);o.type=`button`,o.setAttribute(`aria-label`,`Review queue`),o.setAttribute(`aria-controls`,a.id),o.title=`Collapse or expand the review queue`;let s=WL(16,16);s.append(UL(`rect`,{x:`1.5`,y:`2`,width:`13`,height:`12`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),s.append(UL(`path`,{d:`M5.5 2V14`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`}));let c=UL(`path`,{d:`M11 6L9 8L11 10`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`,"stroke-linejoin":`round`});c.classList.add(`pr-queue-chevron`),s.append(c),o.append(s),o.addEventListener(`click`,()=>{ck(!sk()),a4()});let l=s4(null);i.append(o4(t,o),a,l);let u=V(`div`,`pr-queue-resizer`);u.setAttribute(`role`,`separator`),u.setAttribute(`aria-orientation`,`vertical`),u.setAttribute(`aria-label`,n),u.tabIndex=0;let d=V(`main`,`pr-detail-host`);return r.append(i,u,d),i4(r),n4.add(r),dI({resizer:u,column:i,widthHost:r,widthProperty:`--pr-queue-width`,bounds:e4,keyStepPx:t4,getStoredWidth:ak,setStoredWidth:ok}),{columns:r,queue:a,foot:l,detail:d}}var l4=1.2,u4=1.55,d4=.12,f4=523.25,p4=2,m4=8,$=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),h4={melody:[$(7,4,.5),$(11,4.5,.5),$(12,5,3)],bass:[$(-5,4,1),$(-12,5,3)]},g4=[{melody:[$(0,0,1),$(4,1,1),$(7,2,1),$(9,3,1)],bass:[$(-12,0,2),$(-8,2,2)]},{melody:[$(7,0,.67),$(7,.67,.67),$(7,1.33,.67),$(9,2,1),$(5,3,1)],bass:[$(-12,0,2),$(-7,2,2)]},{melody:[$(5,0,1),$(9,1,1),$(7,2,1),$(4,3,1)],bass:[$(-7,0,2),$(-12,2,2)]},{melody:[$(12,0,.5),$(7,.5,.5),$(12,1,.5),$(16,1.5,.5),$(16,2,1),$(14,3,1)],bass:[$(-12,0,2),$(-3,2,2)]},{melody:[$(4,0,1),$(7,1,1),$(4,2,.5),$(5,2.5,.5),$(7,3,.5),$(4,3.5,.5)],bass:[$(-8,0,2),$(-12,2,2)]}].map(e=>({melody:[...e.melody,...h4.melody],bass:[...e.bass,...h4.bass]}));function _4(e,t){return f4*2**((e+t)/12)}function v4(e,t){let n=(e,n,r)=>e.map(e=>({frequency:_4(e.semitone,t),startSeconds:u4+e.startBeat*d4,durationSeconds:e.beats*d4,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var y4=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:l4,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:l4,durationSeconds:.06,waveform:`square`,gain:.12}];function b4(e){let t=g4[e%g4.length],n=Math.min(e*p4,m4);return{peakGain:.1,tones:[...y4,...v4(t,n)]}}function x4(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function S4(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function C4(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var w4=.6,T4=.25,E4=1.6;function D4(e){return Math.min(w4+e*T4,E4)}var O4=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function k4(e,t=Math.random){let n=S4(320,520,t),r=S4(1800,2800,t);return[[`--confetti-start-x`,`${S4(4,96,t)}%`],[`--confetti-x`,`${S4(-140,140,t)}px`],[`--confetti-rise`,`${-S4(20,55,t)}px`],[`--confetti-fall`,`${S4(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${S4(0,180,t)}deg`],[`--confetti-spin`,`${S4(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${S4(160,340,t)}ms`],[`--confetti-delay`,`${S4(0,160,t)}ms`],[`--confetti-color`,O4[e%O4.length]]]}var A4=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,j4=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function M4(){let e=pf(`div`,`merge-bullseye-target`,A4);return e.append(V(`span`,`merge-bullseye-ripple`)),e}function N4(){let e=V(`div`,`merge-bullseye-dart-drift`),t=V(`div`,`merge-bullseye-dart-arc`),n=V(`div`,`merge-bullseye-dart-aim`);return n.append(pf(`div`,`merge-bullseye-dart`,j4)),t.append(n),e.append(t),e}function P4(){let e=V(`div`,`merge-bullseye-range`),t=V(`div`,`merge-bullseye-track`);return t.append(N4()),e.append(M4(),t),e}var F4={title:`BULLSEYE!`,buildScene:P4},I4=6,L4=30,R4=-14,z4=16;function B4(e=Math.random){return[[`--crosshair-start-left`,`${S4(I4,L4,e)}%`],[`--crosshair-start-offset-y`,`${S4(R4,z4,e)}px`]]}var V4=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,H4=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,U4=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function W4(){let e=V(`div`,`merge-headshot-sweep`);mf(e,B4());let t=V(`div`,`merge-headshot-aim`);t.append(pf(`div`,`merge-headshot-crosshair`,H4));let n=V(`div`,`merge-headshot-bob`);return n.append(t,pf(`div`,`merge-headshot-hitmarker`,U4)),e.append(n),e}function G4(){let e=V(`div`,`merge-headshot-range`),t=V(`div`,`merge-headshot-track`);return t.append(W4()),e.append(pf(`div`,`merge-headshot-target`,V4),t),e}var K4={title:`HEADSHOT!`,buildScene:G4},q4=[`10`,`J`,`Q`,`K`,`A`],J4=19,Y4=5,X4=9,Z4=780,Q4=70,$4=70,e3=35;function t3(e){let t=q4.length-1,n=e-t/2;return{offsetPx:n*J4,titleSpreadFraction:n/t,tiltDegrees:n*Y4,bottomPx:X4-n**2,dealLeadMs:Z4-e*Q4,flipLeadMs:160+(t-e)*$4,waveDelayMs:e*e3}}function n3(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function coe(){return[[`--card-flip-ms`,`160ms`]]}var loe=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function uoe(e,t){let n=V(`div`,`merge-flush-deal`);mf(n,n3(t3(t)));let r=V(`div`,`merge-flush-hop`),i=V(`div`,`merge-flush-card`),a=V(`div`,`merge-flush-face`);return a.append(V(`span`,`merge-flush-rank`,e)),a.insertAdjacentHTML(`beforeend`,loe),i.append(V(`div`,`merge-flush-back`),a),r.append(i),n.append(r),n}function doe(){let e=V(`div`,`merge-flush-table`);return mf(e,coe()),e.append(...q4.map(uoe)),e}var foe={title:`ROYAL FLUSH!`,buildScene:doe},poe=[1,2,3,4],moe=14,hoe=3,goe=3,r3=10,_oe=20,voe=2,i3=28,a3=18,yoe=.01,boe=1.5,xoe=2200,Soe=1,o3=120,s3=.35,Coe=4,woe=65,Toe=145;function Eoe(e){return Math.round(e/(Math.PI*a3)*360)}function c3(e){return _oe-e*voe}function l3(e){return e.rowIndex*moe+e.depthIndex*hoe}function u3(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function d3(){return poe.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function Doe(e,t){let n=C4(u3(15,105,e),t),r=C4(u3(woe,Toe,e),t);return n.map((e,n)=>({angleDegrees:e+S4(-4,Coe,t),depthScalePercent:Math.round(r[n])}))}function Ooe(e,t,n){let r=S4(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=S4(15,45,n),c=x4(o),l=x4(o+s),u=c+l,d=S4(540,1080,n),f=a>=0?1:-1,p=l3(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:c3(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/s3)}}function koe(e=Math.random){let t=d3(),n=Doe(t.length,e);return t.map((t,r)=>Ooe(t,n[r],e))}function Aoe(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*goe}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function joe(){return c3(boe)}function Moe(){return Math.max(...d3().map(l3))+r3}function Noe(){let e=Moe(),t=i3+e+a3-Soe;return[[`--ball-follow-px`,`${o3}px`],[`--ball-follow-ms`,`${Math.round(o3/s3)}ms`],[`--ball-follow-spin`,`${Eoe(o3)}deg`],[`--ball-size`,`${a3}px`],[`--ball-approach-spin`,`${xoe}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(joe())],[`--rack-right`,`${i3}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${r3}px`]]}function Poe(e=Math.random){return e()>=yoe?null:iO[Math.floor(e()*iO.length)].sprite}var Foe=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function Ioe(e){let t=V(`span`,`merge-strike-pin`);return t.append(pf(`span`,`merge-strike-pin-arc`,Foe)),mf(t,Aoe(e)),t}function Loe(){let e=Poe();if(!e)return V(`span`,`merge-strike-ball`);let t=V(`span`,`merge-strike-ball is-animal`);return t.append(V(`span`,`nyan-sprite ${e}`)),t}function Roe(){let e=V(`div`,`merge-strike-lane`);mf(e,Noe());let t=V(`div`,`merge-strike-rack`);t.append(...koe().map(Ioe));let n=V(`div`,`merge-strike-track`);return n.append(Loe()),e.append(t,n),e}var zoe={title:`STRIKE!`,buildScene:Roe},Boe=20,Voe=92,Hoe=23,Uoe=7,Woe=-40;function Goe(){let e=x4(72),t=x4(69),n=780*t/1e3;return{launchHeightPx:Boe,peakHeightPx:Voe,heightThroughRimPx:Hoe,heightLeavingNetPx:Uoe,heightOutOfCardPx:Woe,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:x4(47)}}function Koe(e=Goe()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var qoe=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,Joe=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function Yoe(){let e=V(`div`,`merge-swish-ball-drift`),t=V(`div`,`merge-swish-ball-arc`);return t.append(V(`span`,`merge-swish-ball`)),e.append(t),e}function Xoe(){let e=V(`div`,`merge-swish-court`);mf(e,Koe());let t=V(`div`,`merge-swish-track`);return t.append(Yoe()),e.append(pf(`div`,`merge-swish-hoop-back`,qoe),t,pf(`div`,`merge-swish-hoop-front`,Joe)),e}var f3=[zoe,{title:`SWISH!`,buildScene:Xoe},F4,K4,foe],Zoe=48,p3=5600,Qoe=20,m3=null,h3=[],g3=null,_3=!1,v3=0;function $oe(e){let t=V(`span`,`merge-confetti-piece`),n=V(`span`,`merge-confetti-arc`);return n.append(V(`span`,`merge-confetti-paper`)),t.append(n),mf(t,k4(e)),t}function ese(e){let t=V(`p`,`merge-celebration-title`);return t.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,n)=>{let r=V(`span`,`merge-celebration-letter`,e);r.style.setProperty(`--letter-delay`,`${n*45}ms`),t.append(r)}),t}function tse(e,t){let n=t.firstElementChild,r=t.lastElementChild;n instanceof HTMLElement&&r instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${r.offsetLeft+r.offsetWidth-n.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2}px`))}function nse(e){let t=V(`div`,`merge-celebration-scene`);return t.setAttribute(`aria-hidden`,`true`),t.append(e.buildScene()),t}function rse(){return f3[Math.floor(Math.random()*f3.length)]}function ise(e){if(LO())try{Ex(b4(e))}catch{}}function ase(e,t,n){m3?.remove(),ise(n);let r=V(`div`,`merge-celebration`);r.setAttribute(`role`,`status`);let i=V(`div`,`merge-celebration-card`),a=V(`div`,`merge-celebration-stage`),o=ese(t.title);a.append(o,V(`p`,`merge-celebration-message`,e),nse(t));let s=V(`div`,`merge-confetti`);s.style.setProperty(`--confetti-scale`,String(D4(n)));for(let e=0;e<Zoe;e+=1)s.append($oe(e));i.append(s,a),r.append(i),document.body.append(r),tse(a,o),m3=r,window.setTimeout(()=>{r.remove(),m3===r&&(m3=null)},p3)}function ose(e){return _3?`playing`:e?`queued`:`empty`}function y3(){if(!g3)return;let e=h3.length>0;g3.tray.dataset.state=ose(e),g3.count.textContent=e?String(h3.length):``,g3.button.disabled=_3||!e}function b3(){let e=h3.shift();_3=e!==void 0,y3(),e&&(ase(e.message,e.scene,v3),v3+=1,window.setTimeout(b3,p3))}function sse(e,t,n){g3={tray:e,button:t,count:n},t.addEventListener(`click`,()=>{v3=0,b3()}),y3()}function cse(e,t=rse()){h3.push({message:e,scene:t}),h3.length>Qoe&&h3.shift(),y3()}var lse={MERGE:`a merge commit`,SQUASH:`squash and merge`,REBASE:`rebase and merge`},use=new Set([`FAILURE`,`ERROR`]);function x3(e){return lse[e]}function dse(e){return e.state===`MERGED`?`Already merged`:e.state===`OPEN`?e.isDraft?`Drafts cannot be merged`:e.isInMergeQueue?`Already in the merge queue`:e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?`Resolve the merge conflicts first`:e.checks.failing.length>0||e.checks.state!==null&&use.has(e.checks.state)?`Checks are failing`:e.stage===`ready`?null:`Not ready to merge yet`:`Closed`}function S3(e,t,n,r,i,a){return{isVisible:a&&(e.state===`OPEN`||t),isPressed:t,isDisabled:n,statusText:r||(n?`Saving...`:i)}}function fse(e,t,n=``){if(!t||!e.keepMergeable)return null;let r=C3(e,!1,``,!0,n).statusText;if(e.isKeepMergeableFixInFlight)return{text:`Repairing`,tone:`warn`,title:r};let i=e.keepMergeableAttempt;return!i||i.outcome===`pushed`||i.outcome===`stopped`?null:{text:`Repair failed`,tone:`danger`,title:r}}function C3(e,t,n=``,r=!0,i=``){let a=e.keepMergeableAttempt,o=e.keepMergeable?`On`:`Off`;if(e.keepMergeable&&a&&a.outcome!==`pushed`&&a.outcome!==`stopped`){let e=i?` (${i})`:``;o=`Keep mergeable failed: ${a.reason??`The attempt produced no repair`}${e}`}return e.isKeepMergeableFixInFlight&&(o=`Keep mergeable is running`),S3(e,!!e.keepMergeable,t,n,o,r)}function pse(e){return e?.isKeepMergeableEnabled!==!1}function mse(e){return e?.isMergeQueueEnabled!==!1}var hse={one:`st`,two:`nd`,few:`rd`,other:`th`},gse=new Intl.PluralRules(`en-US`,{type:`ordinal`});function _se(e){return`${e}${hse[gse.select(e)]??`th`}`}function vse(e,t){return e===null?`Not queued`:t?`Repair pushed, waiting for you`:`Queued, ${_se(e)} in line for this repository`}function yse(e,t,n=``,r=!0){let i=e.mergeQueuePosition??null;return S3(e,i!==null,t,n,vse(i,!!e.isMergeQueueHeldForRepairPush),r)}var w3=[`Needs you`,`Waiting`,`Ready to merge`,`Drafts`,`Merged today`],bse=[`Ready to merge`,`Needs you`,`Waiting`,`Drafts`,`Merged today`],xse={conflicts:`Needs you`,behind:`Needs you`,"checks-failing":`Needs you`,"changes-requested":`Needs you`,"unresolved-threads":`Needs you`,"checks-pending":`Waiting`,"needs-approval":`Waiting`,unknown:`Waiting`,ready:`Ready to merge`,draft:`Drafts`,merged:`Merged today`},Sse={merged:`Merged`,draft:`Draft`,conflicts:`Merge conflicts`,behind:`Behind base`,"checks-failing":`Checks failing`,"changes-requested":`Changes requested`,"unresolved-threads":`Unresolved threads`,"checks-pending":`Checks running`,"needs-approval":`Needs approval`,ready:`Ready to merge`,unknown:`Status unknown`},Cse={merged:`muted`,draft:`muted`,conflicts:`danger`,behind:`warn`,"checks-failing":`danger`,"changes-requested":`warn`,"unresolved-threads":`warn`,"checks-pending":`wait`,"needs-approval":`wait`,ready:`ok`,unknown:`muted`},wse={merged:`merged`,draft:`draft`,conflicts:`conflict`,behind:`behind`,"checks-failing":`failed`,"changes-requested":`changes-requested`,"unresolved-threads":`thread`,"checks-pending":`running`,"needs-approval":`reviewer`,ready:`ready`,unknown:`unknown`};function Tse(e){let t=Mu.safeParse(e);return t.success?t.data:null}function Ese(e){let t=e.filter(e=>e.state===`OPEN`&&!e.isCrossRepository),n=new Map(t.map(e=>[JSON.stringify([e.repo.toLowerCase(),e.headRefName]),e])),r=new Map,i=[];for(let t of e){let e=t.state===`OPEN`?n.get(JSON.stringify([t.repo.toLowerCase(),t.baseRefName])):void 0;if(!e||e.key===t.key){i.push(t);continue}let a=r.get(e.key)??[];a.push(t),r.set(e.key,a)}let a=[],o=new Set;for(let t of[...i,...e]){if(o.has(t.key))continue;let e=[],n=[{pr:t,parentKey:null,depth:0}];for(;n.length>0;){let t=n.pop();if(!t||o.has(t.pr.key))continue;o.add(t.pr.key),e.push(t);let i=r.get(t.pr.key)??[];for(let e=i.length-1;e>=0;--e)n.push({pr:i[e],parentKey:t.pr.key,depth:t.depth+1})}a.push({root:t,rows:e})}return a}function Dse(e){return w3[e.rows.reduce((e,{pr:t})=>Math.min(e,w3.indexOf(xse[t.stage])),w3.length-1)]}function Ose(e){let t=new Map(w3.map(e=>[e,{title:e,prs:[],rows:[]}]));for(let n of Ese(e)){let e=t.get(Dse(n));if(e)for(let t of n.rows)e.rows.push(t),e.prs.push(t.pr)}return bse.flatMap(e=>t.get(e)??[])}function T3(e){return Sse[e]}function E3(e){return Cse[e]}function D3(e){return wse[e]}function kse(e){if(e.checks.failing.length>0){let t=e.checks.failing.length-3;return{label:`Checks`,tone:`danger`,icon:`failed`,text:`${e.checks.failing.length} failing: ${e.checks.failing.slice(0,3).join(`, `)}${t>0?` and ${t} more`:``}`}}return e.checks.state===`FAILURE`||e.checks.state===`ERROR`?{label:`Checks`,tone:`danger`,icon:`failed`,text:`Failing`}:e.checks.pendingCount>0?{label:`Checks`,tone:`wait`,icon:`running`,text:`${e.checks.pendingCount} running`}:e.checks.state===`PENDING`||e.checks.state===`EXPECTED`?{label:`Checks`,tone:`wait`,icon:`running`,text:`Running`}:e.checks.state===`SUCCESS`?{label:`Checks`,tone:`ok`,icon:`passed`,text:`Passing`}:{label:`Checks`,tone:`muted`,icon:`none`,text:`No checks`}}function O3(e){return`${e} ${e===1?`approval`:`approvals`}`}function k3(e){return e.reviewRequests.map(e=>e.name).join(`, `)}function Ase(e){let t=e.reviewRequests.length>0?`Requested: ${k3(e)}`:`Approval required`;return e.approvals>0?`${t}, ${O3(e.approvals)}`:t}function jse(e){let t=e.approvals>0?O3(e.approvals):`Approved`;return e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`${t}, merge blocked`}:{label:`Review`,tone:`ok`,icon:`passed`,text:t}}function Mse(e){return e.reviewDecision===`CHANGES_REQUESTED`?{label:`Review`,tone:`warn`,icon:`changes-requested`,text:`Changes requested`}:e.reviewDecision===`APPROVED`?jse(e):e.reviewDecision===`REVIEW_REQUIRED`||e.mergeStateStatus===`BLOCKED`?{label:`Review`,tone:`wait`,icon:`reviewer`,text:Ase(e)}:e.reviewRequests.length>0?{label:`Review`,tone:`wait`,icon:`reviewer`,text:`Requested: ${k3(e)}`}:{label:`Review`,tone:`muted`,icon:`none`,text:`No review requested`}}function A3(e,t){return t?e.lastAuthor!==t:null}function Nse(e){let t=e.line===null?e.path:`${e.path}:${e.line}`;return e.isOutdated?`${t} (outdated)`:t}function Pse(e){let t=e.commentCount-1;return t===0?`No replies`:`${t} ${t===1?`reply`:`replies`}, last by ${e.lastAuthor??`a deleted account`}`}function Fse(e,t){let n=A3(e,t);return n===null?null:n?{tone:`warn`,icon:`your-turn`,text:`Waiting on you`}:{tone:`wait`,icon:`reviewer`,text:`Waiting on reviewer`}}function Ise(e,t){return[...e.threads].sort((e,n)=>{let r=Number(A3(n,t)===!0)-Number(A3(e,t)===!0);return r===0?(Date.parse(n.lastActivityAt)||0)-(Date.parse(e.lastActivityAt)||0):r}).map(e=>({location:Nse(e),url:e.url,author:e.author??`a deleted account`,excerpt:e.excerpt,replySummary:Pse(e),lastActivityAt:e.lastActivityAt,waiting:Fse(e,t)}))}function Lse(e,t){if(e.unresolvedThreads===0)return{label:`Threads`,tone:`ok`,icon:`passed`,text:`None open`};let n=`${e.unresolvedThreads} unresolved`;if(!t||e.threads.length===0)return{label:`Threads`,tone:`warn`,icon:`thread`,text:n};let r=e.threads.filter(e=>A3(e,t)).length;return r===0?{label:`Threads`,tone:`wait`,icon:`thread`,text:`${n}, all waiting on reviewers`}:{label:`Threads`,tone:`warn`,icon:`your-turn`,text:`${n}, ${r} waiting on you`}}function Rse(e){return e.mergeable===`CONFLICTING`||e.mergeStateStatus===`DIRTY`?{label:`Conflicts`,tone:`danger`,icon:`conflict`,text:`Conflicts with ${e.baseRefName}`}:e.mergeable===`MERGEABLE`?{label:`Conflicts`,tone:`ok`,icon:`passed`,text:`None`}:{label:`Conflicts`,tone:`muted`,icon:`unknown`,text:`Not computed yet`}}function zse(e){let t=e.behindBy!==null&&e.behindBy>0;return e.mergeStateStatus===`BEHIND`?{label:`Base`,tone:`warn`,icon:`behind`,text:t?`${e.behindBy} behind ${e.baseRefName}`:`Behind ${e.baseRefName}`}:e.behindBy===null?{label:`Base`,tone:`muted`,icon:`unknown`,text:`Unknown`}:t?{label:`Base`,tone:`muted`,icon:`behind`,text:`${e.behindBy} behind ${e.baseRefName}, update not required`}:{label:`Base`,tone:`ok`,icon:`passed`,text:`Up to date with ${e.baseRefName}`}}var Bse={APPROVED:{text:`Approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{text:`Requested changes`,tone:`warn`,icon:`changes-requested`},COMMENTED:{text:`Commented`,tone:`muted`,icon:`thread`},DISMISSED:{text:`Dismissed`,tone:`muted`,icon:`discarded`},PENDING:{text:`Pending`,tone:`wait`,icon:`running`}};function Vse(e){return[...e.reviews].sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).map(e=>{let t=Bse[e.state]??{text:e.state.toLowerCase().replaceAll(`_`,` `),tone:`muted`,icon:`unknown`};return{reviewer:e.reviewer??`a deleted account`,text:t.text,tone:t.tone,icon:t.icon,submittedAt:e.submittedAt}})}function Hse(e,t=null){if(e.state===`MERGED`)return[];let n=[kse(e),Mse(e),Lse(e,t),Rse(e),zse(e)];return e.autoRebase?[...n,e.autoRebase.outcome===`rebased`?{label:`Auto-rebase`,tone:`ok`,icon:`passed`,text:e.autoRebase.message}:{label:`Auto-rebase`,tone:`danger`,icon:`failed`,text:e.autoRebase.message}]:n}function j3(e){return e?e.configured?e.error&&e.prs.length===0?`Pull requests will show here once GitHub answers.`:`No open or recently merged pull requests found.`:`Enable Team review and set its GitHub organization in settings to see your pull requests.`:`Waiting for your pull requests.`}function Use(e,t=0){if(!e)return[];let n=Q2(e,t),r=n?[{text:n,tone:`error`}]:[];return e.truncatedNote?[...r,{text:e.truncatedNote,tone:`info`}]:r}function Wse(e,t){let n=e.flatMap(e=>e.prs);return t&&n.some(e=>e.key===t)?t:n[0]?.key??null}function Gse(e,t){if(!e)return[];let n=new Set(e.filter(e=>e.state===`OPEN`).map(e=>e.key));return t.filter(e=>e.state===`MERGED`&&n.has(e.key))}function Kse(e){return e.length===1?`Merged ${e[0].key}`:`Merged ${e.length} pull requests`}var qse={isVisible:!1,isDisabled:!0,statusText:``,tone:null},Jse={merged:{statusText:`Merged on GitHub. Refreshing the list.`,tone:`ok`},queued:{statusText:`Added to the merge queue. Refreshing the list.`,tone:`ok`},"auto-merge":{statusText:`Auto-merge enabled. GitHub merges it once its requirements pass.`,tone:`ok`},unconfirmed:{statusText:`GitHub accepted the request but did not confirm a merge. Check GitHub.`,tone:null}};function Yse(e,t){if(e.state!==`OPEN`)return qse;let n=t?.head===e.headRefOid?t:void 0;if(n?.phase===`pending`)return{isVisible:!0,isDisabled:!0,statusText:`Merging on GitHub`,tone:`busy`};if(n&&n.phase!==`failed`)return{isVisible:!0,isDisabled:!0,...Jse[n.phase]};let r=dse(e);return r?{isVisible:!0,isDisabled:!0,statusText:r,tone:null}:n?.phase===`failed`?{isVisible:!0,isDisabled:!1,statusText:n.text,tone:`error`}:{isVisible:!0,isDisabled:!1,statusText:`Merges into ${e.baseRefName} with ${x3(e.mergeMethod)}`,tone:null}}function Xse(e){return`Merge ${e.key} "${e.title}" into ${e.baseRefName} with ${x3(e.mergeMethod)}, your default for this repository. Glimmervoid does not delete the branch.`}function Zse(e){let t=Fu.safeParse(e);if(!t.success)return null;let n=e&&typeof e==`object`&&`requestId`in e?e.requestId:null;return typeof n==`string`?{...t.data,requestId:n}:null}var M3=null,N3=null,P3=null,F3=null,I3=null,L3=null,R3=null,z3=new Map,B3=new Set,V3=new Map,H3={label:`Keep mergeable`,pendingKeys:new Set,errorsByKey:new Map,controlState:(e,t,n,r)=>C3(e,t,n,r,JP(e.keepMergeableAttempt?.at)),isFeatureEnabled:pse,save:async(e,t)=>{let n=await of(`my-pr-keep-mergeable`,{repo:e.repo,number:e.number,keepMergeable:t});if(n.type!==`my-pr-keep-mergeable-result`||n.key!==e.key)throw Error(`Unexpected keep mergeable reply.`);return n.ok?null:n.error??`Could not save Keep mergeable.`}},Qse={label:`Merge when ready`,pendingKeys:new Set,errorsByKey:new Map,controlState:yse,isFeatureEnabled:mse,save:async(e,t)=>{let n=await of(`my-pr-merge-when-ready`,{repo:e.repo,number:e.number,mergeWhenReady:t});if(n.type!==`my-pr-merge-when-ready-result`||n.key!==e.key)throw Error(`Unexpected merge when ready reply.`);return n.ok?null:n.error??`Could not save Merge when ready.`}},$se=6e4,ece=`No reply from the server. Check GitHub before trying again.`;function U3(e,t){let n=V(`div`,`reviews-refresh-control`),r=V(`button`,`pr-action reviews-refresh-button`,`Refresh`);r.type=`button`;let i=V(`span`,`reviews-refresh-status`);i.setAttribute(`role`,`status`);let a=V(`p`,`my-pr-error reviews-retry-notice`);n.append(r,i);let o=null,s=!1,c=``,l=null;function u(){a.textContent=Q2(o,Date.now()),a.hidden!==!o?.error&&(a.hidden=!o?.error);let e=a.isConnected&&!Ef(t)&&!document.hidden&&a.getClientRects().length>0&&Z2(o,Date.now());!e&&l!==null&&(window.clearInterval(l),l=null),e&&l===null&&(l=window.setInterval(u,1e3))}function d(e){e!==o&&(c=``),o=e,r.disabled=s||!!e?.isRefreshing||!e?.configured,i.textContent=$2(e,s,c),i.hidden=!i.textContent,u()}r.addEventListener(`click`,async()=>{if(!s){s=!0,c=``,d(o);try{let t=await of(`reviews-refresh`,{lane:e});t.type===`reviews-refresh-result`&&(c=t.ok?`Refreshed.`:t.error??`Could not refresh from GitHub.`)}catch(e){c=nH(e)}finally{s=!1,d(o)}}});let f=new MutationObserver(u);f.observe(t,{attributes:!0,subtree:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});for(let e=t.parentElement;e;e=e.parentElement)f.observe(e,{attributes:!0,attributeFilter:[`hidden`,`data-queue-collapsed`]});return document.addEventListener(`visibilitychange`,u),{control:n,notice:a,update:d}}function W3(e,t,n,r){z3.set(e,{head:t,phase:n,text:r}),q3()}function tce(e){if(V3.has(e.key))return;let t=af(`my-pr-merge`);if(!B({type:`my-pr-merge`,requestId:t,repo:e.repo,number:e.number,headRefOid:e.headRefOid})){W3(e.key,e.headRefOid,`failed`,`Not connected to the server.`);return}let n=window.setTimeout(()=>{V3.delete(e.key),W3(e.key,e.headRefOid,`failed`,ece)},$se);V3.set(e.key,{requestId:t,head:e.headRefOid,timer:n}),z3.set(e.key,{head:e.headRefOid,phase:`pending`,text:``}),q3()}function nce(e){let t=Yse(e,z3.get(e.key));if(!t.isVisible)return null;let n=V(`div`,`my-pr-merge`),r=V(`button`,`pr-action`,`Merge`);r.type=`button`,r.disabled=t.isDisabled;let i=V(`span`,`pr-action-status`,t.statusText);return i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`),t.tone&&(i.dataset.tone=t.tone),r.addEventListener(`click`,()=>{tp({title:`Merge pull request`,message:Xse(e),confirmLabel:`Merge`,onConfirm:()=>tce(e)})}),n.append(r,i),n}function rce(e,t){let n=t.controlState(e,t.pendingKeys.has(e.key),t.errorsByKey.get(e.key),t.isFeatureEnabled(I3));if(!n.isVisible)return null;let r=V(`div`,`my-pr-merge`),i=V(`button`,`pr-action`,t.label);i.type=`button`,i.disabled=n.isDisabled,i.setAttribute(`aria-pressed`,String(n.isPressed));let a=V(`span`,`pr-action-status`,n.statusText);return a.setAttribute(`role`,`status`),a.setAttribute(`aria-live`,`polite`),i.addEventListener(`click`,async()=>{if(!t.pendingKeys.has(e.key)){t.pendingKeys.add(e.key),t.errorsByKey.delete(e.key),q3();try{let r=await t.save(e,!n.isPressed);r&&t.errorsByKey.set(e.key,r)}catch(n){t.errorsByKey.set(e.key,nH(n))}finally{t.pendingKeys.delete(e.key),q3()}}}),r.append(i,a),r}function G3(e,{hasGlyph:t}){let n=V(`span`,`my-pr-stage`);return n.dataset.tone=E3(e.stage),t&&n.append(XX(D3(e.stage),E3(e.stage))),n.append(T3(e.stage)),n}function ice(e,t){let n=V(`span`,`my-pr-requested`);n.append(V(`span`,null,`Requested`));let r=V(`span`,`avatar-stack`);for(let t of e.reviewRequests){let e=hf({login:t.name,url:t.isTeam?t.avatarUrl:void 0,cssPx:16});e.title=t.name,e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,t.name),r.append(e)}return n.append(r,V(`span`,`my-pr-requested-names`,t.slice(11))),n}function ace(){if(!M3||!N3||P3?.isConnected)return;let e=c4({queueLabel:`My pull requests`,scopeTabs:N3,resizerLabel:`Resize pull request list`});P3=e.queue,F3=e.detail,M3.replaceChildren(e.columns),R3&&e.foot.append(R3.control)}function K3(e){if(!F3)return;if(!e){F3.replaceChildren(V(`p`,`pr-empty`,j3(I3)));return}let t=V(`article`,`pr-detail`),n=V(`div`,`pr-detail-heading`),r=V(`div`,`pr-detail-title`);r.append(vf(`pr-link`,e.key,e.url),V(`h2`,null,e.title)),n.append(r,G3(e,{hasGlyph:!0})),t.append(n);for(let n of[H3,Qse]){let r=rce(e,n);r&&t.append(r)}let i=Hse(e,I3?.viewer??null);if(i.length>0){let n=V(`section`,`pr-readiness-section`);n.append(V(`h3`,`pr-section-heading`,`Merge readiness`));let r=V(`ul`,`pr-readiness`);for(let t of i){let n=V(`li`,`pr-readiness-row`),i=V(`span`,`pr-readiness-value`);t.label===`Review`&&t.text.startsWith(`Requested: `)&&i.append(ice(e,t.text)),i.childNodes.length===0&&(i.textContent=t.text),n.append(XX(t.icon,t.tone),V(`span`,`pr-readiness-label`,t.label),i),r.append(n)}n.append(r);let a=nce(e);a&&n.append(a),t.append(n)}if(e.checks.failing.length>0){let n=V(`section`,`my-pr-failures`);n.append(V(`h3`,`pr-section-heading`,`Failing checks`));let r=V(`ul`,`my-pr-facts`);for(let t of e.checks.failing)r.append(V(`li`,null,t));n.append(r),t.append(n)}let a=Vse(e);if(a.length>0){let e=V(`section`,`pr-readiness-section`);e.append(V(`h3`,`pr-section-heading`,`Reviews`));let n=V(`ul`,`pr-readiness`);for(let e of a){let t=V(`li`,`pr-readiness-row`),r=Date.parse(e.submittedAt??``),i=Number.isFinite(r)?`${e.text} ${JP(r)}`:e.text,a=V(`span`,`my-pr-reviewer`);a.append(gf([{login:e.reviewer,tone:e.tone,title:e.reviewer,url:e.reviewer===`a deleted account`?null:void 0}],16),V(`span`,null,e.reviewer)),t.append(XX(e.icon,e.tone),a,V(`span`,`pr-readiness-value`,i)),n.append(t)}e.append(n),t.append(e)}let o=Ise(e,I3?.viewer??null);if(o.length>0){let e=V(`section`,`my-pr-threads-section`);e.append(V(`h3`,`pr-section-heading`,`Unresolved threads`));let n=V(`ul`,`my-pr-threads`);for(let e of o){let t=V(`li`,`my-pr-thread`),r=V(`div`,`my-pr-thread-heading`);if(r.append(vf(`my-pr-thread-location`,e.location,e.url)),e.waiting){let t=V(`span`,`my-pr-stage`);t.dataset.tone=e.waiting.tone,t.append(XX(e.waiting.icon,e.waiting.tone),e.waiting.text),r.append(t)}let i=V(`p`,`my-pr-thread-excerpt`);i.append(V(`strong`,null,e.author),` ${e.excerpt}`);let a=Date.parse(e.lastActivityAt),o=V(`p`,`my-pr-thread-meta`,Number.isFinite(a)?`${e.replySummary}, ${JP(a)}`:e.replySummary);t.append(r,i,o),n.append(t)}e.append(n),t.append(e)}let s=V(`p`,`pr-detail-meta`);s.append(V(`span`,null,`Opened ${JP(Date.parse(e.createdAt))}`),V(`span`,null,`${e.state===`MERGED`?`Merged`:`Updated`} ${JP(Date.parse(e.state===`MERGED`?e.mergedAt??``:e.updatedAt))}`)),t.append(s),F3.replaceChildren(t)}function q3(){if(ace(),!P3)return;let e=I3?.prs??[],t=Ose(e);L3=Wse(t,L3);let n=document.activeElement instanceof HTMLElement&&P3.contains(document.activeElement)?document.activeElement.dataset.prKey:null,r=t.filter(e=>e.rows.length>0).map(e=>{let t=V(`section`,`pr-queue-section`);t.append(V(`h3`,`pr-section-heading`,`${e.title} ${e.rows.length}`));for(let{pr:n,parentKey:r,depth:i}of e.rows){let e=V(`button`,`pr-queue-row`);e.type=`button`,e.dataset.prKey=n.key,r&&(e.style.paddingInlineStart=`${12+Math.min(i,6)*16}px`),e.setAttribute(`aria-current`,String(n.key===L3)),e.title=`${n.key}: ${T3(n.stage)}`;let a=V(`span`,`pr-queue-glyph`);a.append(XX(D3(n.stage),E3(n.stage)));let o=V(`span`,`pr-queue-top`);o.append(V(`strong`,`pr-queue-ref`,n.key),V(`span`,`pr-queue-title`,n.title));let s=V(`span`,`pr-queue-bottom`);r&&s.append(V(`span`,`my-pr-stage`,`Stacked on ${r}`)),s.append(G3(n,{hasGlyph:!1}),V(`span`,`pr-queue-elapsed`,`opened ${JP(Date.parse(n.createdAt))}`));let c=fse(n,H3.isFeatureEnabled(I3),JP(n.keepMergeableAttempt?.at));if(c){let e=V(`span`,`my-pr-stage`,c.text);e.dataset.tone=c.tone,e.title=c.title,s.append(e)}e.append(a,o,s),e.addEventListener(`click`,()=>{L3=n.key;for(let e of P3?.querySelectorAll(`button[data-pr-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.prKey===L3));K3(n),document.documentElement.dataset.layout===`phone`&&F3?.scrollIntoView({block:`start`,behavior:`smooth`})}),t.append(e)}return t});if(r.length===0&&P3.replaceChildren(V(`p`,`pr-empty`,j3(I3))),r.length>0){let e=Use(I3,Date.now()).filter(e=>e.tone!==`error`).map(e=>V(`p`,e.tone===`error`?`my-pr-error`:`my-pr-note`,e.text));P3.replaceChildren(...e,...r)}R3&&(P3.prepend(R3.notice),R3.update(I3)),n&&[...P3.querySelectorAll(`button[data-pr-key]`)].find(e=>e.dataset.prKey===n)?.focus({preventScroll:!0}),K3(e.find(e=>e.key===L3))}function oce(e,t){return M3||(N3=t,M3=V(`div`,`pr-content`),e.append(M3),R3=U3(`my-prs`,M3),q3(),M3)}function sce(e){let t=Tse(e);if(!t)return;let n=Gse(I3?.prs??null,t.prs);I3=t,q3(),J3(n)}function J3(e){let t=e.filter(e=>!B3.has(e.key));if(t.length!==0){for(let e of t)B3.add(e.key);cse(Kse(t))}}function cce(e){let t=Zse(e);if(!t)return;let n=V3.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),V3.delete(t.key),!t.ok){W3(t.key,n.head,`failed`,t.error||`The merge failed.`);return}if(W3(t.key,n.head,t.kind??`unconfirmed`,``),t.kind!==`merged`)return;let r=I3?.prs.find(e=>e.key===t.key);r&&J3([r])}var lce=Ll.options.join(`|`),Y3=String.raw`\*\*(?:\[([^\]\n]+)\]\s+)?(${lce})\*\*`;function uce(e){return[...e.matchAll(new RegExp(Y3,`g`))].flatMap(e=>{let t=Ll.safeParse(e[2]);return t.success?[t.data]:[]})}function dce(e){let t=new RegExp(String.raw`^${Y3}\s*(?:\r?\n|$)`).exec(e);if(!t)return null;let n=Ll.safeParse(t[2]);return n.success?{reviewer:t[1]??null,severity:n.data,length:t[0].length}:null}function X3(e){let t=e.trimStart();return t.startsWith(`> [!NOTE]
|
|
248
|
+
> Automated review. Not written by a human.`)?t.slice(53).trim():e.trim()}var fce={"direct-request":`Needs you`,"team-request":`Ready`,"changes-requested":`Author to fix`,"checks-failing":`Checks failing`,"checks-pending":`Checks running`,draft:`Draft`,"review-available":`Ready`,approved:`Approved`};function Z3(e){return e.isDraft?{band:`not-ready`,reason:`draft`}:e.reviewDecision===`CHANGES_REQUESTED`?{band:`waiting-on-author`,reason:`changes-requested`}:e.checksState===`FAILURE`||e.checksState===`ERROR`?{band:`waiting-on-author`,reason:`checks-failing`}:e.checksState===`PENDING`||e.checksState===`EXPECTED`?{band:`not-ready`,reason:`checks-pending`}:e.requestSource===`direct`&&e.reviewDecision===`REVIEW_REQUIRED`?{band:`blocking-others`,reason:`direct-request`}:e.reviewDecision===`APPROVED`?{band:`actionable`,reason:`approved`}:{band:`actionable`,reason:e.requestSource===`direct`?`review-available`:`team-request`}}var Q3={APPROVE:{label:`You approved`,tone:`ok`,icon:`passed`},COMMENT:{label:`You commented`,tone:`muted`,icon:`thread`}},$3={APPROVED:{label:`You approved`,tone:`ok`,icon:`passed`},CHANGES_REQUESTED:{label:`You requested changes`,tone:`wait`,icon:`changes-requested`},COMMENTED:{label:`You commented`,tone:`muted`,icon:`thread`}};function e6(e){let t=(e.githubReviews??[]).filter(e=>e.isViewer).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!e.postedEvent)return t?$3[t.state]:null;if(!t)return Q3[e.postedEvent];let n=Date.parse(t.submittedAt??``);return Number.isNaN(n)||e.postedAt!==void 0&&e.postedAt>n?Q3[e.postedEvent]:$3[t.state]}var pce={"changes-requested":`changes-requested`,"checks-failing":`failed`,"checks-pending":`running`,draft:`draft`};function t6(e){let{reason:t}=Z3(e),n=pce[t];return n?{text:fce[t],icon:n}:null}function mce(e){return t6(e)?.text??null}var hce={discarded:{tone:`muted`,icon:`discarded`,meaning:`Discarded`},handReview:{tone:`warn`,icon:`fork`,meaning:`From a fork`}};function n6(e,t){let n=mce(t);return n?`${e}, ${n}`:e}function gce(e){if(Jl(e))return!0;let t=(e.githubReviews??[]).filter(e=>e.isViewer);return t.length===0||t.some(t=>t.commit===h6(e))}var _ce={tone:`warn`,icon:`your-turn`,meaning:`Comments resolved`};function r6(e,t){let n=hce[t];if(n)return n;if(t===`inReview`)return{tone:`wait`,icon:`running`,meaning:n6(`In review`,e)};if(t===`queued`)return{tone:`muted`,icon:`queued`,meaning:n6(`Queued`,e)};if(t===`settled`&&`reviewedHead`in e){let t=gce(e)?e6(e):null;return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`ok`,icon:`passed`,meaning:`Others reviewed`}}if(t===`posted`&&`reviewedHead`in e){let t=e6(e);return t?{tone:t.tone,icon:t.icon,meaning:t.label}:{tone:`muted`,icon:`none`,meaning:`Posted`}}if(t===`attention`&&`status`in e)return e.status===`error`?{tone:`danger`,icon:`failed`,meaning:`Review failed`}:{tone:`warn`,icon:`stale`,meaning:`Out of date`};let r=t6(e);return r?{tone:`wait`,icon:r.icon,meaning:r.text}:t===`ready`&&`reviewedHead`in e&&o6(e)?_ce:{tone:`warn`,icon:`your-turn`,meaning:`Waits on you`}}function i6(e){let t=e.viewerThreads;return t!==void 0&&t.total>0&&t.resolved===t.total}function a6(e){return e.status===`posted`&&o6(e)}function o6(e){if(!i6(e)||Jl(e))return!1;let t=h6(e);return!(e.githubReviews??[]).some(e=>e.isViewer&&e.state===`APPROVED`&&e.commit===t)}function s6(e){return!e||e.total===0?null:e.total===1?e.resolved===1?`Your 1 comment resolved`:`Your 1 comment unresolved`:e.resolved===e.total?`All ${e.total} of your comments resolved`:`${e.resolved} of ${e.total} of your comments resolved`}function vce(e){return`${e} ${e===1?`comment`:`comments`}`}function c6(e,t,n){let r=[`${D6(e.repo,e.number)}: ${e.title}`],i=`reviewedHead`in e?e.assessment?.goal.trim():``;if(i&&r.push(i),r.push(r6(e,t).meaning),n.opened&&r.push(`Opened ${n.opened}`),n.reviewed&&r.push(`Reviewed ${n.reviewed}`),n.posted&&r.push(`Posted ${n.posted}`),!(`reviewedHead`in e))return r.join(`
|
|
249
|
+
`);let a=s6(e.viewerThreads);a&&r.push(a);let o=e.comments.length;e.status!==`error`&&r.push(`Automated review: ${Dce(e.verdict)}, ${vce(o)}`);let s=v6(e);s&&r.push(`You ${p6[s.state]} at ${jl(s.approvedCommit)}${n.viewerApproval?` ${n.viewerApproval}`:``}; new commits since.`),(t===`attention`||t===`discarded`)&&r.push(j6(e));let c=x6(e,{isViewerShown:t!==`posted`});for(let[e,t]of c.entries())r.push(b6(t.text,n.githubReviews?.[e]??null));return r.join(`
|
|
250
|
+
`)}function l6(e){if(e.ready.length+e.attention.length+e.handReview.length>0)return null;let t=e.inReview.length+e.queued.length;return t===0?`Nothing needs you right now.`:`Nothing needs you right now. ${t} ${t===1?`review is`:`reviews are`} still running.`}function yce(e,t){if([...e.ready,...e.attention].filter(e=>e.key!==t).length>0)return{title:`New pull requests need you`,detail:`Pick one from the queue.`};let n=e.handReview.length;return n>0?{title:`Drafts all handled`,detail:`${n} ${n===1?`pull request needs`:`pull requests need`} review by hand.`}:{title:`All caught up`,detail:l6({...e,ready:[],attention:[]})??``}}function u6(e){let t=e.trim();return t.endsWith(`.`)?t:`${t}.`}function bce({action:e,pullRequest:t,warning:n,isActedSelected:r}){let i=L6(e),a=`${t}: ${u6(i)}`;return n.trim()?{statusText:i,shouldAdvance:!1,notice:{text:`${a} ${u6(n)}`,tone:`error`}}:{statusText:i,shouldAdvance:r,notice:null}}function d6(e){let t=[...e.ready,...e.noReviewNeeded,...e.inReview,...e.queued,...e.handReview,...e.attention,...e.posted,...e.discarded];return new Set(t.map(e=>e.repo)).size>1}function f6(e,t,n){return n?D6(e,t):`#${t}`}var xce={CRITICAL:{filledCount:3,colorToken:`--state-failed`},HIGH:{filledCount:3,colorToken:`--state-waiting`},MEDIUM:{filledCount:2,colorToken:`--accent`},LOW:{filledCount:1,colorToken:`--text-dim`}},Sce={APPROVE:`check`,"APPROVE WITH NITS":`dot`,"REQUEST CHANGES":`bar`,BLOCKED:`cross`},Cce=`lanes-team-review`,wce=`team-review-enabled`,Tce=Object.freeze({APPROVE:`approve`,"APPROVE WITH NITS":`approve with nits`,"REQUEST CHANGES":`request changes`,BLOCKED:`blocked`}),Ece={APPROVE:`Approve`,"APPROVE WITH NITS":`Nits`,"REQUEST CHANGES":`Changes`,BLOCKED:`Blocked`};function Dce(e){return Ece[e]}var Oce=Object.freeze({APPROVE:`ok`,"APPROVE WITH NITS":`info`,"REQUEST CHANGES":`warn`,BLOCKED:`crit`}),p6=Object.freeze({APPROVED:`approved`,CHANGES_REQUESTED:`requested changes`,COMMENTED:`commented`}),kce=Object.freeze({preparing:`fetching the diff`,checkout:`checking out the head`,reviewing:`agent reviewing`}),Ace=Object.freeze({approve:`Approved on GitHub`,"approve-only":`Approved on GitHub`,comment:`Comment posted on GitHub`,discard:`Draft discarded`,requeue:`Queued. The next poll reviews it again.`,"resolve-thread":`Thread resolved on GitHub`}),jce=Object.freeze({approve:`Posting the approval`,"approve-only":`Posting the approval`,comment:`Posting the comment`,discard:`Discarding the draft`,requeue:`Queueing the review`,"resolve-thread":`Resolving thread`});function m6(e){let t={ready:[],noReviewNeeded:[],inReview:[],queued:[],handReview:[],attention:[],posted:[],discarded:[]};if(!e)return t;let n={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},r={"blocking-others":[],actionable:[],"waiting-on-author":[],"not-ready":[]},i=[`blocking-others`,`actionable`,`waiting-on-author`,`not-ready`],a=new Set(e.inFlight.map(e=>e.key));t.inReview.push(...e.inFlight);let o=new Set(e.drafts.filter(e=>g6(e).length>0).map(e=>e.key));t.handReview.push(...e.handReview.filter(e=>!a.has(e.key)&&!o.has(e.key)));let s=new Set(t.handReview.map(e=>e.key));for(let t of e.queued)a.has(t.key)||s.has(t.key)||r[Z3(t).band].push(t);for(let e of i)t.queued.push(...r[e]);let c=new Set(t.queued.map(e=>e.key));for(let r of e.drafts){if(a.has(r.key)||c.has(r.key)||s.has(r.key))continue;if(g6(r).length>0||a6(r)){n.actionable.push(r);continue}let e=(r.status===`ready`||r.status===`stale`||r.status===`error`)&&!Ice(r);e&&t.noReviewNeeded.push(r),r.status===`ready`&&!e&&n[Z3(r).band].push(r),(r.status===`stale`||r.status===`error`)&&!e&&t.attention.push(r),r.status===`posted`&&t.posted.push(r),r.status===`discarded`&&t.discarded.push(r)}for(let e of i)t.ready.push(...n[e]);return t}function Mce(e,t){return e.commit===t?e.isViewer||Ul.has(e.state):!1}function h6(e){return e.liveHead??e.reviewedHead}function g6(e){return(e.threads??[]).filter(e=>!e.isNit&&!e.isResolved)}function Nce(e,t){if(e.isNit)return{label:`Automatic resolution failed`,reason:``,tone:`warn`};let n=e.judgement?.head===t&&e.judgement.lastReplyAt===e.lastReplyAt?e.judgement:void 0;if(n)return{label:n.addressed?`Addressed`:`Not addressed`,reason:n.reason,tone:n.addressed?`ok`:`warn`};let r=e.unjudgeable?.head===t&&e.unjudgeable.lastReplyAt===e.lastReplyAt?e.unjudgeable:void 0;return r?{label:`Auto-check skipped`,reason:r.reason,tone:`muted`}:{label:`Auto-check pending`,reason:``,tone:`muted`}}function _6(e){return(e.threads??[]).filter(e=>!e.isResolved&&(!e.isNit||e.resolveError)).map(t=>{let n=Nce(t,h6(e));return{thread:t,location:t.line===null?t.path:`${t.path}:${t.line}`,judgementLabel:n.label,judgementReason:n.reason,judgementTone:n.tone,judgementText:n.reason?`${n.label}: ${n.reason}`:n.label,canResolve:t.viewerCanResolve}})}var Pce=40;function Fce(e,t){return e.split(`
|
|
251
|
+
`).reduce((e,t)=>e+Math.max(1,Math.ceil(t.length/Pce)),0)>t}function Ice(e){return g6(e).length>0?!0:Jl(e)?!1:o6(e)?!0:!(e.githubReviews??[]).some(t=>Mce(t,h6(e)))}function Lce(e,t){let n=p6[e.state];return e.isViewer?e.commit===t?`you ${n}`:`you ${n} (older commit)`:`${n} by ${e.login}`}function v6(e){if(Jl(e))return null;let t=(e.githubReviews??[]).filter(e=>e.isViewer&&Ul.has(e.state)).sort((e,t)=>(Date.parse(t.submittedAt??``)||0)-(Date.parse(e.submittedAt??``)||0)).at(0);if(!t?.commit||t.commit===h6(e)||t.state===`COMMENTED`)return null;let n=Date.parse(t.submittedAt??``);return e.reviewedAt!==void 0&&n>e.reviewedAt?null:{approvedCommit:t.commit,submittedAt:t.submittedAt,state:t.state,isReviewScopeSinceDecision:e.priorReviewedHead===t.commit}}function y6(e,t){let n=e.state===`APPROVED`?`approved this`:`requested changes`,r=e.state===`APPROVED`?`your approval`:`your request for changes`,i=`You ${n} at ${jl(e.approvedCommit)}${t?` ${t}`:``}. It has new commits since`;return e.isReviewScopeSinceDecision?`${i}, so this review covers what changed after ${r}.`:`${i}.`}function Rce(e){return e===`APPROVED`?`ok`:e===`CHANGES_REQUESTED`?`warn`:`muted`}function b6(e,t){return t?`${e}, ${t}`:e}function x6(e,{isViewerShown:t=!0}={}){return(e.githubReviews??[]).filter(e=>t||!e.isViewer).sort((e,t)=>Number(t.isViewer)-Number(e.isViewer)).map(t=>({login:t.login,tone:Rce(t.state),text:Lce(t,h6(e)),submittedAt:t.submittedAt}))}function zce(e){return e.ready.length+e.noReviewNeeded.length+e.inReview.length+e.queued.length+e.handReview.length+e.attention.length+e.posted.length+e.discarded.length>0}function S6(e){return[...e.ready,...e.attention].map(e=>e.key)}function Bce({capturedOrder:e,actedKey:t,groups:n}){let r=S6(n).filter(e=>e!==t),i=new Set(r);return e.slice(e.indexOf(t)+1).find(e=>i.has(e))||(e.find(e=>i.has(e))??r[0]??null)}function C6(e,t,n=!1){if(n&&t===null)return null;let r=[...e.ready,...e.inReview,...e.queued,...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded];return t&&r.some(e=>e.key===t)?t:r[0]?.key??null}function Vce(e){return xce[e]}function Hce(e){return Sce[e]}function Uce(e){let t=uce(e.body);return t.length>0?t:e.severity?[e.severity]:[]}function w6(e){let t=Uce(e);return Ll.options.find(e=>t.includes(e))??null}function Wce(e){return w6(e)!==`LOW`}var Gce=new Set(`ts.tsx.js.jsx.mjs.cjs.json.jsonc.css.scss.less.html.md.mdx.py.go.rs.rb.java.kt.kts.swift.c.h.cc.cpp.hpp.cs.php.sh.bash.zsh.yml.yaml.toml.ini.sql.vue.svelte.astro.lock.txt.ex.exs.erl.scala.dart.lua.tf.proto.graphql.gql.xml.gradle`.split(`.`)),Kce=/^([\w.@~/-]+):\d+(?:-\d+)?$/;function qce(e){let t=Kce.exec(e)?.[1];if(t===void 0)return!1;let n=t.slice(t.lastIndexOf(`/`)+1),r=n.lastIndexOf(`.`);return r<0?!1:Gce.has(n.slice(r+1).toLowerCase())}var Jce=/^```([^\n`]*)\n([\s\S]*?)^```[ \t]*(?=\r?$)/gm;function T6(e){let t=[],n=0;for(let r of e.matchAll(/`([^`\n]+)`/g)){let i=r.index??0;i>n&&t.push({text:e.slice(n,i),kind:`text`});let a=r[1]??``;t.push({text:a,kind:qce(a)?`citation`:`code`}),n=i+r[0].length}return n<e.length&&t.push({text:e.slice(n),kind:`text`}),t}function E6(e){return e.split(/\r?\n\s*\r?\n/).filter(Boolean).map(e=>{let t=e.match(/^(Suggested fix:|Fix:|Open question[.,:])\s*/),n=t?.[1]??``;return{kind:`prose`,lead:n,leadKind:n.startsWith(`Open question`)?`question`:n?`fix`:null,segments:T6(e.slice(t?.[0].length??0))}})}function Yce(e){let t=X3(e),n=dce(t),r=n?t.slice(n.length).trim():t,i=[],a=0;for(let e of r.matchAll(Jce)){let t=e.index??0;i.push(...E6(r.slice(a,t).trim()));let n=(e[1]??``).trim().split(/\s+/)[0]||null;i.push({kind:`code`,language:n,code:(e[2]??``).replace(/\r?\n$/,``)}),a=t+e[0].length}return i.push(...E6(r.slice(a).trim())),{tag:n?.reviewer??null,severity:n?.severity??null,paragraphs:i}}function Xce(e){let t=e.find(e=>e.kind===`prose`);if(!t)return`Open comment`;let n=`${t.lead} ${t.segments.map(e=>e.text).join(``)}`.trim(),r=n.search(/[.!?](?=\s|$)/);return(r<0?n:n.slice(0,r+1))||`Open comment`}function Zce(e){let t=[`Fetch the diff`,`Check out the head`,`Review`,`Draft ready`],n={preparing:0,checkout:1,reviewing:2}[e];return t.map((e,t)=>({label:e,state:t<n?`done`:t===n?`active`:`todo`}))}function D6(e,t){return`${e}#${t}`}function O6(e){return e===`full`?`full`:`light`}function Qce(e){return e.priorReviewedHead?`${O6(e.tier)} review of changes since ${jl(e.priorReviewedHead)}`:`${O6(e.tier)} review`}function $ce(e){return e.reasons.join(`, `)}function ele(e){if(!e)return[];let t=[],n=e.goal.trim(),r=e.change.trim();return n&&t.push({kind:`goal`,text:n}),r&&t.push({kind:`change`,text:r}),t}function tle(e){if(!e)return`No coverage notes`;let t=e.checked.length,n=e.gaps.length,r=[];return t>0&&r.push(`${t} ${t===1?`check`:`checks`}`),n>0&&r.push(`${n} not covered`),r.join(`, `)||`No coverage notes`}function nle(e){return e?{label:`Coverage`,preview:tle(e)}:{label:`Review audit`,preview:``}}var rle=`This review ran before plain summaries existed, so only its verdict and findings remain. The audit log shows what it checked. Queue review to get a plain summary.`,ile=new Set([`error`,`stale`,`discarded`,`posted`]);function k6(e){return ile.has(e)}function ale(e){let t=ole(e);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function ole(e){return Tce[e]??String(e).toLowerCase()}function sle(e){return Oce[e]??`dim`}function cle(e){return kce[e]??e}function A6(e,t){return`${LA(t-e.startedAt)} elapsed`}function lle(e,t){let n=[A6(e,t)],r=e.deadlineAt===null?0:e.deadlineAt-t;return r>0&&n.push(`times out in ${LA(r)}`),e.phase===`reviewing`&&n.push(`${e.toolCalls} ${e.toolCalls===1?`tool call`:`tool calls`}`),n.join(`, `)}function j6(e){return e.status===`stale`?`Out of date. Automatic review runs at the next poll after the configured wait. Queue review bypasses the wait.`:e.status===`discarded`?`Not reviewed again until queued.`:e.error||e.summary||`The review failed.`}function M6(e,t){let n=t.side===`LEFT`?` (old)`:``;return`${e}:${t.line}${n}`}function N6(e){return M6(e.path,e)}function ule(e){return M6(e.path.split(`/`).filter(Boolean).at(-1)??e.path,e)}function dle(e,t){let n=e.trim();return n?t.trim()?`${n}\n\n${t}`:n:t}function fle(e,t,n,r,i){return t===`approve-only`?{key:e.key,head:e.reviewedHead,action:t,body:``,comments:[]}:{key:e.key,head:e.reviewedHead,action:t,body:n,...i?{threadId:i}:{},comments:r.map(({path:e,line:t,side:n,body:r})=>({path:e,line:t,side:n,body:r}))}}var ple=Object.freeze({approve:`Approve and comment`,"approve-only":`Approve`,comment:`Comment`,discard:`Discard`,requeue:`Queue review`,"resolve-thread":`Resolve`});function P6(e){return ple[e]}function F6(e){return e.status===`ready`?{footer:[`comment`,`approve-only`,`approve`],more:[`requeue`,`discard`]}:nu(e)?{footer:[`approve-only`],more:[`requeue`]}:k6(e.status)?{footer:[`requeue`],more:[]}:{footer:[],more:[]}}function I6(e){return jce[e]}function L6(e){return Ace[e]}function mle(e){return e===0?`Picked for review. It starts on the next poll.`:`Waiting for a free review slot. It starts as soon as ${e===1?`the review`:`one of the ${e} reviews`} in progress finishes.`}function hle(e){return e?e.configured?e.error?`Review drafts will show here once GitHub answers.`:`No review drafts yet. New teammate pull requests show up here after the next poll.`:e.reason?`Team review is not running: ${e.reason}.`:`Team review is off.`:`Waiting for the team review lane.`}function R6(e){return e?.configured&&e.reason||null}function gle(e){return kA(m6(e).ready.map(e=>`${e.key}@${e.reviewedHead}`))}function z6(e){return`${e.key}@${e.reviewedHead}:${e.status}:${e.summary}:${x6(e).map(e=>e.text).join(`, `)}`}function B6(e){return`reviewedHead`in e?JSON.stringify([e.prCreatedAt,e.reviewedAt,e.postedAt,e.githubReviews,e.liveHead,e.priorReviewedHead,e.viewerThreads]):JSON.stringify([e.prCreatedAt,e.priorReviewedHead])}function _le(e,t){return!e||e.error!==t.error||e.nextAttemptAt!==t.nextAttemptAt||JSON.stringify(e.retry)!==JSON.stringify(t.retry)||e.isRefreshing!==t.isRefreshing||e.refreshNotice!==t.refreshNotice||JSON.stringify(e.team)!==JSON.stringify(t.team)||e.configured!==t.configured||e.reason!==t.reason||e.inFlight.map(e=>e.key).join(`
|
|
252
252
|
`)!==t.inFlight.map(e=>e.key).join(`
|
|
253
|
-
`)||JSON.stringify(e.handReview)!==JSON.stringify(t.handReview)||JSON.stringify(e.queued)!==JSON.stringify(t.queued)?!1:JSON.stringify(e.drafts)===JSON.stringify(t.drafts)}var yle=12e4,V6=`M4.5 0.5L8.5 5.5L4.5 10.5L0.5 5.5Z`,H6=null,U6=null,W6=null,G6=null,K6=null,q6=null,J6=null,Y6=null,X6=null,Z6=null,Q6=null,$6=null,e8=null,t8=null,n8=XP(()=>U6),r8=XP(()=>U6),i8=XP(()=>U6),a8=new WeakMap,o8=new Map,s8=new Map,c8=new Map,l8=AA({getAck:xk,setAck:Sk,signature:()=>_le(H6),isLooking:()=>!Ef(U6)});function ble(e){let t=Hce(e),n=V(`span`,`pr-severity-meter`);if(n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`${e.toLowerCase()} severity`),n.style.color=`var(${t.colorToken})`,e===`CRITICAL`){let e=WL(14,17);e.classList.add(`pr-severity-halo`),e.setAttribute(`viewBox`,`0 0 9 11`),e.append(UL(`path`,{d:V6,fill:`currentColor`})),n.append(e)}for(let e=0;e<3;e+=1){let r=WL(9,11),i=e<t.filledCount;r.append(UL(`path`,{d:V6,fill:i?`currentColor`:`none`,stroke:i?`currentColor`:`var(--border-hover)`,"stroke-width":`1`})),n.append(r)}return n}function xle(e){let{verdict:t}=e,n=V(`span`,`pr-verdict-seal`);n.dataset.tone=cle(t);let r=WL(20,20),i=Uce(t);return r.append(UL(`circle`,{cx:`10`,cy:`10`,r:`8.5`,fill:i===`cross`?`currentColor`:`none`,stroke:`currentColor`,"stroke-width":`1.5`})),i===`check`&&r.append(UL(`path`,{d:`M6 10.5L8.7 13L14 7.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),i===`dot`&&r.append(UL(`circle`,{cx:`10`,cy:`10`,r:`2.4`,fill:`currentColor`})),i===`bar`&&r.append(UL(`path`,{d:`M6 10H14`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})),i===`cross`&&r.append(UL(`path`,{d:`M7 7L13 13M13 7L7 13`,stroke:`var(--bg)`,"stroke-width":`1.8`,"stroke-linecap":`round`})),n.append(r,V(`span`,null,ole(t))),n}function Sle(){let e=WL(16,16);return e.append(UL(`rect`,{x:`1`,y:`1`,width:`14`,height:`14`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),e.append(UL(`path`,{d:`M6 6.2C6 4.9 7 4.2 8 4.2C9.1 4.2 10 5 10 6C10 7.4 8 7.4 8 9.2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`})),e.append(UL(`circle`,{cx:`8`,cy:`11.6`,r:`0.9`,fill:`currentColor`})),e}function u8(e){return vf(`pr-link`,D6(e.repo,e.number),e.url)}function d8(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?null:t}function f8(e,t){let n=d8(t);if(n===null)return null;let r=V(`span`,null,`${e}${e?` `:``}${JP(n)}`);return r.dataset.ageAt=String(n),r.dataset.ageLabel=e,r}function p8(e){if(e){for(let t of e.querySelectorAll(`.pr-queue-row`)){let e=a8.get(t);if(!e)continue;let n=()=>{t.title=e(),t.setAttribute(`aria-label`,t.title)};n(),i8.onTick(n)}for(let t of e.querySelectorAll(`.pr-rereview-notice`)){let e=H6?.drafts.find(e=>e.key===t.dataset.reviewKey),n=e?v6(e):null;if(!n)continue;let r=()=>{t.textContent=y6(n,h8(n.submittedAt))};r(),i8.onTick(r)}for(let t of e.querySelectorAll(`[data-age-at]`)){let e=Number(t.dataset.ageAt),n=t.dataset.reviewTitle;if(n!==void 0){let r=()=>{let r=b6(n,JP(e));t.title=r,t.setAttribute(`aria-label`,r)};r(),i8.onTick(r);continue}let r=t.dataset.ageLabel??``;i8.track(t,e,()=>`${r}${r?` `:``}${JP(e)}`)}}}function m8(e,t,n,r=!0){let i=x6(e,{isViewerShown:r});if(i.length===0)return null;let a=V(`span`,t),o=gf(i.map(e=>({login:e.login,tone:e.tone,title:b6(e.text,h8(e.submittedAt))})),n);for(let[e,t]of i.entries()){let n=o.children[e];if(!(n instanceof HTMLElement)||!t.submittedAt)continue;let r=d8(t.submittedAt);r!==null&&(n.dataset.ageAt=String(r),n.dataset.reviewTitle=t.text)}return a.append(o),a}function h8(e){let t=d8(e);return t===null?null:JP(t)}function g8(e,t,n){let r=V(`span`,n);return r.append(hf({login:e,cssPx:t}),V(`span`,null,e)),r}function Cle(e,t,n){let r=V(`button`,`pr-queue-row pr-queue-row-quiet`);r.type=`button`,r.dataset.reviewKey=e.key,r.setAttribute(`aria-current`,String(e.key===X6));let i=`reviewedHead`in e?v6(e):null,a=()=>c6(e,t,{opened:h8(e.prCreatedAt),reviewed:`reviewedHead`in e?h8(e.reviewedAt):null,posted:`reviewedHead`in e?h8(e.postedAt):null,viewerApproval:h8(i?.submittedAt),githubReviews:`reviewedHead`in e?x6(e,{isViewerShown:t!==`posted`}).map(e=>h8(e.submittedAt)):[]});r.title=a(),r.setAttribute(`aria-label`,r.title),a8.set(r,a);let o=y8(e,n);if(t===`inReview`){let t=e,n=V(`span`,`pr-queue-elapsed`);n8.track(n,t.startedAt,()=>A6(t,Date.now())),o.append(n)}if(t===`queued`){let t=f8(``,e.prCreatedAt);t&&(t.classList.add(`pr-queue-elapsed`),o.append(t))}if(t!==`inReview`&&t!==`queued`){let t=e,n=f8(``,t.reviewedAt)??f8(``,t.prCreatedAt);n&&(n.classList.add(`pr-queue-elapsed`),o.append(n))}if(t===`discarded`)return r.classList.add(`pr-queue-row-compact`),r.append(o),_8(r,e.key),r;r.classList.remove(`pr-queue-row-quiet`);let s=r6(e,t),c=V(`span`,`pr-queue-glyph`);c.append(ZX(s.icon,s.tone));let l=V(`span`,`pr-queue-bottom`);if(l.append(v8(s),g8(e.author,16,`pr-queue-author`)),e.requestSource===`direct`){let e=V(`span`,`pr-queue-direct`,`@`);e.title=`Requested from you directly`,l.append(e)}t===`inReview`&&l.append(V(`span`,`pr-phase-label`,lle(e.phase))),r.append(c,o,l);let u=t===`inReview`||t===`queued`?null:m8(e,`pr-queue-reviewers`,16,t!==`posted`);return u&&l.append(u),_8(r,e.key),r}function _8(e,t){e.addEventListener(`click`,()=>{X6=t,Z6=null,x8(null);for(let e of K6?.querySelectorAll(`button[data-review-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.reviewKey===X6));W8(m6(H6)),i8.reset(),p8(U6),document.documentElement.dataset.layout===`phone`&&J6?.scrollIntoView({block:`start`,behavior:`smooth`})})}function v8(e){let t=V(`span`,`my-pr-stage pr-queue-state`,e.meaning);return t.dataset.tone=e.tone,t}function y8(e,t){let n=V(`span`,`pr-queue-top`);return n.append(V(`strong`,`pr-queue-ref`,f6(e.repo,e.number,t)),V(`strong`,`pr-queue-ref-compact`,f6(e.repo,e.number,!1)),V(`span`,`pr-queue-title`,e.title)),n}function wle(e,t){let n=V(`section`,`pr-queue-section`);n.append(V(`h3`,`pr-section-heading`,`Review by hand ${e.length}`));for(let r of e){let e=vf(`pr-queue-row`,``,r.url),i=()=>c6(r,`handReview`,{opened:h8(r.prCreatedAt)});e.title=i(),a8.set(e,i);let a=r6(r,`handReview`),o=V(`span`,`pr-queue-glyph`);o.append(ZX(a.icon,a.tone));let s=V(`span`,`pr-queue-bottom`);s.append(v8(a),g8(r.author,16,`pr-queue-author`)),e.append(o,y8(r,t),s),n.append(e)}return n}function b8({title:e,detail:t}){let n=V(`section`,`pr-caught-up`);n.setAttribute(`role`,`status`);let r=V(`strong`,`pr-caught-up-title`);return r.append(ZX(`ready`,`ok`),V(`span`,null,e)),n.append(r,V(`p`,`pr-caught-up-detail`,t)),n}function x8(e){Q6=e,$6&&($6.hidden=e===null,$6.textContent=e?.text??``,e&&($6.dataset.tone=e.tone))}function S8(e,t,n,r){let i=V(`section`,`pr-queue-section`);i.append(V(`h3`,`pr-section-heading`,`${e} ${t.length}`));for(let e of t)i.append(Cle(e,n,r));return i}function C8(e){let t=V(`div`,`pr-detail-heading`);t.dataset.signature=B6(e);let n=V(`div`,`pr-detail-title`);n.append(u8(e),V(`h2`,null,e.title));let r=V(`div`,`pr-detail-meta`);r.append(g8(e.author,20,`pr-detail-author`));let i=V(`span`,null,$ce(e));i.title=ele(e),r.append(i);let a=f8(`Opened`,e.prCreatedAt);if(a&&r.append(a),`reviewedHead`in e){let t=f8(`Reviewed`,e.reviewedAt);t&&r.append(t);let n=f8(`Posted`,e.postedAt);n&&r.append(n)}let o=`reviewedHead`in e?m8(e,`pr-detail-github`,20):null;if(o&&r.append(o),t.append(n,r),`reviewedHead`in e){let n=s6(e.viewerThreads);if(n){let r=V(`p`,`pr-viewer-threads`,n);i6(e)&&(r.dataset.state=`all-resolved`),t.append(r)}}let s=`reviewedHead`in e?v6(e):null;if(s){let n=V(`p`,`pr-rereview-notice`,y6(s,h8(s.submittedAt)));n.dataset.reviewKey=e.key,t.append(n)}return t}function w8(e,t){let n=e.querySelector(`:scope > .pr-detail-heading`);if(!n||n.dataset.signature===B6(t))return e;let r=C8(t),i=n.querySelector(`:scope > .pr-detail-title > .pr-detail-more`);return i&&r.querySelector(`:scope > .pr-detail-title`)?.append(i),n.replaceWith(r),e}function T8(e){return`${JSON.stringify(e.threads)}:${e.liveHead}:${e.status}:${e.reviewedHead}:${e.error??``}:${e.postedEvent??``}`}function E8(e,t){for(let n of t){if(n.kind===`text`){e.append(document.createTextNode(n.text));continue}if(n.kind===`code`){e.append(V(`code`,null,n.text));continue}let t=V(`span`,`pr-citation`,n.text);t.title=n.text,e.append(t)}return e}function D8(e,t){return E8(e,T6(t))}function O8(e,t,n){let r=V(`div`,`pr-assessment-part`);return n&&(r.dataset.tone=n),r.append(V(`h4`,`pr-assessment-title`,e),t),r}function k8(e){let t=V(`ul`,`pr-assessment-list`);for(let n of e)t.append(D8(V(`li`,null),n));return t}function A8(e){let t=tle(e.assessment);if(t.length===0)return[];let n=V(`section`,`pr-about-box`);n.setAttribute(`aria-label`,`About this PR`),n.append(V(`h3`,`pr-assessment-title`,`About this PR`));for(let e of t){let t=e.kind===`goal`?`pr-verdict-summary pr-about-goal`:`pr-verdict-summary`;n.append(D8(V(`p`,t),e.text))}return[n]}function j8(e){let t=V(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Verdict`);let n=V(`div`,`pr-verdict-line`);return n.append(xle(e)),t.append(n),e.assessment?(t.append(D8(V(`p`,`pr-verdict-summary pr-verdict-reason`),e.summary)),t):(t.append(V(`p`,`pr-verdict-legacy`,ile)),t)}function M8(e){let t=V(`details`,`pr-disclosure pr-coverage`),n=V(`summary`,`pr-disclosure-summary`),r=rle(e.assessment);n.append(V(`span`,`pr-disclosure-label`,r.label),V(`span`,`pr-disclosure-preview`,r.preview)),t.append(n);let{assessment:i}=e;return i?(i.checked.length>0&&t.append(O8(`What the review checked`,k8(i.checked))),i.gaps.length>0&&t.append(O8(`Not covered`,k8(i.gaps),`warning`)),t):(t.append(D8(V(`p`,`pr-verdict-summary`),e.summary)),t)}function Tle(e){if(e.kind===`code`){let t=V(`pre`,`pr-comment-code`),n=V(`code`,null);return n.textContent=e.code,t.append(n),t}let t=V(`p`,`pr-comment-paragraph`);if(e.lead){let n=V(`strong`,`pr-comment-lead pr-comment-lead-${e.leadKind}`);e.leadKind===`question`&&n.append(Sle()),n.append(e.lead),t.append(n,` `)}return E8(t,e.segments)}function Ele(e,t,n,r){let i=V(`article`,`pr-comment-card`),a=V(`input`,`pr-comment-checkbox`);a.type=`checkbox`,a.checked=n.has(t),a.setAttribute(`aria-label`,`Include comment on ${N6(e)}`),a.addEventListener(`change`,()=>{a.checked&&n.add(t),a.checked||n.delete(t),i.dataset.included=String(a.checked),r()}),i.dataset.included=String(a.checked);let o=V(`details`,`pr-comment-content`),s=V(`summary`,`pr-comment-header`),c=Xce(e.body),l=w6(e);l&&s.append(ble(l));let u=V(`span`,`pr-comment-location`,dle(e));u.title=N6(e),s.append(u),s.append(V(`span`,`pr-comment-preview`,Zce(c.paragraphs))),o.append(s);let d=V(`div`,`pr-comment-paragraphs`);for(let e of c.paragraphs)d.append(Tle(e));return o.append(d),o.open=l===`HIGH`||l===`CRITICAL`,i.append(a,o),i}var N8=`More review actions`,Dle=`M3 8h0.01M8 8h0.01M13 8h0.01`,Ole=`Your comments are on GitHub. Approve adds an approval without posting them again.`;function P8(e,t,n,r,i,a,o){let s=S6(m6(H6));x8(null);let c=af(`team-review-action`);if(!B({type:`team-review-action`,requestId:c,...ple(t,n,r,i,o)}))return!1;let l=window.setTimeout(()=>{c8.delete(t.key),a(!1,`No reply from the server. Check GitHub before trying again.`)},yle);return c8.set(t.key,{requestId:c,action:n,origin:e,capturedOrder:s,pullRequest:D6(t.repo,t.number),timer:l,settle:a}),!0}var F8=0;function I8(e,t){let n=V(`div`,`pr-detail-more`),r=V(`button`,`review-icon-button review-more-button`);r.type=`button`,r.title=N8,r.setAttribute(`aria-label`,N8),r.setAttribute(`aria-haspopup`,`menu`),r.setAttribute(`aria-expanded`,`false`);let i=WL(16,16);i.append(UL(`path`,{d:Dle,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),r.append(i),F8+=1;let a=V(`div`,`review-more-menu`);a.id=`pr-more-menu-${F8}`,a.setAttribute(`role`,`menu`),a.setAttribute(`aria-label`,N8),a.hidden=!0,r.setAttribute(`aria-controls`,a.id);let o=e=>{e.key===`Escape`&&(e.preventDefault(),c(),r.focus())},s=e=>{e.target instanceof Node&&n.contains(e.target)||c()};function c(){a.hidden=!0,r.setAttribute(`aria-expanded`,`false`),document.removeEventListener(`keydown`,o),document.removeEventListener(`pointerdown`,s)}let l=()=>{a.hidden=!1,r.setAttribute(`aria-expanded`,`true`),document.addEventListener(`keydown`,o),document.addEventListener(`pointerdown`,s),a.querySelector(`button:not(:disabled)`)?.focus()};r.addEventListener(`click`,()=>{if(a.hidden){l();return}c()});let u=[r];for(let n of e){let e=V(`button`,n===`discard`?`review-btn review-btn-danger`:`review-btn`,P6(n));e.type=`button`,e.dataset.action=n,e.setAttribute(`role`,`menuitem`),e.addEventListener(`click`,()=>{c(),t(n)}),u.push(e),a.append(e)}return n.append(r,a),{element:n,controls:u}}function L8(e,t){let n=V(`button`,`pr-action`,P6(e));return n.type=`button`,n.dataset.action=e,n.addEventListener(`click`,()=>t(e)),n}function R8(e,t){e.querySelector(`:scope > .pr-detail-heading > .pr-detail-title`)?.append(t)}function kle(e){let t=V(`article`,`pr-detail`),n=V(`div`);n.dataset.reviewThreads=``,t.append(C8(e),...A8(e),n,j8(e)),z8(t,e);let r=V(`section`,`pr-posts`);r.setAttribute(`aria-label`,`Inline comments`);let i=V(`div`,`pr-posts-heading`);i.append(V(`h3`,null,`Inline comments`),V(`span`,null,String(e.comments.length))),r.append(i);let a=V(`details`,`pr-disclosure`),o=V(`summary`,`pr-disclosure-summary`),s=V(`span`,`pr-disclosure-preview`);o.append(V(`span`,`pr-disclosure-label`,`Review body`),s),a.append(o);let c=V(`textarea`,`pr-body-input`);c.setAttribute(`aria-label`,`Review body`),c.value=e.body,c.rows=Math.min(10,Math.max(3,e.body.split(`
|
|
254
|
-
`).length+1)),c.spellcheck=!0;let l=()=>{s.textContent=X3(c.value).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||`No review body`};c.addEventListener(`input`,l),l(),a.append(c);let u=V(`details`,`pr-disclosure`);u.append(V(`summary`,`pr-disclosure-summary`,`Add a note`));let d=V(`textarea`,`pr-body-input pr-note-input`);d.setAttribute(`aria-label`,`Your note`),d.rows=2,d.spellcheck=!0,d.placeholder=`Posts above the automated-review note`,u.append(d);let f=new Set(e.comments.flatMap((e,t)=>Gce(e)?[t]:[])),p=V(`footer`,`pr-footer`),m=V(`span`,`pr-action-status`);m.setAttribute(`role`,`status`),m.setAttribute(`aria-live`,`polite`);let h=()=>{c8.has(e.key)||m.dataset.tone===`ok`||(m.textContent=``,delete m.dataset.tone)};for(let[t,n]of e.comments.entries())r.append(Ele(n,t,f,h));t.append(r,a,u,M8(e));let g=[],_=e=>{for(let t of g)t.disabled=e;t.dataset.busy=String(e)},v=(e,t)=>{_(e),m.dataset.tone=e?`ok`:`error`,m.textContent=t},y=t=>{if(c8.has(e.key))return;_(!0),m.dataset.tone=`busy`,m.textContent=I6(t);let n=e.comments.filter((e,t)=>f.has(t));P8(`ready`,e,t,fle(d.value,c.value),n,v)||v(!1,`Not connected to the server.`)},ee=F6(e),b=ee.footer.map(e=>L8(e,y)),te=I8(ee.more,y);return g.push(...b,...te.controls),R8(t,te.element),p.append(...b,m),t.append(p),{signature:z6(e),element:t,settle:v}}function Ale(e){let t=o8.get(e.key);if(t&&(c8.has(e.key)||t.signature===z6(e)))return z8(t.element,e),w8(t.element,e);let n=kle(e);return o8.set(e.key,n),n.element}function jle(e,t){let n=V(`article`,`pr-detail`),r=V(`div`,`pr-detail-heading`),i=V(`div`,`pr-detail-title`);i.append(u8(e),V(`h2`,null,e.title));let a=V(`div`,`pr-detail-meta`);a.append(g8(e.author,20,`pr-detail-author`));let o=f8(`Opened`,e.prCreatedAt);return o&&a.append(o),r.append(i,a),n.append(r,V(`p`,`pr-attention-detail`,hle(t))),n}function Mle(e){let t=V(`article`,`pr-detail`);t.append(C8(e));let n=V(`section`,`pr-progress`);n.setAttribute(`aria-label`,`Review progress`);let r=V(`ol`,`pr-progress-tracker`);for(let t of Qce(e.phase)){let e=V(`li`,`pr-progress-stage`);e.dataset.state=t.state,e.append(V(`span`,`pr-progress-bar`),V(`span`,null,t.label)),r.append(e)}let i=V(`div`,`pr-progress-text`);r8.track(i,e.startedAt,()=>ule(e,Date.now())),n.append(r,i),t.append(n);let a=V(`section`,`pr-steps`);a.append(V(`h3`,null,`Latest agent steps`));let o=V(`ol`,`pr-step-list`);for(let t of e.recentSteps){let n=V(`li`,`pr-step`),r=V(`span`,`pr-step-detail`,t.detail);r.title=t.detail,n.append(V(`span`,`pr-step-at`,RA(e.startedAt,t.at)),V(`span`,`pr-step-tool`,t.tool),r),o.append(n)}return a.append(o),t.append(a),t}function z8(e,t){if(c8.has(t.key))return;let n=e.querySelector(`:scope > [data-review-threads]`),r=JSON.stringify([t.liveHead,t.threads]);n&&n.dataset.reviewThreads!==r&&(n.replaceChildren(...V8(t)),n.dataset.reviewThreads=r)}function B8(e,t,n,r){let i=V(`div`,t?`pr-thread-message pr-thread-message-muted`:`pr-thread-message`);if(i.append(V(`p`,`pr-thread-body pr-thread-preview`,e)),!n&&!Ice(e,t?3:8))return i;let a=V(`details`,`pr-thread-disclosure`);return a.append(V(`summary`,`pr-thread-expand`,t?`Expand comment`:`Expand reply`),V(`p`,`pr-thread-body`,e)),n&&a.append(vf(`pr-link pr-thread-continues`,t?`Comment continues on GitHub`:`Reply continues on GitHub`,r)),i.append(a),i}function V8(e){let t=_6(e);if(t.length===0)return[];let n=V(`section`,`my-pr-threads-section`);n.append(V(`h3`,`pr-section-heading`,`Answered threads`));let r=V(`div`,`my-pr-threads`);for(let n of t){let t=V(`div`,`my-pr-thread pr-thread-card`),i=V(`div`,`my-pr-thread-heading pr-thread-heading`),a=V(`span`,`pr-thread-chip`,n.judgementLabel);a.dataset.tone=n.judgementTone,i.append(vf(`pr-link my-pr-thread-location`,n.location,n.thread.url),a),t.append(i),n.judgementReason&&t.append(V(`p`,`my-pr-thread-meta`,n.judgementReason)),n.thread.viewerComment&&t.append(V(`div`,`my-pr-thread-meta`,`Your comment`),B8(n.thread.viewerComment,!0,n.thread.viewerCommentTruncated===!0,n.thread.url));let o=V(`div`,`pr-detail-meta pr-thread-reply-meta`,`${n.thread.lastReplyAuthor} replied`),s=f8(``,n.thread.lastReplyAt);s&&o.append(s);let c=V(`span`,`pr-action-status`);c.setAttribute(`role`,`status`);let l=V(`button`,`pr-action`,`Resolve`);l.type=`button`,l.disabled=!n.canResolve||c8.has(e.key);let u=(e,t)=>{l.disabled=e||!n.canResolve,c.textContent=t,c.dataset.tone=e?`ok`:`error`};l.addEventListener(`click`,()=>{c8.has(e.key)||(l.disabled=!0,c.textContent=I6(`resolve-thread`),!P8(`other`,e,`resolve-thread`,``,[],u,n.thread.id)&&u(!1,`Not connected to the server.`))}),t.append(o),n.thread.lastReplyBody&&t.append(B8(n.thread.lastReplyBody,!1,n.thread.lastReplyTruncated===!0,n.thread.url));let d=V(`footer`,`pr-thread-footer`);d.append(c,l),t.append(d),n.thread.resolveError&&t.append(V(`p`,`pr-attention-detail`,n.thread.resolveError)),r.append(t)}return n.append(r),[n]}function H8(e){let t=V(`article`,`pr-detail`);if(t.append(C8(e),...A8(e),...V8(e)),e.status===`posted`&&t.append(j8(e),M8(e)),e.status!==`posted`&&t.append(V(`p`,`pr-attention-detail`,j6(e))),!k6(e.status))return s8.set(e.key,{signature:T8(e),element:t,settle:()=>{}}),t;let n=V(`footer`,`pr-footer`),r=F6(e),i=V(`span`,`pr-action-status`,r.footer.includes(`approve-only`)?Ole:``);i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`);let a=[],o=(e,t)=>{for(let t of a)t.disabled=e;i.dataset.tone=e?`ok`:`error`,i.textContent=t},s=t=>{if(!c8.has(e.key)){for(let e of a)e.disabled=!0;i.dataset.tone=`busy`,i.textContent=I6(t),!P8(`other`,e,t,``,[],o)&&o(!1,`Not connected to the server.`)}},c=r.footer.map(e=>L8(e,s));if(a.push(...c),r.more.length>0){let e=I8(r.more,s);a.push(...e.controls),R8(t,e.element)}return n.append(...c,i),t.append(n),s8.set(e.key,{signature:T8(e),element:t,settle:o}),t}function U8(e){if(!k6(e.status)&&_6(e).length===0)return H8(e);let t=s8.get(e.key);return t&&(c8.has(e.key)||t.signature===T8(e))?w8(t.element,e):H8(e)}function W8(e){if(!J6)return;if(X6=C6(e,X6,Z6!==null),!X6){if(Z6!==null){let t=Z6.actedKey;t&&![...e.ready,...e.attention].some(e=>e.key===t)&&(Z6={actedKey:null}),J6.replaceChildren(b8(bce(e,Z6.actedKey))),e8=null;return}J6.replaceChildren(),e8=null;return}let t=e.ready.find(e=>e.key===X6&&(g6(e).length>0||a6(e)));if(t&&t.status!==`ready`){let e=`threads:${T8(t)}`,n=U8(t);if(e8===e&&J6.firstElementChild===n)return;J6.replaceChildren(n),e8=e;return}let n=[...e.ready,...e.noReviewNeeded].find(e=>e.key===X6&&e.status===`ready`);if(n){let e=`ready:${z6(n)}`,t=Ale(n);if(e8===e)return;J6.replaceChildren(t),e8=e;return}let r=e.inReview.find(e=>e.key===X6);if(r){r8.reset(),J6.replaceChildren(Mle(r)),e8=`inReview:${r.key}`;return}let i=e.queued.find(e=>e.key===X6);if(i){let t=`queued:${i.key}:${e.inReview.length}`;if(e8===t)return;J6.replaceChildren(jle(i,e.inReview.length)),e8=t;return}let a=[...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded].find(e=>e.key===X6);a&&(J6.replaceChildren(U8(a)),e8=`${a.status}:${a.key}`)}function Nle(){let e=V(`p`,`pr-empty`,gle(H6));return H6&&!H6.configured&&e.append(` `,pW(wce,Tce,`Open Team review settings`)),e}function G8(){let e=R6(H6);return e?[V(`p`,`my-pr-note`,e)]:[]}function Ple(e){for(let t of[...o8.keys()])e.has(t)||c8.has(t)||o8.delete(t);let t=new Set(H6?.drafts.filter(e=>k6(e.status)).map(e=>e.key)??[]);for(let e of s8.keys())t.has(e)||c8.has(e)||s8.delete(e)}function Fle(){if(!U6||!W6||K6?.isConnected)return;let e=l4({queueLabel:`Review queue`,scopeTabs:W6,resizerLabel:`Resize review queue`});K6=e.queue,$6=V(`p`,`pr-action-status pr-action-notice`),$6.setAttribute(`role`,`status`),$6.setAttribute(`aria-live`,`polite`),J6=V(`div`,`pr-detail-body`),e.detail.append($6,J6),x8(Q6),G6&&e.foot.append(G6.control),U6.replaceChildren(e.columns),e8=null,q6=null}function K8(e){if(!e)return;e.querySelector(`.pr-team-chip`)?.remove();let t=H6?.team;if(!t)return;let n=V(`span`,`pr-team-chip`);n.append(hf({login:t.slug,url:t.avatarUrl,cssPx:16}),V(`span`,null,t.name)),e.insertBefore(n,e.querySelector(`.pr-queue-toggle`))}function q8(){let e=document.activeElement;return!(e instanceof HTMLElement)||!K6?.contains(e)?null:e.dataset.reviewKey??null}function J8(e){e&&K6&&[...K6.querySelectorAll(`button[data-review-key]`)].find(t=>t.dataset.reviewKey===e)?.focus({preventScroll:!0})}function Y8(){if(!U6)return;let e=q8(),t=m6(H6);if(Ple(new Set([...t.ready,...t.noReviewNeeded].map(e=>e.key))),i8.reset(),!H6?.configured||!Bce(t)&&Z6===null){n8.reset(),r8.reset();let e=s4(W6);K8(e),U6.replaceChildren(e,...G6?[G6.notice]:[],...G8(),Nle(),c4(G6?.control??null)),G6?.update(H6),K6=null,q6=null,J6=null,$6=null,Y6=null,e8=null;return}if(Fle(),!K6)return;K8(U6.querySelector(`.pr-queue-head`)),X6=C6(t,X6,Z6!==null);let n=d6(t),r=JSON.stringify([t,n,X6,R6(H6)]);if(r===q6){G6?.update(H6),W8(t),p8(U6);return}q6=r,n8.reset();let i=[],a=l6(t);a&&i.push(b8({title:`All caught up`,detail:a})),t.ready.length&&i.push(S8(`Ready`,t.ready,`ready`,n)),t.inReview.length&&(Y6=S8(`In review`,t.inReview,`inReview`,n),i.push(Y6)),t.queued.length&&i.push(S8(`Queued`,t.queued,`queued`,n)),t.noReviewNeeded.length&&i.push(S8(`Already reviewed`,t.noReviewNeeded,`settled`,n)),t.handReview.length&&i.push(wle(t.handReview,n)),t.attention.length&&i.push(S8(`Needs attention`,t.attention,`attention`,n)),t.posted.length&&i.push(S8(`Waiting on author`,t.posted,`posted`,n)),t.discarded.length&&i.push(S8(`Discarded`,t.discarded,`discarded`,n)),K6.replaceChildren(...G6?[G6.notice]:[],...G8(),...i),G6?.update(H6),J8(e),W8(t),p8(U6)}function X8(){t8&&t8(l8.refresh())}function Ile(){l8.acknowledge(),X8()}function Lle(e){t8=e,X8()}function Rle(e,t){return U6||(W6=t,U6=V(`div`,`pr-content`),e.append(U6),G6=U3(`team-review`,U6),n8.ensure(),r8.ensure(),i8.ensure(),Y8(),U6)}function zle(e){let t=fu.safeParse(e);if(!t.success)return;let n=H6;H6=t.data,!(vle(n,t.data)&&Ble())&&(Y8(),X8())}function Ble(){if(!H6||!Y6?.isConnected)return!1;n8.reset(),i8.reset();let e=q8(),t=m6(H6),n=S8(`In review`,t.inReview,`inReview`,d6(t));return Y6.replaceWith(n),Y6=n,J8(e),t.inReview.some(e=>e.key===X6)&&W8(t),p8(U6),!0}function Vle(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.key!=`string`)return;let n=c8.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),c8.delete(t.key),n.action===`resolve-thread`){n.settle?.(t.ok===!0,typeof t.error==`string`?t.error:L6(n.action)),s8.delete(t.key),e8=null,t.ok===!0&&Y8();return}let r=(n.origin===`ready`?o8:s8).get(t.key);if(t.ok===!0){n.origin===`other`&&s8.delete(t.key);let e=xce({action:n.action,pullRequest:n.pullRequest,warning:typeof t.warning==`string`?t.warning:``,isActedSelected:X6===t.key});if((r?.settle??n.settle)?.(!0,e.statusText),(e.notice||e.shouldAdvance)&&x8(e.notice),!e.shouldAdvance)return;X6=Vce({capturedOrder:n.capturedOrder,actedKey:t.key,groups:m6(H6)}),X6===null&&(Z6={actedKey:t.key}),Y8();return}(r?.settle??n.settle)?.(!1,typeof t.error==`string`&&t.error?t.error:`The action failed.`)}function Z8(e,t,n){return n.has(e.id)?`review`:e.state===`open`||e.state===`blocked`?`queue`:e.state===`active`?`workers`:e.state===`completed`?t.has(e.id)?`review`:`shipped`:null}function Hle(e){let t=0;for(let n of e.owner??e.id)t=Math.imul(t,31)+n.charCodeAt(0)>>>0;return iO[t%iO.length]}function Ule(e,t,n){return t?`Scope conflict`:e.state===`blocked`?`Blocked`:e.state===`open`&&e.readiness===`waiting`?`Waiting on dependency`:n===`workers`?`Running`:n===`review`?`Unverified`:n===`shipped`?`Shipped`:`Ready`}function Wle(e,t){let n=new Set,r=e;for(;r;){if(n.has(r.id))return null;if(n.add(r.id),r.parent===null)return r;r=t.get(r.parent)}return null}function Gle(e,t){let n=e.orders.filter(e=>e.parent===null&&e.state!==`completed`&&e.state!==`cancelled`).sort((e,t)=>e.openedAt.localeCompare(t.openedAt)),r=new Set(e.orders.filter(e=>e.state===`active`).map(e=>e.parent)),i=n.find(t=>t.id===e.orchestrator?.intentId)??n.find(e=>r.has(e.id))??n[0]??null,a=i?e.orders.filter(e=>e.parent===i.id):[],o=new Set(e.reviewing??[]),s=new Set(e.unverifiedCompletedWork),c=new Set(e.conflicts.flatMap(e=>[e.left,e.right])),l={queue:[],workers:[],review:[],shipped:[]},u=e.orders.filter(e=>e.parent===i?.id);for(let n of u){let r=Z8(n,s,o);if(!r)continue;let i=c.has(n.id),a=i||n.state===`blocked`||n.state===`open`&&n.readiness===`waiting`;l[r].push({id:n.id,objective:n.objective,sessionId:e.liveWorkers?.find(e=>e.workId===n.id)?.sessionId??null,risk:n.risk,station:r,status:o.has(n.id)?`Reviewing`:Ule(n,i,r),hasConflict:i,isHeld:a,isSelected:n.id===t,animal:Hle(n)})}let d=new Map(e.orders.map(e=>[e.id,e])),f=t===null?void 0:d.get(t),p=f?Wle(f,d):null;return{paused:e.paused,spend:`Factory today: $${(e.spentTodayUsd??0).toFixed(2)} / ${e.dailyBudgetUsd==null?`unlimited`:`$${e.dailyBudgetUsd.toFixed(2)}`}`,note:e.note??null,intent:i?{id:i.id,objective:i.objective,criteria:i.criteria.map(e=>({text:e,isMet:i.state===`completed`})),shippedCount:l.shipped.length,childCount:a.length}:null,upNext:n.filter(e=>e.id!==i?.id).map(({id:e,objective:t})=>({id:e,objective:t})),orchestrator:e.error===null?{action:e.heading.action,reason:e.heading.reasons[0]??``,isException:!1,sessionId:e.orchestrator?.sessionId??null,state:e.orchestrator?.state??null}:{action:`Exception`,reason:e.error,isException:!0,sessionId:e.orchestrator?.sessionId??null,state:e.orchestrator?.state??null},stations:l,ledger:e.orders.flatMap(e=>e.lastEvent?[{orderId:e.id,...e.lastEvent}]:[]).sort((e,t)=>Date.parse(t.at)-Date.parse(e.at)).slice(0,50),selectedOrder:f?{id:f.id,intent:p?.objective??null,writeScopes:f.writeScopes,dependsOn:f.dependsOn,station:f.parent===null?`intent`:Z8(f,s,o)??`cancelled`,owner:f.owner}:null}}function Kle(e,t){return e.find(e=>e.projectId===t)||([...e].sort((e,t)=>e.projectName.localeCompare(t.projectName)||e.projectId.localeCompare(t.projectId))[0]??null)}var Q8=null,$8=null,e5=null,t5=!1,n5=null,r5=null,i5=null,a5=0,o5=new Map,s5=new Map,c5=new Map;function qle(e){let t=o5.get(e);if(t)return t;let n={objective:``,criteria:``,risk:`low`,boundary:``,writeScopes:``};return o5.set(e,n),n}var l5=`.factory-stack, .factory-pads, .factory-ledger, .factory-detail, .factory-intent-queue, .factory-criteria`,Jle=[[`[data-order-id]`,`orderId`],[`[data-factory-field]`,`factoryField`],[`[data-project-id]`,`projectId`]];function u5(e,t,n){let r=V(`button`,e,t);return r.type=`button`,r.addEventListener(`click`,n),r}function d5(e){let t=V(`p`,`factory-request-status`,e?.text??``);return t.setAttribute(`role`,`status`),t.dataset.error=String(e?.hasError===!0),t}function f5(e,t,n,r){let i=t===`factory-queue-intent`?s5:c5;if(i.get(e)?.requestId)return;a5+=1;let a=`factory-${a5}`,o=i5?.({...n,projectId:e,type:t,requestId:a})===!0;i.set(e,{requestId:o?a:null,text:o?r:`Not connected.`,hasError:!o}),_5()}function Yle(e,t){let n=V(`fieldset`,`factory-form-field`);n.append(V(`legend`,`factory-label`,`Protected floor opt-in`));for(let r of il){let i=V(`label`,`factory-floor-allowance`),a=V(`input`);a.type=`checkbox`,a.value=r,a.dataset.factoryField=`floor:${r}`,a.checked=e.floorAllowances?.includes(r)===!0,a.disabled=t,a.addEventListener(`change`,()=>{let t=(e.floorAllowances??[]).filter(e=>e!==r),n=a.checked?[...t,r]:t;e.floorAllowances=il.filter(e=>n.includes(e))}),i.append(a,V(`span`,null,r)),n.append(i)}return n}function Xle(e){let t=qle(e),n=V(`form`,`factory-queue-form`),r=s5.get(e)?.requestId!=null;for(let[e,i,a,o]of[[`objective`,`Objective`,4096,2],[`criteria`,`Criteria, one per line`,49164,2],[`boundary`,`Authority boundary`,4096,1],[`writeScopes`,`Write scopes, one per line`,32800,2]]){let s=V(`label`,`factory-form-field`),c=V(`textarea`,`factory-form-input`);c.name=e,c.dataset.factoryField=e,c.maxLength=a,c.rows=o,c.required=e!==`writeScopes`,c.value=t[e],c.disabled=r,c.addEventListener(`input`,()=>{t[e]=c.value}),s.append(V(`span`,`factory-label`,i),c),n.append(s)}let i=V(`label`,`factory-form-field`),a=V(`select`,`factory-form-input`);a.name=`risk`,a.dataset.factoryField=`risk`,a.disabled=r;for(let e of sl.shape.risk.options){let t=V(`option`,null,e);t.value=e,a.append(t)}a.value=t.risk,a.addEventListener(`change`,()=>{t.risk=sl.shape.risk.parse(a.value)}),i.append(V(`span`,`factory-label`,`Risk`),a),n.append(Yle(t,r));let o=V(`button`,`factory-action`,`Queue intent`);return o.type=`submit`,o.disabled=!t5||r,n.insertBefore(i,n.children[2]??null),n.append(o,d5(s5.get(e))),n.addEventListener(`submit`,n=>{n.preventDefault();let r=sl.safeParse({...t,projectId:e,criteria:t.criteria.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),writeScopes:t.writeScopes.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)});if(!r.success){s5.set(e,{requestId:null,text:r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `),hasError:!0}),_5();return}f5(e,`factory-queue-intent`,r.data,`Queueing intent.`)}),n}function Zle(e,t){let n=V(`div`,`factory-controls`),r=c5.get(e);for(let i of[`pause`,`resume`]){let a=u5(`factory-action`,i===`pause`?`Pause`:`Resume`,()=>f5(e,`factory-control`,{action:i},i===`pause`?`Pausing factory.`:`Resuming factory.`));a.disabled=!t5||r?.requestId!=null||(i===`pause`?t:!t),n.append(a)}return n.append(d5(r)),n}var Qle=[{id:`queue`,label:`Queue`,slots:3},{id:`workers`,label:`Workers`,slots:3},{id:`review`,label:`Review`,slots:2},{id:`shipped`,label:`Shipped`,slots:3}];function p5(e,t){let n=Cf(`factory`,e);return n.classList.add(...t.split(` `)),n.setAttribute(`aria-label`,e),n}function m5(e,t){let n=V(`div`,`factory-sprite`);n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t);let r=V(`span`,`nyan-sprite ${e}`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n}function $le(e){r5=e,_5()}function h5(e,t,n){let r=u5(n,t,()=>$le(e));return r.dataset.orderId=e,r.setAttribute(`aria-pressed`,String(r5===e)),r}function g5(e,t){let n=V(`div`,`factory-crate`);n.dataset.state=e.isHeld?`waiting`:e.station,n.dataset.selected=String(e.isSelected);let r=V(`div`,`factory-crate-id`),i=V(`span`,`factory-crate-risk`,e.risk);i.dataset.risk=e.risk,r.append(V(`span`,null,e.id),i),n.append(r,h5(e.id,e.objective,`factory-crate-title`));let a=e.sessionId;return a&&Q8&&!t&&n.append(u5(`factory-action`,`Open terminal`,()=>Q8?.(a))),e.station!==`workers`&&n.append(V(`span`,`factory-crate-note`,e.status)),n}function eue(e){return`Read-only mirror of the factory harness run at ${e.recordDirectory}. ${e.outcome?`Ended: ${e.outcome}.`:`No verdict yet.`}`}function tue(e,t){let n=t.projectId,r=t.observedRun!==void 0,i=V(`div`,`factory-band factory-head`),a=p5(`Intent`,`factory-intent`);if(a.append(V(`p`,`factory-count`,e.spend)),e.intent){a.append(h5(e.intent.id,e.intent.objective,`factory-intent-title`));let t=V(`ul`,`factory-criteria`);for(let n of e.intent.criteria){let e=V(`li`,null,`${n.isMet?`[x]`:`[ ]`} ${n.text}`);e.dataset.met=String(n.isMet),t.append(e)}a.append(t,V(`p`,`factory-count`,`${e.intent.shippedCount} of ${e.intent.childCount} shipped`))}e.intent||a.append(V(`p`,`factory-empty`,`No open intent.`));let o=p5(`Orchestrator`,`factory-orchestrator`);o.dataset.state=e.orchestrator.isException?`failed`:e.paused?`paused`:`steady`;let s=V(`div`,`factory-heading`);s.append(V(`strong`,`factory-orchestrator-action`,e.orchestrator.action),V(`p`,`factory-reason`,e.orchestrator.reason)),e.note&&s.append(V(`p`,`factory-reason`,e.note));let c=V(`span`,`factory-paused-marker`,`[paused]`);c.hidden=!e.paused,s.append(c),t.observedRun&&s.append(V(`p`,`factory-reason`,eue(t.observedRun))),r||s.append(Zle(n,e.paused));let l=m5(`is-owl`,`Orchestrator owl`),u=e.orchestrator.sessionId;if(u&&Q8&&!r){let e=u5(`factory-action`,null,()=>Q8?.(u));e.setAttribute(`aria-label`,`Open orchestrator terminal`),e.append(l),o.append(e)}(!u||!Q8||r)&&o.append(l),e.orchestrator.state&&s.append(V(`span`,`factory-orchestrator-state`,e.orchestrator.state)),o.append(s);let d=p5(`Up next`,`factory-up-next`),f=V(`ol`,`factory-intent-queue`);for(let t of e.upNext){let e=V(`li`);e.append(h5(t.id,t.objective,`factory-next-title`)),f.append(e)}return d.append(f),e.upNext.length===0&&d.append(V(`p`,`factory-empty`,`No queued intents.`)),r||d.append(Xle(n)),i.append(a,o,d),i}function nue(e,t,n){let r=V(`section`,`factory-station factory-station-${e.id}`);r.setAttribute(`aria-label`,e.label);let i=V(`div`,`factory-station-head`);i.append(V(`h3`,`factory-label`,e.label),V(`span`,`factory-count`,String(t.length)));let a=V(`div`,e.id===`workers`?`factory-pads`:`factory-stack`);for(let r=0;r<Math.max(e.slots,t.length);r+=1){let i=t[r],o=V(`div`,`factory-open`,`Open slot`);if(e.id!==`workers`){a.append(i?g5(i,n):o);continue}let s=V(`div`,`factory-pad`);s.dataset.state=i?.hasConflict?`waiting`:i?`running`:`idle`,i&&s.append(m5(i.animal.sprite,i.animal.name)),i||s.append(V(`div`,`factory-sprite factory-sprite-empty`)),s.append(i?g5(i,n):o,V(`span`,`factory-pad-status`,i?.status??`Idle`)),a.append(s)}return r.append(i,a),r}function rue(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Cp(t)}function iue(e){let t=V(`div`,`factory-band factory-foot`),n=p5(`Ledger`,`factory-ledger-region`),r=V(`ol`,`factory-ledger`);for(let t of e.ledger){let e=V(`li`),n=V(`time`,`factory-ledger-time`,rue(t.at));n.dateTime=t.at,e.append(n,V(`span`,null,`${t.orderId} ${t.event} (${t.session})`)),r.append(e)}e.ledger.length===0&&r.append(V(`li`,`factory-empty`,`No ledger events.`)),n.append(r);let i=p5(`Selected ticket`,`factory-detail-region`),a=V(`div`,`factory-detail`),o=e.selectedOrder;if(o){let e=V(`dl`);for(let[t,n]of[[`Intent`,o.intent??`No parent intent`],[`Fence`,o.writeScopes.join(`, `)||`None`],[`After`,o.dependsOn.join(`, `)||`None`],[`Station`,o.station],[`Session`,o.owner??`Unassigned`]])e.append(V(`dt`,null,t),V(`dd`,null,n));a.append(e)}return o||a.append(V(`p`,`factory-empty`,`Select a ticket to inspect its boundaries.`)),i.append(a),t.append(n,V(`div`,`factory-seam`),i),t}function _5(){if(!$8)return;let e=document.activeElement instanceof HTMLElement?document.activeElement:null,t=e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:null,n=[...$8.querySelectorAll(l5)].map(e=>e.scrollTop),r=document.createDocumentFragment(),i=V(`p`,`factory-connection`,t5?e5?``:`Waiting for the server.`:`Disconnected. Showing the last snapshot.`);i.setAttribute(`role`,`status`),r.append(i);let a=Kle(e5?.projects??[],n5);if(!a){r.append(V(`p`,`factory-empty`,e5?`No repos holding coherence.config.json.`:`Waiting for Factory state.`)),$8.replaceChildren(r);return}if(n5!==a.projectId&&(r5=null),n5=a.projectId,e5&&e5.projects.length>1){let e=V(`div`,`factory-projects`);e.setAttribute(`aria-label`,`Factory projects`);for(let t of e5.projects){let n=u5(`factory-project`,t.projectName,()=>{n5=t.projectId,r5=null,_5()});n.dataset.projectId=t.projectId,n.setAttribute(`aria-pressed`,String(t.projectId===n5)),e.append(n)}r.append(e)}let o=Gle(a,r5),s=V(`div`,`factory-console`),c=p5(`Floor`,`factory-band factory-floor-band`),l=V(`div`,`factory-pipe`);for(let e of Qle)l.append(nue(e,o.stations[e.id],a.observedRun!==void 0));c.append(l),s.append(tue(o,a),c,iue(o)),r.append(s),$8.replaceChildren(r),[...$8.querySelectorAll(l5)].forEach((e,t)=>{e.scrollTop=n[t]??0});for(let[n,r]of Jle){let i=e?.dataset[r];if(!i)continue;let a=[...$8.querySelectorAll(n)].find(e=>e.dataset[r]===i);a?.focus({preventScroll:!0}),a instanceof HTMLTextAreaElement&&t&&a.setSelectionRange(t.start,t.end)}}function aue(e,t){return Q8=t?.openTerminal??null,$8||($8=V(`div`,`factory-content`),e.append($8),_5(),$8)}function oue(e){e5=e,_5()}function sue(e){if(t5=e,!e)for(let e of[s5,c5])for(let[t,n]of e)n.requestId&&e.set(t,{requestId:null,text:`Disconnected. Check the floor before submitting again.`,hasError:!0});_5()}function cue(e){i5=e}function lue(e){s5.get(e.projectId)?.requestId===e.requestId&&(s5.set(e.projectId,{requestId:null,text:e.ok?`Queued ${e.workId??`intent`}.`:e.error??`Could not queue intent.`,hasError:!e.ok}),e.ok&&o5.delete(e.projectId),_5())}function uue(e){c5.get(e.projectId)?.requestId===e.requestId&&(c5.set(e.projectId,{requestId:null,text:e.ok?e.action===`pause`?`Factory paused.`:`Factory resumed.`:e.error??`Could not update factory.`,hasError:!e.ok}),_5())}var due={mine:`Mine`,run:`Run`,cancel:`Cancel`},fue={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},v5=null,y5=null,b5=null,x5=new Map,S5=new Map;function C5(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function pue(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function mue(e,t){if(b5?.({type:`benchmark-action`,requestId:af(`benchmark`),suiteId:e,action:t})!==!0){S5.set(e,`Not connected.`),E5();return}x5.set(e,t),S5.set(e,fue[t]),E5()}function w5(e,t,n){let r=V(`button`,`bench-action-button`,due[t]);return r.type=`button`,r.disabled=n,r.addEventListener(`click`,()=>mue(e.id,t)),r}function hue(e){let t=y5?.inFlight;if(!t||t.suiteId!==e.id)return``;let n=t.caseId?`case ${t.caseId}, `:``;return`Cell ${t.cellIndex+1} of ${t.cellCount}: ${n}arm ${t.armId}, trial ${t.trial}, ${t.phase}.`}function T5(e){let t=V(`td`,`bench-score`,C5(e?.recall??null));return e&&e.invalid>0&&(t.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(t.dataset.degraded=`true`),t}function gue(e){let t=e.armIds.filter(t=>t!==e.baselineArm),n=V(`table`,`bench-table`),r=V(`tr`);r.append(V(`th`,null,`Case`),...e.armIds.map(t=>V(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),r.append(...t.map(e=>V(`th`,null,`${e} vs baseline`))),n.append(r);for(let r of e.rows){let i=V(`tr`);i.append(V(`td`,`bench-case`,r.caseId),...e.armIds.map(e=>T5(r.arms[e]))),i.append(...t.map(e=>V(`td`,`bench-delta`,pue(r.deltaVsBaseline[e]??null)))),n.append(i)}let i=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),a=V(`tr`,`bench-total`);a.append(V(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>T5(e.totals[t]))),n.append(a);for(let t of i){let r=V(`tr`,`bench-total`);r.append(V(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(n=>V(`td`,`bench-score`,C5(e.totals[n]?.recallByTag[t]??null)))),n.append(r)}return n}function _ue(e){let t=V(`div`,`bench-suite`),n=y5?.inFlight?.suiteId===e.id,r=!!y5?.inFlight&&!n,i=x5.has(e.id),a=V(`div`,`bench-summary`);a.append(V(`span`,`bench-suite-title`,e.title),wf(`bench`,e.caseCount===1?`case`:`cases`,String(e.caseCount)),wf(`bench`,e.candidateCount===1?`candidate`:`candidates`,String(e.candidateCount)),wf(`bench`,`arms`,String(e.armIds.length))),t.append(a);let o=V(`div`,`bench-controls`),s=y5?.configured===!0&&e.error===null;o.append(w5(e,`mine`,!s||i||n),w5(e,`run`,!s||i||n||r||e.caseCount===0),w5(e,`cancel`,i||!n));let c=V(`span`,`bench-status`,hue(e)||S5.get(e.id)||``);if(c.setAttribute(`role`,`status`),o.append(c),t.append(o),e.error)return t.append(V(`p`,`bench-error`,e.error)),t;let l=e.latestReport;return l?(t.append(V(`p`,`bench-run-line`,`Latest run ${l.runId}: ${l.status}. Only cases every arm scored count toward paired recall.`)),l.rows.length>0&&t.append(gue(l)),t):(t.append(V(`p`,`bench-empty`,e.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),t)}function E5(){if(!v5)return;v5.textContent=``;let e=Cf(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(v5.append(e),!y5){v5.append(V(`p`,`bench-empty`,`Waiting for the server.`));return}if(!y5.configured){v5.append(V(`p`,`bench-empty`,y5.reason||`Benchmarks are off.`));return}if(y5.suites.length===0){v5.append(V(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));return}for(let e of y5.suites)v5.append(_ue(e))}function vue(e){b5=e}function yue(e){return v5||(v5=V(`div`,`bench-content`),e.append(v5),E5(),v5)}function bue(e){if(!(e||x5.size===0)){for(let e of x5.keys())S5.set(e,`Connection lost.`);x5.clear(),E5()}}function xue(e){y5=e,E5()}function Sue(e){x5.delete(e.suiteId);let t=y5?.suites.find(t=>t.id===e.suiteId)?.candidateCount??0,n={mine:`Mining finished. ${t} candidate${t===1?``:`s`} awaiting approval in the candidates folder.`,run:`Run ${e.runId??``} started.`,cancel:`Run cancelled.`};S5.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),E5()}function Cue(e){return e?e.configured?`No open issues.`:e.reason??`Loading issues.`:`Loading issues.`}function D5(e,t){return t===`all`||e.sources.includes(t)}function wue(e){return{all:e.length,me:e.filter(e=>D5(e,`me`)).length,team:e.filter(e=>D5(e,`team`)).length,project:e.filter(e=>D5(e,`project`)).length}}function Tue(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean),i=e.filter(e=>{if(!D5(e,t.scope)||t.repo&&e.repo!==t.repo||t.label&&!e.labels.includes(t.label)||t.hasSession&&(!e.sessionId||!n.has(e.sessionId))||t.hasPr&&e.pullRequests.length===0||t.isUnassignedOnly&&e.assignees.length>0)return!1;let i=[e.title,`#${e.number}`,e.repo,e.author,...e.labels,...e.assignees,...e.teams].join(` `).toLowerCase();return r.every(e=>i.includes(e))}),a=e=>Date.parse(e)||0,o=e=>t.sort===`comments`?e.comments:t.sort===`created`?a(e.createdAt):a(e.updatedAt);return i.sort((e,t)=>o(t)-o(e)||e.key.localeCompare(t.key))}function Eue(e){let t=new Map;for(let n of e){let e=t.get(n.repo)??[];e.push(n),t.set(n.repo,e)}return t}function Due(e){return{repos:[...new Set(e.map(e=>e.repo))].sort(),labels:[...new Set(e.flatMap(e=>e.labels))].sort()}}function Oue(e){let t=[e.query.trim()&&`search "${e.query.trim()}"`,e.repo,e.label,e.hasSession&&`has session`,e.hasPr&&`has PR`,e.isUnassignedOnly&&`unassigned`].filter(Boolean);return t.length===0?``:`Filtered by ${t.join(`, `)}.`}function O5(e,t){let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.round(Math.max(0,t-n)/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.round(r/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function k5(e,t){let n=O5(e,t);return n===`now`?`just now`:n===`unknown`?`at an unknown time`:`${n} ago`}var A5=45e3,j5=[{id:`all`,label:`All`},{id:`me`,label:`Mine`},{id:`team`,label:`Team`},{id:`project`,label:`Projects`}],M5={scope:`all`,repo:``,label:``,sort:`updated`,query:``,hasSession:!1,hasPr:!1,isUnassignedOnly:!1},N5=null,P5=null,F5=null,I5=null,L5=null,R5=null,z5=null,B5=null,V5=null,H5=null,U5=new Map,W5=!1,G5=null,K5=null,q5=new Map,J5=new Map,Y5=new Map,X5=new Map,Z5=new Map;function Q5(e){return`${e.key}:${e.updatedAt}`}function $5(e){return e.sessionId?U.get(e.sessionId):void 0}function e7(e,t,n){let r=$5(t),i=r?.currentState??F.DORMANT,a=xf(i,r?.awaitingBackgroundTasks),o=r?`Session: ${a.label}`:`No session yet`,s=n?`${a.glyph} ${a.label}`:a.glyph;(e.dataset.state!==i||e.title!==o||e.textContent!==s)&&(e.dataset.state=i,e.title=o,e.setAttribute(`aria-label`,o),e.textContent=s)}function t7(e,t=!1){let n=V(`span`,t?`issues-state`:`pr-queue-glyph issues-state`);return e7(n,e,t),n}function n7(e){let t=$5(e);return t?Kf(t):`none yet`}function r7(e){return[...q5.values()].some(t=>t.issueKey===e.key)}function kue(e){let t=q5.get(e);t&&(q5.delete(e),J5.set(t.issueKey,`No reply from the server.`),c7())}function Aue(e){let t=q5.get(e);return t?(clearTimeout(t.timeoutHandle),q5.delete(e),t):null}function i7(e){let t=Q5(e);if(X5.has(t)||[...Y5.values()].some(e=>e.cacheKey===t))return;let n=af(`issue-detail`);if(Z5.delete(t),!K5?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})){Z5.set(t,`Not connected. Select the issue to load its description.`);return}Y5.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{Y5.delete(n),Z5.set(t,`No reply from the server. Select the issue to load its description.`),c7()},A5)})}function jue(e){let t=e.projectId;if(!t||$5(e)||r7(e))return;let n=af(`open-issue-session`);if(!K5?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})){J5.set(e.key,`Not connected.`),c7();return}q5.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>kue(n),A5)}),J5.set(e.key,`Opening session.`),c7()}function Mue(e){let t=V(`button`,`pr-queue-row issue-row`);t.type=`button`,t.dataset.issueKey=e.key,t.setAttribute(`aria-current`,String(e.key===V5));let n=V(`span`,`pr-queue-top`);n.append(V(`span`,`pr-queue-ref`,`#${e.number}`),V(`span`,`pr-queue-title`,e.title||`Untitled issue`));let r=V(`span`,`pr-queue-bottom`);e.sources.includes(`me`)&&r.append(V(`span`,`issues-why`,`you`)),r.append(V(`span`,`issues-row-labels`,e.labels.join(`, `)));for(let t of e.pullRequests)r.append(V(`span`,`issues-row-pr`,`PR #${t.number}`));let i=V(`span`,`pr-queue-elapsed`,O5(e.updatedAt,Date.now()));return i.dataset.issueAge=e.updatedAt,r.append(i),t.append(t7(e),n,r),t.addEventListener(`click`,()=>{V5=e.key,N5&&(N5.dataset.detailOpen=`true`),i7(e),u7(),I5&&(I5.scrollTop=0)}),t}function a7(e,t,n){let r=V(`dd`);r.append(...n),e.append(V(`dt`,null,t),r)}function o7(e){let t=V(`footer`,`pr-footer issues-detail-footer`),n=$5(e);if(n&&e.sessionId){let n=e.sessionId,r=V(`button`,`pr-action`,`Go to session`);r.type=`button`,r.addEventListener(`click`,()=>wI(n)),t.append(r)}if(e.projectId&&!n){let n=V(`button`,`pr-action`,`Open session`);n.type=`button`,n.disabled=r7(e),n.addEventListener(`click`,()=>jue(e)),t.append(n)}t.append(vf(`pr-action`,`View on GitHub`,e.url));let r=J5.get(e.key),i=e.projectId?``:`Add a project for ${e.repo} in Settings to open sessions from here.`,a=V(`span`,`pr-action-status issue-open-status`,r??i);return a.setAttribute(`role`,`status`),r7(e)&&a.prepend(V(`span`,`issues-spinner`)),t.append(a),t}function s7(e,t){let n=V(`span`,null,k5(e,t));return n.dataset.issueAgo=e,n}function Nue(){let e=I5?.querySelector(`.issues-detail`),t=V5?U5.get(V5):void 0;if(!e||!t)return;let n=e.querySelector(`.issues-facts .issues-state`);n&&e7(n,t,!0);let r=e.querySelector(`.issues-session-name`),i=n7(t);r&&r.textContent!==i&&(r.textContent=i);let a=String(!!$5(t));e.dataset.hasLiveSession!==a&&(e.dataset.hasLiveSession=a,e.querySelector(`.issues-detail-footer`)?.replaceWith(o7(t)))}function c7(){if(!I5)return;let e=H5?.issues.find(e=>e.key===V5);if(!e){I5.replaceChildren(V(`p`,`pr-empty`,`Pick an issue from the queue.`));return}let t=V(`article`,`pr-detail issues-detail`),n=V(`button`,`pr-action issues-back`,`Back to issues`);n.type=`button`,n.addEventListener(`click`,()=>{N5&&(N5.dataset.detailOpen=`false`),[...F5?.querySelectorAll(`[data-issue-key]`)??[]].find(e=>e.dataset.issueKey===V5)?.focus({preventScroll:!0})});let r=V(`header`,`pr-detail-heading`),i=V(`div`,`pr-detail-title`);i.append(vf(`pr-link`,`${e.repo}#${e.number}`,e.url),V(`h2`,null,e.title||`Untitled issue`));let a=Date.now(),o=V(`div`,`pr-detail-meta`),s=V(`span`,null,`opened by ${e.author||`unknown`} `),c=V(`span`,null,`updated `);s.append(s7(e.createdAt,a)),c.append(s7(e.updatedAt,a)),o.append(s,c,V(`span`,null,`${e.comments} comments`)),e.sources.includes(`me`)&&o.append(V(`span`,`issues-why`,`assigned to you`));for(let t of e.teams)o.append(V(`span`,null,`mentions ${t}`));r.append(i,o);let l=V(`dl`,`issues-facts`);a7(l,`Repository`,[e.repo]),a7(l,`Labels`,[e.labels.join(`, `)||`none`]),a7(l,`Assignees`,[e.assignees.join(`, `)||`unassigned`]),t.dataset.hasLiveSession=String(!!$5(e)),a7(l,`Session`,[t7(e,!0),V(`span`,`issues-session-name`,n7(e))]);let u=e.pullRequests.flatMap(e=>{let t=V(`span`,`issues-pr-state`,e.state);return t.dataset.prState=e.state,[t,vf(`issues-inline-link`,`#${e.number} ${e.title}`,e.url)]});a7(l,`Pull request`,u.length>0?u:[`none linked`]);let d=V(`section`,`issues-body-section`),f=Q5(e),p=V(`div`,`issue-body`,X5.get(f)??Z5.get(f)??`Loading description.`);X5.get(f)===``&&(p.textContent=`No description.`),p.setAttribute(`role`,`status`),d.append(V(`h3`,`pr-section-heading`,`Description`),p),t.append(n,r,l,d,o7(e)),I5.replaceChildren(t)}function l7(e,t,n,r){if(!e)return;let i=r&&!n.includes(r)?[...n,r].sort():n;e.replaceChildren(...[``,...i].map(e=>{let n=V(`option`,null,e||t);return n.value=e,n})),e.value=r}function u7(){W5=!1,d7(),c7()}function d7(){if(!N5||!F5||!P5)return;let e=H5?.issues??[],t=wue(e);for(let e of j5){P5.querySelector(`[data-scope="${e.id}"]`)?.setAttribute(`aria-selected`,String(e.id===M5.scope));let n=P5.querySelector(`[data-scope-count="${e.id}"]`);n&&(n.textContent=String(t[e.id]))}let n=Due(e);l7(R5,`All repos`,n.repos,M5.repo),l7(z5,`All labels`,n.labels,M5.label),L5&&(L5.textContent=Oue(M5));let r=Tue(e,M5,new Set(U.keys())),i=document.activeElement instanceof HTMLElement&&F5.contains(document.activeElement)?document.activeElement.dataset.issueKey:null,a=[...Eue(r)].map(([e,t])=>{let n=V(`section`,`pr-queue-section`),r=V(`h3`,`pr-section-heading issues-repo-heading`,e);return t.some(e=>e.projectId)||r.append(V(`span`,`issues-repo-note`,`view only`)),r.append(V(`span`,`issues-repo-count`,String(t.length))),n.append(r,...t.map(Mue)),n});F5.replaceChildren(...a),r.length===0&&F5.append(V(`p`,`pr-empty`,e.length>0?`No open issues match these filters. Clear the search or pick All.`:Cue(H5))),i&&[...F5.querySelectorAll(`[data-issue-key]`)].find(e=>e.dataset.issueKey===i)?.focus({preventScroll:!0}),V5&&!e.some(e=>e.key===V5)&&(V5=null,N5.dataset.detailOpen=`false`),G5?.update(H5),f7()}function Pue(){let e=V(`div`,`issues-filters`),t=V(`div`,`issues-search-row`),n=V(`input`,`issues-search`);n.type=`search`,n.placeholder=`Search issues`,n.autocomplete=`off`,n.setAttribute(`aria-label`,`Search issues`),n.addEventListener(`input`,()=>{M5.query=n.value,u7()});let r=V(`button`,`pr-action`,`Filters`);r.type=`button`,r.setAttribute(`aria-expanded`,`false`),r.setAttribute(`aria-controls`,`issues-filters-panel`);let i=V(`div`,`issues-filters-panel`);i.id=`issues-filters-panel`,i.hidden=!0,r.addEventListener(`click`,()=>{i.hidden=!i.hidden,r.setAttribute(`aria-expanded`,String(!i.hidden))}),t.append(n,r);let a=V(`div`,`issues-filter-row`);function o(e){let t=V(`select`,`issues-field`);return t.setAttribute(`aria-label`,e),a.append(t),t}R5=o(`Repository`),R5.addEventListener(`change`,()=>{M5.repo=R5?.value??``,u7()}),z5=o(`Label`),z5.addEventListener(`change`,()=>{M5.label=z5?.value??``,u7()});let s=o(`Sort`);for(let[e,t]of[[`updated`,`Updated`],[`created`,`Newest`],[`comments`,`Most discussed`]]){let n=V(`option`,null,t);n.value=e??``,s.append(n)}s.addEventListener(`change`,()=>{M5.sort=s.value,u7()});let c=V(`div`,`issues-filter-row`);for(let[e,t]of[[`hasSession`,`Has session`],[`hasPr`,`Has PR`],[`isUnassignedOnly`,`Unassigned`]]){let n=V(`label`,`issues-toggle`),r=V(`input`);r.type=`checkbox`,r.addEventListener(`change`,()=>{M5[e]=r.checked,u7()}),n.append(r,` ${t}`),c.append(n)}return L5=V(`span`,`issues-filter-summary`),L5.setAttribute(`role`,`status`),i.append(a,c),e.append(t,L5,i),e}function f7(){if(!N5||N5.closest(`[hidden]`)||document.hidden)return;let e=Date.now();B5&&(B5.textContent=H5?.lastSyncAt?`Synced ${k5(H5.lastSyncAt,e)}.`:`Not synced yet.`);for(let t of N5.querySelectorAll(`[data-issue-age]`))t.textContent=O5(t.dataset.issueAge??``,e);for(let t of N5.querySelectorAll(`[data-issue-ago]`))t.textContent=k5(t.dataset.issueAgo??``,e)}function Fue(e){K5=e}function Iue(e){if(N5)return N5;N5=V(`div`,`issues-content`),N5.dataset.detailOpen=`false`,e.append(N5),G5=U3(`issues`,N5);let t=V(`div`,`pr-columns issues-columns`),n=V(`section`,`pr-queue-pane`);n.setAttribute(`aria-label`,`Issue queue`),P5=V(`div`,`pr-scope-tabs issues-scope-tabs`),P5.setAttribute(`role`,`tablist`),P5.setAttribute(`aria-label`,`Issue scope`);for(let e of j5){let t=V(`span`,`issues-scope`);t.setAttribute(`role`,`presentation`);let n=V(`button`,`pr-scope-tab`,e.label);n.type=`button`,n.dataset.scope=e.id,n.setAttribute(`role`,`tab`),n.addEventListener(`click`,()=>{M5.scope=e.id,u7()});let r=V(`span`,`issues-scope-count`);r.dataset.scopeCount=e.id,t.append(n,r),P5.append(t)}F5=V(`nav`,`pr-queue`),F5.setAttribute(`aria-label`,`Issues`);let r=c4(G5.control);return B5=V(`span`,`issues-sync`),B5.setAttribute(`role`,`status`),r.prepend(B5),r.append(G5.notice),n.append(s4(P5),Pue(),F5,r),I5=V(`section`,`pr-detail-host`),I5.setAttribute(`aria-label`,`Issue detail`),t.append(n,I5),N5.append(t),window.setInterval(f7,3e4),u7(),N5}function Lue(){W5&&p7(),f7()}function p7(){if(Ef(N5)){W5=!0;return}if(W5=!1,Nue(),M5.hasSession){d7();return}for(let e of F5?.querySelectorAll(`[data-issue-key]`)??[]){let t=U5.get(e.dataset.issueKey??``),n=e.querySelector(`.issues-state`);t&&n&&e7(n,t,!1)}}function Rue(e){if(!e){for(let e of q5.values())clearTimeout(e.timeoutHandle),J5.set(e.issueKey,`Connection lost.`);q5.clear();for(let e of Y5.values())clearTimeout(e.timeoutHandle),Z5.set(e.cacheKey,`Connection lost. Select the issue to load its description.`);Y5.clear(),u7()}}function zue(e){let t=H5?.issues.find(e=>e.key===V5);H5=e,U5=new Map(e.issues.map(e=>[e.key,e]));let n=e.issues.find(e=>e.key===V5);n&&n.updatedAt!==t?.updatedAt&&i7(n),u7()}function Bue(e){let t=Y5.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),Y5.delete(e.requestId),e.ok&&e.body!==null&&X5.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&Z5.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),c7())}function Vue(e){if(typeof e.requestId!=`string`)return;let t=Aue(e.requestId);if(!t)return;let n=t.issueKey;if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``,a=e.existing===!0?`already open`:`created`;J5.set(n,`Session "${r}" ${a}.${i}`);let o=H5?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),u7();return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;J5.set(n,r),c7()}var Hue=4e3;function Uue({render:e,holdMs:t=Hue,setTimer:n=setTimeout,clearTimer:r=clearTimeout}){let i=new Set,a=!1,o=null;function s(e){(o===null||e)&&(o!==null&&r(o),o=n(c,t))}function c(){if(o=null,i.size>0){s(!1);return}a&&(a=!1,e())}return{begin(e){i.add(e)},settle(e){i.delete(e),s(!0)},request(){if(i.size===0&&o===null){e();return}a=!0,s(!1)},_state(){return{pending:i.size,held:a,armed:o!==null}}}}var m7=null,h7=null,g7=null,_7=null,v7=`http://www.w3.org/2000/svg`,y7=AA({getAck:yk,setAck:bk,signature:()=>Lre({posthog:m7}),isLooking:()=>!Ef(h7)}),b7=Uue({render:z7}),x7=new Set,S7=null,C7=new Map,w7=XP(()=>h7),Wue={spiking:`spiking`,regressed:`regressed`,worsened:`worsened`,new:`new`,quiet:`quiet`},T7=[{columnId:`stripe`,headText:``,cellClass:`radar-stripe`,track:`auto`,phoneTrack:`auto`,isMagnitude:!1,startsActionCluster:!1},{columnId:`change`,headText:``,cellClass:`radar-change`,track:`auto`,phoneTrack:`minmax(68px, auto)`,isMagnitude:!1,startsActionCluster:!1},{columnId:`copy`,headText:``,cellClass:`radar-issue-copy`,track:`minmax(0, 1fr)`,phoneTrack:`minmax(0, 1fr)`,isMagnitude:!1,startsActionCluster:!0},{columnId:`occurrences`,headText:`Occurrences`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`users`,headText:`Users`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`trend`,headText:`Trend`,cellClass:`radar-issue-trend`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1}],Gue=T7.map(e=>e.track).join(` `),Kue=T7.filter(e=>!e.isMagnitude).map(e=>e.phoneTrack).join(` `),que=T7.findIndex(e=>e.startsActionCluster)+1;function E7(e){let t=V(`div`,e);return t.style.setProperty(`--radar-issue-grid`,Gue),t.style.setProperty(`--radar-issue-grid-phone`,Kue),t.style.setProperty(`--radar-issue-actions-start`,String(que)),t}function D7(e,t){let n=V(`span`,`radar-issue-magnitudes`),r=!1;for(let i of T7){let a=t(i);if(!i.isMagnitude){e.append(a);continue}r||=(e.append(n),!0),n.append(a)}}function O7(e){return Number.isFinite(e)?String(e):`0`}function Jue(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`elapsed ${qP(Date.now()-e)}`}function k7(e){return typeof e?.issueId==`string`?e.issueId:``}function A7(e,t){return[String(e??``),String(t??``)].join(`::`)}function Yue(e,t,n){let r=C7.get(A7(e,t));if(!r||!r.copy.isConnected)return!1;let i=MA(n);return i?(r.summary||(r.summary=V(`span`,`radar-issue-summary`),r.copy.insertBefore(r.summary,r.copy.querySelector(`.radar-issue-meta`))),r.summary.textContent=i,!0):(r.summary?.remove(),r.summary=null,!0)}function j7(e,t,n){let r=k7(e);if(!r)return;S7?.dialog.close();let i=tF({issueTitle:String(e.title||r),projectLabel:n,onOpenReport:()=>N7(e)});S7={projectId:String(t??``),issueId:r,dialog:i},i.update(NA(e))}function M7(){if(!S7)return;if(!S7.dialog.isOpen()){S7=null;return}let e=PA(m7,S7.projectId,S7.issueId);e&&S7.dialog.update(NA(e))}function N7(e){let t=k7(e);t&&of(`get-posthog-report`,{issueId:t}).then(n=>{if(!n.ok){eF({issueId:t,issueTitle:String(e.title??``),error:String(n.error||`Could not read report`)});return}if(!n.found){eF({issueId:t,issueTitle:String(e.title??``),message:String(n.message||`Report not found`)});return}eF({issueId:t,issueTitle:String(e.title??``),format:String(n.format??``),content:String(n.content||``)})}).catch(n=>{eF({issueId:t,issueTitle:String(e.title??``),error:String(n?.message||`Could not read report`)})})}function P7(){let e=V(`div`,`radar-issue-actions`),t=V(`span`,`radar-issue-action-status`);t.setAttribute(`role`,`status`),e.append(t);let n=[],r=null,i=()=>{r?.remove(),r=null},a=t=>{i(),r=t,e.append(t)},o=e=>{for(let t of n)t.disabled=e};return{addButton:(r,i,a)=>{let o=V(`button`,`radar-issue-action`,r);return o.type=`button`,o.title=i,o.addEventListener(`click`,e=>{e.stopPropagation(),a()}),n.push(o),e.insertBefore(o,t),o},request:(e,n,r,a,s,c=null)=>{b7.begin(e),o(!0),i(),t.dataset.tone=`busy`,t.textContent=a;let l=(n,r)=>{o(!1),i(),t.dataset.tone=n,t.textContent=r,b7.settle(e)};of(n,r).then(e=>{if(!e.ok){l(`error`,String(e.error||`Request failed`));return}l(`ok`,s(e)),c&&c(e)}).catch(e=>l(`error`,String(e?.message||`Request failed`)))},showFollowUp:a,wrap:e}}function Xue(e){let t=V(`button`,`radar-issue-action radar-open-trace`,`Open trace`);return t.type=`button`,t.title=`Open the session trace`,t.addEventListener(`click`,t=>{t.stopPropagation(),lde(e)}),t}function Zue(e,t,n){let{addButton:r,request:i,showFollowUp:a,wrap:o}=P7(),s=(n,r,a,o,s=null)=>i(`${n}:${e.issueId}`,n,{projectId:t,issueId:e.issueId,...r},a,o,s);return e.inFlight&&r(`View investigation`,`Watch the running investigation`,()=>j7(e,t,n)),e.inFlight||r(`Open session`,`Paste an investigation prompt into the mapped project session`,()=>{s(`posthog-open-session`,{},`Opening session`,e=>e.pending?`Starting ${String(e.sessionName||`session`)}; the prompt lands when it is up`:`Prompt pasted into ${String(e.sessionName||`the session`)}; press Enter there`,e=>{typeof e.sessionId==`string`&&_7&&a(Xue(e.sessionId))})}),r(`Resolve`,`Mark this issue resolved in PostHog`,()=>{s(`posthog-issue-action`,{action:`resolve`},`Resolving in PostHog`,()=>`Marked resolved`)}),r(`Suppress`,`Suppress this issue in PostHog`,()=>{s(`posthog-issue-action`,{action:`suppress`},`Suppressing in PostHog`,()=>`Marked suppressed`)}),o}function F7(e,t,n){e.classList.add(`radar-issue-reportable`),e.tabIndex=0,e.setAttribute(`role`,`button`),e.setAttribute(`aria-label`,t),e.title=t,e.addEventListener(`click`,e=>{e.target instanceof Element&&(e.target.closest(`a, button`)||n())}),e.addEventListener(`keydown`,t=>{t.target===e&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n())})}function Que(e,t,n){let r=V(`div`,`radar-issue`);r.dataset.severity=yre(e.change);let i=V(`span`,`radar-stripe`);i.setAttribute(`aria-hidden`,`true`);let a=V(`span`,`radar-change`,Wue[e.change??``]||String(e.change||`unknown`)),o=vf(`radar-issue-title`,String(e.title||`Untitled issue`),e.url,String(e.title||``)),s=V(`span`,`radar-metric`);s.append(V(`span`,`radar-metric-value`,O7(e.occurrences)),V(`span`,`radar-metric-label`,`occ`));let c=V(`span`,`radar-metric`);c.append(V(`span`,`radar-metric-value`,O7(e.users)),V(`span`,`radar-metric-label`,`users`));let l=Cre(e.history),u=wre(l,64,16),d=u?document.createElementNS(v7,`svg`):null;if(d){d.classList.add(`radar-sparkline`),d.setAttribute(`viewBox`,`0 0 64 16`),d.setAttribute(`width`,`64`),d.setAttribute(`height`,`16`),d.setAttribute(`role`,`img`),d.setAttribute(`focusable`,`false`);let e=document.createElementNS(v7,`title`);e.textContent=Ere(l);let t=document.createElementNS(v7,`polyline`);t.setAttribute(`points`,u),d.append(e,t)}let f=MA(e),p=V(`span`,`radar-issue-copy`);p.append(o);let m=null;f&&(m=V(`span`,`radar-issue-summary`),m.textContent=f,p.append(m)),C7.set(A7(t,e.issueId),{copy:p,summary:m});let h=V(`span`,`radar-issue-meta`),g=bre(e);if(g!==null){let e=V(`span`,`radar-issue-seen`);e.title=new Date(g).toLocaleString(),w7.track(e,g,JP),h.append(e)}let _=xre(e);_&&h.append(V(`span`,`radar-issue-status`,_));let v=String(e.title||e.issueId);if(e.inFlight){let i=V(`span`,`radar-verdict`,`investigating`);i.dataset.verdict=`INVESTIGATING`,h.append(i);let a=typeof e.startedAt==`number`?e.startedAt:null;if(a!==null&&Number.isFinite(a)&&a>0){let e=V(`span`,`radar-issue-elapsed`);w7.track(e,a,Jue),h.append(e)}k7(e)&&F7(r,`Watch the investigation of ${v}`,()=>j7(e,t,n))}if(!e.inFlight&&e.verdict){let t=V(`span`,`radar-verdict`,IA(e.verdict));t.dataset.verdict=e.verdict,h.append(t),k7(e)&&F7(r,`View investigation report for ${v}`,()=>N7(e))}h.childElementCount>0&&p.append(h);let y=V(`span`,`radar-issue-trend`);d&&y.append(d);let ee=Tre(l);if(ee){let e=V(`span`,`radar-delta`,`${ee.direction===`up`?`+`:ee.direction===`down`?`-`:`=`}${ee.percent}%`);e.dataset.direction=ee.direction,y.append(e)}let b={stripe:i,change:a,copy:p,occurrences:s,users:c,trend:y};return D7(r,e=>b[e.columnId]),k7(e)&&r.append(Zue(e,t,n)),r}var I7=(e,t,n)=>wf(`radar`,e,t,n);function $ue(e){return e.error?`poll failed: ${e.error}`:e.staleMs>0?`stale ${qP(e.staleMs)}`:``}function L7(e,t,{showHost:n,nameTag:r,nameClass:i,hostClass:a}){let o=V(r,i,BA(t));o.title=String(t.name||``),e.append(o);let s=n?VA(t.host):``;s&&e.append(V(`span`,a,s))}function ede(){let e=E7(`radar-column-heads`);for(let t of T7){if(!t.headText){e.append(V(`span`));continue}let n=V(`span`,`radar-column-head`,t.headText);n.dataset.column=t.columnId,e.append(n)}return e}function tde(e,t){let n=e.project,r=V(`div`,`radar-project`),i=Rre(n.issues),a=zA(i),o=V(`div`,`radar-project-head`);L7(o,n,{showHost:t,nameTag:`h3`,nameClass:`radar-project-name`,hostClass:`radar-project-host`}),r.append(o);let s=V(`div`,`radar-project-summary`);s.append(I7(a.active===1?`active issue`:`active issues`,O7(a.active))),s.append(I7(`spiking`,O7(a.spiking),a.spiking>0?`crit`:null)),s.append(I7(`needs you`,O7(a.needsHuman),a.needsHuman>0?`warn`:null));let c=$ue(e);if(c){let t=V(`span`,`radar-project-alert`,c);t.dataset.tone=e.error?`crit`:`warn`,s.append(t)}if(r.append(s),i.length===0)return r;r.append(ede());let l=E7(`radar-issues`);for(let e of i)l.append(Que(e,n.projectId,BA(n)));return r.append(l),r}function nde(e,t){let n=e.project,r=V(`div`,`radar-quiet-row`),i=V(`span`,`radar-quiet-dot`);return i.setAttribute(`aria-hidden`,`true`),r.append(i),L7(r,n,{showHost:t,nameTag:`span`,nameClass:`radar-quiet-name`,hostClass:`radar-quiet-host`}),r.append(V(`span`,`radar-quiet-count`,`0 issues`)),r}var R7=(e,t)=>Cf(`radar`,e,t);function rde(){let e=V(`div`,`radar-issue`);return e.dataset.skeleton=``,D7(e,e=>V(`span`,e.cellClass)),e}function ide(){let e=E7(`radar-issues`);e.setAttribute(`aria-busy`,`true`),e.setAttribute(`aria-label`,`Loading issues`);for(let t=0;t<5;t+=1)e.append(rde());return e}function ade(e,t=`ready`){let n=R7(`Errors`);if(t===`pending`)return n.append(ide()),n;if(t===`placeholder`||e.length===0){let e=V(`p`,`radar-unconfigured`,gre(m7)),t=pW(`lanes-posthog`,`posthog-enabled`,`PostHog settings`);return e.append(document.createTextNode(` `),t),n.append(e),n}let r=V(`div`,`radar-global-tick`),i=Number(m7?.intervalMinutes);w7.track(r,m7?.ts,e=>{let t=`polled ${JP(e)}`;return!Number.isFinite(i)||i<=0?t:`${t}, every ${i}m`}),n.append(r);let a=i>0?i*6e4:0,{loud:o,quiet:s}=Mre(e,Date.now(),{intervalMs:a}),c=Are(e);for(let e of o)n.append(tde(e,c));if(s.length===0)return n;let l=V(`div`,`radar-quiet`);for(let e of s)l.append(nde(e,c));return n.append(l),n}function ode(e){let{addButton:t,request:n,wrap:r}=P7();return e.issueId&&t(`Open report`,`Open the investigation report for this issue`,()=>{N7({issueId:e.issueId,title:e.title})}),t(`Archive`,`Remove this investigation from the inbox`,()=>{n(`archive:${e.id}`,`posthog-archive-investigation`,{id:e.id},`Archiving`,()=>`Archived`,()=>x7.add(e.id))}),r}function sde(e){let t=V(`div`,`radar-investigation`),n=V(`span`,`radar-verdict`,IA(e.verdict));n.dataset.verdict=e.verdict;let r=vf(`radar-issue-title`,e.title,e.url),i=V(`span`,`radar-issue-copy`);if(i.append(r),e.summaryLine){let t=V(`span`,`radar-issue-summary`);t.textContent=e.summaryLine,i.append(t)}if(e.prUrl){let t=V(`a`,`radar-investigation-pr`,`fix PR`);t.href=e.prUrl,t.target=`_blank`,t.rel=`noopener`,t.title=e.prUrl,i.append(t)}if(t.append(n),e.mode===`fix`){let e=V(`span`,`radar-verdict`,`fix`);e.dataset.mode=`fix`,t.append(e)}if(t.append(i),e.projectLabel){let n=V(`span`,`radar-investigation-project`);n.textContent=e.projectLabel,t.append(n)}if(e.at>0){let n=V(`span`,`radar-investigation-time`,JP(e.at));n.title=new Date(e.at).toLocaleString(),t.append(n)}return t.append(ode(e)),t}function cde(e){let t=R7(`Investigations`,`completed, not yet archived`),n=V(`div`,`radar-investigations`);for(let t of e)n.append(sde(t));return t.append(n),t}function lde(e){_7&&_7(e)}function z7(){if(!h7)return;h7.textContent=``,C7.clear(),w7.reset();let e=Tf(m7),t=Nre(m7,x7),n=vre(m7,e.length);h7.append(ade(e,n)),t.length>0&&h7.append(cde(t))}function B7(){b7.request()}function V7(){g7&&g7(y7.refresh())}function ude(){y7.acknowledge(),V7()}function dde(e){g7=e,V7()}function fde(e){_7=e}function pde(e){if(h7)return h7;let t=V(`div`,`radar-content`);return e.appendChild(t),h7=t,w7.ensure(),z7(),t}function mde(e){m7=e,Pre(m7,x7),B7(),V7(),M7()}function hde(e){let t=PA(m7,e.projectId,e.issueId)?.inFlight===!0;if(!dre(m7,e))return;M7();let n=PA(m7,e.projectId,e.issueId);t&&Yue(e.projectId,e.issueId,n)||B7()}function gde(e){S7?.dialog.isOpen()&&fre(S7,e)&&S7.dialog.update(FA(e))}function _de(e){if(!pre(m7,e)){gde(e);return}M7(),B7(),V7()}function H7(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,worktree:e.worktree??e.isWorktree??!1,workspace:e.workspace??e.isWorkspace??!1,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}}function vde(e,t){return typeof t!=`string`||t===``?{knownBuild:e,reload:!1}:e==null?{knownBuild:t,reload:!1}:e===t?{knownBuild:e,reload:!1}:{knownBuild:t,reload:!0}}function yde(e){if(typeof e!=`object`||!e||!(`telemetry`in e))return!1;let{telemetry:t}=e;return typeof t!=`object`||!t||!(`enabled`in t)?!1:t.enabled===!0}function bde(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function xde(e,t){return t||bde(e)?!1:yde(e)}var Sde=2500;function Cde({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}var U7={teamReview:e=>e?.teamReview?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,visions:e=>e?.visions?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,factory:e=>e?.factory?.enabled===!0,calmLayout:e=>e?.calmLayout===!0};function W7(e,t){let n=document.createElement(`div`);n.className=`pr-scope-tabs`,n.setAttribute(`role`,`tablist`),n.setAttribute(`aria-label`,`Reviews scope`);let r=[`team`,`mine`];for(let i of r){let a=document.createElement(`button`);a.className=`pr-scope-tab`,a.type=`button`,a.setAttribute(`role`,`tab`),a.setAttribute(`aria-selected`,String(i===e)),a.tabIndex=i===e?0:-1,a.textContent=i===`team`?`Team`:`Mine`,a.addEventListener(`click`,()=>t(i,!1)),a.addEventListener(`keydown`,e=>{if(e.key===`ArrowLeft`){e.preventDefault(),t(r[(r.indexOf(i)+r.length-1)%r.length],!0);return}e.key===`ArrowRight`&&(e.preventDefault(),t(r[(r.indexOf(i)+1)%r.length],!0))}),n.append(a)}return n}function G7(){lk()===`team`&&Ile()}function wde(e){let t=(e,t)=>{if(o(e),G7(),!t)return;let s=(e===`team`?n:r).querySelector(`[aria-selected="true"]`);if(s&&s.getClientRects().length>0){s.focus();return}(e===`team`?i:a).querySelector(`.pr-queue-toggle`)?.focus()},n=W7(`team`,t),r=W7(`mine`,t),i=document.createElement(`div`);i.className=`pr-mode-root`;let a=document.createElement(`div`);a.className=`pr-mode-root`,e.append(i,a),Rle(i,n),sce(a,r);function o(e){o4(),i.hidden=e!==`team`,a.hidden=e!==`mine`,uk(e)}o(lk())}function Tde(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function Ede(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function Dde(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function K7(e){return e.map((e,t)=>({view:e,order:e.tabOrder??t})).sort((e,t)=>e.order-t.order).map(({view:e})=>e)}function q7(e,t){e?.refreshOn?.includes(t)&&e.refresh?.(t)}function Ode(e,t,n){for(let r of e)Tde(r.view,t)&&q7(r,n)}function kde(e){let t=[{view:`calm`,label:`Calm`,panelClass:`calm-view`,tabOrder:1,gate:{fromSettings:U7.calmLayout},hasOwnPhoneScreen:!0,hasPanelChrome:!1,mount:t=>gP(t,{openTerminal:e.openTerminal,openPlan:e.openPlan,openCalm:e.openCalm}),activate:_P,deactivate:vP},{view:`focus`,label:`Focus`,panelClass:`focus-view`,tabOrder:0,hasOwnPhoneScreen:!0,hasPanelChrome:!1,hasReviewSidebar:!0,mount:()=>PU({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:uW,deactivate:fW},{view:`prs`,label:`Reviews`,glyph:`⇅`,panelClass:`pr-view`,gate:{fromSettings:U7.teamReview},mount:wde,attention:{subscribe:Lle,acknowledge:G7}},{view:`issues`,label:`Issues`,glyph:`#`,panelClass:`issues-view`,mount:Iue,refreshOn:[`shown`],refresh:Lue,onConnectionChange:Rue},{view:`usage`,label:`Usage`,glyph:`◔`,panelClass:`usage-view`,gate:{fromSettings:U7.usage},mount:DQ,attention:{subscribe:wQ,acknowledge:xQ},refreshOn:[`shown`,`connected`,`usage-sessions`],refresh:e=>{e===`shown`&&OQ(),EQ()}},{view:`radar`,label:`Radar`,glyph:`◎`,panelClass:`radar-view`,gate:{fromSettings:U7.posthog},mount:pde,attention:{subscribe:dde,acknowledge:ude}},{view:`visions`,label:`Visions`,glyph:`◇`,panelClass:`visions-view`,gate:{fromSettings:U7.visions},mount:fK,attention:{subscribe:dK,acknowledge:()=>{mK(),pK()}}},{view:`hooks`,label:`Hooks`,glyph:`◈`,panelClass:`hooks-view`,mount:_J,refreshOn:[`shown`,`connected`,`hooks-updated`],refresh:e=>{e===`shown`&&vJ(),gJ()}},{view:`trace`,label:`Trace`,panelClass:`trace-view`,gate:{subscribe:OV},mount:mV,refreshOn:[`shown`],refresh:yV,onAvailabilityChange:e=>fde(e?_V:null),onConnectionChange:CV},{view:`benchmarks`,label:`Bench`,panelClass:`bench-view`,gate:{fromSettings:U7.benchmarks},mount:yue,onConnectionChange:bue},{view:`factory`,label:`Factory`,panelClass:`factory-floor`,gate:{fromSettings:U7.factory},mount:t=>aue(t,{openTerminal:e.openTerminal}),onConnectionChange:sue},{view:`settings`,label:`Settings`,glyph:`@`,panelClass:`settings-view`,hasPanelChrome:!1,mount:t=>i0(t,{onRestart:e.onRestart,onConfirmUpdateAndRestart:e.onConfirmUpdateAndRestart})}],n=H(document,`#app-main`,`main`),r=t.map(t=>{let r=V(`button`,`header-tab`,t.label);r.id=`tab-${t.view}`,r.type=`button`;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1,t.glyph&&(r.dataset.phoneGlyph=t.glyph);let o=document.getElementById(i)??V(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=V(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=Dde(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return H(document,`#header-tabs`,`div`).replaceChildren(...K7(r).map(e=>e.tab)),r}Rx(qO()),zx(UO()),Bx(GO()),XJ(YO()),Uf(),TS(document);var J7=H(document,`#connection-status`,`span`),Y7=H(J7,`.connection-label`,`span`),X7=H(document,`#loading-screen`,`div`),Z7=H(document,`#loading-status`,`div`),Q7=H(document,`#shutdown-screen`,`div`),$7=H(document,`#shutdown-status`,`div`),e9=!1,t9=null,n9=!1;function Ade(){let e=Uk(),t=X7.querySelector(`.loading-spinner`);e&&t&&t.replaceWith(Hk(e,`loading-animal`))}Ade();function r9(){e9||t9===null||Cde({hasSnapshot:n9,connectingTerminalCount:cA(),msSinceConnected:performance.now()-t9})===`reveal`&&i9()}sA(r9);function i9(){if(e9)return;e9=!0,X7.classList.add(`fade-out`);let e=()=>X7.remove();X7.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function a9(e,t){J7.dataset.state=`shutdown`,Y7.textContent=e,J7.title=e,C9.disabled=!0,$7.textContent=t,Q7.classList.add(`active`)}var jde=new Set([`disconnected`,`connecting`]);function o9(e,t,n){J7.dataset.state=e,J7.toggleAttribute(`data-reconnected`,n),Y7.textContent=t,J7.title=t}function Mde(e,t){o9(e,t,e===`connected`&&jde.has(J7.dataset.state??``))}function Nde(e,t){J7.dataset.state!==`shutdown`&&o9(e===`verified`?`connected`:e,t,!1)}nf((e,t)=>{if(e===`connecting`||e===`verified`){Nde(e,t);return}Mde(e,t),MH(e===`connected`);for(let t of k9)t.onConnectionChange?.(e===`connected`);if(e===`connected`){if(Q7.classList.contains(`active`)){location.reload();return}document.body.classList.add(`app-ready`),!e9&&t9===null&&(t9=performance.now(),Z7.textContent=`Connecting to sessions...`,setTimeout(i9,Sde)),r9(),J9(),g9(`connected`),of(`get-settings`,{}).then(e=>{e.settings&&(B9(e.settings),Rf()===`settings`&&E9(location.hash))}).catch(()=>{});return}if(e===`disconnected`&&Q7.classList.contains(`active`)){$7.textContent=`Waiting for server...`;return}e9||(Z7.textContent=`Reconnecting to server...`)});function s9(){p7(),q2(),tP(),u9()}function c9(){GU(),s9()}var l9=!1;function u9(){mP(l9&&jU()&&!Wf(),NU())}var d9=null;function Pde(e){let t=vde(d9,e);d9=t.knownBuild,t.reload&&location.reload()}function Fde(e){ZG(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),y0(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`})));for(let t of e){t.ephemeral||mI(t.path);let e=_H(t.id);e&&$H(t.id,t.state,t.stateSince),e&&PV(t.id,!!t.saneYolo),e||CH(t.id,t.name,t.state,H7(t)),gH(t.id,t.taskTitle,t.taskTitleIsCustom),PH(t.id,t.agent),KH(t.id,t.mergeStatus,t.mergeReason),NH(t.id,t.effectiveBase),RH(t.id,t.activeAgents,t.awaitingBackgroundTasks),LH(t.id,t.hasEndedTurn),HH(t.id,t.pendingWakeup),BH(t.id,t.pendingPromptKind,t.pendingPromptDetail,t.isCompacting),DH(t.id,t.hasPlan),h9(t.id)}SH(),cI(U),GU(),dW(),s9(),f9(),D9(location.hash),n9=!0,r9()}function f9(){vV([...U].map(([e,t])=>({id:e,name:Kf(t)||e})))}function p9(e,t){DH(e,t?.hasPlan===!0),h9(e)}function Ide(e){if(!_H(e.id)){CH(e.id,e.session,e.to,H7({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),cI(U),p7();return}if(e.to===F.DORMANT&&e.from!==F.DORMANT){let t=U.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;YH(e.id),CH(e.id,e.session,F.DORMANT,H7({skipPerms:i,saneYolo:a,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),PH(e.id,t?.agent),p9(e.id,t),c9(),_z(e.id),cI(U);return}$H(e.id,e.to,e.timestamp,e.event),e.hasEndedTurn!==void 0&&LH(e.id,e.hasEndedTurn),e.saneYolo!==void 0&&PV(e.id,e.saneYolo),cI(U),_z(e.id),c9(),$V(e.id),e.to===F.INITIALIZING&&(e.from===F.DONE||e.from===F.FAILED)&&_A(e.id)}var m9=new Map;function Lde(e){let t=new Set;for(let n of e){if(!n?.id)continue;t.add(n.id);let e={tokens:n.tokens,costUSD:n.costUSD,officialCostUSD:n.officialCostUSD};m9.set(n.id,e),zH(n.id,e)}for(let e of[...m9.keys()])t.has(e)||(m9.delete(e),zH(e,null))}function h9(e){let t=m9.get(e);t&&zH(e,t)}TQ(B),hJ(B),hV(B),Fue(B),vue(B),cue(B);function g9(e){Ode(k9,{isPhoneShellActive:G2(),activeView:Rf(),phoneScreen:Lf.snapshot().phoneScreen},e)}var Rde={snapshot:e=>{Pde(e.serverBuild),Fde(e.sessions)},"hooks-report":e=>yJ(e),"save-hook-result":e=>bJ(e),"delete-hook-result":e=>xJ(e),"state-change":e=>Ide(e),"session-added":e=>{e.ephemeral||mI(e.path),_H(e.id)||(CH(e.id,e.session,e.state,H7(e)),PH(e.id,e.agent),h9(e.id)),cI(U),c9(),f9()},"session-removed":e=>{YH(e.id),yz(e.id),cI(U),c9(),f9()},"session-title":e=>{gH(e.id,e.taskTitle,e.isCustom),c9()},"session-renamed":e=>{JH(e.id,e.newName),s9(),f9()},"session-modified":e=>{e.ephemeral||mI(e.path);let t=U.get(String(e.id));YH(e.id),yz(e.id),CH(e.id,e.session,e.state,H7(e)),PH(e.id,e.agent),p9(e.id,t),cI(U),c9(),f9()},"session-git":e=>FH(e.id,!!e.worktree),"session-agents":e=>{RH(e.id,e.activeAgents,e.awaitingBackgroundTasks),c9(),$V(e.id)},"session-wakeup":e=>HH(e.id,e.pendingWakeup),"session-prompt":e=>{BH(e.id,e.pendingPromptKind,e.pendingPromptDetail??null,e.isCompacting===!0),s9()},"session-merge-status":e=>{GH(e.id,e.mergeStatus,e.reason),aW(e.id,e.mergeStatus),s9()},"session-worktree-blocked":e=>{WS(`${e.session}: ${e.notice||`integration branch not found`}`,{persist:!0})},"session-worktree-warning":e=>{WS(`${e.session}: ${e.notice||`base branch warning`}`)},"session-worktree-ready":e=>{NH(e.id,e.base)},"session-diff":e=>{GN(e),qH(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"session-diff-error":e=>{LN(e),uz(e.id,e.message)},"change-map":e=>dz(e.id,e.map),"branch-sync-status":e=>mz(e.id,e),"session-changed":e=>gz(e.id),"post-turn-result":e=>UH(e.id,e),"debug-state-response":e=>QV(e),"session-trace-response":e=>{PN(e),bV(e)},"session-trace-changed":e=>xV(e),"session-plan-changed":e=>{OH(e),s9()},"session-plan-draft":e=>{kH(e)},"session-plan-response":e=>{AH(e)},"session-docs-changed":e=>eI(e),"session-docs-snapshot":e=>tI(e),notify:e=>{jJ(e),$V(e.session)},"update-status":e=>{Hde(e),g0(e)},"update-progress":e=>_0(e.journal),error:e=>{IN(e),v0(),SV(e),jH(e),WS(e.message,{persist:!0})},"session-error":e=>{jH(e),WS(`${e.session}: ${e.message}`,{persist:!0})},"settings-updated":e=>{e.settings&&B9(e.settings,{isLiveSettingsChange:!0})},"health-snapshot":e=>{e.stats&&XI(e.stats)},"posthog-status":e=>mde(e),"posthog-investigation-activity":e=>hde(e),"posthog-investigation-finished":e=>_de(e),"team-review-status":e=>zle(e),"my-prs-status":e=>cce(e),"factory-state":e=>oue(e),"factory-queue-intent-result":e=>lue(e),"factory-control-result":e=>uue(e),"benchmark-status":e=>xue(e),"benchmark-action-result":e=>Sue(e),"my-pr-merge-result":e=>lce(e),"team-review-action-result":e=>Vle(e),"issues-status":e=>zue(e),"issue-detail-result":e=>Bue(e),"open-issue-session-result":e=>Vue(e),"usage-sessions":e=>{Lde(e.sessions),kQ(e)},"usage-report":e=>{jQ(e),m0()},"plan-limits":e=>AQ(e),"usage-budget-alert":e=>jJ({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>gK(e),"visions-comments":e=>_K(e),"visions-hand":e=>vK(e),"visions-intent":e=>yK(e),"visions-fix":e=>hK(e),"visions-snapshot":e=>SK(e),"ingest-activity":e=>bK(e),"ingest-snapshot":e=>xK(e),"client-trust":e=>Xde(e.trust),"shutting-down":()=>a9(`Shutting down...`,`Shutting down sessions...`),restarting:()=>a9(`Restarting...`,`Restarting server...`)};function zde(e){let t=Rde[e.type];t&&t(e)}rf(e=>{zde(e),g9(e.type)});var _9=!1,Bde=pW(rre,ire,`Update`).href;function Vde(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function Hde(e){let t=H(document,`#update-banner`,`div`);if(!e.updateAvailable){t.hidden=!0;return}if(_9)return;let n=Vde(e);if(n&&hk()===n)return;let r=String(e.command??``);H(document,`#update-banner-text`,`span`).textContent=Fre(e),H(document,`#update-banner-cmd`,`code`).textContent=r;let i=YQ(e),a=H(document,`#update-banner-update`,`a`);a.href=Bde,a.hidden=i!==`link`;let o=H(document,`#update-banner-cmd`,`code`);o.hidden=i!==`command`;let s=H(document,`#update-banner-copy`,`button`);s.hidden=i!==`command`;let c=H(document,`#update-banner-copy-status`,`span`);c.hidden=i!==`command`,c.textContent=``;let l=H(document,`#update-banner-link`,`a`);l.hidden=!e.releaseUrl,l.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,s.onclick=()=>{let e=Df(r);if(!e){c.textContent=`Copy failed`;return}e.then(()=>{c.textContent=`Copied`}).catch(()=>{c.textContent=`Copy failed`})},H(document,`#update-banner-dismiss`,`button`).onclick=()=>{_9=!0,gk(n),t.hidden=!0}}var v9=H(document,`#telemetry-banner`,`div`);function y9(){vk(!0),v9.hidden=!0}function Ude(e){v9.hidden=!xde(e,_k())}var b9=H(document,`#telemetry-banner-settings`,`a`);b9.href=pW(`privacy`,`telemetry-enabled`,`Open settings`).href,b9.addEventListener(`click`,y9),H(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,y9),H(document,`#btn-add-session-header`,`button`).addEventListener(`click`,$P);var x9=H(document,`#btn-mute`,`button`);RQ(x9);var S9=H(document,`#power-menu`,`div`),C9=H(document,`#btn-power`,`button`);function w9(){C9.setAttribute(`aria-expanded`,S9.classList.contains(`open`)?`true`:`false`)}C9.addEventListener(`click`,e=>{e.stopPropagation(),S9.classList.toggle(`open`),w9()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(S9.contains(e.target)||(S9.classList.remove(`open`),w9()))}),Sf(document.querySelector(`.header`));function Wde(e){e&&l0(e),!J2(`settings`)&&L9(`settings`,{section:e})}function T9(){location.hash.startsWith(`#settings/`)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function Gde(e){return e?(l0(e.sectionId,e.settingId),J2(`settings`)||L9(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function E9(e){return Gde(u0(e))}function D9(e){let t=VL(e);return t?!_H(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),G2()?(W2(t)||WS(`No plan is stored for this session yet`),!0):(L9(`focus`,{persist:!1}),sW(t)||WS(`No plan is stored for this session yet`),!0)):!1}function O9(e){return D9(e)?!0:E9(e)}function Kde(){return O9(location.hash)}document.addEventListener(`click`,e=>{if(!G2()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&O9(t.hash)&&e.preventDefault()}),cse(H(document,`#celebration-tray`,`div`),H(document,`#btn-celebrations`,`button`),H(document,`#celebration-tray-count`,`span`)),H(document,`#btn-help`,`button`).addEventListener(`click`,()=>{Wde(`browser-shortcuts`)});var k9=kde({onRestart:q9,onConfirmUpdateAndRestart:Yde,openTerminal:e=>{L9(`focus`),oW(e)},openPlan:e=>{L9(`focus`),sW(e)},openCalm:()=>L9(`calm`),setPhoneAttention:X2});iz({panel:document.getElementById(`review-sidebar`)});for(let e of k9)e.mount(e.el);var A9=MU();A9&&pP(A9),Lf.subscribe((e,t)=>{t.includes(`focusedSessionId`)&&u9()});function j9(e){return k9.find(t=>t.view===e)}function M9(e){return k9.some(t=>t.view===e&&!t.tab.hidden)}var N9=!0,P9=null;function F9(e){j9(e)?.attention?.acknowledge()}function I9(e){q7(j9(e),`shown`)}function L9(e,{section:t,setting:n,persist:r=!0}={}){if(!M9(e))return;let i=Rf();Lf.dispatch(`setActiveView`,e),N9=r,r&&(P9=null),document.body.dataset.activeView=e,document.body.dataset.reviewSidebarHidden=String(j9(e)?.hasReviewSidebar!==!0),r&&QO(e);for(let t of k9){let n=t.view===e;t.el&&(t.el.hidden=!n),t.tab.setAttribute(`aria-selected`,String(n)),t.tab.tabIndex=n?0:-1}i!==e&&j9(i)?.deactivate?.(),j9(e)?.activate?.(),I9(e),i===`settings`&&e!==`settings`&&T9(),e===`settings`&&t&&l0(t,n??null),F9(e),u9()}function R9(e,t){let{view:n}=e;e.tab.hidden=!t,Y2(n,t),e.onAvailabilityChange?.(t),!G2()&&(!t&&Rf()===n&&L9(`focus`),t&&P9===n&&L9(n))}var z9=null;function qde(e,{isLiveSettingsChange:t=!1}={}){let n=Ede(k9,e),r=n.find(e=>e.view.view===`calm`)?.isAvailable===!0,i=t&&z9===!1&&r;z9=r,l9=r,U2(r),iW(!r),u9();for(let{view:e,isAvailable:t}of n)R9(e,t);!i||Rf()!==`focus`||Wf()||VL(location.hash)||L9(`calm`)}function B9(e,{isLiveSettingsChange:t=!1}={}){bH(e),d0(e),rK(e),qde(e,{isLiveSettingsChange:t}),Ude(e)}for(let e of k9)e.gate&&(R9(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>R9(e,t)));gV(()=>{M9(`trace`)&&(J2(`trace`)||L9(`trace`))});function V9(e,t){let n=k9.filter(e=>!e.tab.hidden),r=n[(n.findIndex(t=>t.view===e)+t+n.length)%n.length];return L9(r.view),r.tab}function Jde(e){k9.some(e=>e.tab===document.activeElement)&&e.focus()}for(let e=0;e<k9.length;e++){let{view:t,tab:n}=k9[e];n.addEventListener(`click`,()=>L9(t)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),V9(Rf(),e.key===`ArrowRight`?1:-1).focus()))})}var H9=ZO(),U9=u0(location.hash),W9=VL(location.hash);if(U9&&L9(`settings`,{section:U9.sectionId,setting:U9.settingId,persist:!1}),W9&&L9(`focus`,{persist:!1}),!U9&&!W9){let e=M9(H9);e||(P9=H9),L9(e?H9:`focus`,{persist:e})}z2({panels:MJ(k9),onScreenShown:e=>{I9(e),e!==`settings`&&T9(),e===`settings`&&!location.hash.startsWith(`#settings/`)&&l0(),F9(e)},headerControls:[H(document,`.header-title`,`h1`),H(document,`#status-indicator`,`div`),H(document,`#celebration-tray`,`div`),H(document,`#btn-add-session-header`,`button`),H(document,`#btn-help`,`button`),x9,S9]});function G9(e){if(e===`phone`){let e=NU();for(let e of K7(k9))e.deactivate?.();dP(),u9(),B2({sessionId:e??void 0});return}let t=K2();V2();let n=Rf();L9(M9(n)?n:`focus`,{persist:N9}),t&&oW(t)}Wf()&&G9(`phone`),Gf(G9),window.addEventListener(`hashchange`,Kde);function K9({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){S9.classList.remove(`open`),w9();let o=vH();tp({title:t,message:o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i,confirmLabel:n,danger:r,onConfirm:()=>B({type:e})})}function q9(){K9({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function Yde(e){let t=yH(),n=t.length;if(n===0){e(t);return}tp({title:`Update and restart`,message:`Glimmervoid restarts once the update is staged, which kills ${n} running session${n>1?`s`:``}. Continue?`,confirmLabel:`Update and restart`,danger:!1,onConfirm:()=>e(t)})}H(document,`#btn-restart`,`button`).addEventListener(`click`,q9);function Xde(e){let t=CP(`shutdown`,e);H(document,`#btn-shutdown`,`button`).hidden=!t,H(document,`#menu-divider-shutdown`,`div`).hidden=!t}H(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{K9({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})});function Zde(){let e=document.activeElement;return e instanceof HTMLElement?e.isContentEditable?!0:(e.tagName===`INPUT`||e.tagName===`TEXTAREA`)&&!e.classList.contains(`xterm-helper-textarea`):!1}function Qde({action:e,step:t}){switch(e){case`merge`:return bz(),!0;case`resolve-or-resync`:return xz()||Sz(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`next-attention`:return Rf()===`calm`?oP():jU()?(YU(),!0):!1;case`rail-step`:return jU()?(lW(t),!0):!1;case`view-step`:return!Wf()&&(Jde(V9(Rf(),t)),!0);case`session-nth`:return jU()?(cW(t),!0):!1;case`calm-home`:return!Wf()&&(L9(`calm`),!0);case`calm-terminal`:return aP()}}Xb(()=>({isCalmAvailable:l9,isCalmViewActive:Rf()===`calm`})),document.addEventListener(`keydown`,e=>{if(e.repeat||Zde())return;let t=Vb(e,Jb,Zb());t&&Qde(t)&&e.preventDefault()});var $de=EP({mode:`trailing`,delayMs:150,run:()=>{B({type:`focus-change`,focused:document.hasFocus()})}});function J9(){$de.schedule()}function Y9(){J9(),CA(Jf(DP()))}window.addEventListener(`focus`,Y9),window.addEventListener(`blur`,Y9),document.addEventListener(`visibilitychange`,Y9);var X9=!1,Z9=null;function efe(){if(document.visibilityState!==`visible`)return 0;let e=Z9;return Z9=null,e===null?0:Date.now()-e}async function Q9(){let e=efe();if(!X9){X9=!0,hA();try{if(await uf(e)===`ok`)return;for(let e of U.keys())_A(e)}finally{gA(),X9=!1}}}document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState!==`visible`){Z9??=Date.now();return}yD(),Q9()}),window.addEventListener(`online`,Q9);var $9=NP(B);window.addEventListener(`error`,e=>$9(e.error)),window.addEventListener(`unhandledrejection`,e=>$9(e.reason)),window.addEventListener(`pageshow`,e=>{e.persisted&&(yD(),Q9())}),YI(H(document,`#health-footer-mount`,`div`)),AJ(),Db(xH),lf();
|
|
253
|
+
`)||JSON.stringify(e.handReview)!==JSON.stringify(t.handReview)||JSON.stringify(e.queued)!==JSON.stringify(t.queued)?!1:JSON.stringify(e.drafts)===JSON.stringify(t.drafts)}var vle=12e4,V6=`M4.5 0.5L8.5 5.5L4.5 10.5L0.5 5.5Z`,H6=null,U6=null,W6=null,G6=null,K6=null,q6=null,J6=null,Y6=null,X6=null,Z6=null,Q6=null,$6=null,e8=null,t8=null,n8=XP(()=>U6),r8=XP(()=>U6),i8=XP(()=>U6),a8=new WeakMap,o8=new Map,s8=new Map,c8=new Map,l8=AA({getAck:xk,setAck:Sk,signature:()=>gle(H6),isLooking:()=>!Ef(U6)});function yle(e){let t=Vce(e),n=V(`span`,`pr-severity-meter`);if(n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,`${e.toLowerCase()} severity`),n.style.color=`var(${t.colorToken})`,e===`CRITICAL`){let e=WL(14,17);e.classList.add(`pr-severity-halo`),e.setAttribute(`viewBox`,`0 0 9 11`),e.append(UL(`path`,{d:V6,fill:`currentColor`})),n.append(e)}for(let e=0;e<3;e+=1){let r=WL(9,11),i=e<t.filledCount;r.append(UL(`path`,{d:V6,fill:i?`currentColor`:`none`,stroke:i?`currentColor`:`var(--border-hover)`,"stroke-width":`1`})),n.append(r)}return n}function ble(e){let{verdict:t}=e,n=V(`span`,`pr-verdict-seal`);n.dataset.tone=sle(t);let r=WL(20,20),i=Hce(t);return r.append(UL(`circle`,{cx:`10`,cy:`10`,r:`8.5`,fill:i===`cross`?`currentColor`:`none`,stroke:`currentColor`,"stroke-width":`1.5`})),i===`check`&&r.append(UL(`path`,{d:`M6 10.5L8.7 13L14 7.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),i===`dot`&&r.append(UL(`circle`,{cx:`10`,cy:`10`,r:`2.4`,fill:`currentColor`})),i===`bar`&&r.append(UL(`path`,{d:`M6 10H14`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})),i===`cross`&&r.append(UL(`path`,{d:`M7 7L13 13M13 7L7 13`,stroke:`var(--bg)`,"stroke-width":`1.8`,"stroke-linecap":`round`})),n.append(r,V(`span`,null,ale(t))),n}function xle(){let e=WL(16,16);return e.append(UL(`rect`,{x:`1`,y:`1`,width:`14`,height:`14`,rx:`2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`})),e.append(UL(`path`,{d:`M6 6.2C6 4.9 7 4.2 8 4.2C9.1 4.2 10 5 10 6C10 7.4 8 7.4 8 9.2`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.3`,"stroke-linecap":`round`})),e.append(UL(`circle`,{cx:`8`,cy:`11.6`,r:`0.9`,fill:`currentColor`})),e}function u8(e){return vf(`pr-link`,D6(e.repo,e.number),e.url)}function d8(e){let t=typeof e==`string`?Date.parse(e):e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?null:t}function f8(e,t){let n=d8(t);if(n===null)return null;let r=V(`span`,null,`${e}${e?` `:``}${JP(n)}`);return r.dataset.ageAt=String(n),r.dataset.ageLabel=e,r}function p8(e){if(e){for(let t of e.querySelectorAll(`.pr-queue-row`)){let e=a8.get(t);if(!e)continue;let n=()=>{t.title=e(),t.setAttribute(`aria-label`,t.title)};n(),i8.onTick(n)}for(let t of e.querySelectorAll(`.pr-rereview-notice`)){let e=H6?.drafts.find(e=>e.key===t.dataset.reviewKey),n=e?v6(e):null;if(!n)continue;let r=()=>{t.textContent=y6(n,h8(n.submittedAt))};r(),i8.onTick(r)}for(let t of e.querySelectorAll(`[data-age-at]`)){let e=Number(t.dataset.ageAt),n=t.dataset.reviewTitle;if(n!==void 0){let r=()=>{let r=b6(n,JP(e));t.title=r,t.setAttribute(`aria-label`,r)};r(),i8.onTick(r);continue}let r=t.dataset.ageLabel??``;i8.track(t,e,()=>`${r}${r?` `:``}${JP(e)}`)}}}function m8(e,t,n,r=!0){let i=x6(e,{isViewerShown:r});if(i.length===0)return null;let a=V(`span`,t),o=gf(i.map(e=>({login:e.login,tone:e.tone,title:b6(e.text,h8(e.submittedAt))})),n);for(let[e,t]of i.entries()){let n=o.children[e];if(!(n instanceof HTMLElement)||!t.submittedAt)continue;let r=d8(t.submittedAt);r!==null&&(n.dataset.ageAt=String(r),n.dataset.reviewTitle=t.text)}return a.append(o),a}function h8(e){let t=d8(e);return t===null?null:JP(t)}function g8(e,t,n){let r=V(`span`,n);return r.append(hf({login:e,cssPx:t}),V(`span`,null,e)),r}function Sle(e,t,n){let r=V(`button`,`pr-queue-row pr-queue-row-quiet`);r.type=`button`,r.dataset.reviewKey=e.key,r.setAttribute(`aria-current`,String(e.key===X6));let i=`reviewedHead`in e?v6(e):null,a=()=>c6(e,t,{opened:h8(e.prCreatedAt),reviewed:`reviewedHead`in e?h8(e.reviewedAt):null,posted:`reviewedHead`in e?h8(e.postedAt):null,viewerApproval:h8(i?.submittedAt),githubReviews:`reviewedHead`in e?x6(e,{isViewerShown:t!==`posted`}).map(e=>h8(e.submittedAt)):[]});r.title=a(),r.setAttribute(`aria-label`,r.title),a8.set(r,a);let o=y8(e,n);if(t===`inReview`){let t=e,n=V(`span`,`pr-queue-elapsed`);n8.track(n,t.startedAt,()=>A6(t,Date.now())),o.append(n)}if(t===`queued`){let t=f8(``,e.prCreatedAt);t&&(t.classList.add(`pr-queue-elapsed`),o.append(t))}if(t!==`inReview`&&t!==`queued`){let t=e,n=f8(``,t.reviewedAt)??f8(``,t.prCreatedAt);n&&(n.classList.add(`pr-queue-elapsed`),o.append(n))}if(t===`discarded`)return r.classList.add(`pr-queue-row-compact`),r.append(o),_8(r,e.key),r;r.classList.remove(`pr-queue-row-quiet`);let s=r6(e,t),c=V(`span`,`pr-queue-glyph`);c.append(XX(s.icon,s.tone));let l=V(`span`,`pr-queue-bottom`);if(l.append(v8(s),g8(e.author,16,`pr-queue-author`)),e.requestSource===`direct`){let e=V(`span`,`pr-queue-direct`,`@`);e.title=`Requested from you directly`,l.append(e)}t===`inReview`&&l.append(V(`span`,`pr-phase-label`,cle(e.phase))),r.append(c,o,l);let u=t===`inReview`||t===`queued`?null:m8(e,`pr-queue-reviewers`,16,t!==`posted`);return u&&l.append(u),_8(r,e.key),r}function _8(e,t){e.addEventListener(`click`,()=>{X6=t,Z6=null,x8(null);for(let e of K6?.querySelectorAll(`button[data-review-key]`)??[])e.setAttribute(`aria-current`,String(e.dataset.reviewKey===X6));W8(m6(H6)),i8.reset(),p8(U6),document.documentElement.dataset.layout===`phone`&&J6?.scrollIntoView({block:`start`,behavior:`smooth`})})}function v8(e){let t=V(`span`,`my-pr-stage pr-queue-state`,e.meaning);return t.dataset.tone=e.tone,t}function y8(e,t){let n=V(`span`,`pr-queue-top`);return n.append(V(`strong`,`pr-queue-ref`,f6(e.repo,e.number,t)),V(`strong`,`pr-queue-ref-compact`,f6(e.repo,e.number,!1)),V(`span`,`pr-queue-title`,e.title)),n}function Cle(e,t){let n=V(`section`,`pr-queue-section`);n.append(V(`h3`,`pr-section-heading`,`Review by hand ${e.length}`));for(let r of e){let e=vf(`pr-queue-row`,``,r.url),i=()=>c6(r,`handReview`,{opened:h8(r.prCreatedAt)});e.title=i(),a8.set(e,i);let a=r6(r,`handReview`),o=V(`span`,`pr-queue-glyph`);o.append(XX(a.icon,a.tone));let s=V(`span`,`pr-queue-bottom`);s.append(v8(a),g8(r.author,16,`pr-queue-author`)),e.append(o,y8(r,t),s),n.append(e)}return n}function b8({title:e,detail:t}){let n=V(`section`,`pr-caught-up`);n.setAttribute(`role`,`status`);let r=V(`strong`,`pr-caught-up-title`);return r.append(XX(`ready`,`ok`),V(`span`,null,e)),n.append(r,V(`p`,`pr-caught-up-detail`,t)),n}function x8(e){Q6=e,$6&&($6.hidden=e===null,$6.textContent=e?.text??``,e&&($6.dataset.tone=e.tone))}function S8(e,t,n,r){let i=V(`section`,`pr-queue-section`);i.append(V(`h3`,`pr-section-heading`,`${e} ${t.length}`));for(let e of t)i.append(Sle(e,n,r));return i}function C8(e){let t=V(`div`,`pr-detail-heading`);t.dataset.signature=B6(e);let n=V(`div`,`pr-detail-title`);n.append(u8(e),V(`h2`,null,e.title));let r=V(`div`,`pr-detail-meta`);r.append(g8(e.author,20,`pr-detail-author`));let i=V(`span`,null,Qce(e));i.title=$ce(e),r.append(i);let a=f8(`Opened`,e.prCreatedAt);if(a&&r.append(a),`reviewedHead`in e){let t=f8(`Reviewed`,e.reviewedAt);t&&r.append(t);let n=f8(`Posted`,e.postedAt);n&&r.append(n)}let o=`reviewedHead`in e?m8(e,`pr-detail-github`,20):null;if(o&&r.append(o),t.append(n,r),`reviewedHead`in e){let n=s6(e.viewerThreads);if(n){let r=V(`p`,`pr-viewer-threads`,n);i6(e)&&(r.dataset.state=`all-resolved`),t.append(r)}}let s=`reviewedHead`in e?v6(e):null;if(s){let n=V(`p`,`pr-rereview-notice`,y6(s,h8(s.submittedAt)));n.dataset.reviewKey=e.key,t.append(n)}return t}function w8(e,t){let n=e.querySelector(`:scope > .pr-detail-heading`);if(!n||n.dataset.signature===B6(t))return e;let r=C8(t),i=n.querySelector(`:scope > .pr-detail-title > .pr-detail-more`);return i&&r.querySelector(`:scope > .pr-detail-title`)?.append(i),n.replaceWith(r),e}function T8(e){return`${JSON.stringify(e.threads)}:${e.liveHead}:${e.status}:${e.reviewedHead}:${e.error??``}:${e.postedEvent??``}`}function E8(e,t){for(let n of t){if(n.kind===`text`){e.append(document.createTextNode(n.text));continue}if(n.kind===`code`){e.append(V(`code`,null,n.text));continue}let t=V(`span`,`pr-citation`,n.text);t.title=n.text,e.append(t)}return e}function D8(e,t){return E8(e,T6(t))}function O8(e,t,n){let r=V(`div`,`pr-assessment-part`);return n&&(r.dataset.tone=n),r.append(V(`h4`,`pr-assessment-title`,e),t),r}function k8(e){let t=V(`ul`,`pr-assessment-list`);for(let n of e)t.append(D8(V(`li`,null),n));return t}function A8(e){let t=ele(e.assessment);if(t.length===0)return[];let n=V(`section`,`pr-about-box`);n.setAttribute(`aria-label`,`About this PR`),n.append(V(`h3`,`pr-assessment-title`,`About this PR`));for(let e of t){let t=e.kind===`goal`?`pr-verdict-summary pr-about-goal`:`pr-verdict-summary`;n.append(D8(V(`p`,t),e.text))}return[n]}function j8(e){let t=V(`section`,`pr-verdict-box`);t.setAttribute(`aria-label`,`Verdict`);let n=V(`div`,`pr-verdict-line`);return n.append(ble(e)),t.append(n),e.assessment?(t.append(D8(V(`p`,`pr-verdict-summary pr-verdict-reason`),e.summary)),t):(t.append(V(`p`,`pr-verdict-legacy`,rle)),t)}function M8(e){let t=V(`details`,`pr-disclosure pr-coverage`),n=V(`summary`,`pr-disclosure-summary`),r=nle(e.assessment);n.append(V(`span`,`pr-disclosure-label`,r.label),V(`span`,`pr-disclosure-preview`,r.preview)),t.append(n);let{assessment:i}=e;return i?(i.checked.length>0&&t.append(O8(`What the review checked`,k8(i.checked))),i.gaps.length>0&&t.append(O8(`Not covered`,k8(i.gaps),`warning`)),t):(t.append(D8(V(`p`,`pr-verdict-summary`),e.summary)),t)}function wle(e){if(e.kind===`code`){let t=V(`pre`,`pr-comment-code`),n=V(`code`,null);return n.textContent=e.code,t.append(n),t}let t=V(`p`,`pr-comment-paragraph`);if(e.lead){let n=V(`strong`,`pr-comment-lead pr-comment-lead-${e.leadKind}`);e.leadKind===`question`&&n.append(xle()),n.append(e.lead),t.append(n,` `)}return E8(t,e.segments)}function Tle(e,t,n,r){let i=V(`article`,`pr-comment-card`),a=V(`input`,`pr-comment-checkbox`);a.type=`checkbox`,a.checked=n.has(t),a.setAttribute(`aria-label`,`Include comment on ${N6(e)}`),a.addEventListener(`change`,()=>{a.checked&&n.add(t),a.checked||n.delete(t),i.dataset.included=String(a.checked),r()}),i.dataset.included=String(a.checked);let o=V(`details`,`pr-comment-content`),s=V(`summary`,`pr-comment-header`),c=Yce(e.body),l=w6(e);l&&s.append(yle(l));let u=V(`span`,`pr-comment-location`,ule(e));u.title=N6(e),s.append(u),s.append(V(`span`,`pr-comment-preview`,Xce(c.paragraphs))),o.append(s);let d=V(`div`,`pr-comment-paragraphs`);for(let e of c.paragraphs)d.append(wle(e));return o.append(d),o.open=l===`HIGH`||l===`CRITICAL`,i.append(a,o),i}var N8=`More review actions`,Ele=`M3 8h0.01M8 8h0.01M13 8h0.01`,Dle=`Your comments are on GitHub. Approve adds an approval without posting them again.`;function P8(e,t,n,r,i,a,o){let s=S6(m6(H6));x8(null);let c=af(`team-review-action`);if(!B({type:`team-review-action`,requestId:c,...fle(t,n,r,i,o)}))return!1;let l=window.setTimeout(()=>{c8.delete(t.key),a(!1,`No reply from the server. Check GitHub before trying again.`)},vle);return c8.set(t.key,{requestId:c,action:n,origin:e,capturedOrder:s,pullRequest:D6(t.repo,t.number),timer:l,settle:a}),!0}var F8=0;function I8(e,t){let n=V(`div`,`pr-detail-more`),r=V(`button`,`review-icon-button review-more-button`);r.type=`button`,r.title=N8,r.setAttribute(`aria-label`,N8),r.setAttribute(`aria-haspopup`,`menu`),r.setAttribute(`aria-expanded`,`false`);let i=WL(16,16);i.append(UL(`path`,{d:Ele,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})),r.append(i),F8+=1;let a=V(`div`,`review-more-menu`);a.id=`pr-more-menu-${F8}`,a.setAttribute(`role`,`menu`),a.setAttribute(`aria-label`,N8),a.hidden=!0,r.setAttribute(`aria-controls`,a.id);let o=e=>{e.key===`Escape`&&(e.preventDefault(),c(),r.focus())},s=e=>{e.target instanceof Node&&n.contains(e.target)||c()};function c(){a.hidden=!0,r.setAttribute(`aria-expanded`,`false`),document.removeEventListener(`keydown`,o),document.removeEventListener(`pointerdown`,s)}let l=()=>{a.hidden=!1,r.setAttribute(`aria-expanded`,`true`),document.addEventListener(`keydown`,o),document.addEventListener(`pointerdown`,s),a.querySelector(`button:not(:disabled)`)?.focus()};r.addEventListener(`click`,()=>{if(a.hidden){l();return}c()});let u=[r];for(let n of e){let e=V(`button`,n===`discard`?`review-btn review-btn-danger`:`review-btn`,P6(n));e.type=`button`,e.dataset.action=n,e.setAttribute(`role`,`menuitem`),e.addEventListener(`click`,()=>{c(),t(n)}),u.push(e),a.append(e)}return n.append(r,a),{element:n,controls:u}}function L8(e,t){let n=V(`button`,`pr-action`,P6(e));return n.type=`button`,n.dataset.action=e,n.addEventListener(`click`,()=>t(e)),n}function R8(e,t){e.querySelector(`:scope > .pr-detail-heading > .pr-detail-title`)?.append(t)}function Ole(e){let t=V(`article`,`pr-detail`),n=V(`div`);n.dataset.reviewThreads=``,t.append(C8(e),...A8(e),n,j8(e)),z8(t,e);let r=V(`section`,`pr-posts`);r.setAttribute(`aria-label`,`Inline comments`);let i=V(`div`,`pr-posts-heading`);i.append(V(`h3`,null,`Inline comments`),V(`span`,null,String(e.comments.length))),r.append(i);let a=V(`details`,`pr-disclosure`),o=V(`summary`,`pr-disclosure-summary`),s=V(`span`,`pr-disclosure-preview`);o.append(V(`span`,`pr-disclosure-label`,`Review body`),s),a.append(o);let c=V(`textarea`,`pr-body-input`);c.setAttribute(`aria-label`,`Review body`),c.value=e.body,c.rows=Math.min(10,Math.max(3,e.body.split(`
|
|
254
|
+
`).length+1)),c.spellcheck=!0;let l=()=>{s.textContent=X3(c.value).split(/\r?\n/).map(e=>e.trim()).find(Boolean)||`No review body`};c.addEventListener(`input`,l),l(),a.append(c);let u=V(`details`,`pr-disclosure`);u.append(V(`summary`,`pr-disclosure-summary`,`Add a note`));let d=V(`textarea`,`pr-body-input pr-note-input`);d.setAttribute(`aria-label`,`Your note`),d.rows=2,d.spellcheck=!0,d.placeholder=`Posts above the automated-review note`,u.append(d);let f=new Set(e.comments.flatMap((e,t)=>Wce(e)?[t]:[])),p=V(`footer`,`pr-footer`),m=V(`span`,`pr-action-status`);m.setAttribute(`role`,`status`),m.setAttribute(`aria-live`,`polite`);let h=()=>{c8.has(e.key)||m.dataset.tone===`ok`||(m.textContent=``,delete m.dataset.tone)};for(let[t,n]of e.comments.entries())r.append(Tle(n,t,f,h));t.append(r,a,u,M8(e));let g=[],_=e=>{for(let t of g)t.disabled=e;t.dataset.busy=String(e)},v=(e,t)=>{_(e),m.dataset.tone=e?`ok`:`error`,m.textContent=t},y=t=>{if(c8.has(e.key))return;_(!0),m.dataset.tone=`busy`,m.textContent=I6(t);let n=e.comments.filter((e,t)=>f.has(t));P8(`ready`,e,t,dle(d.value,c.value),n,v)||v(!1,`Not connected to the server.`)},ee=F6(e),b=ee.footer.map(e=>L8(e,y)),te=I8(ee.more,y);return g.push(...b,...te.controls),R8(t,te.element),p.append(...b,m),t.append(p),{signature:z6(e),element:t,settle:v}}function kle(e){let t=o8.get(e.key);if(t&&(c8.has(e.key)||t.signature===z6(e)))return z8(t.element,e),w8(t.element,e);let n=Ole(e);return o8.set(e.key,n),n.element}function Ale(e,t){let n=V(`article`,`pr-detail`),r=V(`div`,`pr-detail-heading`),i=V(`div`,`pr-detail-title`);i.append(u8(e),V(`h2`,null,e.title));let a=V(`div`,`pr-detail-meta`);a.append(g8(e.author,20,`pr-detail-author`));let o=f8(`Opened`,e.prCreatedAt);return o&&a.append(o),r.append(i,a),n.append(r,V(`p`,`pr-attention-detail`,mle(t))),n}function jle(e){let t=V(`article`,`pr-detail`);t.append(C8(e));let n=V(`section`,`pr-progress`);n.setAttribute(`aria-label`,`Review progress`);let r=V(`ol`,`pr-progress-tracker`);for(let t of Zce(e.phase)){let e=V(`li`,`pr-progress-stage`);e.dataset.state=t.state,e.append(V(`span`,`pr-progress-bar`),V(`span`,null,t.label)),r.append(e)}let i=V(`div`,`pr-progress-text`);r8.track(i,e.startedAt,()=>lle(e,Date.now())),n.append(r,i),t.append(n);let a=V(`section`,`pr-steps`);a.append(V(`h3`,null,`Latest agent steps`));let o=V(`ol`,`pr-step-list`);for(let t of e.recentSteps){let n=V(`li`,`pr-step`),r=V(`span`,`pr-step-detail`,t.detail);r.title=t.detail,n.append(V(`span`,`pr-step-at`,RA(e.startedAt,t.at)),V(`span`,`pr-step-tool`,t.tool),r),o.append(n)}return a.append(o),t.append(a),t}function z8(e,t){if(c8.has(t.key))return;let n=e.querySelector(`:scope > [data-review-threads]`),r=JSON.stringify([t.liveHead,t.threads]);n&&n.dataset.reviewThreads!==r&&(n.replaceChildren(...V8(t)),n.dataset.reviewThreads=r)}function B8(e,t,n,r){let i=V(`div`,t?`pr-thread-message pr-thread-message-muted`:`pr-thread-message`);if(i.append(V(`p`,`pr-thread-body pr-thread-preview`,e)),!n&&!Fce(e,t?3:8))return i;let a=V(`details`,`pr-thread-disclosure`);return a.append(V(`summary`,`pr-thread-expand`,t?`Expand comment`:`Expand reply`),V(`p`,`pr-thread-body`,e)),n&&a.append(vf(`pr-link pr-thread-continues`,t?`Comment continues on GitHub`:`Reply continues on GitHub`,r)),i.append(a),i}function V8(e){let t=_6(e);if(t.length===0)return[];let n=V(`section`,`my-pr-threads-section`);n.append(V(`h3`,`pr-section-heading`,`Answered threads`));let r=V(`div`,`my-pr-threads`);for(let n of t){let t=V(`div`,`my-pr-thread pr-thread-card`),i=V(`div`,`my-pr-thread-heading pr-thread-heading`),a=V(`span`,`pr-thread-chip`,n.judgementLabel);a.dataset.tone=n.judgementTone,i.append(vf(`pr-link my-pr-thread-location`,n.location,n.thread.url),a),t.append(i),n.judgementReason&&t.append(V(`p`,`my-pr-thread-meta`,n.judgementReason)),n.thread.viewerComment&&t.append(V(`div`,`my-pr-thread-meta`,`Your comment`),B8(n.thread.viewerComment,!0,n.thread.viewerCommentTruncated===!0,n.thread.url));let o=V(`div`,`pr-detail-meta pr-thread-reply-meta`,`${n.thread.lastReplyAuthor} replied`),s=f8(``,n.thread.lastReplyAt);s&&o.append(s);let c=V(`span`,`pr-action-status`);c.setAttribute(`role`,`status`);let l=V(`button`,`pr-action`,`Resolve`);l.type=`button`,l.disabled=!n.canResolve||c8.has(e.key);let u=(e,t)=>{l.disabled=e||!n.canResolve,c.textContent=t,c.dataset.tone=e?`ok`:`error`};l.addEventListener(`click`,()=>{c8.has(e.key)||(l.disabled=!0,c.textContent=I6(`resolve-thread`),!P8(`other`,e,`resolve-thread`,``,[],u,n.thread.id)&&u(!1,`Not connected to the server.`))}),t.append(o),n.thread.lastReplyBody&&t.append(B8(n.thread.lastReplyBody,!1,n.thread.lastReplyTruncated===!0,n.thread.url));let d=V(`footer`,`pr-thread-footer`);d.append(c,l),t.append(d),n.thread.resolveError&&t.append(V(`p`,`pr-attention-detail`,n.thread.resolveError)),r.append(t)}return n.append(r),[n]}function H8(e){let t=V(`article`,`pr-detail`);if(t.append(C8(e),...A8(e),...V8(e)),e.status===`posted`&&t.append(j8(e),M8(e)),e.status!==`posted`&&t.append(V(`p`,`pr-attention-detail`,j6(e))),!k6(e.status))return s8.set(e.key,{signature:T8(e),element:t,settle:()=>{}}),t;let n=V(`footer`,`pr-footer`),r=F6(e),i=V(`span`,`pr-action-status`,r.footer.includes(`approve-only`)?Dle:``);i.setAttribute(`role`,`status`),i.setAttribute(`aria-live`,`polite`);let a=[],o=(e,t)=>{for(let t of a)t.disabled=e;i.dataset.tone=e?`ok`:`error`,i.textContent=t},s=t=>{if(!c8.has(e.key)){for(let e of a)e.disabled=!0;i.dataset.tone=`busy`,i.textContent=I6(t),!P8(`other`,e,t,``,[],o)&&o(!1,`Not connected to the server.`)}},c=r.footer.map(e=>L8(e,s));if(a.push(...c),r.more.length>0){let e=I8(r.more,s);a.push(...e.controls),R8(t,e.element)}return n.append(...c,i),t.append(n),s8.set(e.key,{signature:T8(e),element:t,settle:o}),t}function U8(e){if(!k6(e.status)&&_6(e).length===0)return H8(e);let t=s8.get(e.key);return t&&(c8.has(e.key)||t.signature===T8(e))?w8(t.element,e):H8(e)}function W8(e){if(!J6)return;if(X6=C6(e,X6,Z6!==null),!X6){if(Z6!==null){let t=Z6.actedKey;t&&![...e.ready,...e.attention].some(e=>e.key===t)&&(Z6={actedKey:null}),J6.replaceChildren(b8(yce(e,Z6.actedKey))),e8=null;return}J6.replaceChildren(),e8=null;return}let t=e.ready.find(e=>e.key===X6&&(g6(e).length>0||a6(e)));if(t&&t.status!==`ready`){let e=`threads:${T8(t)}`,n=U8(t);if(e8===e&&J6.firstElementChild===n)return;J6.replaceChildren(n),e8=e;return}let n=[...e.ready,...e.noReviewNeeded].find(e=>e.key===X6&&e.status===`ready`);if(n){let e=`ready:${z6(n)}`,t=kle(n);if(e8===e)return;J6.replaceChildren(t),e8=e;return}let r=e.inReview.find(e=>e.key===X6);if(r){r8.reset(),J6.replaceChildren(jle(r)),e8=`inReview:${r.key}`;return}let i=e.queued.find(e=>e.key===X6);if(i){let t=`queued:${i.key}:${e.inReview.length}`;if(e8===t)return;J6.replaceChildren(Ale(i,e.inReview.length)),e8=t;return}let a=[...e.noReviewNeeded,...e.attention,...e.posted,...e.discarded].find(e=>e.key===X6);a&&(J6.replaceChildren(U8(a)),e8=`${a.status}:${a.key}`)}function Mle(){let e=V(`p`,`pr-empty`,hle(H6));return H6&&!H6.configured&&e.append(` `,pW(Cce,wce,`Open Team review settings`)),e}function G8(){let e=R6(H6);return e?[V(`p`,`my-pr-note`,e)]:[]}function Nle(e){for(let t of[...o8.keys()])e.has(t)||c8.has(t)||o8.delete(t);let t=new Set(H6?.drafts.filter(e=>k6(e.status)).map(e=>e.key)??[]);for(let e of s8.keys())t.has(e)||c8.has(e)||s8.delete(e)}function Ple(){if(!U6||!W6||K6?.isConnected)return;let e=c4({queueLabel:`Review queue`,scopeTabs:W6,resizerLabel:`Resize review queue`});K6=e.queue,$6=V(`p`,`pr-action-status pr-action-notice`),$6.setAttribute(`role`,`status`),$6.setAttribute(`aria-live`,`polite`),J6=V(`div`,`pr-detail-body`),e.detail.append($6,J6),x8(Q6),G6&&e.foot.append(G6.control),U6.replaceChildren(e.columns),e8=null,q6=null}function K8(e){if(!e)return;e.querySelector(`.pr-team-chip`)?.remove();let t=H6?.team;if(!t)return;let n=V(`span`,`pr-team-chip`);n.append(hf({login:t.slug,url:t.avatarUrl,cssPx:16}),V(`span`,null,t.name)),e.insertBefore(n,e.querySelector(`.pr-queue-toggle`))}function q8(){let e=document.activeElement;return!(e instanceof HTMLElement)||!K6?.contains(e)?null:e.dataset.reviewKey??null}function J8(e){e&&K6&&[...K6.querySelectorAll(`button[data-review-key]`)].find(t=>t.dataset.reviewKey===e)?.focus({preventScroll:!0})}function Y8(){if(!U6)return;let e=q8(),t=m6(H6);if(Nle(new Set([...t.ready,...t.noReviewNeeded].map(e=>e.key))),i8.reset(),!H6?.configured||!zce(t)&&Z6===null){n8.reset(),r8.reset();let e=o4(W6);K8(e),U6.replaceChildren(e,...G6?[G6.notice]:[],...G8(),Mle(),s4(G6?.control??null)),G6?.update(H6),K6=null,q6=null,J6=null,$6=null,Y6=null,e8=null;return}if(Ple(),!K6)return;K8(U6.querySelector(`.pr-queue-head`)),X6=C6(t,X6,Z6!==null);let n=d6(t),r=JSON.stringify([t,n,X6,R6(H6)]);if(r===q6){G6?.update(H6),W8(t),p8(U6);return}q6=r,n8.reset();let i=[],a=l6(t);a&&i.push(b8({title:`All caught up`,detail:a})),t.ready.length&&i.push(S8(`Ready`,t.ready,`ready`,n)),t.inReview.length&&(Y6=S8(`In review`,t.inReview,`inReview`,n),i.push(Y6)),t.queued.length&&i.push(S8(`Queued`,t.queued,`queued`,n)),t.noReviewNeeded.length&&i.push(S8(`Already reviewed`,t.noReviewNeeded,`settled`,n)),t.handReview.length&&i.push(Cle(t.handReview,n)),t.attention.length&&i.push(S8(`Needs attention`,t.attention,`attention`,n)),t.posted.length&&i.push(S8(`Waiting on author`,t.posted,`posted`,n)),t.discarded.length&&i.push(S8(`Discarded`,t.discarded,`discarded`,n)),K6.replaceChildren(...G6?[G6.notice]:[],...G8(),...i),G6?.update(H6),J8(e),W8(t),p8(U6)}function X8(){t8&&t8(l8.refresh())}function Fle(){l8.acknowledge(),X8()}function Ile(e){t8=e,X8()}function Lle(e,t){return U6||(W6=t,U6=V(`div`,`pr-content`),e.append(U6),G6=U3(`team-review`,U6),n8.ensure(),r8.ensure(),i8.ensure(),Y8(),U6)}function Rle(e){let t=fu.safeParse(e);if(!t.success)return;let n=H6;H6=t.data,!(_le(n,t.data)&&zle())&&(Y8(),X8())}function zle(){if(!H6||!Y6?.isConnected)return!1;n8.reset(),i8.reset();let e=q8(),t=m6(H6),n=S8(`In review`,t.inReview,`inReview`,d6(t));return Y6.replaceWith(n),Y6=n,J8(e),t.inReview.some(e=>e.key===X6)&&W8(t),p8(U6),!0}function Ble(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.key!=`string`)return;let n=c8.get(t.key);if(!n||n.requestId!==t.requestId)return;if(window.clearTimeout(n.timer),c8.delete(t.key),n.action===`resolve-thread`){n.settle?.(t.ok===!0,typeof t.error==`string`?t.error:L6(n.action)),s8.delete(t.key),e8=null,t.ok===!0&&Y8();return}let r=(n.origin===`ready`?o8:s8).get(t.key);if(t.ok===!0){n.origin===`other`&&s8.delete(t.key);let e=bce({action:n.action,pullRequest:n.pullRequest,warning:typeof t.warning==`string`?t.warning:``,isActedSelected:X6===t.key});if((r?.settle??n.settle)?.(!0,e.statusText),(e.notice||e.shouldAdvance)&&x8(e.notice),!e.shouldAdvance)return;X6=Bce({capturedOrder:n.capturedOrder,actedKey:t.key,groups:m6(H6)}),X6===null&&(Z6={actedKey:t.key}),Y8();return}(r?.settle??n.settle)?.(!1,typeof t.error==`string`&&t.error?t.error:`The action failed.`)}function Z8(e,t,n){return n.has(e.id)?`review`:e.state===`open`||e.state===`blocked`?`queue`:e.state===`active`?`workers`:e.state===`completed`?t.has(e.id)?`review`:`shipped`:null}function Vle(e){let t=0;for(let n of e.owner??e.id)t=Math.imul(t,31)+n.charCodeAt(0)>>>0;return iO[t%iO.length]}function Hle(e,t,n){return t?`Scope conflict`:e.state===`blocked`?`Blocked`:e.state===`open`&&e.readiness===`waiting`?`Waiting on dependency`:n===`workers`?`Running`:n===`review`?`Unverified`:n===`shipped`?`Shipped`:`Ready`}function Ule(e,t){let n=new Set,r=e;for(;r;){if(n.has(r.id))return null;if(n.add(r.id),r.parent===null)return r;r=t.get(r.parent)}return null}function Wle(e,t){let n=e.orders.filter(e=>e.parent===null&&e.state!==`completed`&&e.state!==`cancelled`).sort((e,t)=>e.openedAt.localeCompare(t.openedAt)),r=new Set(e.orders.filter(e=>e.state===`active`).map(e=>e.parent)),i=n.find(t=>t.id===e.orchestrator?.intentId)??n.find(e=>r.has(e.id))??n[0]??null,a=i?e.orders.filter(e=>e.parent===i.id):[],o=new Set(e.reviewing??[]),s=new Set(e.unverifiedCompletedWork),c=new Set(e.conflicts.flatMap(e=>[e.left,e.right])),l={queue:[],workers:[],review:[],shipped:[]},u=e.orders.filter(e=>e.parent===i?.id);for(let n of u){let r=Z8(n,s,o);if(!r)continue;let i=c.has(n.id),a=i||n.state===`blocked`||n.state===`open`&&n.readiness===`waiting`;l[r].push({id:n.id,objective:n.objective,sessionId:e.liveWorkers?.find(e=>e.workId===n.id)?.sessionId??null,risk:n.risk,station:r,status:o.has(n.id)?`Reviewing`:Hle(n,i,r),hasConflict:i,isHeld:a,isSelected:n.id===t,animal:Vle(n)})}let d=new Map(e.orders.map(e=>[e.id,e])),f=t===null?void 0:d.get(t),p=f?Ule(f,d):null;return{paused:e.paused,spend:`Factory today: $${(e.spentTodayUsd??0).toFixed(2)} / ${e.dailyBudgetUsd==null?`unlimited`:`$${e.dailyBudgetUsd.toFixed(2)}`}`,note:e.note??null,intent:i?{id:i.id,objective:i.objective,criteria:i.criteria.map(e=>({text:e,isMet:i.state===`completed`})),shippedCount:l.shipped.length,childCount:a.length}:null,upNext:n.filter(e=>e.id!==i?.id).map(({id:e,objective:t})=>({id:e,objective:t})),orchestrator:e.error===null?{action:e.heading.action,reason:e.heading.reasons[0]??``,isException:!1,sessionId:e.orchestrator?.sessionId??null,state:e.orchestrator?.state??null}:{action:`Exception`,reason:e.error,isException:!0,sessionId:e.orchestrator?.sessionId??null,state:e.orchestrator?.state??null},stations:l,ledger:e.orders.flatMap(e=>e.lastEvent?[{orderId:e.id,...e.lastEvent}]:[]).sort((e,t)=>Date.parse(t.at)-Date.parse(e.at)).slice(0,50),selectedOrder:f?{id:f.id,intent:p?.objective??null,writeScopes:f.writeScopes,dependsOn:f.dependsOn,station:f.parent===null?`intent`:Z8(f,s,o)??`cancelled`,owner:f.owner}:null}}function Gle(e,t){return e.find(e=>e.projectId===t)||([...e].sort((e,t)=>e.projectName.localeCompare(t.projectName)||e.projectId.localeCompare(t.projectId))[0]??null)}var Q8=null,$8=null,e5=null,t5=!1,n5=null,r5=null,i5=null,a5=0,o5=new Map,s5=new Map,c5=new Map;function Kle(e){let t=o5.get(e);if(t)return t;let n={objective:``,criteria:``,risk:`low`,boundary:``,writeScopes:``};return o5.set(e,n),n}var l5=`.factory-stack, .factory-pads, .factory-ledger, .factory-detail, .factory-intent-queue, .factory-criteria`,qle=[[`[data-order-id]`,`orderId`],[`[data-factory-field]`,`factoryField`],[`[data-project-id]`,`projectId`]];function u5(e,t,n){let r=V(`button`,e,t);return r.type=`button`,r.addEventListener(`click`,n),r}function d5(e){let t=V(`p`,`factory-request-status`,e?.text??``);return t.setAttribute(`role`,`status`),t.dataset.error=String(e?.hasError===!0),t}function f5(e,t,n,r){let i=t===`factory-queue-intent`?s5:c5;if(i.get(e)?.requestId)return;a5+=1;let a=`factory-${a5}`,o=i5?.({...n,projectId:e,type:t,requestId:a})===!0;i.set(e,{requestId:o?a:null,text:o?r:`Not connected.`,hasError:!o}),_5()}function Jle(e,t){let n=V(`fieldset`,`factory-form-field`);n.append(V(`legend`,`factory-label`,`Protected floor opt-in`));for(let r of il){let i=V(`label`,`factory-floor-allowance`),a=V(`input`);a.type=`checkbox`,a.value=r,a.dataset.factoryField=`floor:${r}`,a.checked=e.floorAllowances?.includes(r)===!0,a.disabled=t,a.addEventListener(`change`,()=>{let t=(e.floorAllowances??[]).filter(e=>e!==r),n=a.checked?[...t,r]:t;e.floorAllowances=il.filter(e=>n.includes(e))}),i.append(a,V(`span`,null,r)),n.append(i)}return n}function Yle(e){let t=Kle(e),n=V(`form`,`factory-queue-form`),r=s5.get(e)?.requestId!=null;for(let[e,i,a,o]of[[`objective`,`Objective`,4096,2],[`criteria`,`Criteria, one per line`,49164,2],[`boundary`,`Authority boundary`,4096,1],[`writeScopes`,`Write scopes, one per line`,32800,2]]){let s=V(`label`,`factory-form-field`),c=V(`textarea`,`factory-form-input`);c.name=e,c.dataset.factoryField=e,c.maxLength=a,c.rows=o,c.required=e!==`writeScopes`,c.value=t[e],c.disabled=r,c.addEventListener(`input`,()=>{t[e]=c.value}),s.append(V(`span`,`factory-label`,i),c),n.append(s)}let i=V(`label`,`factory-form-field`),a=V(`select`,`factory-form-input`);a.name=`risk`,a.dataset.factoryField=`risk`,a.disabled=r;for(let e of sl.shape.risk.options){let t=V(`option`,null,e);t.value=e,a.append(t)}a.value=t.risk,a.addEventListener(`change`,()=>{t.risk=sl.shape.risk.parse(a.value)}),i.append(V(`span`,`factory-label`,`Risk`),a),n.append(Jle(t,r));let o=V(`button`,`factory-action`,`Queue intent`);return o.type=`submit`,o.disabled=!t5||r,n.insertBefore(i,n.children[2]??null),n.append(o,d5(s5.get(e))),n.addEventListener(`submit`,n=>{n.preventDefault();let r=sl.safeParse({...t,projectId:e,criteria:t.criteria.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),writeScopes:t.writeScopes.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)});if(!r.success){s5.set(e,{requestId:null,text:r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `),hasError:!0}),_5();return}f5(e,`factory-queue-intent`,r.data,`Queueing intent.`)}),n}function Xle(e,t){let n=V(`div`,`factory-controls`),r=c5.get(e);for(let i of[`pause`,`resume`]){let a=u5(`factory-action`,i===`pause`?`Pause`:`Resume`,()=>f5(e,`factory-control`,{action:i},i===`pause`?`Pausing factory.`:`Resuming factory.`));a.disabled=!t5||r?.requestId!=null||(i===`pause`?t:!t),n.append(a)}return n.append(d5(r)),n}var Zle=[{id:`queue`,label:`Queue`,slots:3},{id:`workers`,label:`Workers`,slots:3},{id:`review`,label:`Review`,slots:2},{id:`shipped`,label:`Shipped`,slots:3}];function p5(e,t){let n=Cf(`factory`,e);return n.classList.add(...t.split(` `)),n.setAttribute(`aria-label`,e),n}function m5(e,t){let n=V(`div`,`factory-sprite`);n.setAttribute(`role`,`img`),n.setAttribute(`aria-label`,t);let r=V(`span`,`nyan-sprite ${e}`);return r.setAttribute(`aria-hidden`,`true`),n.append(r),n}function Qle(e){r5=e,_5()}function h5(e,t,n){let r=u5(n,t,()=>Qle(e));return r.dataset.orderId=e,r.setAttribute(`aria-pressed`,String(r5===e)),r}function g5(e,t){let n=V(`div`,`factory-crate`);n.dataset.state=e.isHeld?`waiting`:e.station,n.dataset.selected=String(e.isSelected);let r=V(`div`,`factory-crate-id`),i=V(`span`,`factory-crate-risk`,e.risk);i.dataset.risk=e.risk,r.append(V(`span`,null,e.id),i),n.append(r,h5(e.id,e.objective,`factory-crate-title`));let a=e.sessionId;return a&&Q8&&!t&&n.append(u5(`factory-action`,`Open terminal`,()=>Q8?.(a))),e.station!==`workers`&&n.append(V(`span`,`factory-crate-note`,e.status)),n}function $le(e){return`Read-only mirror of the factory harness run at ${e.recordDirectory}. ${e.outcome?`Ended: ${e.outcome}.`:`No verdict yet.`}`}function eue(e,t){let n=t.projectId,r=t.observedRun!==void 0,i=V(`div`,`factory-band factory-head`),a=p5(`Intent`,`factory-intent`);if(a.append(V(`p`,`factory-count`,e.spend)),e.intent){a.append(h5(e.intent.id,e.intent.objective,`factory-intent-title`));let t=V(`ul`,`factory-criteria`);for(let n of e.intent.criteria){let e=V(`li`,null,`${n.isMet?`[x]`:`[ ]`} ${n.text}`);e.dataset.met=String(n.isMet),t.append(e)}a.append(t,V(`p`,`factory-count`,`${e.intent.shippedCount} of ${e.intent.childCount} shipped`))}e.intent||a.append(V(`p`,`factory-empty`,`No open intent.`));let o=p5(`Orchestrator`,`factory-orchestrator`);o.dataset.state=e.orchestrator.isException?`failed`:e.paused?`paused`:`steady`;let s=V(`div`,`factory-heading`);s.append(V(`strong`,`factory-orchestrator-action`,e.orchestrator.action),V(`p`,`factory-reason`,e.orchestrator.reason)),e.note&&s.append(V(`p`,`factory-reason`,e.note));let c=V(`span`,`factory-paused-marker`,`[paused]`);c.hidden=!e.paused,s.append(c),t.observedRun&&s.append(V(`p`,`factory-reason`,$le(t.observedRun))),r||s.append(Xle(n,e.paused));let l=m5(`is-owl`,`Orchestrator owl`),u=e.orchestrator.sessionId;if(u&&Q8&&!r){let e=u5(`factory-action`,null,()=>Q8?.(u));e.setAttribute(`aria-label`,`Open orchestrator terminal`),e.append(l),o.append(e)}(!u||!Q8||r)&&o.append(l),e.orchestrator.state&&s.append(V(`span`,`factory-orchestrator-state`,e.orchestrator.state)),o.append(s);let d=p5(`Up next`,`factory-up-next`),f=V(`ol`,`factory-intent-queue`);for(let t of e.upNext){let e=V(`li`);e.append(h5(t.id,t.objective,`factory-next-title`)),f.append(e)}return d.append(f),e.upNext.length===0&&d.append(V(`p`,`factory-empty`,`No queued intents.`)),r||d.append(Yle(n)),i.append(a,o,d),i}function tue(e,t,n){let r=V(`section`,`factory-station factory-station-${e.id}`);r.setAttribute(`aria-label`,e.label);let i=V(`div`,`factory-station-head`);i.append(V(`h3`,`factory-label`,e.label),V(`span`,`factory-count`,String(t.length)));let a=V(`div`,e.id===`workers`?`factory-pads`:`factory-stack`);for(let r=0;r<Math.max(e.slots,t.length);r+=1){let i=t[r],o=V(`div`,`factory-open`,`Open slot`);if(e.id!==`workers`){a.append(i?g5(i,n):o);continue}let s=V(`div`,`factory-pad`);s.dataset.state=i?.hasConflict?`waiting`:i?`running`:`idle`,i&&s.append(m5(i.animal.sprite,i.animal.name)),i||s.append(V(`div`,`factory-sprite factory-sprite-empty`)),s.append(i?g5(i,n):o,V(`span`,`factory-pad-status`,i?.status??`Idle`)),a.append(s)}return r.append(i,a),r}function nue(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:Cp(t)}function rue(e){let t=V(`div`,`factory-band factory-foot`),n=p5(`Ledger`,`factory-ledger-region`),r=V(`ol`,`factory-ledger`);for(let t of e.ledger){let e=V(`li`),n=V(`time`,`factory-ledger-time`,nue(t.at));n.dateTime=t.at,e.append(n,V(`span`,null,`${t.orderId} ${t.event} (${t.session})`)),r.append(e)}e.ledger.length===0&&r.append(V(`li`,`factory-empty`,`No ledger events.`)),n.append(r);let i=p5(`Selected ticket`,`factory-detail-region`),a=V(`div`,`factory-detail`),o=e.selectedOrder;if(o){let e=V(`dl`);for(let[t,n]of[[`Intent`,o.intent??`No parent intent`],[`Fence`,o.writeScopes.join(`, `)||`None`],[`After`,o.dependsOn.join(`, `)||`None`],[`Station`,o.station],[`Session`,o.owner??`Unassigned`]])e.append(V(`dt`,null,t),V(`dd`,null,n));a.append(e)}return o||a.append(V(`p`,`factory-empty`,`Select a ticket to inspect its boundaries.`)),i.append(a),t.append(n,V(`div`,`factory-seam`),i),t}function _5(){if(!$8)return;let e=document.activeElement instanceof HTMLElement?document.activeElement:null,t=e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:null,n=[...$8.querySelectorAll(l5)].map(e=>e.scrollTop),r=document.createDocumentFragment(),i=V(`p`,`factory-connection`,t5?e5?``:`Waiting for the server.`:`Disconnected. Showing the last snapshot.`);i.setAttribute(`role`,`status`),r.append(i);let a=Gle(e5?.projects??[],n5);if(!a){r.append(V(`p`,`factory-empty`,e5?`No repos holding coherence.config.json.`:`Waiting for Factory state.`)),$8.replaceChildren(r);return}if(n5!==a.projectId&&(r5=null),n5=a.projectId,e5&&e5.projects.length>1){let e=V(`div`,`factory-projects`);e.setAttribute(`aria-label`,`Factory projects`);for(let t of e5.projects){let n=u5(`factory-project`,t.projectName,()=>{n5=t.projectId,r5=null,_5()});n.dataset.projectId=t.projectId,n.setAttribute(`aria-pressed`,String(t.projectId===n5)),e.append(n)}r.append(e)}let o=Wle(a,r5),s=V(`div`,`factory-console`),c=p5(`Floor`,`factory-band factory-floor-band`),l=V(`div`,`factory-pipe`);for(let e of Zle)l.append(tue(e,o.stations[e.id],a.observedRun!==void 0));c.append(l),s.append(eue(o,a),c,rue(o)),r.append(s),$8.replaceChildren(r),[...$8.querySelectorAll(l5)].forEach((e,t)=>{e.scrollTop=n[t]??0});for(let[n,r]of qle){let i=e?.dataset[r];if(!i)continue;let a=[...$8.querySelectorAll(n)].find(e=>e.dataset[r]===i);a?.focus({preventScroll:!0}),a instanceof HTMLTextAreaElement&&t&&a.setSelectionRange(t.start,t.end)}}function iue(e,t){return Q8=t?.openTerminal??null,$8||($8=V(`div`,`factory-content`),e.append($8),_5(),$8)}function aue(e){e5=e,_5()}function oue(e){if(t5=e,!e)for(let e of[s5,c5])for(let[t,n]of e)n.requestId&&e.set(t,{requestId:null,text:`Disconnected. Check the floor before submitting again.`,hasError:!0});_5()}function sue(e){i5=e}function cue(e){s5.get(e.projectId)?.requestId===e.requestId&&(s5.set(e.projectId,{requestId:null,text:e.ok?`Queued ${e.workId??`intent`}.`:e.error??`Could not queue intent.`,hasError:!e.ok}),e.ok&&o5.delete(e.projectId),_5())}function lue(e){c5.get(e.projectId)?.requestId===e.requestId&&(c5.set(e.projectId,{requestId:null,text:e.ok?e.action===`pause`?`Factory paused.`:`Factory resumed.`:e.error??`Could not update factory.`,hasError:!e.ok}),_5())}var uue={mine:`Mine`,run:`Run`,cancel:`Cancel`},due={mine:`Mining merged pull requests.`,run:`Starting the run.`,cancel:`Cancelling the run.`},v5=null,y5=null,b5=null,x5=new Map,S5=new Map;function C5(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function fue(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function pue(e,t){if(b5?.({type:`benchmark-action`,requestId:af(`benchmark`),suiteId:e,action:t})!==!0){S5.set(e,`Not connected.`),E5();return}x5.set(e,t),S5.set(e,due[t]),E5()}function w5(e,t,n){let r=V(`button`,`bench-action-button`,uue[t]);return r.type=`button`,r.disabled=n,r.addEventListener(`click`,()=>pue(e.id,t)),r}function mue(e){let t=y5?.inFlight;if(!t||t.suiteId!==e.id)return``;let n=t.caseId?`case ${t.caseId}, `:``;return`Cell ${t.cellIndex+1} of ${t.cellCount}: ${n}arm ${t.armId}, trial ${t.trial}, ${t.phase}.`}function T5(e){let t=V(`td`,`bench-score`,C5(e?.recall??null));return e&&e.invalid>0&&(t.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(t.dataset.degraded=`true`),t}function hue(e){let t=e.armIds.filter(t=>t!==e.baselineArm),n=V(`table`,`bench-table`),r=V(`tr`);r.append(V(`th`,null,`Case`),...e.armIds.map(t=>V(`th`,null,t===e.baselineArm?`${t} (baseline)`:t))),r.append(...t.map(e=>V(`th`,null,`${e} vs baseline`))),n.append(r);for(let r of e.rows){let i=V(`tr`);i.append(V(`td`,`bench-case`,r.caseId),...e.armIds.map(e=>T5(r.arms[e]))),i.append(...t.map(e=>V(`td`,`bench-delta`,fue(r.deltaVsBaseline[e]??null)))),n.append(i)}let i=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),a=V(`tr`,`bench-total`);a.append(V(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>T5(e.totals[t]))),n.append(a);for(let t of i){let r=V(`tr`,`bench-total`);r.append(V(`td`,`bench-case`,`Recall, ${t}`),...e.armIds.map(n=>V(`td`,`bench-score`,C5(e.totals[n]?.recallByTag[t]??null)))),n.append(r)}return n}function gue(e){let t=V(`div`,`bench-suite`),n=y5?.inFlight?.suiteId===e.id,r=!!y5?.inFlight&&!n,i=x5.has(e.id),a=V(`div`,`bench-summary`);a.append(V(`span`,`bench-suite-title`,e.title),wf(`bench`,e.caseCount===1?`case`:`cases`,String(e.caseCount)),wf(`bench`,e.candidateCount===1?`candidate`:`candidates`,String(e.candidateCount)),wf(`bench`,`arms`,String(e.armIds.length))),t.append(a);let o=V(`div`,`bench-controls`),s=y5?.configured===!0&&e.error===null;o.append(w5(e,`mine`,!s||i||n),w5(e,`run`,!s||i||n||r||e.caseCount===0),w5(e,`cancel`,i||!n));let c=V(`span`,`bench-status`,mue(e)||S5.get(e.id)||``);if(c.setAttribute(`role`,`status`),o.append(c),t.append(o),e.error)return t.append(V(`p`,`bench-error`,e.error)),t;let l=e.latestReport;return l?(t.append(V(`p`,`bench-run-line`,`Latest run ${l.runId}: ${l.status}. Only cases every arm scored count toward paired recall.`)),l.rows.length>0&&t.append(hue(l)),t):(t.append(V(`p`,`bench-empty`,e.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),t)}function E5(){if(!v5)return;v5.textContent=``;let e=Cf(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(v5.append(e),!y5){v5.append(V(`p`,`bench-empty`,`Waiting for the server.`));return}if(!y5.configured){v5.append(V(`p`,`bench-empty`,y5.reason||`Benchmarks are off.`));return}if(y5.suites.length===0){v5.append(V(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));return}for(let e of y5.suites)v5.append(gue(e))}function _ue(e){b5=e}function vue(e){return v5||(v5=V(`div`,`bench-content`),e.append(v5),E5(),v5)}function yue(e){if(!(e||x5.size===0)){for(let e of x5.keys())S5.set(e,`Connection lost.`);x5.clear(),E5()}}function bue(e){y5=e,E5()}function xue(e){x5.delete(e.suiteId);let t=y5?.suites.find(t=>t.id===e.suiteId)?.candidateCount??0,n={mine:`Mining finished. ${t} candidate${t===1?``:`s`} awaiting approval in the candidates folder.`,run:`Run ${e.runId??``} started.`,cancel:`Run cancelled.`};S5.set(e.suiteId,e.ok?n[e.action]:e.error||`The server refused the action.`),E5()}function Sue(e){return e?e.configured?`No open issues.`:e.reason??`Loading issues.`:`Loading issues.`}function D5(e,t){return t===`all`||e.sources.includes(t)}function Cue(e){return{all:e.length,me:e.filter(e=>D5(e,`me`)).length,team:e.filter(e=>D5(e,`team`)).length,project:e.filter(e=>D5(e,`project`)).length}}function wue(e,t,n){let r=t.query.trim().toLowerCase().split(/\s+/).filter(Boolean),i=e.filter(e=>{if(!D5(e,t.scope)||t.repo&&e.repo!==t.repo||t.label&&!e.labels.includes(t.label)||t.hasSession&&(!e.sessionId||!n.has(e.sessionId))||t.hasPr&&e.pullRequests.length===0||t.isUnassignedOnly&&e.assignees.length>0)return!1;let i=[e.title,`#${e.number}`,e.repo,e.author,...e.labels,...e.assignees,...e.teams].join(` `).toLowerCase();return r.every(e=>i.includes(e))}),a=e=>Date.parse(e)||0,o=e=>t.sort===`comments`?e.comments:t.sort===`created`?a(e.createdAt):a(e.updatedAt);return i.sort((e,t)=>o(t)-o(e)||e.key.localeCompare(t.key))}function Tue(e){let t=new Map;for(let n of e){let e=t.get(n.repo)??[];e.push(n),t.set(n.repo,e)}return t}function Eue(e){return{repos:[...new Set(e.map(e=>e.repo))].sort(),labels:[...new Set(e.flatMap(e=>e.labels))].sort()}}function Due(e){let t=[e.query.trim()&&`search "${e.query.trim()}"`,e.repo,e.label,e.hasSession&&`has session`,e.hasPr&&`has PR`,e.isUnassignedOnly&&`unassigned`].filter(Boolean);return t.length===0?``:`Filtered by ${t.join(`, `)}.`}function O5(e,t){let n=typeof e==`number`?e:Date.parse(e);if(!Number.isFinite(n))return`unknown`;let r=Math.round(Math.max(0,t-n)/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.round(r/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function k5(e,t){let n=O5(e,t);return n===`now`?`just now`:n===`unknown`?`at an unknown time`:`${n} ago`}var A5=45e3,j5=[{id:`all`,label:`All`},{id:`me`,label:`Mine`},{id:`team`,label:`Team`},{id:`project`,label:`Projects`}],M5={scope:`all`,repo:``,label:``,sort:`updated`,query:``,hasSession:!1,hasPr:!1,isUnassignedOnly:!1},N5=null,P5=null,F5=null,I5=null,L5=null,R5=null,z5=null,B5=null,V5=null,H5=null,U5=new Map,W5=!1,G5=null,K5=null,q5=new Map,J5=new Map,Y5=new Map,X5=new Map,Z5=new Map;function Q5(e){return`${e.key}:${e.updatedAt}`}function $5(e){return e.sessionId?U.get(e.sessionId):void 0}function e7(e,t,n){let r=$5(t),i=r?.currentState??F.DORMANT,a=xf(i,r?.awaitingBackgroundTasks),o=r?`Session: ${a.label}`:`No session yet`,s=n?`${a.glyph} ${a.label}`:a.glyph;(e.dataset.state!==i||e.title!==o||e.textContent!==s)&&(e.dataset.state=i,e.title=o,e.setAttribute(`aria-label`,o),e.textContent=s)}function t7(e,t=!1){let n=V(`span`,t?`issues-state`:`pr-queue-glyph issues-state`);return e7(n,e,t),n}function n7(e){let t=$5(e);return t?Kf(t):`none yet`}function r7(e){return[...q5.values()].some(t=>t.issueKey===e.key)}function Oue(e){let t=q5.get(e);t&&(q5.delete(e),J5.set(t.issueKey,`No reply from the server.`),c7())}function kue(e){let t=q5.get(e);return t?(clearTimeout(t.timeoutHandle),q5.delete(e),t):null}function i7(e){let t=Q5(e);if(X5.has(t)||[...Y5.values()].some(e=>e.cacheKey===t))return;let n=af(`issue-detail`);if(Z5.delete(t),!K5?.({type:`issue-detail`,requestId:n,repo:e.repo,issueNumber:e.number})){Z5.set(t,`Not connected. Select the issue to load its description.`);return}Y5.set(n,{cacheKey:t,timeoutHandle:setTimeout(()=>{Y5.delete(n),Z5.set(t,`No reply from the server. Select the issue to load its description.`),c7()},A5)})}function Aue(e){let t=e.projectId;if(!t||$5(e)||r7(e))return;let n=af(`open-issue-session`);if(!K5?.({type:`open-issue-session`,requestId:n,projectId:t,repo:e.repo,issueNumber:e.number})){J5.set(e.key,`Not connected.`),c7();return}q5.set(n,{issueKey:e.key,issueNumber:e.number,timeoutHandle:setTimeout(()=>Oue(n),A5)}),J5.set(e.key,`Opening session.`),c7()}function jue(e){let t=V(`button`,`pr-queue-row issue-row`);t.type=`button`,t.dataset.issueKey=e.key,t.setAttribute(`aria-current`,String(e.key===V5));let n=V(`span`,`pr-queue-top`);n.append(V(`span`,`pr-queue-ref`,`#${e.number}`),V(`span`,`pr-queue-title`,e.title||`Untitled issue`));let r=V(`span`,`pr-queue-bottom`);e.sources.includes(`me`)&&r.append(V(`span`,`issues-why`,`you`)),r.append(V(`span`,`issues-row-labels`,e.labels.join(`, `)));for(let t of e.pullRequests)r.append(V(`span`,`issues-row-pr`,`PR #${t.number}`));let i=V(`span`,`pr-queue-elapsed`,O5(e.updatedAt,Date.now()));return i.dataset.issueAge=e.updatedAt,r.append(i),t.append(t7(e),n,r),t.addEventListener(`click`,()=>{V5=e.key,N5&&(N5.dataset.detailOpen=`true`),i7(e),u7(),I5&&(I5.scrollTop=0)}),t}function a7(e,t,n){let r=V(`dd`);r.append(...n),e.append(V(`dt`,null,t),r)}function o7(e){let t=V(`footer`,`pr-footer issues-detail-footer`),n=$5(e);if(n&&e.sessionId){let n=e.sessionId,r=V(`button`,`pr-action`,`Go to session`);r.type=`button`,r.addEventListener(`click`,()=>wI(n)),t.append(r)}if(e.projectId&&!n){let n=V(`button`,`pr-action`,`Open session`);n.type=`button`,n.disabled=r7(e),n.addEventListener(`click`,()=>Aue(e)),t.append(n)}t.append(vf(`pr-action`,`View on GitHub`,e.url));let r=J5.get(e.key),i=e.projectId?``:`Add a project for ${e.repo} in Settings to open sessions from here.`,a=V(`span`,`pr-action-status issue-open-status`,r??i);return a.setAttribute(`role`,`status`),r7(e)&&a.prepend(V(`span`,`issues-spinner`)),t.append(a),t}function s7(e,t){let n=V(`span`,null,k5(e,t));return n.dataset.issueAgo=e,n}function Mue(){let e=I5?.querySelector(`.issues-detail`),t=V5?U5.get(V5):void 0;if(!e||!t)return;let n=e.querySelector(`.issues-facts .issues-state`);n&&e7(n,t,!0);let r=e.querySelector(`.issues-session-name`),i=n7(t);r&&r.textContent!==i&&(r.textContent=i);let a=String(!!$5(t));e.dataset.hasLiveSession!==a&&(e.dataset.hasLiveSession=a,e.querySelector(`.issues-detail-footer`)?.replaceWith(o7(t)))}function c7(){if(!I5)return;let e=H5?.issues.find(e=>e.key===V5);if(!e){I5.replaceChildren(V(`p`,`pr-empty`,`Pick an issue from the queue.`));return}let t=V(`article`,`pr-detail issues-detail`),n=V(`button`,`pr-action issues-back`,`Back to issues`);n.type=`button`,n.addEventListener(`click`,()=>{N5&&(N5.dataset.detailOpen=`false`),[...F5?.querySelectorAll(`[data-issue-key]`)??[]].find(e=>e.dataset.issueKey===V5)?.focus({preventScroll:!0})});let r=V(`header`,`pr-detail-heading`),i=V(`div`,`pr-detail-title`);i.append(vf(`pr-link`,`${e.repo}#${e.number}`,e.url),V(`h2`,null,e.title||`Untitled issue`));let a=Date.now(),o=V(`div`,`pr-detail-meta`),s=V(`span`,null,`opened by ${e.author||`unknown`} `),c=V(`span`,null,`updated `);s.append(s7(e.createdAt,a)),c.append(s7(e.updatedAt,a)),o.append(s,c,V(`span`,null,`${e.comments} comments`)),e.sources.includes(`me`)&&o.append(V(`span`,`issues-why`,`assigned to you`));for(let t of e.teams)o.append(V(`span`,null,`mentions ${t}`));r.append(i,o);let l=V(`dl`,`issues-facts`);a7(l,`Repository`,[e.repo]),a7(l,`Labels`,[e.labels.join(`, `)||`none`]),a7(l,`Assignees`,[e.assignees.join(`, `)||`unassigned`]),t.dataset.hasLiveSession=String(!!$5(e)),a7(l,`Session`,[t7(e,!0),V(`span`,`issues-session-name`,n7(e))]);let u=e.pullRequests.flatMap(e=>{let t=V(`span`,`issues-pr-state`,e.state);return t.dataset.prState=e.state,[t,vf(`issues-inline-link`,`#${e.number} ${e.title}`,e.url)]});a7(l,`Pull request`,u.length>0?u:[`none linked`]);let d=V(`section`,`issues-body-section`),f=Q5(e),p=V(`div`,`issue-body`,X5.get(f)??Z5.get(f)??`Loading description.`);X5.get(f)===``&&(p.textContent=`No description.`),p.setAttribute(`role`,`status`),d.append(V(`h3`,`pr-section-heading`,`Description`),p),t.append(n,r,l,d,o7(e)),I5.replaceChildren(t)}function l7(e,t,n,r){if(!e)return;let i=r&&!n.includes(r)?[...n,r].sort():n;e.replaceChildren(...[``,...i].map(e=>{let n=V(`option`,null,e||t);return n.value=e,n})),e.value=r}function u7(){W5=!1,d7(),c7()}function d7(){if(!N5||!F5||!P5)return;let e=H5?.issues??[],t=Cue(e);for(let e of j5){P5.querySelector(`[data-scope="${e.id}"]`)?.setAttribute(`aria-selected`,String(e.id===M5.scope));let n=P5.querySelector(`[data-scope-count="${e.id}"]`);n&&(n.textContent=String(t[e.id]))}let n=Eue(e);l7(R5,`All repos`,n.repos,M5.repo),l7(z5,`All labels`,n.labels,M5.label),L5&&(L5.textContent=Due(M5));let r=wue(e,M5,new Set(U.keys())),i=document.activeElement instanceof HTMLElement&&F5.contains(document.activeElement)?document.activeElement.dataset.issueKey:null,a=[...Tue(r)].map(([e,t])=>{let n=V(`section`,`pr-queue-section`),r=V(`h3`,`pr-section-heading issues-repo-heading`,e);return t.some(e=>e.projectId)||r.append(V(`span`,`issues-repo-note`,`view only`)),r.append(V(`span`,`issues-repo-count`,String(t.length))),n.append(r,...t.map(jue)),n});F5.replaceChildren(...a),r.length===0&&F5.append(V(`p`,`pr-empty`,e.length>0?`No open issues match these filters. Clear the search or pick All.`:Sue(H5))),i&&[...F5.querySelectorAll(`[data-issue-key]`)].find(e=>e.dataset.issueKey===i)?.focus({preventScroll:!0}),V5&&!e.some(e=>e.key===V5)&&(V5=null,N5.dataset.detailOpen=`false`),G5?.update(H5),f7()}function Nue(){let e=V(`div`,`issues-filters`),t=V(`div`,`issues-search-row`),n=V(`input`,`issues-search`);n.type=`search`,n.placeholder=`Search issues`,n.autocomplete=`off`,n.setAttribute(`aria-label`,`Search issues`),n.addEventListener(`input`,()=>{M5.query=n.value,u7()});let r=V(`button`,`pr-action`,`Filters`);r.type=`button`,r.setAttribute(`aria-expanded`,`false`),r.setAttribute(`aria-controls`,`issues-filters-panel`);let i=V(`div`,`issues-filters-panel`);i.id=`issues-filters-panel`,i.hidden=!0,r.addEventListener(`click`,()=>{i.hidden=!i.hidden,r.setAttribute(`aria-expanded`,String(!i.hidden))}),t.append(n,r);let a=V(`div`,`issues-filter-row`);function o(e){let t=V(`select`,`issues-field`);return t.setAttribute(`aria-label`,e),a.append(t),t}R5=o(`Repository`),R5.addEventListener(`change`,()=>{M5.repo=R5?.value??``,u7()}),z5=o(`Label`),z5.addEventListener(`change`,()=>{M5.label=z5?.value??``,u7()});let s=o(`Sort`);for(let[e,t]of[[`updated`,`Updated`],[`created`,`Newest`],[`comments`,`Most discussed`]]){let n=V(`option`,null,t);n.value=e??``,s.append(n)}s.addEventListener(`change`,()=>{M5.sort=s.value,u7()});let c=V(`div`,`issues-filter-row`);for(let[e,t]of[[`hasSession`,`Has session`],[`hasPr`,`Has PR`],[`isUnassignedOnly`,`Unassigned`]]){let n=V(`label`,`issues-toggle`),r=V(`input`);r.type=`checkbox`,r.addEventListener(`change`,()=>{M5[e]=r.checked,u7()}),n.append(r,` ${t}`),c.append(n)}return L5=V(`span`,`issues-filter-summary`),L5.setAttribute(`role`,`status`),i.append(a,c),e.append(t,L5,i),e}function f7(){if(!N5||N5.closest(`[hidden]`)||document.hidden)return;let e=Date.now();B5&&(B5.textContent=H5?.lastSyncAt?`Synced ${k5(H5.lastSyncAt,e)}.`:`Not synced yet.`);for(let t of N5.querySelectorAll(`[data-issue-age]`))t.textContent=O5(t.dataset.issueAge??``,e);for(let t of N5.querySelectorAll(`[data-issue-ago]`))t.textContent=k5(t.dataset.issueAgo??``,e)}function Pue(e){K5=e}function Fue(e){if(N5)return N5;N5=V(`div`,`issues-content`),N5.dataset.detailOpen=`false`,e.append(N5),G5=U3(`issues`,N5);let t=V(`div`,`pr-columns issues-columns`),n=V(`section`,`pr-queue-pane`);n.setAttribute(`aria-label`,`Issue queue`),P5=V(`div`,`pr-scope-tabs issues-scope-tabs`),P5.setAttribute(`role`,`tablist`),P5.setAttribute(`aria-label`,`Issue scope`);for(let e of j5){let t=V(`span`,`issues-scope`);t.setAttribute(`role`,`presentation`);let n=V(`button`,`pr-scope-tab`,e.label);n.type=`button`,n.dataset.scope=e.id,n.setAttribute(`role`,`tab`),n.addEventListener(`click`,()=>{M5.scope=e.id,u7()});let r=V(`span`,`issues-scope-count`);r.dataset.scopeCount=e.id,t.append(n,r),P5.append(t)}F5=V(`nav`,`pr-queue`),F5.setAttribute(`aria-label`,`Issues`);let r=s4(G5.control);return B5=V(`span`,`issues-sync`),B5.setAttribute(`role`,`status`),r.prepend(B5),r.append(G5.notice),n.append(o4(P5),Nue(),F5,r),I5=V(`section`,`pr-detail-host`),I5.setAttribute(`aria-label`,`Issue detail`),t.append(n,I5),N5.append(t),window.setInterval(f7,3e4),u7(),N5}function Iue(){W5&&p7(),f7()}function p7(){if(Ef(N5)){W5=!0;return}if(W5=!1,Mue(),M5.hasSession){d7();return}for(let e of F5?.querySelectorAll(`[data-issue-key]`)??[]){let t=U5.get(e.dataset.issueKey??``),n=e.querySelector(`.issues-state`);t&&n&&e7(n,t,!1)}}function Lue(e){if(!e){for(let e of q5.values())clearTimeout(e.timeoutHandle),J5.set(e.issueKey,`Connection lost.`);q5.clear();for(let e of Y5.values())clearTimeout(e.timeoutHandle),Z5.set(e.cacheKey,`Connection lost. Select the issue to load its description.`);Y5.clear(),u7()}}function Rue(e){let t=H5?.issues.find(e=>e.key===V5);H5=e,U5=new Map(e.issues.map(e=>[e.key,e]));let n=e.issues.find(e=>e.key===V5);n&&n.updatedAt!==t?.updatedAt&&i7(n),u7()}function zue(e){let t=Y5.get(e.requestId);t&&(clearTimeout(t.timeoutHandle),Y5.delete(e.requestId),e.ok&&e.body!==null&&X5.set(t.cacheKey,e.body),(!e.ok||e.body===null)&&Z5.set(t.cacheKey,e.error||`Could not load description. Select the issue to try again.`),c7())}function Bue(e){if(typeof e.requestId!=`string`)return;let t=kue(e.requestId);if(!t)return;let n=t.issueKey;if(e.ok===!0){let r=typeof e.sessionName==`string`?e.sessionName:`issue #${t.issueNumber}`,i=e.pending===!0?` Prompt queued.`:``,a=e.existing===!0?`already open`:`created`;J5.set(n,`Session "${r}" ${a}.${i}`);let o=H5?.issues.find(e=>e.key===n);o&&typeof e.sessionId==`string`&&(o.sessionId=e.sessionId),u7();return}let r=typeof e.error==`string`&&e.error?e.error:`Could not open session.`;J5.set(n,r),c7()}var Vue=4e3;function Hue({render:e,holdMs:t=Vue,setTimer:n=setTimeout,clearTimer:r=clearTimeout}){let i=new Set,a=!1,o=null;function s(e){(o===null||e)&&(o!==null&&r(o),o=n(c,t))}function c(){if(o=null,i.size>0){s(!1);return}a&&(a=!1,e())}return{begin(e){i.add(e)},settle(e){i.delete(e),s(!0)},request(){if(i.size===0&&o===null){e();return}a=!0,s(!1)},_state(){return{pending:i.size,held:a,armed:o!==null}}}}var m7=null,h7=null,g7=null,_7=null,v7=`http://www.w3.org/2000/svg`,y7=AA({getAck:yk,setAck:bk,signature:()=>Lre({posthog:m7}),isLooking:()=>!Ef(h7)}),b7=Hue({render:z7}),x7=new Set,S7=null,C7=new Map,w7=XP(()=>h7),Uue={spiking:`spiking`,regressed:`regressed`,worsened:`worsened`,new:`new`,quiet:`quiet`},T7=[{columnId:`stripe`,headText:``,cellClass:`radar-stripe`,track:`auto`,phoneTrack:`auto`,isMagnitude:!1,startsActionCluster:!1},{columnId:`change`,headText:``,cellClass:`radar-change`,track:`auto`,phoneTrack:`minmax(68px, auto)`,isMagnitude:!1,startsActionCluster:!1},{columnId:`copy`,headText:``,cellClass:`radar-issue-copy`,track:`minmax(0, 1fr)`,phoneTrack:`minmax(0, 1fr)`,isMagnitude:!1,startsActionCluster:!0},{columnId:`occurrences`,headText:`Occurrences`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`users`,headText:`Users`,cellClass:`radar-metric`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1},{columnId:`trend`,headText:`Trend`,cellClass:`radar-issue-trend`,track:`max-content`,phoneTrack:``,isMagnitude:!0,startsActionCluster:!1}],Wue=T7.map(e=>e.track).join(` `),Gue=T7.filter(e=>!e.isMagnitude).map(e=>e.phoneTrack).join(` `),Kue=T7.findIndex(e=>e.startsActionCluster)+1;function E7(e){let t=V(`div`,e);return t.style.setProperty(`--radar-issue-grid`,Wue),t.style.setProperty(`--radar-issue-grid-phone`,Gue),t.style.setProperty(`--radar-issue-actions-start`,String(Kue)),t}function D7(e,t){let n=V(`span`,`radar-issue-magnitudes`),r=!1;for(let i of T7){let a=t(i);if(!i.isMagnitude){e.append(a);continue}r||=(e.append(n),!0),n.append(a)}}function O7(e){return Number.isFinite(e)?String(e):`0`}function que(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`elapsed ${qP(Date.now()-e)}`}function k7(e){return typeof e?.issueId==`string`?e.issueId:``}function A7(e,t){return[String(e??``),String(t??``)].join(`::`)}function Jue(e,t,n){let r=C7.get(A7(e,t));if(!r||!r.copy.isConnected)return!1;let i=MA(n);return i?(r.summary||(r.summary=V(`span`,`radar-issue-summary`),r.copy.insertBefore(r.summary,r.copy.querySelector(`.radar-issue-meta`))),r.summary.textContent=i,!0):(r.summary?.remove(),r.summary=null,!0)}function j7(e,t,n){let r=k7(e);if(!r)return;S7?.dialog.close();let i=tF({issueTitle:String(e.title||r),projectLabel:n,onOpenReport:()=>N7(e)});S7={projectId:String(t??``),issueId:r,dialog:i},i.update(NA(e))}function M7(){if(!S7)return;if(!S7.dialog.isOpen()){S7=null;return}let e=PA(m7,S7.projectId,S7.issueId);e&&S7.dialog.update(NA(e))}function N7(e){let t=k7(e);t&&of(`get-posthog-report`,{issueId:t}).then(n=>{if(!n.ok){eF({issueId:t,issueTitle:String(e.title??``),error:String(n.error||`Could not read report`)});return}if(!n.found){eF({issueId:t,issueTitle:String(e.title??``),message:String(n.message||`Report not found`)});return}eF({issueId:t,issueTitle:String(e.title??``),format:String(n.format??``),content:String(n.content||``)})}).catch(n=>{eF({issueId:t,issueTitle:String(e.title??``),error:String(n?.message||`Could not read report`)})})}function P7(){let e=V(`div`,`radar-issue-actions`),t=V(`span`,`radar-issue-action-status`);t.setAttribute(`role`,`status`),e.append(t);let n=[],r=null,i=()=>{r?.remove(),r=null},a=t=>{i(),r=t,e.append(t)},o=e=>{for(let t of n)t.disabled=e};return{addButton:(r,i,a)=>{let o=V(`button`,`radar-issue-action`,r);return o.type=`button`,o.title=i,o.addEventListener(`click`,e=>{e.stopPropagation(),a()}),n.push(o),e.insertBefore(o,t),o},request:(e,n,r,a,s,c=null)=>{b7.begin(e),o(!0),i(),t.dataset.tone=`busy`,t.textContent=a;let l=(n,r)=>{o(!1),i(),t.dataset.tone=n,t.textContent=r,b7.settle(e)};of(n,r).then(e=>{if(!e.ok){l(`error`,String(e.error||`Request failed`));return}l(`ok`,s(e)),c&&c(e)}).catch(e=>l(`error`,String(e?.message||`Request failed`)))},showFollowUp:a,wrap:e}}function Yue(e){let t=V(`button`,`radar-issue-action radar-open-trace`,`Open trace`);return t.type=`button`,t.title=`Open the session trace`,t.addEventListener(`click`,t=>{t.stopPropagation(),cde(e)}),t}function Xue(e,t,n){let{addButton:r,request:i,showFollowUp:a,wrap:o}=P7(),s=(n,r,a,o,s=null)=>i(`${n}:${e.issueId}`,n,{projectId:t,issueId:e.issueId,...r},a,o,s);return e.inFlight&&r(`View investigation`,`Watch the running investigation`,()=>j7(e,t,n)),e.inFlight||r(`Open session`,`Paste an investigation prompt into the mapped project session`,()=>{s(`posthog-open-session`,{},`Opening session`,e=>e.pending?`Starting ${String(e.sessionName||`session`)}; the prompt lands when it is up`:`Prompt pasted into ${String(e.sessionName||`the session`)}; press Enter there`,e=>{typeof e.sessionId==`string`&&_7&&a(Yue(e.sessionId))})}),r(`Resolve`,`Mark this issue resolved in PostHog`,()=>{s(`posthog-issue-action`,{action:`resolve`},`Resolving in PostHog`,()=>`Marked resolved`)}),r(`Suppress`,`Suppress this issue in PostHog`,()=>{s(`posthog-issue-action`,{action:`suppress`},`Suppressing in PostHog`,()=>`Marked suppressed`)}),o}function F7(e,t,n){e.classList.add(`radar-issue-reportable`),e.tabIndex=0,e.setAttribute(`role`,`button`),e.setAttribute(`aria-label`,t),e.title=t,e.addEventListener(`click`,e=>{e.target instanceof Element&&(e.target.closest(`a, button`)||n())}),e.addEventListener(`keydown`,t=>{t.target===e&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n())})}function Zue(e,t,n){let r=V(`div`,`radar-issue`);r.dataset.severity=yre(e.change);let i=V(`span`,`radar-stripe`);i.setAttribute(`aria-hidden`,`true`);let a=V(`span`,`radar-change`,Uue[e.change??``]||String(e.change||`unknown`)),o=vf(`radar-issue-title`,String(e.title||`Untitled issue`),e.url,String(e.title||``)),s=V(`span`,`radar-metric`);s.append(V(`span`,`radar-metric-value`,O7(e.occurrences)),V(`span`,`radar-metric-label`,`occ`));let c=V(`span`,`radar-metric`);c.append(V(`span`,`radar-metric-value`,O7(e.users)),V(`span`,`radar-metric-label`,`users`));let l=Cre(e.history),u=wre(l,64,16),d=u?document.createElementNS(v7,`svg`):null;if(d){d.classList.add(`radar-sparkline`),d.setAttribute(`viewBox`,`0 0 64 16`),d.setAttribute(`width`,`64`),d.setAttribute(`height`,`16`),d.setAttribute(`role`,`img`),d.setAttribute(`focusable`,`false`);let e=document.createElementNS(v7,`title`);e.textContent=Ere(l);let t=document.createElementNS(v7,`polyline`);t.setAttribute(`points`,u),d.append(e,t)}let f=MA(e),p=V(`span`,`radar-issue-copy`);p.append(o);let m=null;f&&(m=V(`span`,`radar-issue-summary`),m.textContent=f,p.append(m)),C7.set(A7(t,e.issueId),{copy:p,summary:m});let h=V(`span`,`radar-issue-meta`),g=bre(e);if(g!==null){let e=V(`span`,`radar-issue-seen`);e.title=new Date(g).toLocaleString(),w7.track(e,g,JP),h.append(e)}let _=xre(e);_&&h.append(V(`span`,`radar-issue-status`,_));let v=String(e.title||e.issueId);if(e.inFlight){let i=V(`span`,`radar-verdict`,`investigating`);i.dataset.verdict=`INVESTIGATING`,h.append(i);let a=typeof e.startedAt==`number`?e.startedAt:null;if(a!==null&&Number.isFinite(a)&&a>0){let e=V(`span`,`radar-issue-elapsed`);w7.track(e,a,que),h.append(e)}k7(e)&&F7(r,`Watch the investigation of ${v}`,()=>j7(e,t,n))}if(!e.inFlight&&e.verdict){let t=V(`span`,`radar-verdict`,IA(e.verdict));t.dataset.verdict=e.verdict,h.append(t),k7(e)&&F7(r,`View investigation report for ${v}`,()=>N7(e))}h.childElementCount>0&&p.append(h);let y=V(`span`,`radar-issue-trend`);d&&y.append(d);let ee=Tre(l);if(ee){let e=V(`span`,`radar-delta`,`${ee.direction===`up`?`+`:ee.direction===`down`?`-`:`=`}${ee.percent}%`);e.dataset.direction=ee.direction,y.append(e)}let b={stripe:i,change:a,copy:p,occurrences:s,users:c,trend:y};return D7(r,e=>b[e.columnId]),k7(e)&&r.append(Xue(e,t,n)),r}var I7=(e,t,n)=>wf(`radar`,e,t,n);function Que(e){return e.error?`poll failed: ${e.error}`:e.staleMs>0?`stale ${qP(e.staleMs)}`:``}function L7(e,t,{showHost:n,nameTag:r,nameClass:i,hostClass:a}){let o=V(r,i,BA(t));o.title=String(t.name||``),e.append(o);let s=n?VA(t.host):``;s&&e.append(V(`span`,a,s))}function $ue(){let e=E7(`radar-column-heads`);for(let t of T7){if(!t.headText){e.append(V(`span`));continue}let n=V(`span`,`radar-column-head`,t.headText);n.dataset.column=t.columnId,e.append(n)}return e}function ede(e,t){let n=e.project,r=V(`div`,`radar-project`),i=Rre(n.issues),a=zA(i),o=V(`div`,`radar-project-head`);L7(o,n,{showHost:t,nameTag:`h3`,nameClass:`radar-project-name`,hostClass:`radar-project-host`}),r.append(o);let s=V(`div`,`radar-project-summary`);s.append(I7(a.active===1?`active issue`:`active issues`,O7(a.active))),s.append(I7(`spiking`,O7(a.spiking),a.spiking>0?`crit`:null)),s.append(I7(`needs you`,O7(a.needsHuman),a.needsHuman>0?`warn`:null));let c=Que(e);if(c){let t=V(`span`,`radar-project-alert`,c);t.dataset.tone=e.error?`crit`:`warn`,s.append(t)}if(r.append(s),i.length===0)return r;r.append($ue());let l=E7(`radar-issues`);for(let e of i)l.append(Zue(e,n.projectId,BA(n)));return r.append(l),r}function tde(e,t){let n=e.project,r=V(`div`,`radar-quiet-row`),i=V(`span`,`radar-quiet-dot`);return i.setAttribute(`aria-hidden`,`true`),r.append(i),L7(r,n,{showHost:t,nameTag:`span`,nameClass:`radar-quiet-name`,hostClass:`radar-quiet-host`}),r.append(V(`span`,`radar-quiet-count`,`0 issues`)),r}var R7=(e,t)=>Cf(`radar`,e,t);function nde(){let e=V(`div`,`radar-issue`);return e.dataset.skeleton=``,D7(e,e=>V(`span`,e.cellClass)),e}function rde(){let e=E7(`radar-issues`);e.setAttribute(`aria-busy`,`true`),e.setAttribute(`aria-label`,`Loading issues`);for(let t=0;t<5;t+=1)e.append(nde());return e}function ide(e,t=`ready`){let n=R7(`Errors`);if(t===`pending`)return n.append(rde()),n;if(t===`placeholder`||e.length===0){let e=V(`p`,`radar-unconfigured`,gre(m7)),t=pW(`lanes-posthog`,`posthog-enabled`,`PostHog settings`);return e.append(document.createTextNode(` `),t),n.append(e),n}let r=V(`div`,`radar-global-tick`),i=Number(m7?.intervalMinutes);w7.track(r,m7?.ts,e=>{let t=`polled ${JP(e)}`;return!Number.isFinite(i)||i<=0?t:`${t}, every ${i}m`}),n.append(r);let a=i>0?i*6e4:0,{loud:o,quiet:s}=Mre(e,Date.now(),{intervalMs:a}),c=Are(e);for(let e of o)n.append(ede(e,c));if(s.length===0)return n;let l=V(`div`,`radar-quiet`);for(let e of s)l.append(tde(e,c));return n.append(l),n}function ade(e){let{addButton:t,request:n,wrap:r}=P7();return e.issueId&&t(`Open report`,`Open the investigation report for this issue`,()=>{N7({issueId:e.issueId,title:e.title})}),t(`Archive`,`Remove this investigation from the inbox`,()=>{n(`archive:${e.id}`,`posthog-archive-investigation`,{id:e.id},`Archiving`,()=>`Archived`,()=>x7.add(e.id))}),r}function ode(e){let t=V(`div`,`radar-investigation`),n=V(`span`,`radar-verdict`,IA(e.verdict));n.dataset.verdict=e.verdict;let r=vf(`radar-issue-title`,e.title,e.url),i=V(`span`,`radar-issue-copy`);if(i.append(r),e.summaryLine){let t=V(`span`,`radar-issue-summary`);t.textContent=e.summaryLine,i.append(t)}if(e.prUrl){let t=V(`a`,`radar-investigation-pr`,`fix PR`);t.href=e.prUrl,t.target=`_blank`,t.rel=`noopener`,t.title=e.prUrl,i.append(t)}if(t.append(n),e.mode===`fix`){let e=V(`span`,`radar-verdict`,`fix`);e.dataset.mode=`fix`,t.append(e)}if(t.append(i),e.projectLabel){let n=V(`span`,`radar-investigation-project`);n.textContent=e.projectLabel,t.append(n)}if(e.at>0){let n=V(`span`,`radar-investigation-time`,JP(e.at));n.title=new Date(e.at).toLocaleString(),t.append(n)}return t.append(ade(e)),t}function sde(e){let t=R7(`Investigations`,`completed, not yet archived`),n=V(`div`,`radar-investigations`);for(let t of e)n.append(ode(t));return t.append(n),t}function cde(e){_7&&_7(e)}function z7(){if(!h7)return;h7.textContent=``,C7.clear(),w7.reset();let e=Tf(m7),t=Nre(m7,x7),n=vre(m7,e.length);h7.append(ide(e,n)),t.length>0&&h7.append(sde(t))}function B7(){b7.request()}function V7(){g7&&g7(y7.refresh())}function lde(){y7.acknowledge(),V7()}function ude(e){g7=e,V7()}function dde(e){_7=e}function fde(e){if(h7)return h7;let t=V(`div`,`radar-content`);return e.appendChild(t),h7=t,w7.ensure(),z7(),t}function pde(e){m7=e,Pre(m7,x7),B7(),V7(),M7()}function mde(e){let t=PA(m7,e.projectId,e.issueId)?.inFlight===!0;if(!dre(m7,e))return;M7();let n=PA(m7,e.projectId,e.issueId);t&&Jue(e.projectId,e.issueId,n)||B7()}function hde(e){S7?.dialog.isOpen()&&fre(S7,e)&&S7.dialog.update(FA(e))}function gde(e){if(!pre(m7,e)){hde(e);return}M7(),B7(),V7()}function H7(e){return{skipPerms:e.skipPerms??e.dangerouslySkipPermissions??!1,saneYolo:e.saneYolo===!0,worktree:e.worktree??e.isWorktree??!1,workspace:e.workspace??e.isWorkspace??!1,path:e.path,stateSince:e.stateSince,taskTitle:typeof e.taskTitle==`string`?e.taskTitle:null,taskTitleIsCustom:e.taskTitleIsCustom===!0}}function _de(e,t){return typeof t!=`string`||t===``?{knownBuild:e,reload:!1}:e==null?{knownBuild:t,reload:!1}:e===t?{knownBuild:e,reload:!1}:{knownBuild:t,reload:!0}}function vde(e){if(typeof e!=`object`||!e||!(`telemetry`in e))return!1;let{telemetry:t}=e;return typeof t!=`object`||!t||!(`enabled`in t)?!1:t.enabled===!0}function yde(e){return typeof e!=`object`||!e||!(`telemetryForcedOff`in e)?!1:e.telemetryForcedOff===!0}function bde(e,t){return t||yde(e)?!1:vde(e)}var xde=2500;function Sde({hasSnapshot:e,connectingTerminalCount:t,msSinceConnected:n}){return n<2500&&(!e||t>0)?`wait`:`reveal`}var U7={teamReview:e=>e?.teamReview?.enabled===!0,posthog:e=>e?.posthog?.enabled===!0,visions:e=>e?.visions?.enabled===!0,usage:e=>e?.usage?.enabled!==!1,benchmarks:e=>e?.benchmarks?.enabled===!0,factory:e=>e?.factory?.enabled===!0,calmLayout:e=>e?.calmLayout===!0};function W7(e,t){let n=document.createElement(`div`);n.className=`pr-scope-tabs`,n.setAttribute(`role`,`tablist`),n.setAttribute(`aria-label`,`Reviews scope`);let r=[`team`,`mine`];for(let i of r){let a=document.createElement(`button`);a.className=`pr-scope-tab`,a.type=`button`,a.setAttribute(`role`,`tab`),a.setAttribute(`aria-selected`,String(i===e)),a.tabIndex=i===e?0:-1,a.textContent=i===`team`?`Team`:`Mine`,a.addEventListener(`click`,()=>t(i,!1)),a.addEventListener(`keydown`,e=>{if(e.key===`ArrowLeft`){e.preventDefault(),t(r[(r.indexOf(i)+r.length-1)%r.length],!0);return}e.key===`ArrowRight`&&(e.preventDefault(),t(r[(r.indexOf(i)+1)%r.length],!0))}),n.append(a)}return n}function G7(){lk()===`team`&&Fle()}function Cde(e){let t=(e,t)=>{if(o(e),G7(),!t)return;let s=(e===`team`?n:r).querySelector(`[aria-selected="true"]`);if(s&&s.getClientRects().length>0){s.focus();return}(e===`team`?i:a).querySelector(`.pr-queue-toggle`)?.focus()},n=W7(`team`,t),r=W7(`mine`,t),i=document.createElement(`div`);i.className=`pr-mode-root`;let a=document.createElement(`div`);a.className=`pr-mode-root`,e.append(i,a),Lle(i,n),oce(a,r);function o(e){a4(),i.hidden=e!==`team`,a.hidden=e!==`mine`,uk(e)}o(lk())}function wde(e,t){return t.isPhoneShellActive?t.phoneScreen===e:t.activeView===e}function Tde(e,t){return e.flatMap(e=>!e.gate||!(`fromSettings`in e.gate)?[]:[{view:e,isAvailable:e.gate.fromSettings(t)}])}function Ede(e){return{isActive:e===!0||typeof e==`string`,level:typeof e==`string`?e:null}}function K7(e){return e.map((e,t)=>({view:e,order:e.tabOrder??t})).sort((e,t)=>e.order-t.order).map(({view:e})=>e)}function q7(e,t){e?.refreshOn?.includes(t)&&e.refresh?.(t)}function Dde(e,t,n){for(let r of e)wde(r.view,t)&&q7(r,n)}function Ode(e){let t=[{view:`calm`,label:`Calm`,panelClass:`calm-view`,tabOrder:1,gate:{fromSettings:U7.calmLayout},hasOwnPhoneScreen:!0,hasPanelChrome:!1,mount:t=>gP(t,{openTerminal:e.openTerminal,openPlan:e.openPlan,openCalm:e.openCalm}),activate:_P,deactivate:vP},{view:`focus`,label:`Focus`,panelClass:`focus-view`,tabOrder:0,hasOwnPhoneScreen:!0,hasPanelChrome:!1,hasReviewSidebar:!0,mount:()=>PU({rail:document.getElementById(`focus-rail`),center:document.getElementById(`focus-center`),resizer:document.getElementById(`focus-rail-resizer`)}),activate:uW,deactivate:fW},{view:`prs`,label:`Reviews`,glyph:`⇅`,panelClass:`pr-view`,gate:{fromSettings:U7.teamReview},mount:Cde,attention:{subscribe:Ile,acknowledge:G7}},{view:`issues`,label:`Issues`,glyph:`#`,panelClass:`issues-view`,mount:Fue,refreshOn:[`shown`],refresh:Iue,onConnectionChange:Lue},{view:`usage`,label:`Usage`,glyph:`◔`,panelClass:`usage-view`,gate:{fromSettings:U7.usage},mount:EQ,attention:{subscribe:CQ,acknowledge:bQ},refreshOn:[`shown`,`connected`,`usage-sessions`],refresh:e=>{e===`shown`&&DQ(),TQ()}},{view:`radar`,label:`Radar`,glyph:`◎`,panelClass:`radar-view`,gate:{fromSettings:U7.posthog},mount:fde,attention:{subscribe:ude,acknowledge:lde}},{view:`visions`,label:`Visions`,glyph:`◇`,panelClass:`visions-view`,gate:{fromSettings:U7.visions},mount:fK,attention:{subscribe:dK,acknowledge:()=>{mK(),pK()}}},{view:`hooks`,label:`Hooks`,glyph:`◈`,panelClass:`hooks-view`,mount:_J,refreshOn:[`shown`,`connected`,`hooks-updated`],refresh:e=>{e===`shown`&&vJ(),gJ()}},{view:`trace`,label:`Trace`,panelClass:`trace-view`,gate:{subscribe:OV},mount:mV,refreshOn:[`shown`],refresh:yV,onAvailabilityChange:e=>dde(e?_V:null),onConnectionChange:CV},{view:`benchmarks`,label:`Bench`,panelClass:`bench-view`,gate:{fromSettings:U7.benchmarks},mount:vue,onConnectionChange:yue},{view:`factory`,label:`Factory`,panelClass:`factory-floor`,gate:{fromSettings:U7.factory},mount:t=>iue(t,{openTerminal:e.openTerminal}),onConnectionChange:oue},{view:`settings`,label:`Settings`,glyph:`@`,panelClass:`settings-view`,hasPanelChrome:!1,mount:t=>r0(t,{onRestart:e.onRestart,onConfirmUpdateAndRestart:e.onConfirmUpdateAndRestart})}],n=H(document,`#app-main`,`main`),r=t.map(t=>{let r=V(`button`,`header-tab`,t.label);r.id=`tab-${t.view}`,r.type=`button`;let i=`view-${t.view}`;r.setAttribute(`role`,`tab`),r.setAttribute(`aria-controls`,i);let a=t.view===`focus`;r.setAttribute(`aria-selected`,String(a)),r.tabIndex=a?0:-1,t.glyph&&(r.dataset.phoneGlyph=t.glyph);let o=document.getElementById(i)??V(`section`);if(o.classList.add(t.panelClass),o.id=i,o.setAttribute(`role`,`tabpanel`),o.setAttribute(`aria-labelledby`,r.id),o.hidden=!0,o.parentElement||n.append(o),r.hidden=t.gate!==void 0,o.classList.toggle(`view-panel`,t.hasPanelChrome!==!1),t.attention){let n=V(`span`,`tab-activity`);n.id=`tab-${t.view}-activity`,n.setAttribute(`aria-hidden`,`true`),r.append(n),t.attention.subscribe(r=>{let{isActive:i,level:a}=Ede(r);n.classList.toggle(`active`,i),a===null&&n.removeAttribute(`data-attention`),a!==null&&n.setAttribute(`data-attention`,a),e.setPhoneAttention(t.view,r)})}return{...t,tab:r,el:o}});return H(document,`#header-tabs`,`div`).replaceChildren(...K7(r).map(e=>e.tab)),r}Rx(qO()),zx(UO()),Bx(GO()),XJ(YO()),Uf(),TS(document);var J7=H(document,`#connection-status`,`span`),Y7=H(J7,`.connection-label`,`span`),X7=H(document,`#loading-screen`,`div`),Z7=H(document,`#loading-status`,`div`),Q7=H(document,`#shutdown-screen`,`div`),$7=H(document,`#shutdown-status`,`div`),e9=!1,t9=null,n9=!1;function kde(){let e=Uk(),t=X7.querySelector(`.loading-spinner`);e&&t&&t.replaceWith(Hk(e,`loading-animal`))}kde();function r9(){e9||t9===null||Sde({hasSnapshot:n9,connectingTerminalCount:cA(),msSinceConnected:performance.now()-t9})===`reveal`&&i9()}sA(r9);function i9(){if(e9)return;e9=!0,X7.classList.add(`fade-out`);let e=()=>X7.remove();X7.addEventListener(`transitionend`,e,{once:!0}),setTimeout(e,1e3)}function a9(e,t){J7.dataset.state=`shutdown`,Y7.textContent=e,J7.title=e,C9.disabled=!0,$7.textContent=t,Q7.classList.add(`active`)}var Ade=new Set([`disconnected`,`connecting`]);function o9(e,t,n){J7.dataset.state=e,J7.toggleAttribute(`data-reconnected`,n),Y7.textContent=t,J7.title=t}function jde(e,t){o9(e,t,e===`connected`&&Ade.has(J7.dataset.state??``))}function Mde(e,t){J7.dataset.state!==`shutdown`&&o9(e===`verified`?`connected`:e,t,!1)}nf((e,t)=>{if(e===`connecting`||e===`verified`){Mde(e,t);return}jde(e,t),MH(e===`connected`);for(let t of k9)t.onConnectionChange?.(e===`connected`);if(e===`connected`){if(Q7.classList.contains(`active`)){location.reload();return}document.body.classList.add(`app-ready`),!e9&&t9===null&&(t9=performance.now(),Z7.textContent=`Connecting to sessions...`,setTimeout(i9,xde)),r9(),J9(),g9(`connected`),of(`get-settings`,{}).then(e=>{e.settings&&(B9(e.settings),Rf()===`settings`&&E9(location.hash))}).catch(()=>{});return}if(e===`disconnected`&&Q7.classList.contains(`active`)){$7.textContent=`Waiting for server...`;return}e9||(Z7.textContent=`Reconnecting to server...`)});function s9(){p7(),K2(),tP(),u9()}function c9(){GU(),s9()}var l9=!1;function u9(){mP(l9&&jU()&&!Wf(),NU())}var d9=null;function Nde(e){let t=_de(d9,e);d9=t.knownBuild,t.reload&&location.reload()}function Pde(e){ZG(new Map(e.filter(e=>!e.ephemeral).map(e=>[e.id,e.name]))),v0(e.filter(e=>!e.ephemeral).map(e=>({id:e.id,name:e.name,agent:e.agent,permissionMode:e.dangerouslySkipPermissions?`Skip permissions`:`Default`})));for(let t of e){t.ephemeral||mI(t.path);let e=_H(t.id);e&&$H(t.id,t.state,t.stateSince),e&&PV(t.id,!!t.saneYolo),e||CH(t.id,t.name,t.state,H7(t)),gH(t.id,t.taskTitle,t.taskTitleIsCustom),PH(t.id,t.agent),KH(t.id,t.mergeStatus,t.mergeReason),NH(t.id,t.effectiveBase),RH(t.id,t.activeAgents,t.awaitingBackgroundTasks),LH(t.id,t.hasEndedTurn),HH(t.id,t.pendingWakeup),BH(t.id,t.pendingPromptKind,t.pendingPromptDetail,t.isCompacting),DH(t.id,t.hasPlan),h9(t.id)}SH(),cI(U),GU(),dW(),s9(),f9(),D9(location.hash),n9=!0,r9()}function f9(){vV([...U].map(([e,t])=>({id:e,name:Kf(t)||e})))}function p9(e,t){DH(e,t?.hasPlan===!0),h9(e)}function Fde(e){if(!_H(e.id)){CH(e.id,e.session,e.to,H7({skipPerms:e.skipPerms,saneYolo:e.saneYolo,stateSince:e.timestamp})),cI(U),p7();return}if(e.to===F.DORMANT&&e.from!==F.DORMANT){let t=U.get(String(e.id)),n=document.querySelector(`.session-card[data-id="${CSS.escape(String(e.id))}"]`),r=n instanceof HTMLElement?n:null,i=r?r.dataset.skipPerms!==void 0:!1,a=e.saneYolo??(r?r.dataset.saneYolo!==void 0:!1),o=r?r.dataset.path:void 0;YH(e.id),CH(e.id,e.session,F.DORMANT,H7({skipPerms:i,saneYolo:a,worktree:r?.dataset.worktree!==void 0,workspace:r?.dataset.workspace!==void 0,path:o,stateSince:e.timestamp,taskTitle:t?.taskTitle,taskTitleIsCustom:t?.taskTitleIsCustom})),PH(e.id,t?.agent),p9(e.id,t),c9(),_z(e.id),cI(U);return}$H(e.id,e.to,e.timestamp,e.event),e.hasEndedTurn!==void 0&&LH(e.id,e.hasEndedTurn),e.saneYolo!==void 0&&PV(e.id,e.saneYolo),cI(U),_z(e.id),c9(),$V(e.id),e.to===F.INITIALIZING&&(e.from===F.DONE||e.from===F.FAILED)&&_A(e.id)}var m9=new Map;function Ide(e){let t=new Set;for(let n of e){if(!n?.id)continue;t.add(n.id);let e={tokens:n.tokens,costUSD:n.costUSD,officialCostUSD:n.officialCostUSD};m9.set(n.id,e),zH(n.id,e)}for(let e of[...m9.keys()])t.has(e)||(m9.delete(e),zH(e,null))}function h9(e){let t=m9.get(e);t&&zH(e,t)}wQ(B),hJ(B),hV(B),Pue(B),_ue(B),sue(B);function g9(e){Dde(k9,{isPhoneShellActive:W2(),activeView:Rf(),phoneScreen:Lf.snapshot().phoneScreen},e)}var Lde={snapshot:e=>{Nde(e.serverBuild),Pde(e.sessions)},"hooks-report":e=>yJ(e),"save-hook-result":e=>bJ(e),"delete-hook-result":e=>xJ(e),"state-change":e=>Fde(e),"session-added":e=>{e.ephemeral||mI(e.path),_H(e.id)||(CH(e.id,e.session,e.state,H7(e)),PH(e.id,e.agent),h9(e.id)),cI(U),c9(),f9()},"session-removed":e=>{YH(e.id),yz(e.id),cI(U),c9(),f9()},"session-title":e=>{gH(e.id,e.taskTitle,e.isCustom),c9()},"session-renamed":e=>{JH(e.id,e.newName),s9(),f9()},"session-modified":e=>{e.ephemeral||mI(e.path);let t=U.get(String(e.id));YH(e.id),yz(e.id),CH(e.id,e.session,e.state,H7(e)),PH(e.id,e.agent),p9(e.id,t),cI(U),c9(),f9()},"session-git":e=>FH(e.id,!!e.worktree),"session-agents":e=>{RH(e.id,e.activeAgents,e.awaitingBackgroundTasks),c9(),$V(e.id)},"session-wakeup":e=>HH(e.id,e.pendingWakeup),"session-prompt":e=>{BH(e.id,e.pendingPromptKind,e.pendingPromptDetail??null,e.isCompacting===!0),s9()},"session-merge-status":e=>{GH(e.id,e.mergeStatus,e.reason),aW(e.id,e.mergeStatus),s9()},"session-worktree-blocked":e=>{WS(`${e.session}: ${e.notice||`integration branch not found`}`,{persist:!0})},"session-worktree-warning":e=>{WS(`${e.session}: ${e.notice||`base branch warning`}`)},"session-worktree-ready":e=>{NH(e.id,e.base)},"session-diff":e=>{GN(e),qH(e.id,{committed:e.committed,uncommitted:e.uncommitted,hasCommits:e.hasCommits})},"session-diff-error":e=>{LN(e),uz(e.id,e.message)},"change-map":e=>dz(e.id,e.map),"branch-sync-status":e=>mz(e.id,e),"session-changed":e=>gz(e.id),"post-turn-result":e=>UH(e.id,e),"debug-state-response":e=>QV(e),"session-trace-response":e=>{PN(e),bV(e)},"session-trace-changed":e=>xV(e),"session-plan-changed":e=>{OH(e),s9()},"session-plan-draft":e=>{kH(e)},"session-plan-response":e=>{AH(e)},"session-docs-changed":e=>eI(e),"session-docs-snapshot":e=>tI(e),notify:e=>{jJ(e),$V(e.session)},"update-status":e=>{Vde(e),h0(e)},"update-progress":e=>g0(e.journal),error:e=>{IN(e),_0(),SV(e),jH(e),WS(e.message,{persist:!0})},"session-error":e=>{jH(e),WS(`${e.session}: ${e.message}`,{persist:!0})},"settings-updated":e=>{e.settings&&B9(e.settings,{isLiveSettingsChange:!0})},"health-snapshot":e=>{e.stats&&XI(e.stats)},"posthog-status":e=>pde(e),"posthog-investigation-activity":e=>mde(e),"posthog-investigation-finished":e=>gde(e),"team-review-status":e=>Rle(e),"my-prs-status":e=>sce(e),"factory-state":e=>aue(e),"factory-queue-intent-result":e=>cue(e),"factory-control-result":e=>lue(e),"benchmark-status":e=>bue(e),"benchmark-action-result":e=>xue(e),"my-pr-merge-result":e=>cce(e),"team-review-action-result":e=>Ble(e),"issues-status":e=>Rue(e),"issue-detail-result":e=>zue(e),"open-issue-session-result":e=>Bue(e),"usage-sessions":e=>{Ide(e.sessions),OQ(e)},"usage-report":e=>{AQ(e),p0()},"plan-limits":e=>kQ(e),"usage-budget-alert":e=>jJ({session:`budget-${e.scope}-${e.periodKey}`,category:`threshold-${e.threshold}`,message:e.text,ignoreFocus:!0}),"visions-findings":e=>gK(e),"visions-comments":e=>_K(e),"visions-hand":e=>vK(e),"visions-intent":e=>yK(e),"visions-fix":e=>hK(e),"visions-snapshot":e=>SK(e),"ingest-activity":e=>bK(e),"ingest-snapshot":e=>xK(e),"client-trust":e=>Yde(e.trust),"shutting-down":()=>a9(`Shutting down...`,`Shutting down sessions...`),restarting:()=>a9(`Restarting...`,`Restarting server...`)};function Rde(e){let t=Lde[e.type];t&&t(e)}rf(e=>{Rde(e),g9(e.type)});var _9=!1,zde=pW(rre,ire,`Update`).href;function Bde(e){let{latestSha:t,latest:n}=e;return typeof n==`string`&&n?n:typeof t==`string`&&t?t:null}function Vde(e){let t=H(document,`#update-banner`,`div`);if(!e.updateAvailable){t.hidden=!0;return}if(_9)return;let n=Bde(e);if(n&&hk()===n)return;let r=String(e.command??``);H(document,`#update-banner-text`,`span`).textContent=Fre(e),H(document,`#update-banner-cmd`,`code`).textContent=r;let i=JQ(e),a=H(document,`#update-banner-update`,`a`);a.href=zde,a.hidden=i!==`link`;let o=H(document,`#update-banner-cmd`,`code`);o.hidden=i!==`command`;let s=H(document,`#update-banner-copy`,`button`);s.hidden=i!==`command`;let c=H(document,`#update-banner-copy-status`,`span`);c.hidden=i!==`command`,c.textContent=``;let l=H(document,`#update-banner-link`,`a`);l.hidden=!e.releaseUrl,l.href=typeof e.releaseUrl==`string`?e.releaseUrl:``,t.hidden=!1,s.onclick=()=>{let e=Df(r);if(!e){c.textContent=`Copy failed`;return}e.then(()=>{c.textContent=`Copied`}).catch(()=>{c.textContent=`Copy failed`})},H(document,`#update-banner-dismiss`,`button`).onclick=()=>{_9=!0,gk(n),t.hidden=!0}}var v9=H(document,`#telemetry-banner`,`div`);function y9(){vk(!0),v9.hidden=!0}function Hde(e){v9.hidden=!bde(e,_k())}var b9=H(document,`#telemetry-banner-settings`,`a`);b9.href=pW(`privacy`,`telemetry-enabled`,`Open settings`).href,b9.addEventListener(`click`,y9),H(document,`#telemetry-banner-dismiss`,`button`).addEventListener(`click`,y9),H(document,`#btn-add-session-header`,`button`).addEventListener(`click`,$P);var x9=H(document,`#btn-mute`,`button`);LQ(x9);var S9=H(document,`#power-menu`,`div`),C9=H(document,`#btn-power`,`button`);function w9(){C9.setAttribute(`aria-expanded`,S9.classList.contains(`open`)?`true`:`false`)}C9.addEventListener(`click`,e=>{e.stopPropagation(),S9.classList.toggle(`open`),w9()}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(S9.contains(e.target)||(S9.classList.remove(`open`),w9()))}),Sf(document.querySelector(`.header`));function Ude(e){e&&c0(e),!q2(`settings`)&&L9(`settings`,{section:e})}function T9(){location.hash.startsWith(`#settings/`)&&history.replaceState(history.state,``,`${location.pathname}${location.search}`)}function Wde(e){return e?(c0(e.sectionId,e.settingId),q2(`settings`)||L9(`settings`,{section:e.sectionId,setting:e.settingId,persist:!1}),!0):!1}function E9(e){return Wde(l0(e))}function D9(e){let t=VL(e);return t?!_H(t)||(history.replaceState(history.state,``,`${location.pathname}${location.search}`),W2()?(U2(t)||WS(`No plan is stored for this session yet`),!0):(L9(`focus`,{persist:!1}),sW(t)||WS(`No plan is stored for this session yet`),!0)):!1}function O9(e){return D9(e)?!0:E9(e)}function Gde(){return O9(location.hash)}document.addEventListener(`click`,e=>{if(!W2()||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`a[href^="#"]`):null;t instanceof HTMLAnchorElement&&O9(t.hash)&&e.preventDefault()}),sse(H(document,`#celebration-tray`,`div`),H(document,`#btn-celebrations`,`button`),H(document,`#celebration-tray-count`,`span`)),H(document,`#btn-help`,`button`).addEventListener(`click`,()=>{Ude(`browser-shortcuts`)});var k9=Ode({onRestart:q9,onConfirmUpdateAndRestart:Jde,openTerminal:e=>{L9(`focus`),oW(e)},openPlan:e=>{L9(`focus`),sW(e)},openCalm:()=>L9(`calm`),setPhoneAttention:Y2});iz({panel:document.getElementById(`review-sidebar`)});for(let e of k9)e.mount(e.el);var A9=MU();A9&&pP(A9),Lf.subscribe((e,t)=>{t.includes(`focusedSessionId`)&&u9()});function j9(e){return k9.find(t=>t.view===e)}function M9(e){return k9.some(t=>t.view===e&&!t.tab.hidden)}var N9=!0,P9=null;function F9(e){j9(e)?.attention?.acknowledge()}function I9(e){q7(j9(e),`shown`)}function L9(e,{section:t,setting:n,persist:r=!0}={}){if(!M9(e))return;let i=Rf();Lf.dispatch(`setActiveView`,e),N9=r,r&&(P9=null),document.body.dataset.activeView=e,document.body.dataset.reviewSidebarHidden=String(j9(e)?.hasReviewSidebar!==!0),r&&QO(e);for(let t of k9){let n=t.view===e;t.el&&(t.el.hidden=!n),t.tab.setAttribute(`aria-selected`,String(n)),t.tab.tabIndex=n?0:-1}i!==e&&j9(i)?.deactivate?.(),j9(e)?.activate?.(),I9(e),i===`settings`&&e!==`settings`&&T9(),e===`settings`&&t&&c0(t,n??null),F9(e),u9()}function R9(e,t){let{view:n}=e;e.tab.hidden=!t,J2(n,t),e.onAvailabilityChange?.(t),!W2()&&(!t&&Rf()===n&&L9(`focus`),t&&P9===n&&L9(n))}var z9=null;function Kde(e,{isLiveSettingsChange:t=!1}={}){let n=Tde(k9,e),r=n.find(e=>e.view.view===`calm`)?.isAvailable===!0,i=t&&z9===!1&&r;z9=r,l9=r,H2(r),iW(!r),u9();for(let{view:e,isAvailable:t}of n)R9(e,t);!i||Rf()!==`focus`||Wf()||VL(location.hash)||L9(`calm`)}function B9(e,{isLiveSettingsChange:t=!1}={}){bH(e),u0(e),rK(e),Kde(e,{isLiveSettingsChange:t}),Hde(e)}for(let e of k9)e.gate&&(R9(e,!1),`subscribe`in e.gate&&e.gate.subscribe(t=>R9(e,t)));gV(()=>{M9(`trace`)&&(q2(`trace`)||L9(`trace`))});function V9(e,t){let n=k9.filter(e=>!e.tab.hidden),r=n[(n.findIndex(t=>t.view===e)+t+n.length)%n.length];return L9(r.view),r.tab}function qde(e){k9.some(e=>e.tab===document.activeElement)&&e.focus()}for(let e=0;e<k9.length;e++){let{view:t,tab:n}=k9[e];n.addEventListener(`click`,()=>L9(t)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||(e.preventDefault(),V9(Rf(),e.key===`ArrowRight`?1:-1).focus()))})}var H9=ZO(),U9=l0(location.hash),W9=VL(location.hash);if(U9&&L9(`settings`,{section:U9.sectionId,setting:U9.settingId,persist:!1}),W9&&L9(`focus`,{persist:!1}),!U9&&!W9){let e=M9(H9);e||(P9=H9),L9(e?H9:`focus`,{persist:e})}R2({panels:MJ(k9),onScreenShown:e=>{I9(e),e!==`settings`&&T9(),e===`settings`&&!location.hash.startsWith(`#settings/`)&&c0(),F9(e)},headerControls:[H(document,`.header-title`,`h1`),H(document,`#status-indicator`,`div`),H(document,`#celebration-tray`,`div`),H(document,`#btn-add-session-header`,`button`),H(document,`#btn-help`,`button`),x9,S9]});function G9(e){if(e===`phone`){let e=NU();for(let e of K7(k9))e.deactivate?.();dP(),u9(),z2({sessionId:e??void 0});return}let t=G2();B2();let n=Rf();L9(M9(n)?n:`focus`,{persist:N9}),t&&oW(t)}Wf()&&G9(`phone`),Gf(G9),window.addEventListener(`hashchange`,Gde);function K9({type:e,title:t,confirmLabel:n,danger:r,idleMessage:i,actionAfterKillingSessions:a}){S9.classList.remove(`open`),w9();let o=vH();tp({title:t,message:o>0?`Kill ${o} session${o>1?`s`:``} and ${a}?`:i,confirmLabel:n,danger:r,onConfirm:()=>B({type:e})})}function q9(){K9({type:`restart-server`,title:`Restart Server`,confirmLabel:`Restart`,danger:!1,idleMessage:`Restart the server?`,actionAfterKillingSessions:`restart the server`})}function Jde(e){let t=yH(),n=t.length;if(n===0){e(t);return}tp({title:`Update and restart`,message:`Glimmervoid restarts once the update is staged, which kills ${n} running session${n>1?`s`:``}. Continue?`,confirmLabel:`Update and restart`,danger:!1,onConfirm:()=>e(t)})}H(document,`#btn-restart`,`button`).addEventListener(`click`,q9);function Yde(e){let t=CP(`shutdown`,e);H(document,`#btn-shutdown`,`button`).hidden=!t,H(document,`#menu-divider-shutdown`,`div`).hidden=!t}H(document,`#btn-shutdown`,`button`).addEventListener(`click`,()=>{K9({type:`shutdown`,title:`Shut Down Server`,confirmLabel:`Shut Down`,danger:!0,idleMessage:`Shut down the server?`,actionAfterKillingSessions:`shut down the server`})});function Xde(){let e=document.activeElement;return e instanceof HTMLElement?e.isContentEditable?!0:(e.tagName===`INPUT`||e.tagName===`TEXTAREA`)&&!e.classList.contains(`xterm-helper-textarea`):!1}function Zde({action:e,step:t}){switch(e){case`merge`:return bz(),!0;case`resolve-or-resync`:return xz()||Sz(),!0;case`new-session`:return document.getElementById(`btn-add-session-header`)?.click(),!0;case`next-attention`:return Rf()===`calm`?oP():jU()?(YU(),!0):!1;case`rail-step`:return jU()?(lW(t),!0):!1;case`view-step`:return!Wf()&&(qde(V9(Rf(),t)),!0);case`session-nth`:return jU()?(cW(t),!0):!1;case`calm-home`:return!Wf()&&(L9(`calm`),!0);case`calm-terminal`:return aP()}}Xb(()=>({isCalmAvailable:l9,isCalmViewActive:Rf()===`calm`})),document.addEventListener(`keydown`,e=>{if(e.repeat||Xde())return;let t=Vb(e,Jb,Zb());t&&Zde(t)&&e.preventDefault()});var Qde=EP({mode:`trailing`,delayMs:150,run:()=>{B({type:`focus-change`,focused:document.hasFocus()})}});function J9(){Qde.schedule()}function Y9(){J9(),CA(Jf(DP()))}window.addEventListener(`focus`,Y9),window.addEventListener(`blur`,Y9),document.addEventListener(`visibilitychange`,Y9);var X9=!1,Z9=null;function $de(){if(document.visibilityState!==`visible`)return 0;let e=Z9;return Z9=null,e===null?0:Date.now()-e}async function Q9(){let e=$de();if(!X9){X9=!0,hA();try{if(await uf(e)===`ok`)return;for(let e of U.keys())_A(e)}finally{gA(),X9=!1}}}document.addEventListener(`visibilitychange`,()=>{if(document.visibilityState!==`visible`){Z9??=Date.now();return}yD(),Q9()}),window.addEventListener(`online`,Q9);var $9=NP(B);window.addEventListener(`error`,e=>$9(e.error)),window.addEventListener(`unhandledrejection`,e=>$9(e.reason)),window.addEventListener(`pageshow`,e=>{e.persisted&&(yD(),Q9())}),YI(H(document,`#health-footer-mount`,`div`)),AJ(),Db(xH),lf();
|