claude-remote-cli 3.3.1 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +0,0 @@
1
- var S_=Object.defineProperty;var Xh=e=>{throw TypeError(e)};var y_=(e,t,i)=>t in e?S_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Bi=(e,t,i)=>y_(e,typeof t!="symbol"?t+"":t,i),Ea=(e,t,i)=>t.has(e)||Xh("Cannot "+i);var _=(e,t,i)=>(Ea(e,t,"read from private field"),i?i.call(e):t.get(e)),ee=(e,t,i)=>t.has(e)?Xh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),G=(e,t,i,s)=>(Ea(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),ye=(e,t,i)=>(Ea(e,t,"access private method"),i);var Po=(e,t,i,s)=>({set _(r){G(e,t,r,i)},get _(){return _(e,t,s)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function i(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=i(r);fetch(r.href,n)}})();const Qa=!1;var ph=Array.isArray,w_=Array.prototype.indexOf,gn=Array.prototype.includes,ca=Array.from,C_=Object.defineProperty,Yr=Object.getOwnPropertyDescriptor,k_=Object.getOwnPropertyDescriptors,x_=Object.prototype,E_=Array.prototype,zu=Object.getPrototypeOf,Qh=Object.isExtensible;const P_=()=>{};function R_(e){for(var t=0;t<e.length;t++)e[t]()}function Uu(){var e,t,i=new Promise((s,r)=>{e=s,t=r});return{promise:i,resolve:e,reject:t}}function D_(e,t){if(Array.isArray(e))return e;if(!(Symbol.iterator in e))return Array.from(e);const i=[];for(const s of e)if(i.push(s),i.length===t)break;return i}const It=2,go=4,mo=8,Ku=1<<24,ks=16,ji=32,Hr=64,Ja=128,Pi=512,Et=1024,Nt=2048,qi=4096,ui=8192,ms=16384,Ar=32768,Or=65536,Jh=1<<17,qu=1<<18,kn=1<<19,ju=1<<20,vs=1<<25,Ir=65536,$a=1<<21,gh=1<<22,Vs=1<<23,Rr=Symbol("$state"),T_=Symbol("legacy props"),M_=Symbol(""),lr=new class extends Error{constructor(){super(...arguments);Bi(this,"name","StaleReactionError");Bi(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var xu;const B_=!!((xu=globalThis.document)!=null&&xu.contentType)&&globalThis.document.contentType.includes("xml");function mh(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function L_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function A_(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function O_(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function I_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function N_(e){throw new Error("https://svelte.dev/e/effect_orphan")}function F_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function W_(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function H_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function z_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function U_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function K_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const q_=1,j_=2,Vu=4,V_=8,Y_=16,G_=1,X_=4,Q_=8,J_=16,$_=1,Z_=2,Dt=Symbol(),Yu="http://www.w3.org/1999/xhtml",ev="http://www.w3.org/2000/svg",tv="http://www.w3.org/1998/Math/MathML";function iv(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function sv(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Gu(e){return e===this.v}function rv(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Xu(e){return!rv(e,this.v)}let nv=!1,gt=null;function mn(e){gt=e}function Qu(e){return $u().get(e)}function ov(e,t){return $u().set(e,t),t}function ct(e,t=!1,i){gt={p:gt,i:!1,c:null,e:null,s:e,x:null,l:null}}function ut(e){var t=gt,i=t.e;if(i!==null){t.e=null;for(var s of i)Sd(s)}return e!==void 0&&(t.x=e),t.i=!0,gt=t.p,e??{}}function Ju(){return!0}function $u(e){return gt===null&&mh(),gt.c??(gt.c=new Map(av(gt)||void 0))}function av(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let hr=[];function Zu(){var e=hr;hr=[],R_(e)}function is(e){if(hr.length===0&&!qn){var t=hr;queueMicrotask(()=>{t===hr&&Zu()})}hr.push(e)}function lv(){for(;hr.length>0;)Zu()}function ed(e){var t=Ke;if(t===null)return We.f|=Vs,e;if((t.f&Ar)===0&&(t.f&go)===0)throw e;qs(e,t)}function qs(e,t){for(;t!==null;){if((t.f&Ja)!==0){if((t.f&Ar)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const hv=-7169;function ht(e,t){e.f=e.f&hv|t}function bh(e){(e.f&Pi)!==0||e.deps===null?ht(e,Et):ht(e,qi)}function td(e){if(e!==null)for(const t of e)(t.f&It)===0||(t.f&Ir)===0||(t.f^=Ir,td(t.deps))}function id(e,t,i){(e.f&Nt)!==0?t.add(e):(e.f&qi)!==0&&i.add(e),td(e.deps),ht(e,Et)}const Ro=new Set;let Me=null,Yo=null,Lt=null,$t=[],ua=null,Za=!1,qn=!1;var Qr,Jr,_r,$r,ao,lo,vr,cs,Zr,di,el,tl,il,sd;const Vh=class Vh{constructor(){ee(this,di);Bi(this,"current",new Map);Bi(this,"previous",new Map);ee(this,Qr,new Set);ee(this,Jr,new Set);ee(this,_r,0);ee(this,$r,0);ee(this,ao,null);ee(this,lo,new Set);ee(this,vr,new Set);ee(this,cs,new Map);Bi(this,"is_fork",!1);ee(this,Zr,!1)}skip_effect(t){_(this,cs).has(t)||_(this,cs).set(t,{d:[],m:[]})}unskip_effect(t){var i=_(this,cs).get(t);if(i){_(this,cs).delete(t);for(var s of i.d)ht(s,Nt),Ui(s);for(s of i.m)ht(s,qi),Ui(s)}}process(t){var r;$t=[],this.apply();var i=[],s=[];for(const n of t)ye(this,di,tl).call(this,n,i,s);if(ye(this,di,el).call(this)){ye(this,di,il).call(this,s),ye(this,di,il).call(this,i);for(const[n,o]of _(this,cs))ad(n,o)}else{for(const n of _(this,Qr))n();_(this,Qr).clear(),_(this,_r)===0&&ye(this,di,sd).call(this),Yo=this,Me=null,$h(s),$h(i),Yo=null,(r=_(this,ao))==null||r.resolve()}Lt=null}capture(t,i){i!==Dt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&Vs)===0&&(this.current.set(t,t.v),Lt==null||Lt.set(t,t.v))}activate(){Me=this,this.apply()}deactivate(){Me===this&&(Me=null,Lt=null)}flush(){if(this.activate(),$t.length>0){if(rd(),Me!==null&&Me!==this)return}else _(this,_r)===0&&this.process([]);this.deactivate()}discard(){for(const t of _(this,Jr))t(this);_(this,Jr).clear()}increment(t){G(this,_r,_(this,_r)+1),t&&G(this,$r,_(this,$r)+1)}decrement(t){G(this,_r,_(this,_r)-1),t&&G(this,$r,_(this,$r)-1),!_(this,Zr)&&(G(this,Zr,!0),is(()=>{G(this,Zr,!1),ye(this,di,el).call(this)?$t.length>0&&this.flush():this.revive()}))}revive(){for(const t of _(this,lo))_(this,vr).delete(t),ht(t,Nt),Ui(t);for(const t of _(this,vr))ht(t,qi),Ui(t);this.flush()}oncommit(t){_(this,Qr).add(t)}ondiscard(t){_(this,Jr).add(t)}settled(){return(_(this,ao)??G(this,ao,Uu())).promise}static ensure(){if(Me===null){const t=Me=new Vh;Ro.add(Me),qn||is(()=>{Me===t&&t.flush()})}return Me}apply(){}};Qr=new WeakMap,Jr=new WeakMap,_r=new WeakMap,$r=new WeakMap,ao=new WeakMap,lo=new WeakMap,vr=new WeakMap,cs=new WeakMap,Zr=new WeakMap,di=new WeakSet,el=function(){return this.is_fork||_(this,$r)>0},tl=function(t,i,s){t.f^=Et;for(var r=t.first;r!==null;){var n=r.f,o=(n&(ji|Hr))!==0,l=o&&(n&Et)!==0,c=l||(n&ui)!==0||_(this,cs).has(r);if(!c&&r.fn!==null){o?r.f^=Et:(n&go)!==0?i.push(r):So(r)&&((n&ks)!==0&&_(this,vr).add(r),Sn(r));var h=r.first;if(h!==null){r=h;continue}}for(;r!==null;){var d=r.next;if(d!==null){r=d;break}r=r.parent}}},il=function(t){for(var i=0;i<t.length;i+=1)id(t[i],_(this,lo),_(this,vr))},sd=function(){var r;if(Ro.size>1){this.previous.clear();var t=Lt,i=!0;for(const n of Ro){if(n===this){i=!1;continue}const o=[];for(const[c,h]of this.current){if(n.current.has(c))if(i&&h!==n.current.get(c))n.current.set(c,h);else continue;o.push(c)}if(o.length===0)continue;const l=[...n.current.keys()].filter(c=>!this.current.has(c));if(l.length>0){var s=$t;$t=[];const c=new Set,h=new Map;for(const d of o)nd(d,l,c,h);if($t.length>0){Me=n,n.apply();for(const d of $t)ye(r=n,di,tl).call(r,d,[],[]);n.deactivate()}$t=s}}Me=null,Lt=t}Ro.delete(this)};let Ys=Vh;function cv(e){var t=qn;qn=!0;try{for(var i;;){if(lv(),$t.length===0&&(Me==null||Me.flush(),$t.length===0))return ua=null,i;rd()}}finally{qn=t}}function rd(){Za=!0;var e=null;try{for(var t=0;$t.length>0;){var i=Ys.ensure();if(t++>1e3){var s,r;uv()}i.process($t),Gs.clear()}}finally{$t=[],Za=!1,ua=null}}function uv(){try{F_()}catch(e){qs(e,ua)}}let Oi=null;function $h(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var s=e[i++];if((s.f&(ms|ui))===0&&So(s)&&(Oi=new Set,Sn(s),s.deps===null&&s.first===null&&s.nodes===null&&s.teardown===null&&s.ac===null&&kd(s),(Oi==null?void 0:Oi.size)>0)){Gs.clear();for(const r of Oi){if((r.f&(ms|ui))!==0)continue;const n=[r];let o=r.parent;for(;o!==null;)Oi.has(o)&&(Oi.delete(o),n.push(o)),o=o.parent;for(let l=n.length-1;l>=0;l--){const c=n[l];(c.f&(ms|ui))===0&&Sn(c)}}Oi.clear()}}Oi=null}}function nd(e,t,i,s){if(!i.has(e)&&(i.add(e),e.reactions!==null))for(const r of e.reactions){const n=r.f;(n&It)!==0?nd(r,t,i,s):(n&(gh|ks))!==0&&(n&Nt)===0&&od(r,t,s)&&(ht(r,Nt),Ui(r))}}function od(e,t,i){const s=i.get(e);if(s!==void 0)return s;if(e.deps!==null)for(const r of e.deps){if(gn.call(t,r))return!0;if((r.f&It)!==0&&od(r,t,i))return i.set(r,!0),!0}return i.set(e,!1),!1}function Ui(e){var t=ua=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(go|mo|Ku))!==0&&(e.f&Ar)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var s=t.f;if(Za&&t===Ke&&(s&ks)!==0&&(s&qu)===0&&(s&Ar)!==0)return;if((s&(Hr|ji))!==0){if((s&Et)===0)return;t.f^=Et}}$t.push(t)}function ad(e,t){if(!((e.f&ji)!==0&&(e.f&Et)!==0)){(e.f&Nt)!==0?t.d.push(e):(e.f&qi)!==0&&t.m.push(e),ht(e,Et);for(var i=e.first;i!==null;)ad(i,t),i=i.next}}function dv(e){let t=0,i=Zs(0),s;return()=>{wh()&&(a(i),_a(()=>(t===0&&(s=tr(()=>e(()=>Xs(i)))),t+=1,()=>{is(()=>{t-=1,t===0&&(s==null||s(),s=void 0,Xs(i))})})))}}var fv=Or|kn;function _v(e,t,i,s){new vv(e,t,i,s)}var Si,_h,Xi,pr,Qt,Qi,li,Ii,us,gr,As,en,tn,sn,ds,oa,mt,pv,gv,mv,sl,Fo,Wo,rl;class vv{constructor(t,i,s,r){ee(this,mt);Bi(this,"parent");Bi(this,"is_pending",!1);Bi(this,"transform_error");ee(this,Si);ee(this,_h,null);ee(this,Xi);ee(this,pr);ee(this,Qt);ee(this,Qi,null);ee(this,li,null);ee(this,Ii,null);ee(this,us,null);ee(this,gr,0);ee(this,As,0);ee(this,en,!1);ee(this,tn,new Set);ee(this,sn,new Set);ee(this,ds,null);ee(this,oa,dv(()=>(G(this,ds,Zs(_(this,gr))),()=>{G(this,ds,null)})));var n;G(this,Si,t),G(this,Xi,i),G(this,pr,o=>{var l=Ke;l.b=this,l.f|=Ja,s(o)}),this.parent=Ke.b,this.transform_error=r??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),G(this,Qt,va(()=>{ye(this,mt,sl).call(this)},fv))}defer_effect(t){id(t,_(this,tn),_(this,sn))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!_(this,Xi).pending}update_pending_count(t){ye(this,mt,rl).call(this,t),G(this,gr,_(this,gr)+t),!(!_(this,ds)||_(this,en))&&(G(this,en,!0),is(()=>{G(this,en,!1),_(this,ds)&&bn(_(this,ds),_(this,gr))}))}get_effect_pending(){return _(this,oa).call(this),a(_(this,ds))}error(t){var i=_(this,Xi).onerror;let s=_(this,Xi).failed;if(!i&&!s)throw t;_(this,Qi)&&(ti(_(this,Qi)),G(this,Qi,null)),_(this,li)&&(ti(_(this,li)),G(this,li,null)),_(this,Ii)&&(ti(_(this,Ii)),G(this,Ii,null));var r=!1,n=!1;const o=()=>{if(r){sv();return}r=!0,n&&K_(),_(this,Ii)!==null&&Tr(_(this,Ii),()=>{G(this,Ii,null)}),ye(this,mt,Wo).call(this,()=>{Ys.ensure(),ye(this,mt,sl).call(this)})},l=c=>{try{n=!0,i==null||i(c,o),n=!1}catch(h){qs(h,_(this,Qt)&&_(this,Qt).parent)}s&&G(this,Ii,ye(this,mt,Wo).call(this,()=>{Ys.ensure();try{return Ci(()=>{var h=Ke;h.b=this,h.f|=Ja,s(_(this,Si),()=>c,()=>o)})}catch(h){return qs(h,_(this,Qt).parent),null}}))};is(()=>{var c;try{c=this.transform_error(t)}catch(h){qs(h,_(this,Qt)&&_(this,Qt).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(l,h=>qs(h,_(this,Qt)&&_(this,Qt).parent)):l(c)})}}Si=new WeakMap,_h=new WeakMap,Xi=new WeakMap,pr=new WeakMap,Qt=new WeakMap,Qi=new WeakMap,li=new WeakMap,Ii=new WeakMap,us=new WeakMap,gr=new WeakMap,As=new WeakMap,en=new WeakMap,tn=new WeakMap,sn=new WeakMap,ds=new WeakMap,oa=new WeakMap,mt=new WeakSet,pv=function(){try{G(this,Qi,Ci(()=>_(this,pr).call(this,_(this,Si))))}catch(t){this.error(t)}},gv=function(t){const i=_(this,Xi).failed;i&&G(this,Ii,Ci(()=>{i(_(this,Si),()=>t,()=>()=>{})}))},mv=function(){const t=_(this,Xi).pending;t&&(this.is_pending=!0,G(this,li,Ci(()=>t(_(this,Si)))),is(()=>{var i=G(this,us,document.createDocumentFragment()),s=bs();i.append(s),G(this,Qi,ye(this,mt,Wo).call(this,()=>(Ys.ensure(),Ci(()=>_(this,pr).call(this,s))))),_(this,As)===0&&(_(this,Si).before(i),G(this,us,null),Tr(_(this,li),()=>{G(this,li,null)}),ye(this,mt,Fo).call(this))}))},sl=function(){try{if(this.is_pending=this.has_pending_snippet(),G(this,As,0),G(this,gr,0),G(this,Qi,Ci(()=>{_(this,pr).call(this,_(this,Si))})),_(this,As)>0){var t=G(this,us,document.createDocumentFragment());Pd(_(this,Qi),t);const i=_(this,Xi).pending;G(this,li,Ci(()=>i(_(this,Si))))}else ye(this,mt,Fo).call(this)}catch(i){this.error(i)}},Fo=function(){this.is_pending=!1;for(const t of _(this,tn))ht(t,Nt),Ui(t);for(const t of _(this,sn))ht(t,qi),Ui(t);_(this,tn).clear(),_(this,sn).clear()},Wo=function(t){var i=Ke,s=We,r=gt;ns(_(this,Qt)),Ti(_(this,Qt)),mn(_(this,Qt).ctx);try{return t()}catch(n){return ed(n),null}finally{ns(i),Ti(s),mn(r)}},rl=function(t){var i;if(!this.has_pending_snippet()){this.parent&&ye(i=this.parent,mt,rl).call(i,t);return}G(this,As,_(this,As)+t),_(this,As)===0&&(ye(this,mt,Fo).call(this),_(this,li)&&Tr(_(this,li),()=>{G(this,li,null)}),_(this,us)&&(_(this,Si).before(_(this,us)),G(this,us,null)))};function bv(e,t,i,s){const r=da;var n=e.filter(u=>!u.settled);if(i.length===0&&n.length===0){s(t.map(r));return}var o=Ke,l=Sv(),c=n.length===1?n[0].promise:n.length>1?Promise.all(n.map(u=>u.promise)):null;function h(u){l();try{s(u)}catch(f){(o.f&ms)===0&&qs(f,o)}nl()}if(i.length===0){c.then(()=>h(t.map(r)));return}function d(){l(),Promise.all(i.map(u=>wv(u))).then(u=>h([...t.map(r),...u])).catch(u=>qs(u,o))}c?c.then(d):d()}function Sv(){var e=Ke,t=We,i=gt,s=Me;return function(n=!0){ns(e),Ti(t),mn(i),n&&(s==null||s.activate())}}function nl(e=!0){ns(null),Ti(null),mn(null),e&&(Me==null||Me.deactivate())}function yv(){var e=Ke.b,t=Me,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function da(e){var t=It|Nt,i=We!==null&&(We.f&It)!==0?We:null;return Ke!==null&&(Ke.f|=kn),{ctx:gt,deps:null,effects:null,equals:Gu,f:t,fn:e,reactions:null,rv:0,v:Dt,wv:0,parent:i??Ke,ac:null}}function wv(e,t,i){Ke===null&&L_();var r=void 0,n=Zs(Dt),o=!We,l=new Map;return Nv(()=>{var f;var c=Uu();r=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(nl)}catch(v){c.reject(v),nl()}var h=Me;if(o){var d=yv();(f=l.get(h))==null||f.reject(lr),l.delete(h),l.set(h,c)}const u=(v,g=void 0)=>{if(h.activate(),g)g!==lr&&(n.f|=Vs,bn(n,g));else{(n.f&Vs)!==0&&(n.f^=Vs),bn(n,v);for(const[b,p]of l){if(l.delete(b),b===h)break;p.reject(lr)}}d&&d()};c.promise.then(u,v=>u(null,v||"unknown"))}),Ch(()=>{for(const c of l.values())c.reject(lr)}),new Promise(c=>{function h(d){function u(){d===r?c(n):h(r)}d.then(u,u)}h(r)})}function _e(e){const t=da(e);return Rd(t),t}function ld(e){const t=da(e);return t.equals=Xu,t}function Cv(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)ti(t[i])}}function kv(e){for(var t=e.parent;t!==null;){if((t.f&It)===0)return(t.f&ms)===0?t:null;t=t.parent}return null}function Sh(e){var t,i=Ke;ns(kv(e));try{e.f&=~Ir,Cv(e),t=Bd(e)}finally{ns(i)}return t}function hd(e){var t=Sh(e);if(!e.equals(t)&&(e.wv=Td(),(!(Me!=null&&Me.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){ht(e,Et);return}er||(Lt!==null?(wh()||Me!=null&&Me.is_fork)&&Lt.set(e,t):bh(e))}function xv(e){var t,i;if(e.effects!==null)for(const s of e.effects)(s.teardown||s.ac)&&((t=s.teardown)==null||t.call(s),(i=s.ac)==null||i.abort(lr),s.teardown=P_,s.ac=null,Jn(s,0),kh(s))}function cd(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&Sn(t)}let ol=new Set;const Gs=new Map;let ud=!1;function Zs(e,t){var i={f:0,v:e,reactions:null,equals:Gu,rv:0,wv:0};return i}function F(e,t){const i=Zs(e);return Rd(i),i}function Ev(e,t=!1,i=!0){const s=Zs(e);return t||(s.equals=Xu),s}function m(e,t,i=!1){We!==null&&(!Ki||(We.f&Jh)!==0)&&Ju()&&(We.f&(It|ks|gh|Jh))!==0&&(Ri===null||!gn.call(Ri,e))&&U_();let s=i?Xe(t):t;return bn(e,s)}function bn(e,t){if(!e.equals(t)){var i=e.v;er?Gs.set(e,t):Gs.set(e,i),e.v=t;var s=Ys.ensure();if(s.capture(e,i),(e.f&It)!==0){const r=e;(e.f&Nt)!==0&&Sh(r),bh(r)}e.wv=Td(),dd(e,Nt),Ke!==null&&(Ke.f&Et)!==0&&(Ke.f&(ji|Hr))===0&&(bi===null?Wv([e]):bi.push(e)),!s.is_fork&&ol.size>0&&!ud&&Pv()}return t}function Pv(){ud=!1;for(const e of ol)(e.f&Et)!==0&&ht(e,qi),So(e)&&Sn(e);ol.clear()}function Rv(e,t=1){var i=a(e),s=t===1?i++:i--;return m(e,i),s}function Xs(e){m(e,e.v+1)}function dd(e,t){var i=e.reactions;if(i!==null)for(var s=i.length,r=0;r<s;r++){var n=i[r],o=n.f,l=(o&Nt)===0;if(l&&ht(n,t),(o&It)!==0){var c=n;Lt==null||Lt.delete(c),(o&Ir)===0&&(o&Pi&&(n.f|=Ir),dd(c,qi))}else l&&((o&ks)!==0&&Oi!==null&&Oi.add(n),Ui(n))}}function Xe(e){if(typeof e!="object"||e===null||Rr in e)return e;const t=zu(e);if(t!==x_&&t!==E_)return e;var i=new Map,s=ph(e),r=F(0),n=Ss,o=l=>{if(Ss===n)return l();var c=We,h=Ss;Ti(null),ic(n);var d=l();return Ti(c),ic(h),d};return s&&i.set("length",F(e.length)),new Proxy(e,{defineProperty(l,c,h){(!("value"in h)||h.configurable===!1||h.enumerable===!1||h.writable===!1)&&H_();var d=i.get(c);return d===void 0?o(()=>{var u=F(h.value);return i.set(c,u),u}):m(d,h.value,!0),!0},deleteProperty(l,c){var h=i.get(c);if(h===void 0){if(c in l){const d=o(()=>F(Dt));i.set(c,d),Xs(r)}}else m(h,Dt),Xs(r);return!0},get(l,c,h){var v;if(c===Rr)return e;var d=i.get(c),u=c in l;if(d===void 0&&(!u||(v=Yr(l,c))!=null&&v.writable)&&(d=o(()=>{var g=Xe(u?l[c]:Dt),b=F(g);return b}),i.set(c,d)),d!==void 0){var f=a(d);return f===Dt?void 0:f}return Reflect.get(l,c,h)},getOwnPropertyDescriptor(l,c){var h=Reflect.getOwnPropertyDescriptor(l,c);if(h&&"value"in h){var d=i.get(c);d&&(h.value=a(d))}else if(h===void 0){var u=i.get(c),f=u==null?void 0:u.v;if(u!==void 0&&f!==Dt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return h},has(l,c){var f;if(c===Rr)return!0;var h=i.get(c),d=h!==void 0&&h.v!==Dt||Reflect.has(l,c);if(h!==void 0||Ke!==null&&(!d||(f=Yr(l,c))!=null&&f.writable)){h===void 0&&(h=o(()=>{var v=d?Xe(l[c]):Dt,g=F(v);return g}),i.set(c,h));var u=a(h);if(u===Dt)return!1}return d},set(l,c,h,d){var x;var u=i.get(c),f=c in l;if(s&&c==="length")for(var v=h;v<u.v;v+=1){var g=i.get(v+"");g!==void 0?m(g,Dt):v in l&&(g=o(()=>F(Dt)),i.set(v+"",g))}if(u===void 0)(!f||(x=Yr(l,c))!=null&&x.writable)&&(u=o(()=>F(void 0)),m(u,Xe(h)),i.set(c,u));else{f=u.v!==Dt;var b=o(()=>Xe(h));m(u,b)}var p=Reflect.getOwnPropertyDescriptor(l,c);if(p!=null&&p.set&&p.set.call(d,h),!f){if(s&&typeof c=="string"){var w=i.get("length"),R=Number(c);Number.isInteger(R)&&R>=w.v&&m(w,R+1)}Xs(r)}return!0},ownKeys(l){a(r);var c=Reflect.ownKeys(l).filter(u=>{var f=i.get(u);return f===void 0||f.v!==Dt});for(var[h,d]of i)d.v!==Dt&&!(h in l)&&c.push(h);return c},setPrototypeOf(){z_()}})}function Zh(e){try{if(e!==null&&typeof e=="object"&&Rr in e)return e[Rr]}catch{}return e}function Dv(e,t){return Object.is(Zh(e),Zh(t))}var Go,fd,_d,vd,pd;function Tv(){if(Go===void 0){Go=window,fd=document,_d=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;vd=Yr(t,"firstChild").get,pd=Yr(t,"nextSibling").get,Qh(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Qh(i)&&(i.__t=void 0)}}function bs(e=""){return document.createTextNode(e)}function Dr(e){return vd.call(e)}function bo(e){return pd.call(e)}function S(e,t){return Dr(e)}function _t(e,t=!1){{var i=Dr(e);return i instanceof Comment&&i.data===""?bo(i):i}}function k(e,t=1,i=!1){let s=e;for(;t--;)s=bo(s);return s}function Mv(e){e.textContent=""}function gd(){return!1}function md(e,t,i){return document.createElementNS(t??Yu,e,void 0)}function Bv(e,t){{const i=document.body;e.autofocus=!0,is(()=>{document.activeElement===i&&e.focus()})}}let ec=!1;function Lv(){ec||(ec=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const i of e.target.elements)(t=i.__on_r)==null||t.call(i)})},{capture:!0}))}function fa(e){var t=We,i=Ke;Ti(null),ns(null);try{return e()}finally{Ti(t),ns(i)}}function yh(e,t,i,s=i){e.addEventListener(t,()=>fa(i));const r=e.__on_r;r?e.__on_r=()=>{r(),s(!0)}:e.__on_r=()=>s(!0),Lv()}function bd(e){Ke===null&&(We===null&&N_(),I_()),er&&O_()}function Av(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function as(e,t,i){var s=Ke;s!==null&&(s.f&ui)!==0&&(e|=ui);var r={ctx:gt,deps:null,nodes:null,f:e|Nt|Pi,first:null,fn:t,last:null,next:null,parent:s,b:s&&s.b,prev:null,teardown:null,wv:0,ac:null};if(i)try{Sn(r)}catch(l){throw ti(r),l}else t!==null&&Ui(r);var n=r;if(i&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&kn)===0&&(n=n.first,(e&ks)!==0&&(e&Or)!==0&&n!==null&&(n.f|=Or)),n!==null&&(n.parent=s,s!==null&&Av(n,s),We!==null&&(We.f&It)!==0&&(e&Hr)===0)){var o=We;(o.effects??(o.effects=[])).push(n)}return r}function wh(){return We!==null&&!Ki}function Ch(e){const t=as(mo,null,!1);return ht(t,Et),t.teardown=e,t}function ss(e){bd();var t=Ke.f,i=!We&&(t&ji)!==0&&(t&Ar)===0;if(i){var s=gt;(s.e??(s.e=[])).push(e)}else return Sd(e)}function Sd(e){return as(go|ju,e,!1)}function Ov(e){return bd(),as(mo|ju,e,!0)}function Iv(e){Ys.ensure();const t=as(Hr|kn,e,!0);return(i={})=>new Promise(s=>{i.outro?Tr(t,()=>{ti(t),s(void 0)}):(ti(t),s(void 0))})}function yd(e){return as(go,e,!1)}function Nv(e){return as(gh|kn,e,!0)}function _a(e,t=0){return as(mo|t,e,!0)}function le(e,t=[],i=[],s=[]){bv(s,t,i,r=>{as(mo,()=>e(...r.map(a)),!0)})}function va(e,t=0){var i=as(ks|t,e,!0);return i}function Ci(e){return as(ji|kn,e,!0)}function wd(e){var t=e.teardown;if(t!==null){const i=er,s=We;tc(!0),Ti(null);try{t.call(null)}finally{tc(i),Ti(s)}}}function kh(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const r=i.ac;r!==null&&fa(()=>{r.abort(lr)});var s=i.next;(i.f&Hr)!==0?i.parent=null:ti(i,t),i=s}}function Fv(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&ji)===0&&ti(t),t=i}}function ti(e,t=!0){var i=!1;(t||(e.f&qu)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Cd(e.nodes.start,e.nodes.end),i=!0),kh(e,t&&!i),Jn(e,0),ht(e,ms);var s=e.nodes&&e.nodes.t;if(s!==null)for(const n of s)n.stop();wd(e);var r=e.parent;r!==null&&r.first!==null&&kd(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Cd(e,t){for(;e!==null;){var i=e===t?null:bo(e);e.remove(),e=i}}function kd(e){var t=e.parent,i=e.prev,s=e.next;i!==null&&(i.next=s),s!==null&&(s.prev=i),t!==null&&(t.first===e&&(t.first=s),t.last===e&&(t.last=i))}function Tr(e,t,i=!0){var s=[];xd(e,s,!0);var r=()=>{i&&ti(e),t&&t()},n=s.length;if(n>0){var o=()=>--n||r();for(var l of s)l.out(o)}else r()}function xd(e,t,i){if((e.f&ui)===0){e.f^=ui;var s=e.nodes&&e.nodes.t;if(s!==null)for(const l of s)(l.is_global||i)&&t.push(l);for(var r=e.first;r!==null;){var n=r.next,o=(r.f&Or)!==0||(r.f&ji)!==0&&(e.f&ks)!==0;xd(r,t,o?i:!1),r=n}}}function xh(e){Ed(e,!0)}function Ed(e,t){if((e.f&ui)!==0){e.f^=ui,(e.f&Et)===0&&(ht(e,Nt),Ui(e));for(var i=e.first;i!==null;){var s=i.next,r=(i.f&Or)!==0||(i.f&ji)!==0;Ed(i,r?t:!1),i=s}var n=e.nodes&&e.nodes.t;if(n!==null)for(const o of n)(o.is_global||t)&&o.in()}}function Pd(e,t){if(e.nodes)for(var i=e.nodes.start,s=e.nodes.end;i!==null;){var r=i===s?null:bo(i);t.append(i),i=r}}let Ho=!1,er=!1;function tc(e){er=e}let We=null,Ki=!1;function Ti(e){We=e}let Ke=null;function ns(e){Ke=e}let Ri=null;function Rd(e){We!==null&&(Ri===null?Ri=[e]:Ri.push(e))}let Zt=null,ai=0,bi=null;function Wv(e){bi=e}let Dd=1,cr=0,Ss=cr;function ic(e){Ss=e}function Td(){return++Dd}function So(e){var t=e.f;if((t&Nt)!==0)return!0;if(t&It&&(e.f&=~Ir),(t&qi)!==0){for(var i=e.deps,s=i.length,r=0;r<s;r++){var n=i[r];if(So(n)&&hd(n),n.wv>e.wv)return!0}(t&Pi)!==0&&Lt===null&&ht(e,Et)}return!1}function Md(e,t,i=!0){var s=e.reactions;if(s!==null&&!(Ri!==null&&gn.call(Ri,e)))for(var r=0;r<s.length;r++){var n=s[r];(n.f&It)!==0?Md(n,t,!1):t===n&&(i?ht(n,Nt):(n.f&Et)!==0&&ht(n,qi),Ui(n))}}function Bd(e){var b;var t=Zt,i=ai,s=bi,r=We,n=Ri,o=gt,l=Ki,c=Ss,h=e.f;Zt=null,ai=0,bi=null,We=(h&(ji|Hr))===0?e:null,Ri=null,mn(e.ctx),Ki=!1,Ss=++cr,e.ac!==null&&(fa(()=>{e.ac.abort(lr)}),e.ac=null);try{e.f|=$a;var d=e.fn,u=d();e.f|=Ar;var f=e.deps,v=Me==null?void 0:Me.is_fork;if(Zt!==null){var g;if(v||Jn(e,ai),f!==null&&ai>0)for(f.length=ai+Zt.length,g=0;g<Zt.length;g++)f[ai+g]=Zt[g];else e.deps=f=Zt;if(wh()&&(e.f&Pi)!==0)for(g=ai;g<f.length;g++)((b=f[g]).reactions??(b.reactions=[])).push(e)}else!v&&f!==null&&ai<f.length&&(Jn(e,ai),f.length=ai);if(Ju()&&bi!==null&&!Ki&&f!==null&&(e.f&(It|qi|Nt))===0)for(g=0;g<bi.length;g++)Md(bi[g],e);if(r!==null&&r!==e){if(cr++,r.deps!==null)for(let p=0;p<i;p+=1)r.deps[p].rv=cr;if(t!==null)for(const p of t)p.rv=cr;bi!==null&&(s===null?s=bi:s.push(...bi))}return(e.f&Vs)!==0&&(e.f^=Vs),u}catch(p){return ed(p)}finally{e.f^=$a,Zt=t,ai=i,bi=s,We=r,Ri=n,mn(o),Ki=l,Ss=c}}function Hv(e,t){let i=t.reactions;if(i!==null){var s=w_.call(i,e);if(s!==-1){var r=i.length-1;r===0?i=t.reactions=null:(i[s]=i[r],i.pop())}}if(i===null&&(t.f&It)!==0&&(Zt===null||!gn.call(Zt,t))){var n=t;(n.f&Pi)!==0&&(n.f^=Pi,n.f&=~Ir),bh(n),xv(n),Jn(n,0)}}function Jn(e,t){var i=e.deps;if(i!==null)for(var s=t;s<i.length;s++)Hv(e,i[s])}function Sn(e){var t=e.f;if((t&ms)===0){ht(e,Et);var i=Ke,s=Ho;Ke=e,Ho=!0;try{(t&(ks|Ku))!==0?Fv(e):kh(e),wd(e);var r=Bd(e);e.teardown=typeof r=="function"?r:null,e.wv=Dd;var n;Qa&&nv&&(e.f&Nt)!==0&&e.deps}finally{Ho=s,Ke=i}}}async function zv(){await Promise.resolve(),cv()}function a(e){var t=e.f,i=(t&It)!==0;if(We!==null&&!Ki){var s=Ke!==null&&(Ke.f&ms)!==0;if(!s&&(Ri===null||!gn.call(Ri,e))){var r=We.deps;if((We.f&$a)!==0)e.rv<cr&&(e.rv=cr,Zt===null&&r!==null&&r[ai]===e?ai++:Zt===null?Zt=[e]:Zt.push(e));else{(We.deps??(We.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[We]:gn.call(n,We)||n.push(We)}}}if(er&&Gs.has(e))return Gs.get(e);if(i){var o=e;if(er){var l=o.v;return((o.f&Et)===0&&o.reactions!==null||Ad(o))&&(l=Sh(o)),Gs.set(o,l),l}var c=(o.f&Pi)===0&&!Ki&&We!==null&&(Ho||(We.f&Pi)!==0),h=(o.f&Ar)===0;So(o)&&(c&&(o.f|=Pi),hd(o)),c&&!h&&(cd(o),Ld(o))}if(Lt!=null&&Lt.has(e))return Lt.get(e);if((e.f&Vs)!==0)throw e.v;return e.v}function Ld(e){if(e.f|=Pi,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&It)!==0&&(t.f&Pi)===0&&(cd(t),Ld(t))}function Ad(e){if(e.v===Dt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(Gs.has(t)||(t.f&It)!==0&&Ad(t))return!0;return!1}function tr(e){var t=Ki;try{return Ki=!0,e()}finally{Ki=t}}const Uv=["touchstart","touchmove"];function Kv(e){return Uv.includes(e)}const ur=Symbol("events"),Od=new Set,al=new Set;function qv(e,t,i,s={}){function r(n){if(s.capture||ll.call(t,n),!n.cancelBubble)return fa(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?is(()=>{t.addEventListener(e,r,s)}):t.addEventListener(e,r,s),r}function ps(e,t,i,s,r){var n={capture:s,passive:r},o=qv(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Ch(()=>{t.removeEventListener(e,o,n)})}function Q(e,t,i){(t[ur]??(t[ur]={}))[e]=i}function ot(e){for(var t=0;t<e.length;t++)Od.add(e[t]);for(var i of al)i(e)}let sc=null;function ll(e){var p,w;var t=this,i=t.ownerDocument,s=e.type,r=((p=e.composedPath)==null?void 0:p.call(e))||[],n=r[0]||e.target;sc=e;var o=0,l=sc===e&&e[ur];if(l){var c=r.indexOf(l);if(c!==-1&&(t===document||t===window)){e[ur]=t;return}var h=r.indexOf(t);if(h===-1)return;c<=h&&(o=c)}if(n=r[o]||e.target,n!==t){C_(e,"currentTarget",{configurable:!0,get(){return n||i}});var d=We,u=Ke;Ti(null),ns(null);try{for(var f,v=[];n!==null;){var g=n.assignedSlot||n.parentNode||n.host||null;try{var b=(w=n[ur])==null?void 0:w[s];b!=null&&(!n.disabled||e.target===n)&&b.call(n,e)}catch(R){f?v.push(R):f=R}if(e.cancelBubble||g===t||g===null)break;n=g}if(f){for(let R of v)queueMicrotask(()=>{throw R});throw f}}finally{e[ur]=t,delete e.currentTarget,Ti(d),ns(u)}}}var Eu;const Pa=((Eu=globalThis==null?void 0:globalThis.window)==null?void 0:Eu.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function jv(e){return(Pa==null?void 0:Pa.createHTML(e))??e}function Vv(e){var t=md("template");return t.innerHTML=jv(e.replaceAll("<!>","<!---->")),t.content}function $n(e,t){var i=Ke;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function W(e,t){var i=(t&$_)!==0,s=(t&Z_)!==0,r,n=!e.startsWith("<!>");return()=>{r===void 0&&(r=Vv(n?e:"<!>"+e),i||(r=Dr(r)));var o=s||_d?document.importNode(r,!0):r.cloneNode(!0);if(i){var l=Dr(o),c=o.lastChild;$n(l,c)}else $n(o,o);return o}}function Mr(e=""){{var t=bs(e+"");return $n(t,t),t}}function ys(){var e=document.createDocumentFragment(),t=document.createComment(""),i=bs();return e.append(t,i),$n(t,i),e}function O(e,t){e!==null&&e.before(t)}function re(e,t){var i=t==null?"":typeof t=="object"?`${t}`:t;i!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=i,e.nodeValue=`${i}`)}function Yv(e,t){return Gv(e,t)}const Do=new Map;function Gv(e,{target:t,anchor:i,props:s={},events:r,context:n,intro:o=!0,transformError:l}){Tv();var c=void 0,h=Iv(()=>{var d=i??t.appendChild(bs());_v(d,{pending:()=>{}},v=>{ct({});var g=gt;n&&(g.c=n),r&&(s.$$events=r),c=e(v,s)||{},ut()},l);var u=new Set,f=v=>{for(var g=0;g<v.length;g++){var b=v[g];if(!u.has(b)){u.add(b);var p=Kv(b);for(const x of[t,document]){var w=Do.get(x);w===void 0&&(w=new Map,Do.set(x,w));var R=w.get(b);R===void 0?(x.addEventListener(b,ll,{passive:p}),w.set(b,1)):w.set(b,R+1)}}}};return f(ca(Od)),al.add(f),()=>{var p;for(var v of u)for(const w of[t,document]){var g=Do.get(w),b=g.get(v);--b==0?(w.removeEventListener(v,ll),g.delete(v),g.size===0&&Do.delete(w)):g.set(v,b)}al.delete(f),d!==i&&((p=d.parentNode)==null||p.removeChild(d))}});return Xv.set(c,h),c}let Xv=new WeakMap;var Ni,Ji,hi,mr,ho,co,aa;class Id{constructor(t,i=!0){Bi(this,"anchor");ee(this,Ni,new Map);ee(this,Ji,new Map);ee(this,hi,new Map);ee(this,mr,new Set);ee(this,ho,!0);ee(this,co,()=>{var t=Me;if(_(this,Ni).has(t)){var i=_(this,Ni).get(t),s=_(this,Ji).get(i);if(s)xh(s),_(this,mr).delete(i);else{var r=_(this,hi).get(i);r&&(_(this,Ji).set(i,r.effect),_(this,hi).delete(i),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),s=r.effect)}for(const[n,o]of _(this,Ni)){if(_(this,Ni).delete(n),n===t)break;const l=_(this,hi).get(o);l&&(ti(l.effect),_(this,hi).delete(o))}for(const[n,o]of _(this,Ji)){if(n===i||_(this,mr).has(n))continue;const l=()=>{if(Array.from(_(this,Ni).values()).includes(n)){var h=document.createDocumentFragment();Pd(o,h),h.append(bs()),_(this,hi).set(n,{effect:o,fragment:h})}else ti(o);_(this,mr).delete(n),_(this,Ji).delete(n)};_(this,ho)||!s?(_(this,mr).add(n),Tr(o,l,!1)):l()}}});ee(this,aa,t=>{_(this,Ni).delete(t);const i=Array.from(_(this,Ni).values());for(const[s,r]of _(this,hi))i.includes(s)||(ti(r.effect),_(this,hi).delete(s))});this.anchor=t,G(this,ho,i)}ensure(t,i){var s=Me,r=gd();if(i&&!_(this,Ji).has(t)&&!_(this,hi).has(t))if(r){var n=document.createDocumentFragment(),o=bs();n.append(o),_(this,hi).set(t,{effect:Ci(()=>i(o)),fragment:n})}else _(this,Ji).set(t,Ci(()=>i(this.anchor)));if(_(this,Ni).set(s,t),r){for(const[l,c]of _(this,Ji))l===t?s.unskip_effect(c):s.skip_effect(c);for(const[l,c]of _(this,hi))l===t?s.unskip_effect(c.effect):s.skip_effect(c.effect);s.oncommit(_(this,co)),s.ondiscard(_(this,aa))}else _(this,co).call(this)}}Ni=new WeakMap,Ji=new WeakMap,hi=new WeakMap,mr=new WeakMap,ho=new WeakMap,co=new WeakMap,aa=new WeakMap;function ne(e,t,i=!1){var s=new Id(e),r=i?Or:0;function n(o,l){s.ensure(o,l)}va(()=>{var o=!1;t((l,c=0)=>{o=!0,n(c,l)}),o||n(!1,null)},r)}function Zn(e,t){return t}function Qv(e,t,i){for(var s=[],r=t.length,n,o=t.length,l=0;l<r;l++){let u=t[l];Tr(u,()=>{if(n){if(n.pending.delete(u),n.done.add(u),n.pending.size===0){var f=e.outrogroups;hl(ca(n.done)),f.delete(n),f.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var c=s.length===0&&i!==null;if(c){var h=i,d=h.parentNode;Mv(d),d.append(h),e.items.clear()}hl(t,!c)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function hl(e,t=!0){for(var i=0;i<e.length;i++)ti(e[i],t)}var rc;function Ot(e,t,i,s,r,n=null){var o=e,l=new Map,c=(t&Vu)!==0;if(c){var h=e;o=h.appendChild(bs())}var d=null,u=ld(()=>{var w=i();return ph(w)?w:w==null?[]:ca(w)}),f,v=!0;function g(){p.fallback=d,Jv(p,f,o,t,s),d!==null&&(f.length===0?(d.f&vs)===0?xh(d):(d.f^=vs,Nn(d,null,o)):Tr(d,()=>{d=null}))}var b=va(()=>{f=a(u);for(var w=f.length,R=new Set,x=Me,y=gd(),C=0;C<w;C+=1){var L=f[C],z=s(L,C),Y=v?null:l.get(z);Y?(Y.v&&bn(Y.v,L),Y.i&&bn(Y.i,C),y&&x.unskip_effect(Y.e)):(Y=$v(l,v?o:rc??(rc=bs()),L,z,C,r,t,i),v||(Y.e.f|=vs),l.set(z,Y)),R.add(z)}if(w===0&&n&&!d&&(v?d=Ci(()=>n(o)):(d=Ci(()=>n(rc??(rc=bs()))),d.f|=vs)),w>R.size&&A_(),!v)if(y){for(const[J,ae]of l)R.has(J)||x.skip_effect(ae.e);x.oncommit(g),x.ondiscard(()=>{})}else g();a(u)}),p={effect:b,items:l,outrogroups:null,fallback:d};v=!1}function Dn(e){for(;e!==null&&(e.f&ji)===0;)e=e.next;return e}function Jv(e,t,i,s,r){var ae,X,N,B,M,T,j,D,P;var n=(s&V_)!==0,o=t.length,l=e.items,c=Dn(e.effect.first),h,d=null,u,f=[],v=[],g,b,p,w;if(n)for(w=0;w<o;w+=1)g=t[w],b=r(g,w),p=l.get(b).e,(p.f&vs)===0&&((X=(ae=p.nodes)==null?void 0:ae.a)==null||X.measure(),(u??(u=new Set)).add(p));for(w=0;w<o;w+=1){if(g=t[w],b=r(g,w),p=l.get(b).e,e.outrogroups!==null)for(const U of e.outrogroups)U.pending.delete(p),U.done.delete(p);if((p.f&vs)!==0)if(p.f^=vs,p===c)Nn(p,null,i);else{var R=d?d.next:c;p===e.effect.last&&(e.effect.last=p.prev),p.prev&&(p.prev.next=p.next),p.next&&(p.next.prev=p.prev),Rs(e,d,p),Rs(e,p,R),Nn(p,R,i),d=p,f=[],v=[],c=Dn(d.next);continue}if((p.f&ui)!==0&&(xh(p),n&&((B=(N=p.nodes)==null?void 0:N.a)==null||B.unfix(),(u??(u=new Set)).delete(p))),p!==c){if(h!==void 0&&h.has(p)){if(f.length<v.length){var x=v[0],y;d=x.prev;var C=f[0],L=f[f.length-1];for(y=0;y<f.length;y+=1)Nn(f[y],x,i);for(y=0;y<v.length;y+=1)h.delete(v[y]);Rs(e,C.prev,L.next),Rs(e,d,C),Rs(e,L,x),c=x,d=L,w-=1,f=[],v=[]}else h.delete(p),Nn(p,c,i),Rs(e,p.prev,p.next),Rs(e,p,d===null?e.effect.first:d.next),Rs(e,d,p),d=p;continue}for(f=[],v=[];c!==null&&c!==p;)(h??(h=new Set)).add(c),v.push(c),c=Dn(c.next);if(c===null)continue}(p.f&vs)===0&&f.push(p),d=p,c=Dn(p.next)}if(e.outrogroups!==null){for(const U of e.outrogroups)U.pending.size===0&&(hl(ca(U.done)),(M=e.outrogroups)==null||M.delete(U));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||h!==void 0){var z=[];if(h!==void 0)for(p of h)(p.f&ui)===0&&z.push(p);for(;c!==null;)(c.f&ui)===0&&c!==e.fallback&&z.push(c),c=Dn(c.next);var Y=z.length;if(Y>0){var J=(s&Vu)!==0&&o===0?i:null;if(n){for(w=0;w<Y;w+=1)(j=(T=z[w].nodes)==null?void 0:T.a)==null||j.measure();for(w=0;w<Y;w+=1)(P=(D=z[w].nodes)==null?void 0:D.a)==null||P.fix()}Qv(e,z,J)}}n&&is(()=>{var U,Z;if(u!==void 0)for(p of u)(Z=(U=p.nodes)==null?void 0:U.a)==null||Z.apply()})}function $v(e,t,i,s,r,n,o,l){var c=(o&q_)!==0?(o&Y_)===0?Ev(i,!1,!1):Zs(i):null,h=(o&j_)!==0?Zs(r):null;return{v:c,i:h,e:Ci(()=>(n(t,c??i,h??r,l),()=>{e.delete(s)}))}}function Nn(e,t,i){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end,n=t&&(t.f&vs)===0?t.nodes.start:i;s!==null;){var o=bo(s);if(n.before(s),s===r)return;s=o}}function Rs(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function nc(e,t,i=!1,s=!1,r=!1){var n=e,o="";le(()=>{var l=Ke;if(o!==(o=t()??"")&&(l.nodes!==null&&(Cd(l.nodes.start,l.nodes.end),l.nodes=null),o!=="")){var c=i?ev:s?tv:void 0,h=md(i?"svg":s?"math":"template",c);h.innerHTML=o;var d=i||s?h:h.content;if($n(Dr(d),d.lastChild),i||s)for(;Dr(d);)n.before(Dr(d));else n.before(d)}})}function Zv(e,t,...i){var s=new Id(e);va(()=>{const r=t()??null;s.ensure(r,r&&(n=>r(n,...i)))},Or)}function Nd(e){var t,i,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(i=Nd(e[t]))&&(s&&(s+=" "),s+=i)}else for(i in e)e[i]&&(s&&(s+=" "),s+=i);return s}function ep(){for(var e,t,i=0,s="",r=arguments.length;i<r;i++)(e=arguments[i])&&(t=Nd(e))&&(s&&(s+=" "),s+=t);return s}function Fd(e){return typeof e=="object"?ep(e):e??""}const oc=[...`
2
- \r\f \v\uFEFF`];function tp(e,t,i){var s=e==null?"":""+e;if(t&&(s=s?s+" "+t:t),i){for(var r of Object.keys(i))if(i[r])s=s?s+" "+r:r;else if(s.length)for(var n=r.length,o=0;(o=s.indexOf(r,o))>=0;){var l=o+n;(o===0||oc.includes(s[o-1]))&&(l===s.length||oc.includes(s[l]))?s=(o===0?"":s.substring(0,o))+s.substring(l+1):o=l}}return s===""?null:s}function ac(e,t=!1){var i=t?" !important;":";",s="";for(var r of Object.keys(e)){var n=e[r];n!=null&&n!==""&&(s+=" "+r+": "+n+i)}return s}function Ra(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function ip(e,t){if(t){var i="",s,r;if(Array.isArray(t)?(s=t[0],r=t[1]):s=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var n=!1,o=0,l=!1,c=[];s&&c.push(...Object.keys(s).map(Ra)),r&&c.push(...Object.keys(r).map(Ra));var h=0,d=-1;const b=e.length;for(var u=0;u<b;u++){var f=e[u];if(l?f==="/"&&e[u-1]==="*"&&(l=!1):n?n===f&&(n=!1):f==="/"&&e[u+1]==="*"?l=!0:f==='"'||f==="'"?n=f:f==="("?o++:f===")"&&o--,!l&&n===!1&&o===0){if(f===":"&&d===-1)d=u;else if(f===";"||u===b-1){if(d!==-1){var v=Ra(e.substring(h,d).trim());if(!c.includes(v)){f!==";"&&u++;var g=e.substring(h,u).trim();i+=" "+g+";"}}h=u+1,d=-1}}}}return s&&(i+=ac(s)),r&&(i+=ac(r,!0)),i=i.trim(),i===""?null:i}return e==null?null:String(e)}function Ze(e,t,i,s,r,n){var o=e.__className;if(o!==i||o===void 0){var l=tp(i,s,n);l==null?e.removeAttribute("class"):t?e.className=l:e.setAttribute("class",l),e.__className=i}else if(n&&r!==n)for(var c in n){var h=!!n[c];(r==null||h!==!!r[c])&&e.classList.toggle(c,h)}return n}function Da(e,t={},i,s){for(var r in i){var n=i[r];t[r]!==n&&(i[r]==null?e.style.removeProperty(r):e.style.setProperty(r,n,s))}}function xn(e,t,i,s){var r=e.__style;if(r!==t){var n=ip(t,s);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else s&&(Array.isArray(s)?(Da(e,i==null?void 0:i[0],s[0]),Da(e,i==null?void 0:i[1],s[1],"important")):Da(e,i,s));return s}function Wd(e,t,i=!1){if(e.multiple){if(t==null)return;if(!ph(t))return iv();for(var s of e.options)s.selected=t.includes(jn(s));return}for(s of e.options){var r=jn(s);if(Dv(r,t)){s.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function sp(e){var t=new MutationObserver(()=>{Wd(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Ch(()=>{t.disconnect()})}function Xo(e,t,i=t){var s=new WeakSet,r=!0;yh(e,"change",n=>{var o=n?"[selected]":":checked",l;if(e.multiple)l=[].map.call(e.querySelectorAll(o),jn);else{var c=e.querySelector(o)??e.querySelector("option:not([disabled])");l=c&&jn(c)}i(l),Me!==null&&s.add(Me)}),yd(()=>{var n=t();if(e===document.activeElement){var o=Yo??Me;if(s.has(o))return}if(Wd(e,n,r),r&&n===void 0){var l=e.querySelector(":checked");l!==null&&(n=jn(l),i(n))}e.__value=n,r=!1}),sp(e)}function jn(e){return"__value"in e?e.__value:e.value}const rp=Symbol("is custom element"),np=Symbol("is html"),op=B_?"progress":"PROGRESS";function ap(e,t){var i=Eh(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==op)||(e.value=t??"")}function lp(e,t){var i=Eh(e);i.checked!==(i.checked=t??void 0)&&(e.checked=t)}function Ne(e,t,i,s){var r=Eh(e);r[t]!==(r[t]=i)&&(t==="loading"&&(e[M_]=i),i==null?e.removeAttribute(t):typeof i!="string"&&hp(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function Eh(e){return e.__attributes??(e.__attributes={[rp]:e.nodeName.includes("-"),[np]:e.namespaceURI===Yu})}var lc=new Map;function hp(e){var t=e.getAttribute("is")||e.nodeName,i=lc.get(t);if(i)return i;lc.set(t,i=[]);for(var s,r=e,n=Element.prototype;n!==r;){s=k_(r);for(var o in s)s[o].set&&i.push(o);r=zu(r)}return i}function Ei(e,t,i=t){var s=new WeakSet;yh(e,"input",async r=>{var n=r?e.defaultValue:e.value;if(n=Ta(e)?Ma(n):n,i(n),Me!==null&&s.add(Me),await zv(),n!==(n=t())){var o=e.selectionStart,l=e.selectionEnd,c=e.value.length;if(e.value=n??"",l!==null){var h=e.value.length;o===l&&l===c&&h>c?(e.selectionStart=h,e.selectionEnd=h):(e.selectionStart=o,e.selectionEnd=Math.min(l,h))}}}),tr(t)==null&&e.value&&(i(Ta(e)?Ma(e.value):e.value),Me!==null&&s.add(Me)),_a(()=>{var r=t();if(e===document.activeElement){var n=Yo??Me;if(s.has(n))return}Ta(e)&&r===Ma(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}function zi(e,t,i=t){yh(e,"change",s=>{var r=s?e.defaultChecked:e.checked;i(r)}),tr(t)==null&&i(e.checked),_a(()=>{var s=t();e.checked=!!s})}function Ta(e){var t=e.type;return t==="number"||t==="range"}function Ma(e){return e===""?null:+e}function hc(e,t){return e===t||(e==null?void 0:e[Rr])===t}function $e(e={},t,i,s){return yd(()=>{var r,n;return _a(()=>{r=n,n=[],tr(()=>{e!==i(...n)&&(t(e,...n),r&&hc(i(...r),e)&&t(null,...r))})}),()=>{is(()=>{n&&hc(i(...n),e)&&t(null,...n)})}}),e}let To=!1;function cp(e){var t=To;try{return To=!1,[e(),To]}finally{To=t}}function ws(e,t,i,s){var R;var r=(i&Q_)!==0,n=(i&J_)!==0,o=s,l=!0,c=()=>(l&&(l=!1,o=n?tr(s):s),o),h;if(r){var d=Rr in e||T_ in e;h=((R=Yr(e,t))==null?void 0:R.set)??(d&&t in e?x=>e[t]=x:void 0)}var u,f=!1;r?[u,f]=cp(()=>e[t]):u=e[t],u===void 0&&s!==void 0&&(u=c(),h&&(W_(),h(u)));var v;if(v=()=>{var x=e[t];return x===void 0?c():(l=!0,x)},(i&X_)===0)return v;if(h){var g=e.$$legacy;return(function(x,y){return arguments.length>0?((!y||g||f)&&h(y?v():x),x):v()})}var b=!1,p=((i&G_)!==0?da:ld)(()=>(b=!1,v()));r&&a(p);var w=Ke;return(function(x,y){if(arguments.length>0){const C=y?a(p):r?Xe(x):x;return m(p,C),b=!0,o!==void 0&&(o=C),x}return er&&b||(w.f&ms)!==0?p.v:a(p)})}function En(e){gt===null&&mh(),ss(()=>{const t=tr(e);if(typeof t=="function")return t})}function up(e){gt===null&&mh(),En(()=>()=>tr(e))}const dp="5";var Pu;typeof window<"u"&&((Pu=window.__svelte??(window.__svelte={})).v??(Pu.v=new Set)).add(dp);class Hd extends Error{constructor(i){super("conflict");Bi(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function Pt(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function fp(e){const t=await fetch("/auth",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pin:e})});if(!t.ok){const i=await t.json();throw new Error(i.error||"Authentication failed")}}async function _p(){return(await fetch("/sessions")).ok}async function vp(){return Pt(await fetch("/sessions"))}async function pp(){return Pt(await fetch("/worktrees"))}async function gp(){return(await Pt(await fetch("/workspaces"))).workspaces}async function cc(e,t){const i=new URLSearchParams;return e&&i.set("path",e),Pt(await fetch("/workspaces/browse?"+i.toString()))}async function mp(e){return Pt(await fetch("/workspaces/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))}async function bp(e){var i,s;const t=await Pt(await fetch("/workspaces/dashboard?path="+encodeURIComponent(e)));return{prs:((i=t.pullRequests)==null?void 0:i.prs)??[],activity:t.activity??[],isGitRepo:!0,defaultBranch:null,hasGhCli:!((s=t.pullRequests)!=null&&s.error)}}async function Sp(e,t){const i=await fetch("/workspaces/ci-status?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function yp(e,t){const i=await fetch("/workspaces/pr?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function wp(e){return(await Pt(await fetch("/workspaces/current-branch?path="+encodeURIComponent(e)))).branch}async function Ba(e,t){const i=await fetch("/workspaces/worktree?path="+encodeURIComponent(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!i.ok){const s=await i.json();throw new Error(s.error||"Failed to create worktree")}return i.json()}async function Cp(e,t){return(await fetch("/workspaces/branch?path="+encodeURIComponent(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})})).json()}async function Ph(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),Pt(await fetch("/branches?"+i.toString()))}async function Br(e){const t=await fetch("/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.status===409){const i=await t.json();throw new Hd(i.sessionId??"")}return Pt(t)}async function kp(e){const t=await fetch("/sessions/repo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(t.status===409){const i=await t.json();throw new Hd(i.sessionId??"")}return Pt(t)}async function xp(e){await fetch("/sessions/"+e,{method:"DELETE"})}async function zd(e,t){const i=await fetch("/worktrees",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreePath:e,repoPath:t})});if(!i.ok){const s=await i.json();throw new Error(s.error||"Failed to delete worktree")}}async function Ep(e,t,i){return Pt(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function Ud(){return Pt(await fetch("/version"))}async function Kd(){return Pt(await fetch("/update",{method:"POST"}))}async function Pp(){return(await Pt(await fetch("/config/defaultAgent"))).defaultAgent}async function Rp(e){if(!(await fetch("/config/defaultAgent",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultAgent:e})})).ok)throw new Error("Failed to update default agent")}async function pa(e){return(await Pt(await fetch(`/config/${e}`)))[e]}async function ga(e,t){const i=await fetch(`/config/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(!i.ok){const s=await i.json();throw new Error(s.error||`Failed to update ${e}`)}}const Dp=()=>pa("defaultContinue"),Tp=e=>ga("defaultContinue",e),Mp=()=>pa("defaultYolo"),Bp=e=>ga("defaultYolo",e),Lp=()=>pa("launchInTmux"),Ap=e=>ga("launchInTmux",e),Op=()=>pa("defaultNotifications"),Ip=e=>ga("defaultNotifications",e);async function Np(e,t){if(!(await fetch("/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscription:e,sessionIds:t})})).ok)throw new Error("Push subscribe failed")}async function cl(e){return Pt(await fetch("/workspaces/settings?path="+encodeURIComponent(e)))}async function Fp(e,t){const i=await fetch("/workspaces/settings?path="+encodeURIComponent(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){const s=await i.json();throw new Error(s.error||"Failed to update workspace settings")}}async function Wp(){return Pt(await fetch("/sessions/meta"))}async function Hp(e,t){const i="/sessions/"+encodeURIComponent(e)+"/meta?refresh=true";return Pt(await fetch(i))}let Qo=F(!1),ul=F(null),dl=F(!0);function qd(){return{get authenticated(){return a(Qo)},get pinError(){return a(ul)},get checking(){return a(dl)}}}async function zp(){m(dl,!0);try{m(Qo,await _p(),!0)}catch{m(Qo,!1)}finally{m(dl,!1)}}async function Up(e){m(ul,null);try{await fp(e),m(Qo,!0)}catch(t){m(ul,t instanceof Error?t.message:"Authentication failed",!0)}}const jd="claude-remote-sidebar-width",Vd="claude-remote-sidebar-collapsed",fl="claude-remote-active-workspace",Yd=240,Gd=180,Xd=500,Kp=44;function qp(){try{const e=localStorage.getItem(jd);if(e){const t=parseInt(e,10);if(t>=Gd&&t<=Xd)return t}}catch{}return Yd}function jp(){try{return localStorage.getItem(Vd)==="true"}catch{return!1}}function Vp(){try{return localStorage.getItem(fl)}catch{return null}}let Jo=F(!1),_l=F(Xe(qp())),Vn=F(Xe(jp())),uc=F(""),dc=F(Xe(Vp()));function Qd(){return{get sidebarOpen(){return a(Jo)},set sidebarOpen(e){m(Jo,e,!0)},get sidebarWidth(){return a(_l)},set sidebarWidth(e){m(_l,e,!0)},get sidebarCollapsed(){return a(Vn)},set sidebarCollapsed(e){m(Vn,e,!0)},get searchQuery(){return a(uc)},set searchQuery(e){m(uc,e,!0)},get activeWorkspacePath(){return a(dc)},set activeWorkspacePath(e){m(dc,e,!0);try{e===null?localStorage.removeItem(fl):localStorage.setItem(fl,e)}catch{}}}}function fc(){m(Jo,!0)}function ci(){m(Jo,!1)}function _c(){try{localStorage.setItem(jd,String(a(_l)))}catch{}}function La(){m(Vn,!a(Vn));try{localStorage.setItem(Vd,String(a(Vn)))}catch{}}const Jd="claude-remote-collapsed-workspaces";function Yp(){try{const e=localStorage.getItem(Jd);if(e)return new Set(JSON.parse(e))}catch{}return new Set}let ar=F(Xe(Yp()));function Gp(){try{localStorage.setItem(Jd,JSON.stringify([...a(ar)]))}catch{}}function Xp(e){a(ar).has(e)?a(ar).delete(e):a(ar).add(e),m(ar,new Set(a(ar)),!0),Gp()}function Qp(e){return a(ar).has(e)}let $d=F(0);setInterval(()=>{Rv($d)},3e4);function Jp(){return a($d)}let Yn=null,$p=null;function Zp(e){Yn=e,"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const i=t.data;i.type==="notification-click"&&i.sessionId&&Yn&&Yn(i.sessionId,i.sessionType||"repo")})}function eg(){return document.hidden||!document.hasFocus()}function tg(e){if(typeof Notification>"u"||Notification.permission!=="granted")return;const t=new Notification(e.displayName||"Claude Remote CLI",{body:"Session needs your input",tag:"session-"+e.id,data:{sessionId:e.id,sessionType:e.type}});t.onclick=()=>{window.focus(),Yn&&Yn(e.id,e.type),t.close()}}function Zd(){return"serviceWorker"in navigator&&"PushManager"in window}async function ig(){if(Zd())try{$p=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function sg(e){if(Zd())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await Np(i.toJSON(),e)}catch{}}const ef="claude-remote-notifications",vl="claude-remote-active-session";function rg(){try{return localStorage.getItem(vl)}catch{return null}}function tf(e){try{e===null?localStorage.removeItem(vl):localStorage.setItem(vl,e)}catch{}}let eo=F(Xe([])),sf=F(Xe([])),rf=F(Xe([])),Gr=F(Xe(rg())),Nr=Xe({}),to=Xe({}),Rh=Xe({}),Gn=F(Xe(new Map)),Cs=F(Xe({}));try{const e=localStorage.getItem(ef);e&&m(Cs,JSON.parse(e),!0)}catch{}function nf(){try{localStorage.setItem(ef,JSON.stringify(a(Cs)))}catch{}}function Dh(){return{get sessions(){return a(eo)},get worktrees(){return a(sf)},get workspaces(){return a(rf)},get activeSessionId(){return a(Gr)},set activeSessionId(e){m(Gr,e,!0),tf(e)},get attentionSessions(){return Nr},get loadingItems(){return Rh},get notificationSessions(){return a(Cs)}}}async function Mt(){try{const[e,t,i]=await Promise.all([vp(),pp(),gp()]);m(eo,e,!0),m(sf,t,!0),m(rf,i,!0);const s=new Set(a(eo).map(n=>n.id));a(Gr)!==null&&!s.has(a(Gr))&&(m(Gr,null),tf(null));let r=!1;for(const n of Object.keys(Nr))s.has(n)||delete Nr[n];for(const n of Object.keys(to))s.has(n)||delete to[n];for(const n of Object.keys(a(Cs)))s.has(n)||(delete a(Cs)[n],r=!0);r&&nf();try{const n=await Wp(),o=new Map;for(const[l,c]of Object.entries(n))o.set(l,c);m(Gn,o,!0)}catch{}}catch{}}function of(e){return a(eo).filter(t=>t.repoPath===e||t.repoPath.startsWith(e+"/"))}const ng=3e4;function og(e,t){const i=a(eo).find(s=>s.id===e);if(i&&(i.idle=t),t&&e!==a(Gr)&&(i==null?void 0:i.type)!=="terminal"){const s=to[e];if(s&&Date.now()-s<ng)return;delete to[e],Nr[e]=!0,i&&a(Cs)[e]&&eg()&&tg(i)}else delete Nr[e]}function vc(e){delete Nr[e],to[e]=Date.now()}function Tn(e,t){e in a(Cs)||(a(Cs)[e]=t,nf())}function ag(){return Object.entries(a(Cs)).filter(([,e])=>e).map(([e])=>e)}function Aa(e){return Nr[e.id]?"attention":e.idle?"idle":"running"}function lg(e){Rh[e]=!0}function hg(e){delete Rh[e]}function pc(e){return a(Gn).get(e)}async function cg(e){try{const t=await Hp(e,{refresh:!0});a(Gn).set(e,t),m(Gn,new Map(a(Gn)),!0)}catch{}}const af=location.protocol==="https:"?"wss:":"ws:";let sr=null,ei=null,pi=null;const gc=30;let Xn=null,Xr=0;function lf(e){sr&&(sr.close(),sr=null);const t=af+"//"+location.host+"/ws/events";sr=new WebSocket(t),sr.onmessage=i=>{try{e(JSON.parse(i.data))}catch{}},sr.onclose=()=>{setTimeout(()=>lf(e),3e3)},sr.onerror=()=>{}}function hf(e,t,i,s){Xn&&(clearTimeout(Xn),Xn=null),Xr=0,pi&&(pi.onopen=null,pi.onmessage=null,pi.onclose=null,pi.onerror=null,pi.close(),pi=null),ei&&(ei.onclose=null,ei.close(),ei=null);const r=af+"//"+location.host+"/ws/"+e,n=new WebSocket(r);pi=n,n.onopen=()=>{pi=null,ei=n,Xr=0,i()},n.onmessage=o=>{t.write(o.data)},n.onclose=o=>{if(pi===n&&(pi=null),!(pi!==n&&ei!==n)){if(o.code===1e3){t.write(`\r
3
- [Session ended]\r
4
- `),ei=null,s();return}ei=null,Xr===0&&t.write(`\r
5
- [Reconnecting...]\r
6
- `),cf(e,t,i,s)}},n.onerror=()=>{}}function cf(e,t,i,s){if(Xr>=gc){t.write(`\r
7
- [Gave up reconnecting after `+gc+` attempts]\r
8
- `);return}const r=Math.min(1e3*2**Xr,1e4);Xr++,Xn=setTimeout(async()=>{Xn=null;try{if(!(await(await fetch("/sessions")).json()).some(l=>l.id===e)){t.write(`\r
9
- [Session ended]\r
10
- `),s();return}t.clear(),hf(e,t,i,s)}catch{cf(e,t,i,s)}},r)}function Qs(e){ei&&ei.readyState===WebSocket.OPEN&&ei.send(e)}function Oa(e,t){ei&&ei.readyState===WebSocket.OPEN&&ei.send(JSON.stringify({type:"resize",cols:e,rows:t}))}const Li=Xe({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Th(){return Li}async function uf(){const[e,t,i,s,r]=await Promise.all([Dp().catch(()=>Li.defaultContinue),Mp().catch(()=>Li.defaultYolo),Lp().catch(()=>Li.launchInTmux),Pp().catch(()=>Li.defaultAgent),Op().catch(()=>Li.defaultNotifications)]);Li.defaultContinue=e,Li.defaultYolo=t,Li.launchInTmux=i,Li.defaultAgent=s,Li.defaultNotifications=r}function ug(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),s=Math.floor((t-i)/1e3);if(s<60)return"just now";const r=Math.floor(s/60);if(r<60)return r+"m ago";const n=Math.floor(r/60);if(n<24)return n+"h ago";const o=Math.floor(n/24);if(o===1)return"yesterday";if(o<7)return o+"d ago";const l=new Date(e);return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][l.getMonth()]+" "+l.getDate()}function mc(e){if(!e)return"";const t=Date.now(),i=new Date(e).getTime(),s=Math.floor((t-i)/1e3);if(s<60)return s+"s";const r=Math.floor(s/60);if(r<60)return r+"m";const n=Math.floor(r/60);if(n<24)return n+"h";const o=new Date(e),l=String(o.getDate()).padStart(2,"0"),c=String(o.getMonth()+1).padStart(2,"0"),h=o.getFullYear();return`${l}/${c}/${h}`}const Tt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);function Mh(e){const{commitsAhead:t,prState:i,ciFailing:s,ciPending:r,ciTotal:n,mergeable:o,unresolvedCommentCount:l}=e;return t<=0&&i===null?{type:"none",color:"none",label:""}:i===null?{type:"create-pr",color:"accent",label:"Create PR"}:i==="DRAFT"?{type:"ready-for-review",color:"muted",label:"Ready for Review"}:i==="MERGED"?{type:"archive-merged",color:"merged",label:"Archive"}:i==="CLOSED"?{type:"archive-closed",color:"muted",label:"Archive"}:i==="OPEN"?o==="CONFLICTING"?{type:"fix-conflicts",color:"error",label:"Fix Conflicts"}:s>0?{type:"fix-errors",color:"error",label:`Fix Errors ${s}/${n}`}:r>0?{type:"checks-running",color:"warning",label:"Checks Running..."}:l>0?{type:"resolve-comments",color:"accent",label:`Resolve Comments (${l})`}:{type:"review-pr",color:"success",label:"Review PR"}:{type:"none",color:"none",label:""}}function dg(e,t){return e.type==="resolve-comments"?{type:"review-pr",color:"muted",label:"Review PR"}:null}function df(e,t){switch(e.type){case"create-pr":return`Create a pull request for the branch "${t.branchName}". Write a clear title and description based on the changes.`;case"ready-for-review":return`Mark the draft PR for branch "${t.branchName}" as ready for review using: gh pr ready`;case"review-pr":return`Review the pull request #${t.prNumber} for branch "${t.branchName}". Read the diff, check for bugs and code quality.`;case"fix-conflicts":return`There are merge conflicts with the base branch "${t.baseBranch}". Run \`git merge ${t.baseBranch}\` and resolve all conflicts.`;case"resolve-comments":return`There are ${t.unresolvedCommentCount} unresolved review comments on PR #${t.prNumber}. Read each comment thread, triage them, and address the feedback.`;case"fix-errors":return`The CI checks are failing on branch "${t.branchName}". Investigate the failing checks and fix the errors.`;case"archive-merged":case"archive-closed":return null;case"checks-running":case"none":return null}}function ff(e){switch(e){case"accent":return"var(--accent)";case"success":return"var(--status-success)";case"error":return"var(--status-error)";case"warning":return"var(--status-warning)";case"merged":return"var(--status-merged)";case"muted":return"var(--border)";case"none":return"transparent"}}function _f(e){return e==="success"||e==="warning"}var fg=W('<p class="error svelte-1qp96yb"> </p>'),_g=W('<div class="pin-gate svelte-1qp96yb"><div class="pin-container svelte-1qp96yb"><h1 class="svelte-1qp96yb">Claude Remote CLI</h1> <p class="svelte-1qp96yb">Enter PIN to continue</p> <input type="password" inputmode="numeric" maxlength="20" placeholder="PIN" class="svelte-1qp96yb"/> <button class="svelte-1qp96yb">Unlock</button> <!></div></div>');function vg(e,t){ct(t,!0);const i=qd();let s=F("");async function r(){const f=a(s).trim();f&&(await Up(f),i.pinError&&m(s,""))}function n(f){f.key==="Enter"&&r()}var o=_g(),l=S(o),c=k(S(l),4);Bv(c);var h=k(c,2),d=k(h,2);{var u=f=>{var v=fg(),g=S(v);le(()=>re(g,i.pinError)),O(f,v)};ne(d,f=>{i.pinError&&f(u)})}Q("keydown",c,n),Ei(c,()=>a(s),f=>m(s,f)),Q("click",h,r),O(e,o),ut()}ot(["keydown","click"]);var pg=W('<li role="menuitem"> </li>'),gg=W('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),mg=W('<button class="context-menu-trigger svelte-1nmhce7" aria-label="Actions" aria-haspopup="true">&middot;&middot;&middot;</button> <!>',1);function bc(e,t){let i=F(!1),s=F(null),r=F(null);function n(b){b.stopPropagation(),a(i)?o():(m(i,!0),requestAnimationFrame(l))}function o(){m(i,!1)}function l(){if(!a(s)||!a(r))return;const b=a(s).getBoundingClientRect(),p=a(r).getBoundingClientRect();let w=b.bottom+4,R=b.right-p.width;w+p.height>window.innerHeight-8&&(w=b.top-p.height-4),R<8&&(R=8),a(r).style.top=w+"px",a(r).style.left=R+"px"}function c(b,p){p.stopPropagation(),!b.disabled&&(o(),b.action())}function h(b){!a(i)||b.key!=="Escape"||(b.stopPropagation(),o())}function d(b){b.stopPropagation(),o()}var u=mg();ps("keydown",fd,h);var f=_t(u);$e(f,b=>m(s,b),()=>a(s));var v=k(f,2);{var g=b=>{var p=gg(),w=_t(p),R=k(w,2);Ot(R,21,()=>t.items,Zn,(x,y)=>{var C=pg();let L;var z=S(C);le(()=>{L=Ze(C,1,"context-menu-item svelte-1nmhce7",null,L,{"context-menu-item--danger":a(y).danger,"context-menu-item--disabled":a(y).disabled}),Ne(C,"tabindex",a(y).disabled?-1:0),re(z,a(y).label)}),Q("click",C,Y=>c(a(y),Y)),Q("keydown",C,Y=>Y.key==="Enter"&&c(a(y),Y)),O(x,C)}),$e(R,x=>m(r,x),()=>a(r)),Q("click",w,d),Q("click",R,x=>x.stopPropagation()),O(b,p)};ne(v,b=>{a(i)&&b(g)})}le(()=>Ne(f,"aria-expanded",a(i))),Q("click",f,n),O(e,u)}ot(["click","keydown"]);var bg=W('<span class="collapse-count svelte-168i8d5"> </span>'),Sg=W('<span class="terminal-icon svelte-168i8d5">&gt;_</span>'),yg=W("<span></span>"),wg=W('<span class="session-count-badge svelte-168i8d5"> </span>'),Cg=W('<span class="diff-badge svelte-168i8d5"><span class="diff-add svelte-168i8d5"> </span> <span class="diff-del svelte-168i8d5"> </span></span>'),kg=W('<span class="secondary-worktree svelte-168i8d5"> </span>'),xg=W('<span class="secondary-pr svelte-168i8d5"> </span>'),Eg=W('<li><div class="session-row-primary svelte-168i8d5"><!> <span> </span> <!> <!></div> <div class="session-row-secondary svelte-168i8d5"><!> <!> <span class="secondary-time svelte-168i8d5"> </span> <!></div></li>'),Pg=W('<li class="session-row inactive svelte-168i8d5"><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span></div></li>'),Rg=W('<span class="diff-badge svelte-168i8d5"><span class="diff-add svelte-168i8d5"> </span> <span class="diff-del svelte-168i8d5"> </span></span>'),Dg=W('<span class="secondary-pr svelte-168i8d5"> </span>'),Tg=W('<li class="session-row inactive svelte-168i8d5"><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span> <!></div> <div class="session-row-secondary svelte-168i8d5"><!> <span class="secondary-time svelte-168i8d5"> </span> <!></div></li>'),Mg=W('<ul class="session-list svelte-168i8d5"><!> <!></ul>'),Bg=W('<div class="add-worktree-row svelte-168i8d5"><span class="add-worktree-btn svelte-168i8d5">+ new worktree</span></div>'),Lg=W('<div><div><div class="workspace-left svelte-168i8d5"><span> </span> <span class="initial-block svelte-168i8d5"> </span> <span class="workspace-name svelte-168i8d5"> </span> <!></div> <div class="workspace-actions svelte-168i8d5"><span class="action-btn svelte-168i8d5" title="New session">+</span> <span class="action-btn svelte-168i8d5" title="New terminal">&gt;_</span> <span class="action-btn svelte-168i8d5" title="Settings">⚙</span></div></div> <!> <!> <div class="workspace-divider svelte-168i8d5"></div></div>');function Ag(e,t){ct(t,!0);const i=Dh();let s=ws(t,"inactiveWorktrees",19,()=>[]),r=_e(()=>[...t.sessionGroups.values()].flat());const n=["#d97757","#4ade80","#60a5fa","#a78bfa","#f472b6","#fb923c","#34d399","#f87171"];function o($){let ve=0;for(let Re=0;Re<$.length;Re++)ve=(ve<<5)-ve+$.charCodeAt(Re)|0;return n[Math.abs(ve)%n.length]??"#d97757"}let l=_e(()=>o(t.workspace.name)),c=_e(()=>t.workspace.name.charAt(0).toUpperCase()),h=_e(()=>Qp(t.workspace.path)),d=_e(()=>a(r).length+s().length);function u($){return"status-dot status-dot--"+Aa($)}function f($){return $.displayName||$.branchName||$.repoName||$.id}let v=_e(()=>a(r).some($=>Aa($)==="attention")),g=_e(Jp);function b($){return a(g),mc($.lastActivity)}function p($){return a(g),mc($.lastActivity)}async function w($){const ve=prompt("Rename session:",f($));ve&&ve.trim()&&(await fetch(`/sessions/${$.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:ve.trim()})}),await Mt())}function R($){return[{label:"Rename",action:()=>w($)},{label:"Kill",action:()=>{var ve;return(ve=t.onDeleteSession)==null?void 0:ve.call(t,$.id)},danger:!0}]}function x($){return[{label:"Resume",action:async()=>{try{const ve=await Br({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:$.path,branchName:$.branchName||$.name});await Mt(),t.onSelectSession(ve.id)}catch{}}},{label:"Resume (YOLO)",action:async()=>{try{const ve=await Br({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:$.path,branchName:$.branchName||$.name,yolo:!0});await Mt(),t.onSelectSession(ve.id)}catch{}}},{label:"Delete Worktree",action:()=>{var ve;return(ve=t.onDeleteWorktree)==null?void 0:ve.call(t,$)},danger:!0}]}var y=Lg();let C;var L=S(y);let z;var Y=S(L),J=S(Y);let ae;var X=S(J),N=k(J,2);let B;var M=S(N),T=k(N,2),j=S(T),D=k(T,2);{var P=$=>{var ve=bg(),Re=S(ve);le(()=>re(Re,a(d))),O($,ve)};ne(D,$=>{a(h)&&a(d)>0&&$(P)})}var U=k(Y,2),Z=S(U),me=k(Z,2),be=k(me,2),fe=k(L,2);{var ke=$=>{var ve=Mg(),Re=S(ve);Ot(Re,17,()=>[...t.sessionGroups.entries()],([Fe,Te])=>Fe,(Fe,Te)=>{var ge=_e(()=>D_(a(Te),2));let Qe=()=>a(ge)[0],Le=()=>a(ge)[1];const Be=_e(()=>Le().sort((I,K)=>K.lastActivity.localeCompare(I.lastActivity))[0]),A=_e(()=>Le().length),ie=_e(()=>Qe()===t.workspace.path),de=_e(()=>a(A)>0),he=_e(()=>Le().some(I=>Aa(I)==="attention"));var Se=ys(),se=_t(Se);{var Ie=I=>{const K=_e(()=>pc(a(Be).id)),H=_e(()=>a(K)&&(a(K).additions>0||a(K).deletions>0));var E=Eg();let V;var ce=S(E),pe=S(ce);{var we=je=>{var tt=Sg();O(je,tt)},xe=je=>{var tt=yg();le(Gt=>Ze(tt,1,Gt,"svelte-168i8d5"),[()=>Fd(u(a(Be)))]),O(je,tt)};ne(pe,je=>{a(Be).type==="terminal"?je(we):je(xe,!1)})}var Ue=k(pe,2);let Ft;var ii=S(Ue),Mi=k(Ue,2);{var De=je=>{var tt=wg(),Gt=S(tt);le(()=>re(Gt,a(A))),O(je,tt)};ne(Mi,je=>{a(A)>1&&je(De)})}var Yt=k(Mi,2);{var si=je=>{var tt=Cg(),Gt=S(tt),Ca=S(Gt),Eo=k(Gt,2),ka=S(Eo);le(()=>{re(Ca,`+${a(K).additions??""}`),re(ka,`-${a(K).deletions??""}`)}),O(je,tt)};ne(Yt,je=>{a(H)&&je(si)})}var fi=k(ce,2),_i=S(fi);{var ir=je=>{var tt=kg(),Gt=S(tt);le(()=>re(Gt,a(Be).worktreeName)),O(je,tt)},Ut=_e(()=>a(Be).worktreeName&&a(Be).worktreeName!==f(a(Be)));ne(_i,je=>{a(Ut)&&je(ir)})}var ri=k(_i,2);{var vi=je=>{var tt=xg(),Gt=S(tt);le(()=>re(Gt,`PR #${a(K).prNumber??""}`)),O(je,tt)};ne(ri,je=>{var tt;(tt=a(K))!=null&&tt.prNumber&&je(vi)})}var Ps=k(ri,2),Ur=S(Ps),wa=k(Ps,2);{let je=_e(()=>R(a(Be)));bc(wa,{get items(){return a(je)}})}le((je,tt,Gt)=>{V=Ze(E,1,"session-row svelte-168i8d5",null,V,je),Ft=Ze(Ue,1,"session-name svelte-168i8d5",null,Ft,{bold:a(he)}),re(ii,tt),re(Ur,Gt)},[()=>({terminal:a(Be).type==="terminal",selected:Le().some(je=>i.activeSessionId===je.id),attention:a(he)}),()=>f(a(Be)),()=>b(a(Be))]),Q("click",E,()=>t.onSelectSession(a(Be).id)),O(I,E)},ze=I=>{var K=Pg(),H=S(K),E=k(S(H),2),V=S(E);le(()=>re(V,t.workspace.name)),Q("click",K,()=>t.onSelectWorkspace(t.workspace.path)),O(I,K)};ne(se,I=>{a(de)&&a(Be)?I(Ie):a(ie)&&I(ze,1)})}O(Fe,Se)});var Ye=k(Re,2);Ot(Ye,17,s,Fe=>Fe.path,(Fe,Te)=>{const ge=_e(()=>pc(a(Te).path)),Qe=_e(()=>a(ge)&&(a(ge).additions>0||a(ge).deletions>0));var Le=Tg(),Be=S(Le),A=k(S(Be),2),ie=S(A),de=k(A,2);{var he=H=>{var E=Rg(),V=S(E),ce=S(V),pe=k(V,2),we=S(pe);le(()=>{re(ce,`+${a(ge).additions??""}`),re(we,`-${a(ge).deletions??""}`)}),O(H,E)};ne(de,H=>{a(Qe)&&H(he)})}var Se=k(Be,2),se=S(Se);{var Ie=H=>{var E=Dg(),V=S(E);le(()=>re(V,`PR #${a(ge).prNumber??""}`)),O(H,E)};ne(se,H=>{var E;(E=a(ge))!=null&&E.prNumber&&H(Ie)})}var ze=k(se,2),I=S(ze),K=k(ze,2);{let H=_e(()=>x(a(Te)));bc(K,{get items(){return a(H)}})}le(H=>{re(ie,a(Te).branchName||a(Te).displayName||a(Te).name),re(I,H)},[()=>p(a(Te))]),Q("click",Le,async()=>{try{const H=await Br({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:a(Te).path,branchName:a(Te).branchName||a(Te).name});await Mt(),t.onSelectSession(H.id)}catch{}}),O(Fe,Le)}),O($,ve)};ne(fe,$=>{!a(h)&&(a(r).length>0||s().length>0)&&$(ke)})}var Ee=k(fe,2);{var Ce=$=>{var ve=Bg();Q("click",ve,()=>t.onNewWorktree(t.workspace)),O($,ve)};ne(Ee,$=>{a(h)||$(Ce)})}le(()=>{C=Ze(y,1,"workspace-item svelte-168i8d5",null,C,{active:t.isActive}),z=Ze(L,1,"workspace-header svelte-168i8d5",null,z,{attention:a(v)}),ae=Ze(J,1,"collapse-chevron svelte-168i8d5",null,ae,{collapsed:a(h)}),re(X,a(h)?"›":"⌄"),B=xn(N,"",B,{background:a(l)}),re(M,a(c)),re(j,t.workspace.name)}),Q("click",L,()=>t.onSelectWorkspace(t.workspace.path)),Q("click",J,$=>{$.stopPropagation(),Xp(t.workspace.path)}),Q("click",Z,$=>{$.stopPropagation(),t.onNewSession(t.workspace)}),Q("click",me,$=>{$.stopPropagation(),t.onNewTerminal(t.workspace)}),Q("click",be,$=>{$.stopPropagation(),t.onOpenSettings(t.workspace)}),O(e,y),ut()}ot(["click"]);var Og=W('<strong class="svelte-itm1qs"> </strong>'),Ig=W("<span> </span>"),Ng=W('<li role="option"><!> <span class="dropdown-path svelte-itm1qs"> </span></li>'),Fg=W('<ul class="dropdown svelte-itm1qs" role="listbox"></ul>'),Wg=W('<div class="smart-search svelte-itm1qs"><div class="input-row svelte-itm1qs"><span class="prompt svelte-itm1qs">&gt;</span> <input type="text" class="search-input svelte-itm1qs" placeholder="search workspaces..." autocomplete="off"/></div> <!></div>');function Hg(e,t){ct(t,!0);let i=F(""),s=F(0),r=F(void 0),n=_e(()=>{if(!a(i).trim())return[];const p=a(i).toLowerCase();return t.workspaces.filter(w=>w.name.toLowerCase().includes(p))}),o=_e(()=>a(i).trim().length>0&&a(n).length>0);ss(()=>{a(n).length,m(s,0)});function l(p){m(i,p.target.value,!0)}function c(p){var w;if(p.key==="Escape"){m(i,""),(w=a(r))==null||w.blur();return}if(a(o)){if(p.key==="ArrowDown")p.preventDefault(),m(s,Math.min(a(s)+1,a(n).length-1),!0);else if(p.key==="ArrowUp")p.preventDefault(),m(s,Math.max(a(s)-1,0),!0);else if(p.key==="Enter"){p.preventDefault();const R=a(n)[a(s)];R&&h(R)}}}function h(p){var w;t.onSelect(p.path),m(i,""),(w=a(r))==null||w.blur()}function d(p,w){if(!w)return[{text:p,bold:!1}];const R=p.toLowerCase(),x=w.toLowerCase(),y=R.indexOf(x);return y===-1?[{text:p,bold:!1}]:[{text:p.slice(0,y),bold:!1},{text:p.slice(y,y+x.length),bold:!0},{text:p.slice(y+x.length),bold:!1}].filter(C=>C.text.length>0)}var u=Wg(),f=S(u),v=k(S(f),2);Ne(v,"spellcheck",!1),$e(v,p=>m(r,p),()=>a(r));var g=k(f,2);{var b=p=>{var w=Fg();Ot(w,23,()=>a(n),R=>R.path,(R,x,y)=>{var C=Ng();let L;var z=S(C);Ot(z,17,()=>d(a(x).name,a(i)),Zn,(ae,X)=>{var N=ys(),B=_t(N);{var M=j=>{var D=Og(),P=S(D);le(()=>re(P,a(X).text)),O(j,D)},T=j=>{var D=Ig(),P=S(D);le(()=>re(P,a(X).text)),O(j,D)};ne(B,j=>{a(X).bold?j(M):j(T,!1)})}O(ae,N)});var Y=k(z,2),J=S(Y);le(()=>{L=Ze(C,1,"dropdown-item svelte-itm1qs",null,L,{focused:a(y)===a(s)}),Ne(C,"aria-selected",a(y)===a(s)),re(J,a(x).path)}),Q("click",C,()=>h(a(x))),ps("mouseenter",C,()=>{m(s,a(y),!0)}),O(R,C)}),O(p,w)};ne(g,p=>{a(o)&&p(b)})}le(()=>ap(v,a(i))),Q("input",v,l),Q("keydown",v,c),O(e,u),ut()}ot(["input","keydown","click"]);var zg=W('<span class="sidebar-label svelte-owj5vn">Workspaces</span>'),Ug=W('<div class="empty-state svelte-owj5vn"><span>No workspaces</span></div>'),Kg=W('<!> <div class="workspace-list svelte-owj5vn"><!> <!></div> <button class="add-workspace-btn svelte-owj5vn">+ Add Workspace</button> <button class="settings-btn svelte-owj5vn">⚙ Settings</button> <div class="resize-handle svelte-owj5vn"></div>',1),qg=W('<aside><div class="sidebar-header svelte-owj5vn"><button class="collapse-btn svelte-owj5vn"> </button> <!> <button class="icon-btn svelte-owj5vn" aria-label="Close sidebar">✕</button></div> <!></aside>');function jg(e,t){ct(t,!0);const i=Qd(),s=Dh();let r=_e(()=>i.sidebarCollapsed?Kp:i.sidebarWidth);function n(y){i.activeWorkspacePath=y,s.activeSessionId=null}function o(y){i.activeWorkspacePath=y,ci()}function l(y){y.preventDefault();const C=y.clientX,L=i.sidebarWidth,z=J=>{const ae=Math.min(Xd,Math.max(Gd,L+(J.clientX-C)));i.sidebarWidth=ae},Y=()=>{document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",Y),document.body.style.cursor="",document.body.style.userSelect="",_c()};document.addEventListener("mousemove",z),document.addEventListener("mouseup",Y),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function c(y){y.preventDefault(),i.sidebarWidth=Yd,_c()}var h=qg();let d,u;var f=S(h),v=S(f),g=S(v),b=k(v,2);{var p=y=>{var C=zg();O(y,C)};ne(b,y=>{i.sidebarCollapsed||y(p)})}var w=k(b,2),R=k(f,2);{var x=y=>{var C=Kg(),L=_t(C);Hg(L,{get workspaces(){return s.workspaces},onSelect:o});var z=k(L,2),Y=S(z);Ot(Y,17,()=>s.workspaces,M=>M.path,(M,T)=>{const j=_e(()=>of(a(T).path)),D=_e(()=>new Set(a(j).map(Z=>Z.repoPath))),P=_e(()=>s.worktrees.filter(Z=>Z.repoPath===a(T).path&&Z.path.startsWith(a(T).path+"/")&&!a(D).has(Z.path))),U=_e(()=>(()=>{const Z=new Map;Z.set(a(T).path,[]);for(const me of a(j)){const be=Z.get(me.repoPath);be?be.push(me):Z.set(me.repoPath,[me])}return Z})());{let Z=_e(()=>i.activeWorkspacePath===a(T).path&&!s.activeSessionId);Ag(M,{get workspace(){return a(T)},get sessionGroups(){return a(U)},get inactiveWorktrees(){return a(P)},get isActive(){return a(Z)},onSelectWorkspace:n,get onSelectSession(){return t.onSelectSession},get onNewWorktree(){return t.onNewWorktree},get onNewSession(){return t.onNewSession},get onNewTerminal(){return t.onNewTerminal},onOpenSettings:me=>t.onOpenSettings(me),onDeleteSession:me=>{var be;return(be=t.onDeleteSession)==null?void 0:be.call(t,me)},onDeleteWorktree:me=>{var be;return(be=t.onDeleteWorktree)==null?void 0:be.call(t,me)}})}});var J=k(Y,2);{var ae=M=>{var T=Ug();O(M,T)};ne(J,M=>{s.workspaces.length===0&&M(ae)})}var X=k(z,2),N=k(X,2),B=k(N,2);Q("click",X,function(...M){var T;(T=t.onAddWorkspace)==null||T.apply(this,M)}),Q("click",N,()=>t.onOpenSettings()),Q("mousedown",B,l),Q("dblclick",B,c),O(y,C)};ne(R,y=>{i.sidebarCollapsed||y(x)})}le(()=>{d=Ze(h,1,"sidebar svelte-owj5vn",null,d,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),u=xn(h,"",u,{width:`${a(r)??""}px`,"min-width":`${a(r)??""}px`}),Ne(v,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),re(g,i.sidebarCollapsed?"»":"«")}),Q("click",v,function(...y){La==null||La.apply(this,y)}),Q("click",w,function(...y){ci==null||ci.apply(this,y)}),O(e,h),ut()}ot(["click","mousedown","dblclick"]);/**
11
- * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
12
- * @license MIT
13
- *
14
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
15
- * @license MIT
16
- *
17
- * Originally forked from (with the author's permission):
18
- * Fabrice Bellard's javascript vt100 for jslinux:
19
- * http://bellard.org/jslinux/
20
- * Copyright (c) 2011 Fabrice Bellard
21
- */var vf=Object.defineProperty,Vg=Object.getOwnPropertyDescriptor,Yg=(e,t)=>{for(var i in t)vf(e,i,{get:t[i],enumerable:!0})},at=(e,t,i,s)=>{for(var r=s>1?void 0:s?Vg(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&vf(t,i,r),r},ue=(e,t)=>(i,s)=>t(i,s,e),Sc="Terminal input",pl={get:()=>Sc,set:e=>Sc=e},yc="Too much output to announce, navigate to rows manually to read",gl={get:()=>yc,set:e=>yc=e};function Gg(e){return e.replace(/\r?\n/g,"\r")}function Xg(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Qg(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Jg(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");pf(r,t,i,s)}}function pf(e,t,i,s){e=Gg(e),e=Xg(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function gf(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function wc(e,t,i,s,r){gf(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ls(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ma(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var $g=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let l=e.charCodeAt(n);56320<=l&&l<=57343?t[s++]=(o-55296)*1024+l-56320+65536:(t[s++]=o,t[s++]=l);continue}o!==65279&&(t[s++]=o)}return s}},Zg=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,l,c=0,h=0;if(this.interim[0]){let f=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let g=0,b;for(;(b=this.interim[++g]&63)&&g<4;)v<<=6,v|=b;let p=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,w=p-g;for(;h<w;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,f=!0;break}else this.interim[g++]=b,v<<=6,v|=b&63}f||(p===2?v<128?h--:t[s++]=v:p===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let d=i-4,u=h;for(;u<i;){for(;u<d&&!((r=e[u])&128)&&!((n=e[u+1])&128)&&!((o=e[u+2])&128)&&!((l=e[u+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=l,u+=4;if(r=e[u++],r<128)t[s++]=r;else if((r&224)===192){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(c=(r&31)<<6|n&63,c<128){u--;continue}t[s++]=c}else if((r&240)===224){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(c=(r&15)<<12|(n&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[s++]=c}else if((r&248)===240){if(u>=i)return this.interim[0]=r,s;if(n=e[u++],(n&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[u++],(o&192)!==128){u--;continue}if(u>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(l=e[u++],(l&192)!==128){u--;continue}if(c=(r&7)<<18|(n&63)<<12|(o&63)<<6|l&63,c<65536||c>1114111)continue;t[s++]=c}}return s}},mf="",js=" ",yo=class bf{constructor(){this.fg=0,this.bg=0,this.extended=new $o}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new bf;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},$o=class Sf{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Sf(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Di=class yf extends yo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new $o,this.combinedData=""}static fromCharData(t){let i=new yf;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ls(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Cc="di$target",ml="di$dependencies",Ia=new Map;function em(e){return e[ml]||[]}function Rt(e){if(Ia.has(e))return Ia.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");tm(t,i,r)};return t._id=e,Ia.set(e,t),t}function tm(e,t,i){t[Cc]===t?t[ml].push({id:e,index:i}):(t[ml]=[{id:e,index:i}],t[Cc]=t)}var jt=Rt("BufferService"),wf=Rt("CoreMouseService"),zr=Rt("CoreService"),im=Rt("CharsetService"),Bh=Rt("InstantiationService"),Cf=Rt("LogService"),Vt=Rt("OptionsService"),kf=Rt("OscLinkService"),sm=Rt("UnicodeService"),wo=Rt("DecorationService"),bl=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var d;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Di,o=i.getTrimmedLength(),l=-1,c=-1,h=!1;for(let u=0;u<o;u++)if(!(c===-1&&!i.hasContent(u))){if(i.loadCell(u,n),n.hasExtendedAttrs()&&n.extended.urlId)if(c===-1){c=u,l=n.extended.urlId;continue}else h=n.extended.urlId!==l;else c!==-1&&(h=!0);if(h||c!==-1&&u===o-1){let f=(d=this._oscLinkService.getLinkData(l))==null?void 0:d.uri;if(f){let v={start:{x:c+1,y:e},end:{x:u+(!h&&u===o-1?1:0),y:e}},g=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let b=new URL(f);["http:","https:"].includes(b.protocol)||(g=!0)}catch{g=!0}g||s.push({text:f,range:v,activate:(b,p)=>r?r.activate(b,p,v):rm(b,p),hover:(b,p)=>{var w;return(w=r==null?void 0:r.hover)==null?void 0:w.call(r,b,p,v)},leave:(b,p)=>{var w;return(w=r==null?void 0:r.leave)==null?void 0:w.call(r,b,p,v)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(c=u,l=n.extended.urlId):(c=-1,l=-1)}}t(s)}};bl=at([ue(0,jt),ue(1,Vt),ue(2,kf)],bl);function rm(e,t){if(confirm(`Do you want to navigate to ${t}?
22
-
23
- WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var ba=Rt("CharSizeService"),xs=Rt("CoreBrowserService"),Lh=Rt("MouseService"),Es=Rt("RenderService"),nm=Rt("SelectionService"),xf=Rt("CharacterJoinerService"),Pn=Rt("ThemeService"),Ef=Rt("LinkProviderService"),om=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?kc.isErrorNoTelemetry(e)?new kc(e.message+`
24
-
25
- `+e.stack):new Error(e.message+`
26
-
27
- `+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)}},am=new om;function zo(e){lm(e)||am.onUnexpectedError(e)}var Sl="Canceled";function lm(e){return e instanceof hm?!0:e instanceof Error&&e.name===Sl&&e.message===Sl}var hm=class extends Error{constructor(){super(Sl),this.name=this.message}};function cm(e){return new Error(`Illegal argument: ${e}`)}var kc=class yl extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof yl)return t;let i=new yl;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},wl=class Pf extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Pf.prototype)}};function ni(e,t=0){return e[e.length-(1+t)]}var um;(e=>{function t(n){return n<0}e.isLessThan=t;function i(n){return n<=0}e.isLessThanOrEqual=i;function s(n){return n>0}e.isGreaterThan=s;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(um||(um={}));function dm(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Rf;(e=>{function t(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(y){yield y}e.single=r;function n(y){return t(y)?y:r(y)}e.wrap=n;function o(y){return y||i}e.from=o;function*l(y){for(let C=y.length-1;C>=0;C--)yield y[C]}e.reverse=l;function c(y){return!y||y[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(y){return y[Symbol.iterator]().next().value}e.first=h;function d(y,C){let L=0;for(let z of y)if(C(z,L++))return!0;return!1}e.some=d;function u(y,C){for(let L of y)if(C(L))return L}e.find=u;function*f(y,C){for(let L of y)C(L)&&(yield L)}e.filter=f;function*v(y,C){let L=0;for(let z of y)yield C(z,L++)}e.map=v;function*g(y,C){let L=0;for(let z of y)yield*C(z,L++)}e.flatMap=g;function*b(...y){for(let C of y)yield*C}e.concat=b;function p(y,C,L){let z=L;for(let Y of y)z=C(z,Y);return z}e.reduce=p;function*w(y,C,L=y.length){for(C<0&&(C+=y.length),L<0?L+=y.length:L>y.length&&(L=y.length);C<L;C++)yield y[C]}e.slice=w;function R(y,C=Number.POSITIVE_INFINITY){let L=[];if(C===0)return[L,y];let z=y[Symbol.iterator]();for(let Y=0;Y<C;Y++){let J=z.next();if(J.done)return[L,e.empty()];L.push(J.value)}return[L,{[Symbol.iterator](){return z}}]}e.consume=R;async function x(y){let C=[];for await(let L of y)C.push(L);return Promise.resolve(C)}e.asyncToArray=x})(Rf||(Rf={}));function Fr(e){if(Rf.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function fm(...e){return et(()=>Fr(e))}function et(e){return{dispose:dm(()=>{e()})}}var Df=class Tf{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Fr(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Tf.DISABLE_DISPOSED_WARNING||console.warn(new 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(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Df.DISABLE_DISPOSED_WARNING=!1;var Js=Df,Oe=class{constructor(){this._store=new Js,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Oe.None=Object.freeze({dispose(){}});var yn=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},gs=typeof window=="object"?window:globalThis,Cl=class kl{constructor(t){this.element=t,this.next=kl.Undefined,this.prev=kl.Undefined}};Cl.Undefined=new Cl(void 0);var it=Cl,xc=class{constructor(){this._first=it.Undefined,this._last=it.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===it.Undefined}clear(){let e=this._first;for(;e!==it.Undefined;){let t=e.next;e.prev=it.Undefined,e.next=it.Undefined,e=t}this._first=it.Undefined,this._last=it.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new it(e);if(this._first===it.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==it.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==it.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==it.Undefined&&e.next!==it.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===it.Undefined&&e.next===it.Undefined?(this._first=it.Undefined,this._last=it.Undefined):e.next===it.Undefined?(this._last=this._last.prev,this._last.next=it.Undefined):e.prev===it.Undefined&&(this._first=this._first.next,this._first.prev=it.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==it.Undefined;)yield e.element,e=e.next}},_m=globalThis.performance&&typeof globalThis.performance.now=="function",vm=class Mf{static create(t){return new Mf(t)}constructor(t){this._now=_m&&t===!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._stopTime-this._startTime:this._now()-this._startTime}},At;(e=>{e.None=()=>Oe.None;function t(N,B){return u(N,()=>{},0,void 0,!0,void 0,B)}e.defer=t;function i(N){return(B,M=null,T)=>{let j=!1,D;return D=N(P=>{if(!j)return D?D.dispose():j=!0,B.call(M,P)},null,T),j&&D.dispose(),D}}e.once=i;function s(N,B,M){return h((T,j=null,D)=>N(P=>T.call(j,B(P)),null,D),M)}e.map=s;function r(N,B,M){return h((T,j=null,D)=>N(P=>{B(P),T.call(j,P)},null,D),M)}e.forEach=r;function n(N,B,M){return h((T,j=null,D)=>N(P=>B(P)&&T.call(j,P),null,D),M)}e.filter=n;function o(N){return N}e.signal=o;function l(...N){return(B,M=null,T)=>{let j=fm(...N.map(D=>D(P=>B.call(M,P))));return d(j,T)}}e.any=l;function c(N,B,M,T){let j=M;return s(N,D=>(j=B(j,D),j),T)}e.reduce=c;function h(N,B){let M,T={onWillAddFirstListener(){M=N(j.fire,j)},onDidRemoveLastListener(){M==null||M.dispose()}},j=new te(T);return B==null||B.add(j),j.event}function d(N,B){return B instanceof Array?B.push(N):B&&B.add(N),N}function u(N,B,M=100,T=!1,j=!1,D,P){let U,Z,me,be=0,fe,ke={leakWarningThreshold:D,onWillAddFirstListener(){U=N(Ce=>{be++,Z=B(Z,Ce),T&&!me&&(Ee.fire(Z),Z=void 0),fe=()=>{let $=Z;Z=void 0,me=void 0,(!T||be>1)&&Ee.fire($),be=0},typeof M=="number"?(clearTimeout(me),me=setTimeout(fe,M)):me===void 0&&(me=0,queueMicrotask(fe))})},onWillRemoveListener(){j&&be>0&&(fe==null||fe())},onDidRemoveLastListener(){fe=void 0,U.dispose()}},Ee=new te(ke);return P==null||P.add(Ee),Ee.event}e.debounce=u;function f(N,B=0,M){return e.debounce(N,(T,j)=>T?(T.push(j),T):[j],B,void 0,!0,void 0,M)}e.accumulate=f;function v(N,B=(T,j)=>T===j,M){let T=!0,j;return n(N,D=>{let P=T||!B(D,j);return T=!1,j=D,P},M)}e.latch=v;function g(N,B,M){return[e.filter(N,B,M),e.filter(N,T=>!B(T),M)]}e.split=g;function b(N,B=!1,M=[],T){let j=M.slice(),D=N(Z=>{j?j.push(Z):U.fire(Z)});T&&T.add(D);let P=()=>{j==null||j.forEach(Z=>U.fire(Z)),j=null},U=new te({onWillAddFirstListener(){D||(D=N(Z=>U.fire(Z)),T&&T.add(D))},onDidAddFirstListener(){j&&(B?setTimeout(P):P())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return T&&T.add(U),U.event}e.buffer=b;function p(N,B){return(M,T,j)=>{let D=B(new R);return N(function(P){let U=D.evaluate(P);U!==w&&M.call(T,U)},void 0,j)}}e.chain=p;let w=Symbol("HaltChainable");class R{constructor(){this.steps=[]}map(B){return this.steps.push(B),this}forEach(B){return this.steps.push(M=>(B(M),M)),this}filter(B){return this.steps.push(M=>B(M)?M:w),this}reduce(B,M){let T=M;return this.steps.push(j=>(T=B(T,j),T)),this}latch(B=(M,T)=>M===T){let M=!0,T;return this.steps.push(j=>{let D=M||!B(j,T);return M=!1,T=j,D?j:w}),this}evaluate(B){for(let M of this.steps)if(B=M(B),B===w)break;return B}}function x(N,B,M=T=>T){let T=(...U)=>P.fire(M(...U)),j=()=>N.on(B,T),D=()=>N.removeListener(B,T),P=new te({onWillAddFirstListener:j,onDidRemoveLastListener:D});return P.event}e.fromNodeEventEmitter=x;function y(N,B,M=T=>T){let T=(...U)=>P.fire(M(...U)),j=()=>N.addEventListener(B,T),D=()=>N.removeEventListener(B,T),P=new te({onWillAddFirstListener:j,onDidRemoveLastListener:D});return P.event}e.fromDOMEventEmitter=y;function C(N){return new Promise(B=>i(N)(B))}e.toPromise=C;function L(N){let B=new te;return N.then(M=>{B.fire(M)},()=>{B.fire(void 0)}).finally(()=>{B.dispose()}),B.event}e.fromPromise=L;function z(N,B){return N(M=>B.fire(M))}e.forward=z;function Y(N,B,M){return B(M),N(T=>B(T))}e.runAndSubscribe=Y;class J{constructor(B,M){this._observable=B,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{B.addObserver(this)},onDidRemoveLastListener:()=>{B.removeObserver(this)}};this.emitter=new te(T),M&&M.add(this.emitter)}beginUpdate(B){this._counter++}handlePossibleChange(B){}handleChange(B,M){this._hasChanged=!0}endUpdate(B){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function ae(N,B){return new J(N,B).emitter.event}e.fromObservable=ae;function X(N){return(B,M,T)=>{let j=0,D=!1,P={beginUpdate(){j++},endUpdate(){j--,j===0&&(N.reportChanges(),D&&(D=!1,B.call(M)))},handlePossibleChange(){},handleChange(){D=!0}};N.addObserver(P),N.reportChanges();let U={dispose(){N.removeObserver(P)}};return T instanceof Js?T.add(U):Array.isArray(T)&&T.push(U),U}}e.fromObservableLight=X})(At||(At={}));var xl=class El{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${El._idPool++}`,El.all.add(this)}start(t){this._stopWatch=new vm,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};xl.all=new Set,xl._idPool=0;var pm=xl,gm=-1,Bf=class Lf{constructor(t,i,s=(Lf._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let c=new Sm(l,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,r]of this._stacks)(!t||i<r)&&(t=[s,r],i=r);return t}};Bf._idPool=1;var mm=Bf,bm=class Af{constructor(t){this.value=t}static create(){let t=new Error;return new Af(t.stack??"")}print(){console.warn(this.value.split(`
28
- `).slice(2).join(`
29
- `))}},Sm=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ym=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},wm=0,Na=class{constructor(e){this.value=e,this.id=wm++}},Cm=2,km,te=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new mm((e==null?void 0:e.onListenerError)??zo,((i=this._options)==null?void 0:i.leakWarningThreshold)??gm):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new pm(this._options._profName):void 0,this._deliveryQueue=(r=this._options)==null?void 0:r.deliveryQueue}dispose(){var e,t,i,s;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||i.call(t),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(e,t,i)=>{var o,l,c,h,d;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let f=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],v=new ym(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||zo)(v),Oe.None}if(this._disposed)return Oe.None;t&&(e=e.bind(t));let s=new Na(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=bm.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Na?(this._deliveryQueue??(this._deliveryQueue=new xm),this._listeners=[this._listeners,s]):this._listeners.push(s):((c=(l=this._options)==null?void 0:l.onWillAddFirstListener)==null||c.call(l,this),this._listeners=s,(d=(h=this._options)==null?void 0:h.onDidAddFirstListener)==null||d.call(h,this)),this._size++;let n=et(()=>{r==null||r(),this._removeListener(s)});return i instanceof Js?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,l;if((n=(r=this._options)==null?void 0:r.onWillRemoveListener)==null||n.call(r,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(l=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||l.call(o,this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*Cm<=t.length){let c=0;for(let h=0;h<t.length;h++)t[h]?t[c++]=t[h]:s&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=c}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||zo;if(!i){e.value(t);return}try{e.value(t)}catch(r){i(r)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,i,s,r;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof Na)this._deliver(this._listeners,e);else{let n=this._deliveryQueue;n.enqueue(this,e,this._listeners.length),this._deliverQueue(n)}(r=this._perfMon)==null||r.stop()}hasListeners(){return this._size>0}},xm=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Pl=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new te,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new te,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Pl.INSTANCE=new Pl;var Ah=Pl;function Em(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Ah.INSTANCE.onDidChangeZoomLevel;function Pm(e){return Ah.INSTANCE.getZoomFactor(e)}Ah.INSTANCE.onDidChangeFullscreen;var Rn=typeof navigator=="object"?navigator.userAgent:"",Rl=Rn.indexOf("Firefox")>=0,Rm=Rn.indexOf("AppleWebKit")>=0,Oh=Rn.indexOf("Chrome")>=0,Dm=!Oh&&Rn.indexOf("Safari")>=0;Rn.indexOf("Electron/")>=0;Rn.indexOf("Android")>=0;var Fa=!1;if(typeof gs.matchMedia=="function"){let e=gs.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=gs.matchMedia("(display-mode: fullscreen)");Fa=e.matches,Em(gs,e,({matches:i})=>{Fa&&t.matches||(Fa=i)})}var Vr="en",Dl=!1,Tl=!1,Uo=!1,Of=!1,Mo,Ko=Vr,Ec=Vr,Tm,Ai,Lr=globalThis,Bt,Ru;typeof Lr.vscode<"u"&&typeof Lr.vscode.process<"u"?Bt=Lr.vscode.process:typeof process<"u"&&typeof((Ru=process==null?void 0:process.versions)==null?void 0:Ru.node)=="string"&&(Bt=process);var Du,Mm=typeof((Du=Bt==null?void 0:Bt.versions)==null?void 0:Du.electron)=="string",Bm=Mm&&(Bt==null?void 0:Bt.type)==="renderer",Tu;if(typeof Bt=="object"){Dl=Bt.platform==="win32",Tl=Bt.platform==="darwin",Uo=Bt.platform==="linux",Uo&&Bt.env.SNAP&&Bt.env.SNAP_REVISION,Bt.env.CI||Bt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Mo=Vr,Ko=Vr;let e=Bt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Mo=t.userLocale,Ec=t.osLocale,Ko=t.resolvedLanguage||Vr,Tm=(Tu=t.languagePack)==null?void 0:Tu.translationsConfigFile}catch{}Of=!0}else typeof navigator=="object"&&!Bm?(Ai=navigator.userAgent,Dl=Ai.indexOf("Windows")>=0,Tl=Ai.indexOf("Macintosh")>=0,(Ai.indexOf("Macintosh")>=0||Ai.indexOf("iPad")>=0||Ai.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Uo=Ai.indexOf("Linux")>=0,(Ai==null?void 0:Ai.indexOf("Mobi"))>=0,Ko=globalThis._VSCODE_NLS_LANGUAGE||Vr,Mo=navigator.language.toLowerCase(),Ec=Mo):console.error("Unable to resolve platform.");var If=Dl,rs=Tl,Lm=Uo,Pc=Of,os=Ai,Ds=Ko,Am;(e=>{function t(){return Ds}e.value=t;function i(){return Ds.length===2?Ds==="en":Ds.length>=3?Ds[0]==="e"&&Ds[1]==="n"&&Ds[2]==="-":!1}e.isDefaultVariant=i;function s(){return Ds==="en"}e.isDefault=s})(Am||(Am={}));var Om=typeof Lr.postMessage=="function"&&!Lr.importScripts;(()=>{if(Om){let e=[];Lr.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),Lr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Im=!!(os&&os.indexOf("Chrome")>=0);os&&os.indexOf("Firefox")>=0;!Im&&os&&os.indexOf("Safari")>=0;os&&os.indexOf("Edg/")>=0;os&&os.indexOf("Android")>=0;var qr=typeof navigator=="object"?navigator:{};Pc||document.queryCommandSupported&&document.queryCommandSupported("copy")||qr&&qr.clipboard&&qr.clipboard.writeText,Pc||qr&&qr.clipboard&&qr.clipboard.readText;var Ih=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}},Wa=new Ih,Rc=new Ih,Dc=new Ih,Nm=new Array(230),Nf;(e=>{function t(l){return Wa.keyCodeToStr(l)}e.toString=t;function i(l){return Wa.strToKeyCode(l)}e.fromString=i;function s(l){return Rc.keyCodeToStr(l)}e.toUserSettingsUS=s;function r(l){return Dc.keyCodeToStr(l)}e.toUserSettingsGeneral=r;function n(l){return Rc.strToKeyCode(l)||Dc.strToKeyCode(l)}e.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Wa.keyCodeToStr(l)}e.toElectronAccelerator=o})(Nf||(Nf={}));var Fm=class Ff{constructor(t,i,s,r,n){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof Ff&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${i}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Wm([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Wm=class{constructor(e){if(e.length===0)throw cm("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;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 Hm(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Nf.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Rl)switch(t){case 59:return 85;case 60:if(Lm)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(rs)return 57;break}else if(Rm&&(rs&&t===93||!rs&&t===92))return 57;return Nm[t]||0}var zm=rs?256:2048,Um=512,Km=1024,qm=rs?2048:256,Tc=class{constructor(e){var i;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=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=Hm(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|=zm),this.altKey&&(t|=Um),this.shiftKey&&(t|=Km),this.metaKey&&(t|=qm),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Fm(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Mc=new WeakMap;function jm(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Vm=class{static getSameOriginWindowChain(e){let t=Mc.get(e);if(!t){t=[],Mc.set(e,t);let i=e,s;do s=jm(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,r=this.getSameOriginWindowChain(e);for(let n of r){let o=n.window.deref();if(i+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===t||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();i+=l.top,s+=l.left}return{top:i,left:s}}},Bo=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 i=Vm.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Bc=class{constructor(e,t=0,i=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Oh){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,l=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*l):this.deltaY=n.wheelDeltaY/120;else if(typeof o.VERTICAL_AXIS<"u"&&o.axis===o.VERTICAL_AXIS)this.deltaY=-o.detail/3;else if(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?Rl&&!rs?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Dm&&If?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*l):this.deltaX=n.wheelDeltaX/120;else if(typeof o.HORIZONTAL_AXIS<"u"&&o.axis===o.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let c=e;c.deltaMode===c.DOM_DELTA_LINE?Rl&&!rs?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Wf=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Ym;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Gm?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:At.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Wf})})(Ym||(Ym={}));var Gm=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?Wf:(this._emitter||(this._emitter=new te),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Nh=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 wl("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new wl("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Xm=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new wl("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=et(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Qm;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})(Qm||(Qm={}));var Lc=class mi{static fromArray(t){return new mi(i=>{i.emitMany(t)})}static fromPromise(t){return new mi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new mi(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new mi(async i=>{await Promise.all(t.map(async s=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new te,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await At.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new mi(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return mi.map(this,t)}static filter(t,i){return new mi(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return mi.filter(this,t)}static coalesce(t){return mi.filter(t,i=>!!i)}coalesce(){return mi.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return mi.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Lc.EMPTY=Lc.fromArray([]);var{getWindow:ts,getWindowId:Jm,onDidRegisterWindow:$m}=(function(){let e=new Map,t={window:gs,disposables:new Js};e.set(gs.vscodeWindowId,t);let i=new te,s=new te,r=new te;function n(o,l){return(typeof o=="number"?e.get(o):void 0)??(l?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Oe.None;let l=new Js,c={window:o,disposables:l.add(new Js)};return e.set(o.vscodeWindowId,c),l.add(et(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),l.add(Pe(o,wt.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(c),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var h;let l=o;if((h=l==null?void 0:l.ownerDocument)!=null&&h.defaultView)return l.ownerDocument.defaultView.window;let c=o;return c!=null&&c.view?c.view.window:gs},getDocument(o){return ts(o).document}}})(),Zm=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!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,this._handler=null)}};function Pe(e,t,i,s){return new Zm(e,t,i,s)}var Ac=function(e,t,i,s){return Pe(e,t,i,s)},Fh,eb=class extends Xm{constructor(e){super(),this.defaultTarget=e&&ts(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Oc=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){zo(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,r=n=>{i.set(n,!1);let o=e.get(n)??[];for(t.set(n,o),e.set(n,[]),s.set(n,!0);o.length>0;)o.sort(Oc.sort),o.shift().execute();s.set(n,!1)};Fh=(n,o,l=0)=>{let c=Jm(n),h=new Oc(o,l),d=e.get(c);return d||(d=[],e.set(c,d)),d.push(h),i.get(c)||(i.set(c,!0),n.requestAnimationFrame(()=>r(c))),h}})();function tb(e){let t=e.getBoundingClientRect(),i=ts(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var wt={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},ib=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=Xt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Xt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Xt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Xt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Xt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Xt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Xt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Xt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Xt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Xt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Xt(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=Xt(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=Xt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Xt(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 Xt(e){return typeof e=="number"?`${e}px`:e}function Qn(e){return new ib(e)}var Hf=class{constructor(){this._hooks=new Js,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 i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(et(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=ts(e)}this._hooks.add(Pe(n,wt.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Pe(n,wt.POINTER_UP,o=>this.stopMonitoring(!0)))}};function sb(e,t,i){let s=null,r=null;if(typeof i.value=="function"?(s="value",r=i.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",r=i.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;i[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Gi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Gi||(Gi={}));var Fn=class Wt extends Oe{constructor(){super(),this.dispatched=!1,this.targets=new xc,this.ignoreTargets=new xc,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(At.runAndSubscribe($m,({window:t,disposables:i})=>{i.add(Pe(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Pe(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Pe(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:gs,disposables:this._store}))}static addTarget(t){if(!Wt.isTouchDevice())return Oe.None;Wt.INSTANCE||(Wt.INSTANCE=new Wt);let i=Wt.INSTANCE.targets.push(t);return et(i)}static ignoreTarget(t){if(!Wt.isTouchDevice())return Oe.None;Wt.INSTANCE||(Wt.INSTANCE=new Wt);let i=Wt.INSTANCE.ignoreTargets.push(t);return et(i)}static isTouchDevice(){return"ontouchstart"in gs||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=t.targetTouches.length;s<r;s++){let n=t.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:i,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[i],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Gi.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=i.changedTouches.length;n<o;n++){let l=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],h=Date.now()-c.initialTimeStamp;if(h<Wt.HOLD_DELAY&&Math.abs(c.initialPageX-ni(c.rollingPageX))<30&&Math.abs(c.initialPageY-ni(c.rollingPageY))<30){let d=this.newGestureEvent(Gi.Tap,c.initialTarget);d.pageX=ni(c.rollingPageX),d.pageY=ni(c.rollingPageY),this.dispatchEvent(d)}else if(h>=Wt.HOLD_DELAY&&Math.abs(c.initialPageX-ni(c.rollingPageX))<30&&Math.abs(c.initialPageY-ni(c.rollingPageY))<30){let d=this.newGestureEvent(Gi.Contextmenu,c.initialTarget);d.pageX=ni(c.rollingPageX),d.pageY=ni(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=ni(c.rollingPageX),u=ni(c.rollingPageY),f=ni(c.rollingTimestamps)-c.rollingTimestamps[0],v=d-c.rollingPageX[0],g=u-c.rollingPageY[0],b=[...this.targets].filter(p=>c.initialTarget instanceof Node&&p.contains(c.initialTarget));this.inertia(t,b,s,Math.abs(v)/f,v>0?1:-1,d,Math.abs(g)/f,g>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Gi.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===Gi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Wt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Gi.Change||t.type===Gi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;i.push([r,s])}i.sort((s,r)=>s[0]-r[0]);for(let[s,r]of i)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,r,n,o,l,c,h){this.handle=Fh(t,()=>{let d=Date.now(),u=d-s,f=0,v=0,g=!0;r+=Wt.SCROLL_FRICTION*u,l+=Wt.SCROLL_FRICTION*u,r>0&&(g=!1,f=n*r*u),l>0&&(g=!1,v=c*l*u);let b=this.newGestureEvent(Gi.Change);b.translationX=f,b.translationY=v,i.forEach(p=>p.dispatchEvent(b)),g||this.inertia(t,i,d,r,n,o+f,l,c,h+v)})}onTouchMove(t){let i=Date.now();for(let s=0,r=t.changedTouches.length;s<r;s++){let n=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],l=this.newGestureEvent(Gi.Change,o.initialTarget);l.translationX=n.pageX-ni(o.rollingPageX),l.translationY=n.pageY-ni(o.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Fn.SCROLL_FRICTION=-.005,Fn.HOLD_DELAY=700,Fn.CLEAR_TAP_COUNT_TIME=400,at([sb],Fn,"isTouchDevice",1);var rb=Fn,Wh=class extends Oe{onclick(e,t){this._register(Pe(e,wt.CLICK,i=>t(new Bo(ts(e),i))))}onmousedown(e,t){this._register(Pe(e,wt.MOUSE_DOWN,i=>t(new Bo(ts(e),i))))}onmouseover(e,t){this._register(Pe(e,wt.MOUSE_OVER,i=>t(new Bo(ts(e),i))))}onmouseleave(e,t){this._register(Pe(e,wt.MOUSE_LEAVE,i=>t(new Bo(ts(e),i))))}onkeydown(e,t){this._register(Pe(e,wt.KEY_DOWN,i=>t(new Tc(i))))}onkeyup(e,t){this._register(Pe(e,wt.KEY_UP,i=>t(new Tc(i))))}oninput(e,t){this._register(Pe(e,wt.INPUT,t))}onblur(e,t){this._register(Pe(e,wt.BLUR,t))}onfocus(e,t){this._register(Pe(e,wt.FOCUS,t))}onchange(e,t){this._register(Pe(e,wt.CHANGE,t))}ignoreGesture(e){return rb.ignoreTarget(e)}},Ic=11,nb=class extends Wh{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=Ic+"px",this.domNode.style.height=Ic+"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 Hf),this._register(Ac(this.bgDomNode,wt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Ac(this.domNode,wt.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new eb),this._pointerdownScheduleRepeatTimer=this._register(new Nh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ts(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},ob=class Ml{constructor(t,i,s,r,n,o,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Ml(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ml(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(t,i){let s=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,o=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:c}}},ab=class extends Oe{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new ob(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.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(),this._smoothScrolling=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 i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new Fc(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Fc.start(this._state,i,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 i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},Nc=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Ha(e,t){let i=t-e;return function(s){return e+i*cb(s)}}function lb(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Fc=class Bl{constructor(t,i,s,r){this.from=t,this.to=i,this.duration=r,this.startTime=s,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(t,i,s){if(Math.abs(t-i)>2.5*s){let r,n;return t<i?(r=t+.75*s,n=i-.75*s):(r=t-.75*s,n=i+.75*s),lb(Ha(t,r),Ha(n,i),.33)}return Ha(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),r=this.scrollTop(i);return new Nc(s,r,!1)}return new Nc(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Bl.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Bl(t,i,r,s)}};function hb(e){return Math.pow(e,3)}function cb(e){return 1-hb(1-e)}var ub=class extends Oe{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Nh)}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?!0: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(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},db=140,zf=class extends Wh{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 ub(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Hf),this._shouldRender=!0,this.domNode=Qn(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(Pe(this.domNode.domNode,wt.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new nb(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Qn(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Pe(this.slider.domNode,wt.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.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,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);i<=r&&r<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let r=tb(this.domNode.domNode);t=e.pageX-r.left,i=e.pageY-r.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),o=Math.abs(n-i);if(If&&o>db){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let l=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(l))},()=>{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()}},Uf=class Ll{constructor(t,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ll(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,r,n){let o=Math.max(0,s-t),l=Math.max(0,o-2*i),c=r>0&&r>s;if(!c)return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*l/r))),d=(l-h)/(r-s),u=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(h),computedSliderRatio:d,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=Ll._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(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},fb=class extends zf{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Uf(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new 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}},_b=class extends zf{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Uf(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new 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}},vb=500,Wc=50,pb=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Al=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-s);if(t-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Oh){let i=ts(t.browserEvent),s=Pm(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let r=null,n=new pb(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,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]=n),n.score=this._computeScore(n,r)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),o=Math.abs(i.deltaX),l=Math.abs(i.deltaY),c=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,l),1),d=Math.max(r,o),u=Math.max(n,l);d%c===0&&u%h===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Al.INSTANCE=new Al;var gb=Al,mb=class extends Wh{constructor(e,t,i){super(),this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new te),this.onWillScroll=this._onWillScroll.event,this._options=Sb(t),this._scrollable=i,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new _b(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new fb(this._scrollable,this._options,s)),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=Qn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Qn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Qn(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,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new Nh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Fr(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,rs&&(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 Bc(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Fr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Bc(i))};this._mouseWheelToDispose.push(Pe(this._listenOnDomNode,wt.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=gb.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!rs&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let c=this._scrollable.getFutureScrollPosition(),h={};if(n){let d=Wc*n,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let d=Wc*o,u=c.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(h,u)}h=this._scrollable.validateScrollPosition(h),(c.scrollLeft!==h.scrollLeft||c.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(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 new 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,i=e.scrollLeft>0,s=i?" left":"",r=t?" top":"",n=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_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(),vb)}},bb=class extends mb{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Sb(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,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:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,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:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,rs&&(t.className+=" mac"),t}var Ol=class extends Oe{constructor(e,t,i,s,r,n,o,l){super(),this._bufferService=i,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new ab({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Fh(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new bb(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(r.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(At.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(et(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(et(()=>this._styleElement.remove())),this._register(At.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
30
- `)})),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(h=>this._handleScroll(h)))}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(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.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),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};Ol=at([ue(2,jt),ue(3,xs),ue(4,wf),ue(5,Pn),ue(6,Vt),ue(7,Es)],Ol);var Il=class extends Oe{constructor(e,t,i,s,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=r,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(n=>this._removeDecoration(n))),this._register(et(()=>{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){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.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 i=e.options.x??0;return i&&i>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 i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Il=at([ue(1,jt),ue(2,xs),ue(3,wo),ue(4,Es)],Il);var yb=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,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},Vi={full:0,left:0,center:0,right:0},Ts={full:0,left:0,center:0,right:0},Mn={full:0,left:0,center:0,right:0},Zo=class extends Oe{constructor(e,t,i,s,r,n,o,l){var h;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=l,this._colorZoneStore=new yb,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(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(et(()=>{var d;return(d=this._canvas)==null?void 0:d.remove()}));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new 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(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ts.full=this._canvas.width,Ts.left=e,Ts.center=t,Ts.right=e,this._refreshDrawHeightConstants(),Mn.full=1,Mn.left=1,Mn.center=1+Ts.left,Mn.right=1+Ts.left+Ts.center}_refreshDrawHeightConstants(){Vi.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);Vi.left=t,Vi.center=t,Vi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Vi.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 t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);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(Mn[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Vi[e.position||"full"]/2),Ts[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Vi[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}))}};Zo=at([ue(2,jt),ue(3,wo),ue(4,Es),ue(5,Vt),ue(6,Pn),ue(7,xs)],Zo);var q;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
31
- `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(q||(q={}));var qo;(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="Ÿ"))(qo||(qo={}));var Kf;(e=>e.ST=`${q.ESC}\\`)(Kf||(Kf={}));var Nl=class{constructor(e,t,i,s,r,n){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=r,this._renderService=n,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):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${q.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Nl=at([ue(2,jt),ue(3,Vt),ue(4,zr),ue(5,Es)],Nl);var Ct=0,kt=0,xt=0,nt=0,Hc={css:"#00000000",rgba:0},ft;(e=>{function t(r,n,o,l){return l!==void 0?`#${rr(r)}${rr(n)}${rr(o)}${rr(l)}`:`#${rr(r)}${rr(n)}${rr(o)}`}e.toCss=t;function i(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}e.toRgba=i;function s(r,n,o,l){return{css:e.toCss(r,n,o,l),rgba:e.toRgba(r,n,o,l)}}e.toColor=s})(ft||(ft={}));var Je;(e=>{function t(c,h){if(nt=(h.rgba&255)/255,nt===1)return{css:h.css,rgba:h.rgba};let d=h.rgba>>24&255,u=h.rgba>>16&255,f=h.rgba>>8&255,v=c.rgba>>24&255,g=c.rgba>>16&255,b=c.rgba>>8&255;Ct=v+Math.round((d-v)*nt),kt=g+Math.round((u-g)*nt),xt=b+Math.round((f-b)*nt);let p=ft.toCss(Ct,kt,xt),w=ft.toRgba(Ct,kt,xt);return{css:p,rgba:w}}e.blend=t;function i(c){return(c.rgba&255)===255}e.isOpaque=i;function s(c,h,d){let u=jo.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return ft.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(c){let h=(c.rgba|255)>>>0;return[Ct,kt,xt]=jo.toChannels(h),{css:ft.toCss(Ct,kt,xt),rgba:h}}e.opaque=r;function n(c,h){return nt=Math.round(h*255),[Ct,kt,xt]=jo.toChannels(c.rgba),{css:ft.toCss(Ct,kt,xt,nt),rgba:ft.toRgba(Ct,kt,xt,nt)}}e.opacity=n;function o(c,h){return nt=c.rgba&255,n(c,nt*h/255)}e.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=l})(Je||(Je={}));var st;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ct=parseInt(r.slice(1,2).repeat(2),16),kt=parseInt(r.slice(2,3).repeat(2),16),xt=parseInt(r.slice(3,4).repeat(2),16),ft.toColor(Ct,kt,xt);case 5:return Ct=parseInt(r.slice(1,2).repeat(2),16),kt=parseInt(r.slice(2,3).repeat(2),16),xt=parseInt(r.slice(3,4).repeat(2),16),nt=parseInt(r.slice(4,5).repeat(2),16),ft.toColor(Ct,kt,xt,nt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Ct=parseInt(n[1]),kt=parseInt(n[2]),xt=parseInt(n[3]),nt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ft.toColor(Ct,kt,xt,nt);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ct,kt,xt,nt]=t.getImageData(0,0,1,1).data,nt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ft.toRgba(Ct,kt,xt,nt),css:r}}e.toColor=s})(st||(st={}));var Kt;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,r,n){let o=s/255,l=r/255,c=n/255,h=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),u=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return h*.2126+d*.7152+u*.0722}e.relativeLuminance2=i})(Kt||(Kt={}));var jo;(e=>{function t(o,l){if(nt=(l&255)/255,nt===1)return l;let c=l>>24&255,h=l>>16&255,d=l>>8&255,u=o>>24&255,f=o>>16&255,v=o>>8&255;return Ct=u+Math.round((c-u)*nt),kt=f+Math.round((h-f)*nt),xt=v+Math.round((d-v)*nt),ft.toRgba(Ct,kt,xt)}e.blend=t;function i(o,l,c){let h=Kt.relativeLuminance(o>>8),d=Kt.relativeLuminance(l>>8);if(ls(h,d)<c){if(d<h){let v=s(o,l,c),g=ls(h,Kt.relativeLuminance(v>>8));if(g<c){let b=r(o,l,c),p=ls(h,Kt.relativeLuminance(b>>8));return g>p?v:b}return v}let u=r(o,l,c),f=ls(h,Kt.relativeLuminance(u>>8));if(f<c){let v=s(o,l,c),g=ls(h,Kt.relativeLuminance(v>>8));return f>g?u:v}return u}}e.ensureContrastRatio=i;function s(o,l,c){let h=o>>24&255,d=o>>16&255,u=o>>8&255,f=l>>24&255,v=l>>16&255,g=l>>8&255,b=ls(Kt.relativeLuminance2(f,v,g),Kt.relativeLuminance2(h,d,u));for(;b<c&&(f>0||v>0||g>0);)f-=Math.max(0,Math.ceil(f*.1)),v-=Math.max(0,Math.ceil(v*.1)),g-=Math.max(0,Math.ceil(g*.1)),b=ls(Kt.relativeLuminance2(f,v,g),Kt.relativeLuminance2(h,d,u));return(f<<24|v<<16|g<<8|255)>>>0}e.reduceLuminance=s;function r(o,l,c){let h=o>>24&255,d=o>>16&255,u=o>>8&255,f=l>>24&255,v=l>>16&255,g=l>>8&255,b=ls(Kt.relativeLuminance2(f,v,g),Kt.relativeLuminance2(h,d,u));for(;b<c&&(f<255||v<255||g<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),b=ls(Kt.relativeLuminance2(f,v,g),Kt.relativeLuminance2(h,d,u));return(f<<24|v<<16|g<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(jo||(jo={}));function rr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ls(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var wb=class extends yo{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ea=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Di}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 i=[],s=t.translateToString(!0),r=0,n=0,o=0,l=t.getFg(0),c=t.getBg(0);for(let h=0;h<t.getTrimmedLength();h++)if(t.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(h-r>1){let d=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<d.length;u++)i.push(d[u])}r=h,o=n,l=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||js.length}if(this._bufferService.cols-r>1){let h=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<h.length;d++)i.push(h[d])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(n);for(let h=0;h<c.length;h++)ea._mergeRanges(o,c[h])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(e,t,i){let s=0,r=!1,n=0,o=e[s];if(o){for(let l=i;l<this._bufferService.cols;l++){let c=t.getWidth(l),h=t.getString(l).length||js.length;if(c!==0){if(!r&&o[0]<=n&&(o[0]=l,r=!0),o[1]<=n){if(o[1]=l,o=e[++s],!o)break;o[0]<=n?(o[0]=l,r=!0):r=!1}n+=h}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let r=e[s];if(i){if(t[1]<=r[0])return e[s-1][1]=t[1],e;if(t[1]<=r[1])return e[s-1][1]=Math.max(t[1],r[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=r[0])return e.splice(s,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ea=at([ue(0,jt)],ea);function Cb(e){return 57508<=e&&e<=57558}function kb(e){return 9472<=e&&e<=9631}function xb(e){return Cb(e)||kb(e)}function Eb(){return{css:{canvas:Lo(),cell:Lo()},device:{canvas:Lo(),cell:Lo(),char:{width:0,height:0,left:0,top:0}}}}function Lo(){return{width:0,height:0}}var Fl=class{constructor(e,t,i,s,r,n,o){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._themeService=o,this._workCell=new Di,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,r,n,o,l,c,h,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,g=e.getNoBgTrimmedLength();i&&g<n+1&&(g=n+1);let b,p=0,w="",R=0,x=0,y=0,C=0,L=!1,z=0,Y=!1,J=0,ae=0,X=[],N=h!==-1&&d!==-1;for(let B=0;B<g;B++){e.loadCell(B,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let T=!1,j=B>=ae,D=B,P=this._workCell;if(f.length>0&&B===f[0][0]&&j){let ge=f.shift(),Qe=this._isCellInSelection(ge[0],t);for(R=ge[0]+1;R<ge[1];R++)j&&(j=Qe===this._isCellInSelection(R,t));j&&(j=!i||n<ge[0]||n>=ge[1]),j?(T=!0,P=new wb(this._workCell,e.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),D=ge[1]-1,M=P.getWidth()):ae=ge[1]}let U=this._isCellInSelection(B,t),Z=i&&B===n,me=N&&B>=h&&B<=d,be=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,ge=>{be=!0});let fe=P.getChars()||js;if(fe===" "&&(P.isUnderline()||P.isOverline())&&(fe=" "),J=M*l-c.get(fe,P.isBold(),P.isItalic()),!b)b=this._document.createElement("span");else if(p&&(U&&Y||!U&&!Y&&P.bg===x)&&(U&&Y&&v.selectionForeground||P.fg===y)&&P.extended.ext===C&&me===L&&J===z&&!Z&&!T&&!be&&j){P.isInvisible()?w+=js:w+=fe,p++;continue}else p&&(b.textContent=w),b=this._document.createElement("span"),p=0,w="";if(x=P.bg,y=P.fg,C=P.extended.ext,L=me,z=J,Y=U,T&&n>=B&&n<=D&&(n=B),!this._coreService.isCursorHidden&&Z&&this._coreService.isCursorInitialized){if(X.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&X.push("xterm-cursor-blink"),X.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){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");break}}if(P.isBold()&&X.push("xterm-bold"),P.isItalic()&&X.push("xterm-italic"),P.isDim()&&X.push("xterm-dim"),P.isInvisible()?w=js:w=P.getChars()||js,P.isUnderline()&&(X.push(`xterm-underline-${P.extended.underlineStyle}`),w===" "&&(w=" "),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${yo.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let ge=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&ge<8&&(ge+=8),b.style.textDecorationColor=v.ansi[ge].css}P.isOverline()&&(X.push("xterm-overline"),w===" "&&(w=" ")),P.isStrikethrough()&&X.push("xterm-strikethrough"),me&&(b.style.textDecoration="underline");let ke=P.getFgColor(),Ee=P.getFgColorMode(),Ce=P.getBgColor(),$=P.getBgColorMode(),ve=!!P.isInverse();if(ve){let ge=ke;ke=Ce,Ce=ge;let Qe=Ee;Ee=$,$=Qe}let Re,Ye,Fe=!1;this._decorationService.forEachDecorationAtCell(B,t,void 0,ge=>{ge.options.layer!=="top"&&Fe||(ge.backgroundColorRGB&&($=50331648,Ce=ge.backgroundColorRGB.rgba>>8&16777215,Re=ge.backgroundColorRGB),ge.foregroundColorRGB&&(Ee=50331648,ke=ge.foregroundColorRGB.rgba>>8&16777215,Ye=ge.foregroundColorRGB),Fe=ge.options.layer==="top")}),!Fe&&U&&(Re=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,Ce=Re.rgba>>8&16777215,$=50331648,Fe=!0,v.selectionForeground&&(Ee=50331648,ke=v.selectionForeground.rgba>>8&16777215,Ye=v.selectionForeground)),Fe&&X.push("xterm-decoration-top");let Te;switch($){case 16777216:case 33554432:Te=v.ansi[Ce],X.push(`xterm-bg-${Ce}`);break;case 50331648:Te=ft.toColor(Ce>>16,Ce>>8&255,Ce&255),this._addStyle(b,`background-color:#${zc((Ce>>>0).toString(16),"0",6)}`);break;case 0:default:ve?(Te=v.foreground,X.push("xterm-bg-257")):Te=v.background}switch(Re||P.isDim()&&(Re=Je.multiplyOpacity(Te,.5)),Ee){case 16777216:case 33554432:P.isBold()&&ke<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ke+=8),this._applyMinimumContrast(b,Te,v.ansi[ke],P,Re,void 0)||X.push(`xterm-fg-${ke}`);break;case 50331648:let ge=ft.toColor(ke>>16&255,ke>>8&255,ke&255);this._applyMinimumContrast(b,Te,ge,P,Re,Ye)||this._addStyle(b,`color:#${zc(ke.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,Te,v.foreground,P,Re,Ye)||ve&&X.push("xterm-fg-257")}X.length&&(b.className=X.join(" "),X.length=0),!Z&&!T&&!be&&j?p++:b.textContent=w,J!==this.defaultSpacing&&(b.style.letterSpacing=`${J}px`),u.push(b),B=D}return b&&p&&(b.textContent=w),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||xb(s.getCode()))return!1;let o=this._getContrastCache(s),l;if(!r&&!n&&(l=o.getColor(t.rgba,i.rgba)),l===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);l=Je.ensureContrastRatio(r||t,n||i,c),o.setColor((r||t).rgba,(n||i).rgba,l??null)}return l?(this._addStyle(e,`color:${l.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 i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};Fl=at([ue(1,xf),ue(2,Vt),ue(3,xs),ue(4,zr),ue(5,wo),ue(6,Pn)],Fl);function zc(e,t,i){for(;e.length<i;)e=t+e;return e}var Pb=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 i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[i,s,r,n],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),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,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let o=this._measure(e,0);return o>0&&(this._flat[s]=o),o}let r=e;t&&(r+="B"),i&&(r+="I");let n=this._holey.get(r);if(n===void 0){let o=0;t&&(o|=1),i&&(o|=2),n=this._measure(e,o),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},Rb=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,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,o=i[1]-r,l=Math.max(n,0),c=Math.min(o,e.rows-1);if(l>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function Db(){return new Rb}var za="xterm-dom-renderer-owner-",gi="xterm-rows",Ao="xterm-fg-",Uc="xterm-bg-",Bn="xterm-focus",Oo="xterm-selection",Tb=1,Wl=class extends Oe{constructor(e,t,i,s,r,n,o,l,c,h,d,u,f,v){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=c,this._optionsService=h,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=v,this._terminalClass=Tb++,this._rowElements=[],this._selectionRenderModel=Db(),this.onRequestRedraw=this._register(new te).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(gi),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(Oo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Eb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(g=>this._injectCss(g))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Fl,document),this._element.classList.add(za+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(g=>this._handleLinkHover(g))),this._register(this._linkifier2.onHideLinkUnderline(g=>this._handleLinkLeave(g))),this._register(et(()=>{this._element.classList.remove(za+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Pb(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 i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${gi} 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} .${gi} { 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} .${gi} .xterm-dim { color: ${Je.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 i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${gi}.${Bn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${gi}.${Bn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${gi}.${Bn} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${gi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${gi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${gi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${gi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${gi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Oo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Oo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Oo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Ao}${n} { color: ${o.css}; }${this._terminalSelector} .${Ao}${n}.xterm-dim { color: ${Je.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${Uc}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Ao}257 { color: ${Je.opaque(e.background).css}; }${this._terminalSelector} .${Ao}257.xterm-dim { color: ${Je.multiplyOpacity(Je.opaque(e.background),.5).css}; }${this._terminalSelector} .${Uc}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 i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}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(Bn),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Bn),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(i){let c=e[0]>t[0];l.appendChild(this._createSelectionElement(n,c?t[0]:e[0],c?e[0]:t[0],o-n+1))}else{let c=s===n?e[0]:0,h=n===r?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,c,h));let d=o-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==o){let u=r===o?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,0,u))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,i,s=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(i-t);return n+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-n),r.style.height=`${s*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${o}px`,r}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 i=this._bufferService.buffer,s=i.ybase+i.y,r=Math.min(i.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let h=c+i.ydisp,d=this._rowElements[c],u=i.lines.get(h);if(!d||!u)break;d.replaceChildren(...this._rowFactory.createRow(u,h,h===s,o,l,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${za}${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,i,s,r,n){i<0&&(e=0),s<0&&(t=0);let o=this._bufferService.rows-1;i=Math.max(Math.min(i,o),0),s=Math.max(Math.min(s,o),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,c=l.ybase+l.y,h=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=i;v<=s;++v){let g=v+l.ydisp,b=this._rowElements[v],p=l.lines.get(g);if(!b||!p)break;b.replaceChildren(...this._rowFactory.createRow(p,g,g===c,u,f,h,d,this.dimensions.css.cell.width,this._widthCache,n?v===i?e:0:-1,n?(v===s?t:r)-1:-1))}}};Wl=at([ue(7,Bh),ue(8,ba),ue(9,Vt),ue(10,jt),ue(11,zr),ue(12,xs),ue(13,Pn)],Wl);var Hl=class extends Oe{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new te),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Bb(this._optionsService))}catch{this._measureStrategy=this._register(new Mb(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())}};Hl=at([ue(2,Vt)],Hl);var qf=class extends Oe{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)}},Mb=class extends qf{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,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}},Bb=class extends qf{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 new 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}},Lb=class extends Oe{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Ab(this._window)),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new te),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(At.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Pe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Pe(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}},Ab=class extends Oe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yn),this._onDprChange=this._register(new te),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(et(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Pe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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)}},Ob=class extends Oe{constructor(){super(),this.linkProviders=[],this._register(et(()=>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 Hh(e,t,i){let s=i.getBoundingClientRect(),r=e.getComputedStyle(i),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-s.left-n,t.clientY-s.top-o]}function Ib(e,t,i,s,r,n,o,l,c){if(!n)return;let h=Hh(e,t,i);if(h)return h[0]=Math.ceil((h[0]+(c?o/2:0))/o),h[1]=Math.ceil(h[1]/l),h[0]=Math.min(Math.max(h[0],1),s+(c?1:0)),h[1]=Math.min(Math.max(h[1],1),r),h}var zl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Ib(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let i=Hh(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};zl=at([ue(0,Es),ue(1,ba)],zl);var Nb=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):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=[]}},jf={};Yg(jf,{getSafariVersion:()=>Wb,isChromeOS:()=>Xf,isFirefox:()=>Vf,isIpad:()=>Hb,isIphone:()=>zb,isLegacyEdge:()=>Fb,isLinux:()=>zh,isMac:()=>ta,isNode:()=>Sa,isSafari:()=>Yf,isWindows:()=>Gf});var Sa=typeof process<"u"&&"title"in process,Co=Sa?"node":navigator.userAgent,ko=Sa?"node":navigator.platform,Vf=Co.includes("Firefox"),Fb=Co.includes("Edge"),Yf=/^((?!chrome|android).)*safari/i.test(Co);function Wb(){if(!Yf)return 0;let e=Co.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ta=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(ko),Hb=ko==="iPad",zb=ko==="iPhone",Gf=["Windows","Win16","Win32","WinCE"].includes(ko),zh=ko.indexOf("Linux")>=0,Xf=/\bCrOS\b/.test(Co),Qf=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),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),r=e.timeRemaining(),i*1.5>r){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=r}this.clear()}},Ub=class extends Qf{_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())}}},Kb=class extends Qf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ia=!Sa&&"requestIdleCallback"in window?Kb:Ub,qb=class{constructor(){this._queue=new ia}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Ul=class extends Oe{constructor(e,t,i,s,r,n,o,l,c){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new yn),this._pausedResizeTask=new qb,this._observerDisposable=this._register(new yn),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 te),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new te),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new te),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Nb((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new jb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(et(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.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(h=>this._registerIntersectionObserver(h,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=et(()=>i.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,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(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),this._needsSelectionRefresh=!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(t=>this.refreshRows(t.start,t.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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),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(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Ul=at([ue(2,Vt),ue(3,ba),ue(4,zr),ue(5,wo),ue(6,jt),ue(7,xs),ue(8,Pn)],Ul);var jb=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,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 Vb(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Xb(r,n,e,t,i,s)+ya(n,t,i,s)+Qb(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",so(Math.abs(r-e),io(o,s));o=n>t?"D":"C";let l=Math.abs(n-t),c=Gb(n>t?e:r,i)+(l-1)*i.cols+1+Yb(n>t?r:e);return so(c,io(o,s))}function Yb(e,t){return e-1}function Gb(e,t){return t.cols-e}function Xb(e,t,i,s,r,n){return ya(t,s,r,n).length===0?"":so($f(e,t,e,t-Wr(t,r),!1,r).length,io("D",n))}function ya(e,t,i,s){let r=e-Wr(e,i),n=t-Wr(t,i),o=Math.abs(r-n)-Jb(e,t,i);return so(o,io(Jf(e,t),s))}function Qb(e,t,i,s,r,n){let o;ya(t,s,r,n).length>0?o=s-Wr(s,r):o=t;let l=s,c=$b(e,t,i,s,r,n);return so($f(e,o,i,l,c==="C",r).length,io(c,n))}function Jb(e,t,i){var o;let s=0,r=e-Wr(e,i),n=t-Wr(t,i);for(let l=0;l<Math.abs(r-n);l++){let c=Jf(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+c*l))!=null&&o.isWrapped&&s++}return s}function Wr(e,t){let i=0,s=t.buffer.lines.get(e),r=s==null?void 0:s.isWrapped;for(;r&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),r=s==null?void 0:s.isWrapped;return i}function $b(e,t,i,s,r,n){let o;return ya(i,s,r,n).length>0?o=s-Wr(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function Jf(e,t){return e>t?"A":"B"}function $f(e,t,i,s,r,n){let o=e,l=t,c="";for(;(o!==i||l!==s)&&l>=0&&l<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(l,!1,e,o),o=0,e=0,l++):!r&&o<0&&(c+=n.buffer.translateBufferLineToString(l,!1,0,e+1),o=n.cols-1,e=o,l--);return c+n.buffer.translateBufferLineToString(l,!1,e,o)}function io(e,t){let i=t?"O":"[";return q.ESC+i+e}function so(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var Zb=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 Kc(e,t){if(e.start.y>e.end.y)throw new 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 Ua=50,eS=15,tS=50,iS=500,sS=" ",rS=new RegExp(sS,"g"),Kl=class extends Oe{constructor(e,t,i,s,r,n,o,l,c){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=l,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Di,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new te),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new te),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new te),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new Zb(this._bufferService),this._activeSelectionMode=0,this._register(et(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.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 i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let l=i.translateBufferLineToString(o,!0,r,n);s.push(l)}}else{let r=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let o=i.lines.get(n),l=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=l:s.push(l)}if(e[1]!==t[1]){let n=i.lines.get(t[1]),o=i.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?s[s.length-1]+=o:s.push(o)}}return s.map(r=>r.replace(rS," ")).join(Gf?`\r
32
- `:`
33
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),zh&&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),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let i=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=Kc(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,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=Hh(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-Ua),Ua),t/=Ua,t/Math.abs(t)+Math.round(t*(eS-1)))}shouldForceSelection(e){return ta?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(),tS)}_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&&!(ta&&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 i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.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<iS&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=Vb(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);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,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let r=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:r>1&&t!==s&&(i+=r-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let o=r.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(n,e[0]),c=l,h=e[0]-l,d=0,u=0,f=0,v=0;if(o.charAt(l)===" "){for(;l>0&&o.charAt(l-1)===" ";)l--;for(;c<o.length&&o.charAt(c+1)===" ";)c++}else{let p=e[0],w=e[0];n.getWidth(p)===0&&(d++,p--),n.getWidth(w)===2&&(u++,w++);let R=n.getString(w).length;for(R>1&&(v+=R-1,c+=R-1);p>0&&l>0&&!this._isCharWordSeparator(n.loadCell(p-1,this._workCell));){n.loadCell(p-1,this._workCell);let x=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,p--):x>1&&(f+=x-1,l-=x-1),l--,p--}for(;w<n.length&&c+1<o.length&&!this._isCharWordSeparator(n.loadCell(w+1,this._workCell));){n.loadCell(w+1,this._workCell);let x=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,w++):x>1&&(v+=x-1,c+=x-1),c++,w++}}c++;let g=l+h-d+f,b=Math.min(this._bufferService.cols,c-l+d+u-f-v);if(!(!t&&o.slice(l,c).trim()==="")){if(i&&g===0&&n.getCodePoint(0)!==32){let p=r.lines.get(e[1]-1);if(p&&n.isWrapped&&p.getCodePoint(this._bufferService.cols-1)!==32){let w=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(w){let R=this._bufferService.cols-w.start;g-=R,b+=R}}}if(s&&g+b===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let p=r.lines.get(e[1]+1);if(p!=null&&p.isWrapped&&p.getCodePoint(0)!==32){let w=this._getWordAt([0,e[1]+1],!1,!1,!0);w&&(b+=w.length)}}return{start:g,length:b}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={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=Kc(i,this._bufferService.cols)}};Kl=at([ue(3,jt),ue(4,zr),ue(5,Lh),ue(6,Vt),ue(7,Es),ue(8,xs)],Kl);var qc=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},jc=class{constructor(){this._color=new qc,this._css=new qc}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},vt=Object.freeze((()=>{let e=[st.toColor("#2e3436"),st.toColor("#cc0000"),st.toColor("#4e9a06"),st.toColor("#c4a000"),st.toColor("#3465a4"),st.toColor("#75507b"),st.toColor("#06989a"),st.toColor("#d3d7cf"),st.toColor("#555753"),st.toColor("#ef2929"),st.toColor("#8ae234"),st.toColor("#fce94f"),st.toColor("#729fcf"),st.toColor("#ad7fa8"),st.toColor("#34e2e2"),st.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ft.toCss(s,r,n),rgba:ft.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ft.toCss(s,s,s),rgba:ft.toRgba(s,s,s)})}return e})()),nr=st.toColor("#ffffff"),Wn=st.toColor("#000000"),Vc=st.toColor("#ffffff"),Yc=Wn,Ln={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},nS=nr,ql=class extends Oe{constructor(e){super(),this._optionsService=e,this._contrastCache=new jc,this._halfContrastCache=new jc,this._onChangeColors=this._register(new te),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:nr,background:Wn,cursor:Vc,cursorAccent:Yc,selectionForeground:void 0,selectionBackgroundTransparent:Ln,selectionBackgroundOpaque:Je.blend(Wn,Ln),selectionInactiveBackgroundTransparent:Ln,selectionInactiveBackgroundOpaque:Je.blend(Wn,Ln),scrollbarSliderBackground:Je.opacity(nr,.2),scrollbarSliderHoverBackground:Je.opacity(nr,.4),scrollbarSliderActiveBackground:Je.opacity(nr,.5),overviewRulerBorder:nr,ansi:vt.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=Ge(e.foreground,nr),t.background=Ge(e.background,Wn),t.cursor=Je.blend(t.background,Ge(e.cursor,Vc)),t.cursorAccent=Je.blend(t.background,Ge(e.cursorAccent,Yc)),t.selectionBackgroundTransparent=Ge(e.selectionBackground,Ln),t.selectionBackgroundOpaque=Je.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ge(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Je.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ge(e.selectionForeground,Hc):void 0,t.selectionForeground===Hc&&(t.selectionForeground=void 0),Je.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Je.opacity(t.selectionBackgroundTransparent,.3)),Je.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Je.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ge(e.scrollbarSliderBackground,Je.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ge(e.scrollbarSliderHoverBackground,Je.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ge(e.scrollbarSliderActiveBackground,Je.opacity(t.foreground,.5)),t.overviewRulerBorder=Ge(e.overviewRulerBorder,nS),t.ansi=vt.slice(),t.ansi[0]=Ge(e.black,vt[0]),t.ansi[1]=Ge(e.red,vt[1]),t.ansi[2]=Ge(e.green,vt[2]),t.ansi[3]=Ge(e.yellow,vt[3]),t.ansi[4]=Ge(e.blue,vt[4]),t.ansi[5]=Ge(e.magenta,vt[5]),t.ansi[6]=Ge(e.cyan,vt[6]),t.ansi[7]=Ge(e.white,vt[7]),t.ansi[8]=Ge(e.brightBlack,vt[8]),t.ansi[9]=Ge(e.brightRed,vt[9]),t.ansi[10]=Ge(e.brightGreen,vt[10]),t.ansi[11]=Ge(e.brightYellow,vt[11]),t.ansi[12]=Ge(e.brightBlue,vt[12]),t.ansi[13]=Ge(e.brightMagenta,vt[13]),t.ansi[14]=Ge(e.brightCyan,vt[14]),t.ansi[15]=Ge(e.brightWhite,vt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Ge(e.extendedAnsi[s],vt[s+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 t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];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()}}};ql=at([ue(0,Vt)],ql);function Ge(e,t){if(e!==void 0)try{return st.toColor(e)}catch{}return t}var oS=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},aS=class{constructor(){this._services=new oS,this._services.set(Bh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=em(e).sort((n,o)=>n.index-o.index),s=[];for(let n of i){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=i.length>0?i[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},lS={trace:0,debug:1,info:2,warn:3,error:4,off:5},hS="xterm.js: ",jl=class extends Oe{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=lS[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,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":hS)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};jl=at([ue(0,Vt)],jl);var Gc=class extends Oe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new te),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new te),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new te),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];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 new 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,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let r=t-1;r>=0;r--)this.set(e+r+i,this.get(e+r));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Ae=3,dt=Object.freeze(new yo),Io=0,Ka=2,Hn=class Zf{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Ae);let r=i||Di.fromCharData([0,mf,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*Ae+0],s=i&2097151;return[this._data[t*Ae+1],i&2097152?this._combined[t]:s?Ls(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Ae+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Ae+0]=t|2097152|i[2]<<22):this._data[t*Ae+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Ae+0]>>22}hasWidth(t){return this._data[t*Ae+0]&12582912}getFg(t){return this._data[t*Ae+1]}getBg(t){return this._data[t*Ae+2]}hasContent(t){return this._data[t*Ae+0]&4194303}getCodePoint(t){let i=this._data[t*Ae+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Ae+0]&2097152}getString(t){let i=this._data[t*Ae+0];return i&2097152?this._combined[t]:i&2097151?Ls(i&2097151):""}isProtected(t){return this._data[t*Ae+2]&536870912}loadCell(t,i){return Io=t*Ae,i.content=this._data[Io+0],i.fg=this._data[Io+1],i.bg=this._data[Io+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Ae+0]=i.content,this._data[t*Ae+1]=i.fg,this._data[t*Ae+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*Ae+0]=i|s<<22,this._data[t*Ae+1]=r.fg,this._data[t*Ae+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*Ae+0];r&2097152?this._combined[t]+=Ls(i):r&2097151?(this._combined[t]=Ls(r&2097151)+Ls(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*Ae+0]=r}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let r=new Di;for(let n=this.length-t-i-1;n>=0;--n)this.setCell(t+i+n,this.loadCell(t+n,r));for(let n=0;n<i;++n)this.setCell(t+n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let r=new Di;for(let n=0;n<this.length-t-i;++n)this.setCell(t+n,this.loadCell(t+i+n,r));for(let n=this.length-i;n<this.length;++n)this.setCell(n,s)}else for(let r=t;r<this.length;++r)this.setCell(r,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*Ka<this._data.buffer.byteLength;let s=t*Ae;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,i)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let l=parseInt(r[o],10);l>=t&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let l=parseInt(n[o],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,s*4*Ka<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ka<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new Zf(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303)return t+(this._data[t*Ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Ae+0]&4194303||this._data[t*Ae+2]&50331648)return t+(this._data[t*Ae+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let c=r-1;c>=0;c--){for(let h=0;h<Ae;h++)this._data[(s+c)*Ae+h]=o[(i+c)*Ae+h];o[(i+c)*Ae+2]&268435456&&(this._extendedAttrs[s+c]=t._extendedAttrs[i+c])}else for(let c=0;c<r;c++){for(let h=0;h<Ae;h++)this._data[(s+c)*Ae+h]=o[(i+c)*Ae+h];o[(i+c)*Ae+2]&268435456&&(this._extendedAttrs[s+c]=t._extendedAttrs[i+c])}let l=Object.keys(t._combined);for(let c=0;c<l.length;c++){let h=parseInt(l[c],10);h>=i&&(this._combined[h-i+s]=t._combined[h])}}translateToString(t,i,s,r){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let o=this._data[i*Ae+0],l=o&2097151,c=o&2097152?this._combined[i]:l?Ls(l):js;if(n+=c,r)for(let h=0;h<c.length;++h)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function cS(e,t,i,s,r,n){let o=[];for(let l=0;l<e.length-1;l++){let c=l,h=e.get(++c);if(!h.isWrapped)continue;let d=[e.get(l)];for(;c<e.length&&h.isWrapped;)d.push(h),h=e.get(++c);if(!n&&s>=l&&s<c){l+=d.length-1;continue}let u=0,f=ro(d,u,t),v=1,g=0;for(;v<d.length;){let p=ro(d,v,t),w=p-g,R=i-f,x=Math.min(w,R);d[u].copyCellsFrom(d[v],g,f,x,!1),f+=x,f===i&&(u++,f=0),g+=x,g===p&&(v++,g=0),f===0&&u!==0&&d[u-1].getWidth(i-1)===2&&(d[u].copyCellsFrom(d[u-1],i-1,f++,1,!1),d[u-1].setCell(i-1,r))}d[u].replaceCells(f,i,r);let b=0;for(let p=d.length-1;p>0&&(p>u||d[p].getTrimmedLength()===0);p--)b++;b>0&&(o.push(l+d.length-b),o.push(b)),l+=d.length-1}return o}function uS(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let l=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:l}),o+=l-1,n+=l,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function dS(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function fS(e,t,i){let s=[],r=e.map((c,h)=>ro(e,h,t)).reduce((c,h)=>c+h),n=0,o=0,l=0;for(;l<r;){if(r-l<i){s.push(r-l);break}n+=i;let c=ro(e,o,t);n>c&&(n-=c,o++);let h=e[o].getWidth(n-1)===2;h&&n--;let d=h?i-1:i;s.push(d),l+=d}return s}function ro(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,r=e[t+1].getWidth(0)===2;return s&&r?i-1:i}var e_=class t_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=t_._nextId++,this._onDispose=this.register(new te),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Fr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};e_._nextId=1;var _S=e_,bt={},or=bt.B;bt[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:"≥","{":"π","|":"≠","}":"£","~":"·"};bt.A={"#":"£"};bt.B=void 0;bt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};bt.C=bt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};bt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};bt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};bt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};bt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};bt.E=bt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};bt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};bt.H=bt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};bt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Xc=4294967295,Qc=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=dt.clone(),this.savedCharset=or,this.markers=[],this._nullCell=Di.fromCharData([0,mf,1,0]),this._whitespaceCell=Di.fromCharData([0,js,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ia,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Gc(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 $o),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 $o),this._whitespaceCell}getBlankLine(e,t){return new Hn(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>Xc?Xc:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=dt);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 Gc(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(dt),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)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 Hn(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new Hn(e,i)));else for(let o=this._rows;o>t;o--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),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 n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.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 i=this._optionsService.rawOptions.reflowCursorLine,s=cS(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(dt),i);if(s.length>0){let r=uS(this.lines,s);dS(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(dt),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Hn(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(dt),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let c=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),c.unshift(l);if(!i){let x=this.ybase+this.y;if(x>=o&&x<o+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=fS(c,this._cols,e),u=d.length-c.length,f;this.ybase===0&&this.y!==this.lines.length-1?f=Math.max(0,this.y-this.lines.maxLength+u):f=Math.max(0,this.lines.length-this.lines.maxLength+u);let v=[];for(let x=0;x<u;x++){let y=this.getBlankLine(dt,!0);v.push(y)}v.length>0&&(r.push({start:o+c.length+n,newLines:v}),n+=v.length),c.push(...v);let g=d.length-1,b=d[g];b===0&&(g--,b=d[g]);let p=c.length-u-1,w=h;for(;p>=0;){let x=Math.min(w,b);if(c[g]===void 0)break;if(c[g].copyCellsFrom(c[p],w-x,b-x,x,!0),b-=x,b===0&&(g--,b=d[g]),w-=x,w===0){p--;let y=Math.max(p,0);w=ro(c,y,this._cols)}}for(let x=0;x<c.length;x++)d[x]<e&&c[x].setCell(d[x],s);let R=u-f;for(;R-- >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+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+t-1)}if(r.length>0){let o=[],l=[];for(let b=0;b<this.lines.length;b++)l.push(this.lines.get(b));let c=this.lines.length,h=c-1,d=0,u=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let f=0;for(let b=Math.min(this.lines.maxLength-1,c+n-1);b>=0;b--)if(u&&u.start>h+f){for(let p=u.newLines.length-1;p>=0;p--)this.lines.set(b--,u.newLines[p]);b++,o.push({index:h+1,amount:u.newLines.length}),f+=u.newLines.length,u=r[++d]}else this.lines.set(b,l[h--]);let v=0;for(let b=o.length-1;b>=0;b--)o[b].index+=v,this.lines.onInsertEmitter.fire(o[b]),v+=o[b].amount;let g=Math.max(0,c+n-this.lines.maxLength);g>0&&this.lines.onTrimEmitter.fire(g)}}translateBufferLineToString(e,t,i=0,s){let r=this.lines.get(e);return r?r.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(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 _S(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},vS=class extends Oe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new te),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 Qc(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Qc(!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)}},i_=2,s_=1,Vl=class extends Oe{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,i_),this.rows=Math.max(e.rawOptions.rows||0,s_),this.buffers=this._register(new vS(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let r=i.ybase+i.scrollTop,n=i.ybase+i.scrollBottom;if(i.scrollTop===0){let o=i.lines.isFull;n===i.lines.length-1?o?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let o=n-r+1;i.lines.shiftElements(r+1,o-1,-1),i.lines.set(n,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};Vl=at([ue(0,Vt)],Vl);var jr={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:ta,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},pS=["normal","bold","100","200","300","400","500","600","700","800","900"],gS=class extends Oe{constructor(e){super(),this._onOptionChange=this._register(new te),this.onOptionChange=this._onOptionChange.event;let t={...jr};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(et(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in jr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in jr))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=jr[e]),!mS(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=jr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=pS.includes(t)?t:jr[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new 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 new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function mS(e){return e==="block"||e==="underline"||e==="bar"}function zn(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&zn(e[s],t-1);return i}var Jc=Object.freeze({insertMode:!1}),$c=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Yl=class extends Oe{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new te),this.onData=this._onData.event,this._onUserInput=this._register(new te),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new te),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=zn(Jc),this.decPrivateModes=zn($c)}reset(){this.modes=zn(Jc),this.decPrivateModes=zn($c)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.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(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Yl=at([ue(0,jt),ue(1,Cf),ue(2,Vt)],Yl);var Zc={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 qa(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var ja=String.fromCharCode,eu={DEFAULT:e=>{let t=[qa(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${ja(t[0])}${ja(t[1])}${ja(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${qa(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${qa(e,!0)};${e.x};${e.y}${t}`}},Gl=class extends Oe{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new te),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Zc))this.addProtocol(s,Zc[s]);for(let s of Object.keys(eu))this.addEncoding(s,eu[s]);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 new 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 new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_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,i){if(i){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)}};Gl=at([ue(0,jt),ue(1,zr),ue(2,Vt)],Gl);var Va=[[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]],bS=[[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]],pt;function SS(e,t){let i=0,s=t.length-1,r;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(r=i+s>>1,e>t[r][1])i=r+1;else if(e<t[r][0])s=r-1;else return!0;return!1}var yS=class{constructor(){if(this.version="6",!pt){pt=new Uint8Array(65536),pt.fill(1),pt[0]=0,pt.fill(0,1,32),pt.fill(0,127,160),pt.fill(2,4352,4448),pt[9001]=2,pt[9002]=2,pt.fill(2,11904,42192),pt[12351]=1,pt.fill(2,44032,55204),pt.fill(2,63744,64256),pt.fill(2,65040,65050),pt.fill(2,65072,65136),pt.fill(2,65280,65377),pt.fill(2,65504,65511);for(let e=0;e<Va.length;++e)pt.fill(0,Va[e][0],Va[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pt[e]:SS(e,bS)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=dr.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return dr.createPropertyValue(0,i,s)}},dr=class Vo{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new te,this.onChange=this._onChange.event;let t=new yS;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,r=t.length;for(let n=0;n<r;++n){let o=t.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return i+this.wcwidth(o);let h=t.charCodeAt(n);56320<=h&&h<=57343?o=(o-55296)*1024+h-56320+65536:i+=this.wcwidth(h)}let l=this.charProperties(o,s),c=Vo.extractWidth(l);Vo.extractShouldJoin(l)&&(c-=Vo.extractWidth(s)),i+=c,s=l}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},wS=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 tu(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var An=2147483647,CS=256,r_=class Xl{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>CS)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new Xl;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let r=t[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)i.addSubParam(r[n]);else i.addParam(r)}return i}clone(){let t=new Xl(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 t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>An?An:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>An?An:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=this._subParamsIdx[i]&255;r-s>0&&(t[i]=this._subParams.slice(s,r))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(r*10+t,An):t}},On=[],kS=class{constructor(){this._state=0,this._active=On,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 i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=On}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=On,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||On,!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,i){if(!this._active.length)this._handlerFb(this._id,"PUT",ma(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}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 i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=On,this._id=-1,this._state=0}}},oi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ma(e,t,i),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(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},In=[],xS=class{constructor(){this._handlers=Object.create(null),this._active=In,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=In}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,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=In,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||In,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",ma(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,r=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=In,this._ident=0}},Un=new r_;Un.addParam(0);var iu=class{constructor(e){this._handler=e,this._data="",this._params=Un,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Un,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=ma(e,t,i),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(i=>(this._params=Un,this._data="",this._hitLimit=!1,i));return this._params=Un,this._data="",this._hitLimit=!1,t}},ES=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},ki=160,PS=(function(){let e=new ES(4095),t=Array.apply(null,Array(256)).map((l,c)=>c),i=(l,c)=>t.slice(l,c),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(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(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ki,0,2,0),e.add(ki,8,5,8),e.add(ki,6,0,6),e.add(ki,11,0,11),e.add(ki,13,13,13),e})(),RS=class extends Oe{constructor(e=PS){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 r_,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(et(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new kS),this._dcsParser=this._register(new xS),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}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 i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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 i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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,i,s,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=r}parse(e,t,i){let s=0,r=0,n=0,o;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&c>-1){for(;c>=0&&(o=l[c](this._params),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&c>-1){for(;c>=0&&(o=l[c](),o!==!0);c--)if(o instanceof Promise)return this._parseStack.handlerPos=c,o}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],o=this._oscParser.end(s!==24&&s!==26,i),o)return o;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<t;++l){switch(s=e[l],r=this._transitions.table[this.currentState<<8|(s<160?s:ki)],r>>4){case 2:for(let f=l+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<ki){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<ki){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<ki){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<ki){this._printHandler(e,l,f),l=f-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|s],h=c?c.length-1:-1;for(;h>=0&&(o=c[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._preserveStack(3,c,h,r,l),o;h<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++l<t&&(s=e[l])>47&&s<60);l--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let d=this._escHandlers[this._collect<<8|s],u=d?d.length-1:-1;for(;u>=0&&(o=d[u](),o!==!0);u--)if(o instanceof Promise)return this._preserveStack(4,d,u,r,l),o;u<0&&this._escHandlerFb(this._collect<<8|s),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|s,this._params);break;case 13:for(let f=l+1;;++f)if(f>=t||(s=e[f])===24||s===26||s===27||s>127&&s<ki){this._dcsParser.put(e,l,f),l=f-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,l),o;s===27&&(r|=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 f=l+1;;f++)if(f>=t||(s=e[f])<32||s>127&&s<ki){this._oscParser.put(e,l,f),l=f-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,l),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},DS=/^([\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})$/,TS=/^[\da-f]+$/;function su(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=DS.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),TS.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(i*r,i*r+i),16);s[r]=i===1?n<<4:i===2?n:i===3?n>>4:n>>8}return s}}function Ya(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function MS(e,t=16){let[i,s,r]=e;return`rgb:${Ya(i,t)}/${Ya(s,t)}/${Ya(r,t)}`}var BS={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ms=131072,ru=10;function nu(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 ou=5e3,au=0,LS=class extends Oe{constructor(e,t,i,s,r,n,o,l,c=new RS){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new $g,this._utf8Decoder=new Zg,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=dt.clone(),this._eraseAttrDataInternal=dt.clone(),this._onRequestBell=this._register(new te),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new te),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new te),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new te),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new te),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new te),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new te),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new te),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new te),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new te),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 Ql(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:d.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,d,u)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:d,data:u})}),this._parser.setDcsHandlerFallback((h,d,u)=>{d==="HOOK"&&(u=u.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:d,payload:u})}),this._parser.setPrintHandler((h,d,u)=>this.print(h,d,u)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(q.BEL,()=>this.bell()),this._parser.setExecuteHandler(q.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(q.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(q.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(q.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(q.BS,()=>this.backspace()),this._parser.setExecuteHandler(q.HT,()=>this.tab()),this._parser.setExecuteHandler(q.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(q.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(qo.IND,()=>this.index()),this._parser.setExecuteHandler(qo.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(qo.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new oi(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new oi(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new oi(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new oi(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new oi(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new oi(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new oi(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new oi(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new oi(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new oi(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new oi(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new oi(h=>this.restoreCursorColor(h))),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 h in bt)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new iu((h,d)=>this.requestStatusString(h,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),ou))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${ou} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ms&&(n=this._parseStack.position+Ms)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ms&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ms))),o||this._dirtyRowTracker.clearRange(),e.length>Ms)for(let h=n;h<e.length;h+=Ms){let d=h+Ms<e.length?h+Ms:e.length,u=typeof e=="string"?this._stringDecoder.decode(e.substring(h,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,d),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,r,u,h),this._logSlowResolvingAsync(i),i}else if(!o){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,h))return this._preserveStack(s,r,h,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=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(l,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&u.getWidth(this._activeBuffer.x-1)===2&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&n){let w=n[String.fromCharCode(s)];w&&(s=w.charCodeAt(0))}let g=this._unicodeService.charProperties(s,f);r=dr.extractWidth(g);let b=dr.extractShouldJoin(g),p=b?dr.extractWidth(f):0;if(f=g,o&&this._onA11yChar.fire(Ls(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-p>l){if(c){let w=u,R=this._activeBuffer.x-p;for(this._activeBuffer.x=p,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),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),p>0&&u instanceof Hn&&u.copyCellsFrom(w,R,0,p,!1);R<l;)w.setCellFromCodepoint(R++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(b&&this._activeBuffer.x){let w=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-w,s,r);for(let R=r-p;--R>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,r-p,this._activeBuffer.getNullCell(d)),u.getWidth(l-1)===2&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&i-t>0&&u.getWidth(this._activeBuffer.x)===0&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>nu(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new iu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new oi(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(){var e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.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,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}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);break}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 i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,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 i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,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(dt));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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.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 i=e.params[0]||1,s=dr.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),l=0;for(let h=0;h<n.length;){let d=n.codePointAt(h)||0;o[l++]=d,h+=d>65535?2:1}let c=l;for(let h=1;h<i;++h)o.copyWithin(c,0,l),c+=l;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(q.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(q.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(q.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(q.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(q.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}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,or),this._charsetService.setgCharset(1,or),this._charsetService.setgCharset(2,or),this._charsetService.setgCharset(3,or);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;break}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;break}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);break}return!0}requestMode(e,t){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:h,alt:d}=l,u=this._optionsService.rawOptions,f=(b,p)=>(o.triggerDataEvent(`${q.ESC}[${t?"":"?"}${b};${p}$y`),!0),v=b=>b?1:2,g=e.params[0];return t?g===2?f(g,4):g===4?f(g,v(o.modes.insertMode)):g===12?f(g,3):g===20?f(g,v(u.convertEol)):f(g,0):g===1?f(g,v(s.applicationCursorKeys)):g===3?f(g,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):g===6?f(g,v(s.origin)):g===7?f(g,v(s.wraparound)):g===8?f(g,3):g===9?f(g,v(r==="X10")):g===12?f(g,v(u.cursorBlink)):g===25?f(g,v(!o.isCursorHidden)):g===45?f(g,v(s.reverseWraparound)):g===66?f(g,v(s.applicationKeypad)):g===67?f(g,4):g===1e3?f(g,v(r==="VT200")):g===1002?f(g,v(r==="DRAG")):g===1003?f(g,v(r==="ANY")):g===1004?f(g,v(s.sendFocus)):g===1005?f(g,4):g===1006?f(g,v(n==="SGR")):g===1015?f(g,4):g===1016?f(g,v(n==="SGR_PIXELS")):g===1048?f(g,1):g===47||g===1047||g===1049?f(g,v(h===d)):g===2004?f(g,v(s.bracketedPasteMode)):g===2026?f(g,v(s.synchronizedOutput)):f(g,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=yo.fromColorRGB([i,s,r])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=e.params[t+n],e.hasSubParams(t+n)){let o=e.getSubParams(t+n),l=0;do s[1]===5&&(r=1),s[n+l+1+r]=o[l];while(++l<o.length&&l+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_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=dt.fg,e.bg=dt.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,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=dt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=dt.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=dt.fg&16777215,s.bg&=-67108864,s.bg|=dt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${q.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${q.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${q.ESC}[?${t};${i}R`);break}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=dt.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";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!nu(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${q.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ru&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ru&&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());break}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=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(lu(n))if(r==="?")t.push({type:0,index:n});else{let o=su(r);o&&t.push({type:1,index:n,color:o})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,r=i.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=i[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,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 i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=su(i[s]);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=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let r=parseInt(i[s]);lu(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,or),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(BS[e[0]],bt[e[1]]||or),!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=dt.clone(),this._eraseAttrDataInternal=dt.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 Di;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=o=>(this._coreService.triggerDataEvent(`${q.ESC}${o}${q.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ql=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&&(au=e,e=t,t=au),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ql=at([ue(0,jt)],Ql);function lu(e){return 0<=e&&e<256}var AS=5e7,hu=12,OS=50,IS=class extends Oe{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 te),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 i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>AS)throw new 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 i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],r=this._action(s,t);if(r){let o=l=>performance.now()-i>=hu?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(i,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=hu)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>OS&&(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()}},Jl=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 l=t.addMarker(t.ybase+t.y),c={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(c,l)),this._dataByLinkId.set(c.id,c),c.id}let i=e,s=this._getEntryIdKey(i),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Jl=at([ue(0,jt)],Jl);var cu=!1,NS=class extends Oe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yn),this._onBinary=this._register(new te),this.onBinary=this._onBinary.event,this._onData=this._register(new te),this.onData=this._onData.event,this._onLineFeed=this._register(new te),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new te),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new te),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new te),this._instantiationService=new aS,this.optionsService=this._register(new gS(e)),this._instantiationService.setService(Vt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vl)),this._instantiationService.setService(jt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(jl)),this._instantiationService.setService(Cf,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Yl)),this._instantiationService.setService(zr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Gl)),this._instantiationService.setService(wf,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(dr)),this._instantiationService.setService(sm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(wS),this._instantiationService.setService(im,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Jl),this._instantiationService.setService(kf,this._oscLinkService),this._inputHandler=this._register(new LS(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(At.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(At.forward(this._bufferService.onResize,this._onResize)),this._register(At.forward(this.coreService.onData,this._onData)),this._register(At.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 IS((t,i)=>this._inputHandler.parse(t,i))),this._register(At.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new te),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.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&&!cu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),cu=!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,i_),t=Math.max(t,s_),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(tu.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(tu(this._bufferService),!1))),this._windowsWrappingHeuristics.value=et(()=>{for(let t of e)t.dispose()})}}},FS={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 WS(e,t,i,s){var o;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=q.ESC+"OA":r.key=q.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=q.ESC+"OD":r.key=q.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=q.ESC+"OC":r.key=q.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=q.ESC+"OB":r.key=q.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":q.DEL,e.altKey&&(r.key=q.ESC+r.key);break;case 9:if(e.shiftKey){r.key=q.ESC+"[Z";break}r.key=q.HT,r.cancel=!0;break;case 13:r.key=e.altKey?q.ESC+q.CR:q.CR,r.cancel=!0;break;case 27:r.key=q.ESC,e.altKey&&(r.key=q.ESC+q.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"D":t?r.key=q.ESC+"OD":r.key=q.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"C":t?r.key=q.ESC+"OC":r.key=q.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"A":t?r.key=q.ESC+"OA":r.key=q.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=q.ESC+"[1;"+(n+1)+"B":t?r.key=q.ESC+"OB":r.key=q.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=q.ESC+"[2~");break;case 46:n?r.key=q.ESC+"[3;"+(n+1)+"~":r.key=q.ESC+"[3~";break;case 36:n?r.key=q.ESC+"[1;"+(n+1)+"H":t?r.key=q.ESC+"OH":r.key=q.ESC+"[H";break;case 35:n?r.key=q.ESC+"[1;"+(n+1)+"F":t?r.key=q.ESC+"OF":r.key=q.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=q.ESC+"[5;"+(n+1)+"~":r.key=q.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=q.ESC+"[6;"+(n+1)+"~":r.key=q.ESC+"[6~";break;case 112:n?r.key=q.ESC+"[1;"+(n+1)+"P":r.key=q.ESC+"OP";break;case 113:n?r.key=q.ESC+"[1;"+(n+1)+"Q":r.key=q.ESC+"OQ";break;case 114:n?r.key=q.ESC+"[1;"+(n+1)+"R":r.key=q.ESC+"OR";break;case 115:n?r.key=q.ESC+"[1;"+(n+1)+"S":r.key=q.ESC+"OS";break;case 116:n?r.key=q.ESC+"[15;"+(n+1)+"~":r.key=q.ESC+"[15~";break;case 117:n?r.key=q.ESC+"[17;"+(n+1)+"~":r.key=q.ESC+"[17~";break;case 118:n?r.key=q.ESC+"[18;"+(n+1)+"~":r.key=q.ESC+"[18~";break;case 119:n?r.key=q.ESC+"[19;"+(n+1)+"~":r.key=q.ESC+"[19~";break;case 120:n?r.key=q.ESC+"[20;"+(n+1)+"~":r.key=q.ESC+"[20~";break;case 121:n?r.key=q.ESC+"[21;"+(n+1)+"~":r.key=q.ESC+"[21~";break;case 122:n?r.key=q.ESC+"[23;"+(n+1)+"~":r.key=q.ESC+"[23~";break;case 123:n?r.key=q.ESC+"[24;"+(n+1)+"~":r.key=q.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=q.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=q.DEL:e.keyCode===219?r.key=q.ESC:e.keyCode===220?r.key=q.FS:e.keyCode===221&&(r.key=q.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let l=(o=FS[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)r.key=q.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let c=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(c);e.shiftKey&&(h=h.toUpperCase()),r.key=q.ESC+h}else if(e.keyCode===32)r.key=q.ESC+(e.ctrlKey?q.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),r.key=q.ESC+c,r.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=q.US),e.key==="@"&&(r.key=q.NUL));break}return r}var lt=0,HS=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ia,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ia,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((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,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||(lt=this._search(t),lt===-1)||this._getKey(this._array[lt])!==t)return!1;do if(this._array[lt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(lt),!0;while(++lt<this._array.length&&this._getKey(this._array[lt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,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&&(lt=this._search(e),!(lt<0||lt>=this._array.length)&&this._getKey(this._array[lt])===e))do yield this._array[lt];while(++lt<this._array.length&&this._getKey(this._array[lt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(lt=this._search(e),!(lt<0||lt>=this._array.length)&&this._getKey(this._array[lt])===e))do t(this._array[lt]);while(++lt<this._array.length&&this._getKey(this._array[lt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},Ga=0,uu=0,zS=class extends Oe{constructor(){super(),this._decorations=new HS(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new te),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new te),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(et(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new US(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.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,i){let s=0,r=0;for(let n of this._decorations.getKeyIterator(t))s=n.options.x??0,r=s+(n.options.width??1),e>=s&&e<r&&(!i||(n.options.layer??"bottom")===i)&&(yield n)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,r=>{Ga=r.options.x??0,uu=Ga+(r.options.width??1),e>=Ga&&e<uu&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},US=class extends Js{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new te),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new te),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.options.backgroundColor?this._cachedBg=st.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=st.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},KS=1e3,qS=class{constructor(e,t=KS){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=s-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_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)}},du=20,sa=class extends Oe{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,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=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new qS(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
34
- `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Pe(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(et(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<du+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
35
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===du+1&&(this._liveRegion.textContent+=gl.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let r=e;r<=t;r++){let n=i.lines.get(i.ydisp+r),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(i.ydisp+r+1).toString(),h=this._rowElements[r];h&&(l.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=l,this._rowColumns.set(h,o)),h.setAttribute("aria-posinset",c),h.setAttribute("aria-setsize",s),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],r=i.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==s)return;let o,l;if(t===0?(o=i,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}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(){var l;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},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,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 s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((l=s.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:c,offset:h})=>{let d=c instanceof Text?c.parentNode:c,u=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(u))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(d);if(!f)return console.warn("columns is null. Race condition?"),null;let v=h<f.length?f[h]:f.slice(-1)[0]+1;return v>=this._terminal.cols&&(++u,v=0),{row:u,column:v}},n=r(t),o=r(i);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);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){var r,n;e.style.transform="";let t=e.getBoundingClientRect().width,i=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};sa=at([ue(1,Bh),ue(2,xs),ue(3,Es)],sa);var $l=class extends Oe{constructor(e,t,i,s,r){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new te),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new te),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(et(()=>{var n;Fr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Pe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Pe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Pe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Pe(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 i=e.composedPath();for(let s=0;s<i.length;s++){let r=i[s];if(r.classList.contains("xterm"))break;if(r.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){var s,r;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(i=this._checkLinkProviderResult(n,e,i)):o.provideLinks(e.y,l=>{var h,d;if(this._isMouseOut)return;let c=l==null?void 0:l.map(u=>({link:u}));(h=this._activeProviderReplies)==null||h.set(n,c),i=this._checkLinkProviderResult(n,e,i),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let r=t.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],l=o.link.range.start.y<e?0:o.link.range.start.x,c=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let h=l;h<=c;h++){if(i.has(h)){r.splice(n--,1);break}i.add(h)}}}}_checkLinkProviderResult(e,t,i){var n;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),r=!1;for(let o=0;o<e;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(l=>this._linkAtPosition(l.link,t));o&&(i=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(c=>this._linkAtPosition(c.link,t));if(l){i=!0,this._handleNewLink(l);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&jS(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,Fr(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?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!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:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.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(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return i<=r&&r<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,r){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:r}}};$l=at([ue(1,Lh),ue(2,Es),ue(3,jt),ue(4,Ef)],$l);function jS(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 VS=class extends NS{constructor(e={}){super(e),this._linkifier=this._register(new yn),this.browser=jf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yn),this._onCursorMove=this._register(new te),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new te),this.onKey=this._onKey.event,this._onRender=this._register(new te),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new te),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new te),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new te),this.onBell=this._onBell.event,this._onFocus=this._register(new te),this._onBlur=this._register(new te),this._onA11yCharEmitter=this._register(new te),this._onA11yTabEmitter=this._register(new te),this._onWillOpen=this._register(new te),this._setup(),this._decorationService=this._instantiationService.createInstance(zS),this._instantiationService.setService(wo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Ob),this._instantiationService.setService(Ef,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(bl)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(At.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(At.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(At.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(At.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(et(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.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 i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let r=Je.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${q.ESC}]${s};${MS(r)}${Kf.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ft.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ft.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_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(sa,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,r=t.getWidth(i),n=this._renderService.dimensions.css.cell.width*r,o=this.buffer.y*this._renderService.dimensions.css.cell.height,l=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=o+"px",this.textarea.style.width=n+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Pe(this.element,"copy",t=>{this.hasSelection()&&Qg(t,this._selectionService)}));let e=t=>Jg(t,this.textarea,this.coreService,this.optionsService);this._register(Pe(this.textarea,"paste",e)),this._register(Pe(this.element,"paste",e)),Vf?this._register(Pe(this.element,"mousedown",t=>{t.button===2&&wc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Pe(this.element,"contextmenu",t=>{wc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),zh&&this._register(Pe(this.element,"auxclick",t=>{t.button===1&&gf(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Pe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Pe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Pe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Pe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Pe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Pe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Pe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new 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"),((r=this.element)==null?void 0:r.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(Pe(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",pl.get()),Xf||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",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Lb,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(xs,this._coreBrowserService),this._register(Pe(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Pe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Hl,this._document,this._helperContainer),this._instantiationService.setService(ba,this._charSizeService),this._themeService=this._instantiationService.createInstance(ql),this._instantiationService.setService(Pn,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ea),this._instantiationService.setService(xf,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Ul,this.rows,this.screenElement)),this._instantiationService.setService(Es,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Nl,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(zl),this._instantiationService.setService(Lh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance($l,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(Ol,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Kl,this.element,this.screenElement,s)),this._instantiationService.setService(nm,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(At.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Il,this.screenElement)),this._register(Pe(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),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(sa,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zo,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Zo,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Wl,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var h,d,u,f,v;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let l,c;switch(n.overrideType||n.type){case"mousemove":c=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":c=0,l=n.button<3?n.button:3;break;case"mousedown":c=1,l=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let g=n.deltaY;if(g===0||e.coreMouseService.consumeWheelEvent(n,(f=(u=(d=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:d.device)==null?void 0:u.cell)==null?void 0:f.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;c=g<0?0:1,l=4;break;default:return!1}return c===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:l,action:c,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(i(n),n.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(n)),wheel:n=>(i(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&i(n)},mousemove:n=>{n.buttons||i(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?s.mousemove||(t.addEventListener("mousemove",r.mousemove),s.mousemove=r.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),n&16?s.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),s.wheel=r.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),n&2?s.mouseup||(s.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),n&4?s.mousedrag||(s.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Pe(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return i(n),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(n)})),this._register(Pe(t,"wheel",n=>{var o,l,c,h,d;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(h=(c=(l=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:l.device)==null?void 0:c.cell)==null?void 0:h.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let u=q.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(u,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.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){pf(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 new 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 new 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,i){this._selectionService.setSelection(e,t,i)}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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.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 i=WS(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.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((i.key===q.ETX||i.key===q.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=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"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(YS(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){var i;(i=this._charSizeService)==null||i.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(dt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(q.ESC+"[I"):this.coreService.triggerDataEvent(q.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${q.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${q.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function YS(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var GS=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},XS=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 Di)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},fu=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 XS(t)}getNullCell(){return new Di}},QS=class extends Oe{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new te),this.onBufferChange=this._onBufferChange.event,this._normal=new fu(this._core.buffers.normal,"normal"),this._alternate=new fu(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 new 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)}},JS=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.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)}},$S=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}},ZS=["cols","rows"],Yi=0,ey=class extends Oe{constructor(e){super(),this._core=this._register(new VS(e)),this._addonManager=this._register(new GS),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(e){if(ZS.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new 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||(this._parser=new JS(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new $S(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._buffer=this._register(new QS(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";break}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,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}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
36
- `,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 pl.get()},set promptLabel(e){pl.set(e)},get tooMuchOutput(){return gl.get()},set tooMuchOutput(e){gl.set(e)}}}_verifyIntegers(...e){for(Yi of e)if(Yi===1/0||isNaN(Yi)||Yi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Yi of e)if(Yi&&(Yi===1/0||isNaN(Yi)||Yi%1!==0||Yi<0))throw new Error("This API only accepts positive integers")}};/**
37
- * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
38
- * @license MIT
39
- *
40
- * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
41
- * @license MIT
42
- *
43
- * Originally forked from (with the author's permission):
44
- * Fabrice Bellard's javascript vt100 for jslinux:
45
- * http://bellard.org/jslinux/
46
- * Copyright (c) 2011 Fabrice Bellard
47
- */var ty=2,iy=1,sy=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var u;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((u=this._terminal.options.overviewRuler)==null?void 0:u.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),r=Math.max(0,parseInt(i.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=o.top+o.bottom,c=o.right+o.left,h=s-l,d=r-c-t;return{cols:Math.max(ty,Math.floor(d/e.css.cell.width)),rows:Math.max(iy,Math.floor(h/e.css.cell.height))}}},ry=W('<div class="scroll-fabs svelte-5qgfij"><button class="scroll-fab svelte-5qgfij" data-dir="up" aria-label="Page up">&#9650;</button> <button class="scroll-fab svelte-5qgfij" data-dir="down" aria-label="Page down">&#9660;</button> <button class="scroll-fab scroll-fab-bottom svelte-5qgfij" data-dir="bottom" aria-label="Skip to bottom">&#8615;</button></div>'),ny=W('<div><div class="terminal-container svelte-5qgfij" role="presentation"></div> <div class="terminal-scrollbar svelte-5qgfij" role="scrollbar" aria-orientation="vertical"><div class="terminal-scrollbar-thumb svelte-5qgfij" role="presentation"></div></div> <!></div>');function oy(e,t){ct(t,!0);let i=ws(t,"useTmux",3,!1),s=ws(t,"companionMode",3,!1),r,n=F(null),o,l=!1;function c(){return a(n)}function h(){var I;(I=a(n))==null||I.focus()}function d(){if(!a(n))return;const I=a(n).buffer.active,K=I.viewportY>=I.baseY,H=I.viewportY;o==null||o.fit(),K?a(n).scrollToBottom():a(n).scrollToLine(H),Oa(a(n).cols,a(n).rows),T()}En(()=>{const I=new ey({cursorBlink:!0,fontSize:Tt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new sy,I.loadAddon(o),I.open(r),Tt){const E=r.querySelector(".xterm-viewport");E&&(E.style.touchAction="none",E.style.overflowY="hidden");const V=r.querySelector(".xterm-screen");if(V){V.addEventListener("wheel",pe=>{pe.stopImmediatePropagation(),pe.preventDefault()},{capture:!0,passive:!1});const ce=pe=>{I.modes.mouseTrackingMode!=="none"&&pe.stopImmediatePropagation()};for(const pe of["mousedown","mouseup","mousemove"])V.addEventListener(pe,ce,{capture:!0})}}o.fit(),I.onData(E=>Qs(E));{const E=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");I.attachCustomKeyEventHandler(V=>!E&&V.type==="keydown"&&V.ctrlKey&&!V.shiftKey&&!V.altKey&&!V.metaKey&&(V.key==="v"||V.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(ce=>{let pe=null,we=null;for(const xe of ce){for(const Ue of xe.types)if(Ue.startsWith("image/")){we=Ue,pe=xe;break}if(pe)break}pe&&we?pe.getType(we).then(xe=>Re(xe,we)):navigator.clipboard.readText().then(xe=>{xe&&I.paste(xe)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(ce=>{ce&&I.paste(ce)}).catch(()=>{})}),!1):!0)}I.parser.registerOscHandler(52,E=>{var pe;const V=E.indexOf(";");if(V===-1)return!0;const ce=E.slice(V+1);if(!ce||ce==="?")return!0;try{const we=Uint8Array.from(atob(ce),Ue=>Ue.charCodeAt(0)),xe=new TextDecoder("utf-8").decode(we);(pe=navigator.clipboard)==null||pe.writeText(xe).catch(()=>{})}catch{}return!0}),I.onScroll(T),I.onWriteParsed(T);let K=null;const H=new ResizeObserver(()=>{K&&clearTimeout(K),K=setTimeout(()=>{const E=I.buffer.active,V=E.viewportY>=E.baseY,ce=E.viewportY;o.fit(),V?I.scrollToBottom():I.scrollToLine(ce),Oa(I.cols,I.rows),T()},Tt?150:0)});return H.observe(r),Tt&&(document.addEventListener("touchmove",fe,{passive:!1}),document.addEventListener("touchend",ke),document.addEventListener("touchcancel",ke)),m(n,I,!0),()=>{K&&clearTimeout(K),J&&clearTimeout(J),H.disconnect(),I.dispose(),m(n,null),w=!1,u=!1,Tt&&(document.removeEventListener("touchmove",fe),document.removeEventListener("touchend",ke),document.removeEventListener("touchcancel",ke))}}),ss(()=>{t.sessionId&&a(n)&&!s()&&(a(n).write("\x1B[?1049l"),a(n).clear(),hf(t.sessionId,a(n),()=>{a(n)&&Oa(a(n).cols,a(n).rows)},()=>{}))});let u=!1,f=0,v=0,g=F(0),b=F(0),p=F(!1),w=!1,R=0,x=0,y=!1,C=0,L=0,z=F(!1),Y=F(!1),J=null,ae=0,X=0;const N=500,B=10;let M=!1;function T(){M||(M=!0,requestAnimationFrame(j))}function j(){if(M=!1,!a(n))return;const I=a(n).buffer.active,K=I.baseY+a(n).rows,H=I.viewportY,E=$;if(!E)return;const V=E.clientHeight;if(K<=a(n).rows){m(p,!1);return}m(p,!0),m(g,Math.max(Tt?44:20,a(n).rows/K*V),!0),m(b,H/(K-a(n).rows)*(V-a(g)))}function D(I){if(!a(n)||!$)return;const K=$.getBoundingClientRect(),E=a(n).buffer.active.baseY+a(n).rows;if(E<=a(n).rows)return;const V=$.clientHeight,ce=Math.max(Tt?44:20,a(n).rows/E*V),pe=V-ce,we=I-K.top-ce/2,xe=Math.max(0,Math.min(1,we/pe)),Ue=Math.round(xe*(E-a(n).rows));a(n).scrollToLine(Ue)}function P(I){const K=I.touches[0];K&&(u=!0,f=K.clientY,v=a(b))}function U(){var I;a(Y)&&(m(Y,!1),(I=t.onCopyModeChange)==null||I.call(t,!1))}function Z(){var H;if(J=null,w=!1,navigator.vibrate&&navigator.vibrate(50),i()){m(Y,!0),(H=t.onCopyModeChange)==null||H.call(t,!0),Qs("[");return}m(z,!0);const I=r.querySelector(".xterm-screen");I&&(I.style.userSelect="text",I.style.webkitUserSelect="text"),r.querySelectorAll("canvas").forEach(E=>{E.style.pointerEvents="none"});const K=r.querySelector(".xterm-rows");if(K){const E=document.createRange();E.selectNodeContents(K);const V=window.getSelection();V==null||V.removeAllRanges(),V==null||V.addRange(E)}}function me(){var K;m(z,!1);const I=r.querySelector(".xterm-screen");I&&(I.style.userSelect="",I.style.webkitUserSelect=""),r.querySelectorAll("canvas").forEach(H=>{H.style.pointerEvents=""}),(K=window.getSelection())==null||K.removeAllRanges()}function be(I){var H;if(a(z)){const E=((H=window.getSelection())==null?void 0:H.toString())??"";E.trim().length>0&&(navigator.clipboard.writeText(E).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),me();return}if(a(Y)||I.target.closest(".terminal-scrollbar")||I.target.closest(".scroll-fabs")||!a(n))return;const K=I.touches[0];K&&(R=K.clientY,L=K.clientY,x=a(n).buffer.active.viewportY,y=!1,C=0,w=!0,ae=K.clientX,X=K.clientY,J&&clearTimeout(J),J=setTimeout(()=>{Z()},N))}function fe(I){const K=I.touches[0];if(K){if(u){if(!a(n)||!$)return;I.preventDefault();const H=K.clientY-f,V=a(n).buffer.active.baseY+a(n).rows;if(V<=a(n).rows)return;const ce=$.clientHeight,pe=Math.max(44,a(n).rows/V*ce),we=ce-pe,Ue=Math.max(0,Math.min(we,v+H))/we,Ft=Math.round(Ue*(V-a(n).rows));a(n).scrollToLine(Ft);return}if(w&&a(n)&&!a(z)){if(J){const E=Math.abs(K.clientX-ae),V=Math.abs(K.clientY-X);(E>B||V>B)&&(clearTimeout(J),J=null)}if(a(n).rows===0||r.clientHeight===0)return;const H=R-K.clientY;if(Math.abs(H)>5){y=!0,I.preventDefault();const E=r.clientHeight/a(n).rows;if(a(n).buffer.active.type==="alternate"){const V=L-K.clientY;L=K.clientY;const ce=V/E;C+=ce;const pe=Math.trunc(C);if(pe!==0){C-=pe;const we=pe>0?65:64,xe=Math.max(1,Math.round(a(n).cols/2)),Ue=Math.max(1,Math.round(a(n).rows/2)),Ft=`\x1B[<${we};${xe};${Ue}M`,ii=Math.min(Math.abs(pe),5);for(let Mi=0;Mi<ii;Mi++)Qs(Ft)}}else{const V=H/E,ce=a(n).buffer.active.baseY,pe=Math.max(0,Math.min(ce,Math.round(x+V)));a(n).scrollToLine(pe)}}}}}function ke(){J&&(clearTimeout(J),J=null),u=!1,w=!1,y=!1,C=0}function Ee(I){I.target!==ve&&D(I.clientY)}function Ce(I){var E,V,ce;I.preventDefault();const K=I.target.closest("button");if(!K)return;const H=K.dataset.dir;H==="up"?(E=a(n))==null||E.scrollPages(-1):H==="down"?(V=a(n))==null||V.scrollPages(1):H==="bottom"&&((ce=a(n))==null||ce.scrollToBottom())}let $,ve;async function Re(I,K){var E;if(l||!t.sessionId)return;l=!0,(E=t.onImageUpload)==null||E.call(t,"Pasting image…",!1);const H=new FileReader;H.onload=async()=>{var ce,pe,we;const V=H.result.split(",")[1];try{const xe=await Ep(t.sessionId,V,K);xe.clipboardSet?(ce=t.onImageUpload)==null||ce.call(t,"Image pasted",!1):(pe=t.onImageUpload)==null||pe.call(t,xe.path,!0,xe.path)}catch(xe){const Ue=xe instanceof Error?xe.message:"Image upload failed";(we=t.onImageUpload)==null||we.call(t,Ue,!1)}finally{l=!1}},H.readAsDataURL(I)}function Ye(I){var K;if((K=I.clipboardData)!=null&&K.items){for(const H of I.clipboardData.items)if(H.type.startsWith("image/")){I.preventDefault(),I.stopPropagation();const E=H.getAsFile();E&&Re(E,H.type);return}}}let Fe=F(!1);function Te(I){var K;(K=I.dataTransfer)!=null&&K.types.includes("Files")&&(I.preventDefault(),m(Fe,!0))}function ge(){m(Fe,!1)}function Qe(I){var H;if(I.preventDefault(),m(Fe,!1),!((H=I.dataTransfer)!=null&&H.files.length))return;const K=I.dataTransfer.files[0];K.type.startsWith("image/")&&Re(K,K.type)}function Le(I){var K;u||y||I.target.closest(".terminal-scrollbar")||a(z)||((K=a(n))==null||K.focus(),I.preventDefault())}var Be={getTerm:c,focusTerm:h,fitTerm:d,exitCopyMode:U,handleImageUpload:Re},A=ny();let ie;var de=S(A);$e(de,I=>r=I,()=>r);var he=k(de,2);Ne(he,"aria-valuenow",0);var Se=S(he);let se;$e(Se,I=>ve=I,()=>ve),$e(he,I=>$=I,()=>$);var Ie=k(he,2);{var ze=I=>{var K=ry();Q("mousedown",K,Ce),O(I,K)};ne(Ie,I=>{Tt&&a(p)&&I(ze)})}return le(()=>{ie=Ze(A,1,"terminal-wrapper svelte-5qgfij",null,ie,{"drag-over":a(Fe),"selection-mode":a(z)}),se=xn(Se,"",se,{display:a(p)?"block":"none",height:a(g)+"px",top:a(b)+"px"})}),Q("touchstart",A,function(...I){var K;(K=Tt?be:void 0)==null||K.apply(this,I)}),Q("touchend",A,function(...I){var K;(K=Tt?Le:void 0)==null||K.apply(this,I)}),ps("paste",de,Ye),ps("dragover",de,Te),ps("dragleave",de,ge),ps("drop",de,Qe),Q("click",he,Ee),Q("touchstart",Se,P),O(e,A),ut(Be)}ot(["touchstart","touchend","click","mousedown"]);var xo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ay={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Os,vh,Mu,ly=(Mu=class{constructor(){ee(this,Os,ay);ee(this,vh,!1)}setTimeoutProvider(e){G(this,Os,e)}setTimeout(e,t){return _(this,Os).setTimeout(e,t)}clearTimeout(e){_(this,Os).clearTimeout(e)}setInterval(e,t){return _(this,Os).setInterval(e,t)}clearInterval(e){_(this,Os).clearInterval(e)}},Os=new WeakMap,vh=new WeakMap,Mu),fr=new ly;function hy(e){setTimeout(e,0)}var wn=typeof window>"u"||"Deno"in globalThis;function wi(){}function cy(e,t){return typeof e=="function"?e(t):e}function Zl(e){return typeof e=="number"&&e>=0&&e!==1/0}function n_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function $s(e,t){return typeof e=="function"?e(t):e}function xi(e,t){return typeof e=="function"?e(t):e}function _u(e,t){const{type:i="all",exact:s,fetchStatus:r,predicate:n,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==Uh(o,t.options))return!1}else if(!oo(t.queryKey,o))return!1}if(i!=="all"){const c=t.isActive();if(i==="active"&&!c||i==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||r&&r!==t.state.fetchStatus||n&&!n(t))}function vu(e,t){const{exact:i,status:s,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(no(t.options.mutationKey)!==no(n))return!1}else if(!oo(t.options.mutationKey,n))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Uh(e,t){return((t==null?void 0:t.queryKeyHashFn)||no)(e)}function no(e){return JSON.stringify(e,(t,i)=>th(i)?Object.keys(i).sort().reduce((s,r)=>(s[r]=i[r],s),{}):i)}function oo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>oo(e[i],t[i])):!1}var uy=Object.prototype.hasOwnProperty;function o_(e,t,i=0){if(e===t)return e;if(i>500)return t;const s=pu(e)&&pu(t);if(!s&&!(th(e)&&th(t)))return t;const n=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),l=o.length,c=s?new Array(l):{};let h=0;for(let d=0;d<l;d++){const u=s?d:o[d],f=e[u],v=t[u];if(f===v){c[u]=f,(s?d<n:uy.call(e,u))&&h++;continue}if(f===null||v===null||typeof f!="object"||typeof v!="object"){c[u]=v;continue}const g=o_(f,v,i+1);c[u]=g,g===f&&h++}return n===l&&h===n?e:c}function eh(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}function pu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function th(e){if(!gu(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!gu(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function gu(e){return Object.prototype.toString.call(e)==="[object Object]"}function dy(e){return new Promise(t=>{fr.setTimeout(t,e)})}function ih(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?o_(e,t):t}function fy(e,t,i=0){const s=[...e,t];return i&&s.length>i?s.slice(1):s}function _y(e,t,i=0){const s=[t,...e];return i&&s.length>i?s.slice(0,-1):s}var Kh=Symbol();function a_(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Kh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function vy(e,t,i){let s=!1,r;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(r??(r=t()),s||(s=!0,r.aborted?i():r.addEventListener("abort",i,{once:!0})),r)}),e}var br,Is,rn,Bu,py=(Bu=class extends xo{constructor(){super();ee(this,br);ee(this,Is);ee(this,rn);G(this,rn,t=>{if(!wn&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){_(this,Is)||this.setEventListener(_(this,rn))}onUnsubscribe(){var t;this.hasListeners()||((t=_(this,Is))==null||t.call(this),G(this,Is,void 0))}setEventListener(t){var i;G(this,rn,t),(i=_(this,Is))==null||i.call(this),G(this,Is,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){_(this,br)!==t&&(G(this,br,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof _(this,br)=="boolean"?_(this,br):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},br=new WeakMap,Is=new WeakMap,rn=new WeakMap,Bu),qh=new py;function sh(){let e,t;const i=new Promise((r,n)=>{e=r,t=n});i.status="pending",i.catch(()=>{});function s(r){Object.assign(i,r),delete i.resolve,delete i.reject}return i.resolve=r=>{s({status:"fulfilled",value:r}),e(r)},i.reject=r=>{s({status:"rejected",reason:r}),t(r)},i}var gy=hy;function my(){let e=[],t=0,i=l=>{l()},s=l=>{l()},r=gy;const n=l=>{t?e.push(l):r(()=>{i(l)})},o=()=>{const l=e;e=[],l.length&&r(()=>{s(()=>{l.forEach(c=>{i(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{n(()=>{l(...c)})},schedule:n,setNotifyFunction:l=>{i=l},setBatchNotifyFunction:l=>{s=l},setScheduler:l=>{r=l}}}var zt=my(),nn,Ns,on,Lu,by=(Lu=class extends xo{constructor(){super();ee(this,nn,!0);ee(this,Ns);ee(this,on);G(this,on,t=>{if(!wn&&window.addEventListener){const i=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",i,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",s)}}})}onSubscribe(){_(this,Ns)||this.setEventListener(_(this,on))}onUnsubscribe(){var t;this.hasListeners()||((t=_(this,Ns))==null||t.call(this),G(this,Ns,void 0))}setEventListener(t){var i;G(this,on,t),(i=_(this,Ns))==null||i.call(this),G(this,Ns,t(this.setOnline.bind(this)))}setOnline(t){_(this,nn)!==t&&(G(this,nn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return _(this,nn)}},nn=new WeakMap,Ns=new WeakMap,on=new WeakMap,Lu),ra=new by;function Sy(e){return Math.min(1e3*2**e,3e4)}function l_(e){return(e??"online")==="online"?ra.isOnline():!0}var rh=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function h_(e){let t=!1,i=0,s;const r=sh(),n=()=>r.status!=="pending",o=b=>{var p;if(!n()){const w=new rh(b);f(w),(p=e.onCancel)==null||p.call(e,w)}},l=()=>{t=!0},c=()=>{t=!1},h=()=>qh.isFocused()&&(e.networkMode==="always"||ra.isOnline())&&e.canRun(),d=()=>l_(e.networkMode)&&e.canRun(),u=b=>{n()||(s==null||s(),r.resolve(b))},f=b=>{n()||(s==null||s(),r.reject(b))},v=()=>new Promise(b=>{var p;s=w=>{(n()||h())&&b(w)},(p=e.onPause)==null||p.call(e)}).then(()=>{var b;s=void 0,n()||(b=e.onContinue)==null||b.call(e)}),g=()=>{if(n())return;let b;const p=i===0?e.initialPromise:void 0;try{b=p??e.fn()}catch(w){b=Promise.reject(w)}Promise.resolve(b).then(u).catch(w=>{var L;if(n())return;const R=e.retry??(wn?0:3),x=e.retryDelay??Sy,y=typeof x=="function"?x(i,w):x,C=R===!0||typeof R=="number"&&i<R||typeof R=="function"&&R(i,w);if(t||!C){f(w);return}i++,(L=e.onFail)==null||L.call(e,i,w),dy(y).then(()=>h()?void 0:v()).then(()=>{t?f(w):g()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(s==null||s(),r),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?g():v().then(g),r)}}var Sr,Au,c_=(Au=class{constructor(){ee(this,Sr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Zl(this.gcTime)&&G(this,Sr,fr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wn?1/0:300*1e3))}clearGcTimeout(){_(this,Sr)&&(fr.clearTimeout(_(this,Sr)),G(this,Sr,void 0))}},Sr=new WeakMap,Au),yr,an,yi,wr,yt,uo,Cr,Fi,hs,Ou,yy=(Ou=class extends c_{constructor(t){super();ee(this,Fi);ee(this,yr);ee(this,an);ee(this,yi);ee(this,wr);ee(this,yt);ee(this,uo);ee(this,Cr);G(this,Cr,!1),G(this,uo,t.defaultOptions),this.setOptions(t.options),this.observers=[],G(this,wr,t.client),G(this,yi,_(this,wr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,G(this,yr,bu(this.options)),this.state=t.state??_(this,yr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=_(this,yt))==null?void 0:t.promise}setOptions(t){if(this.options={..._(this,uo),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=bu(this.options);i.data!==void 0&&(this.setState(mu(i.data,i.dataUpdatedAt)),G(this,yr,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&_(this,yi).remove(this)}setData(t,i){const s=ih(this.state.data,t,this.options);return ye(this,Fi,hs).call(this,{data:s,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),s}setState(t,i){ye(this,Fi,hs).call(this,{type:"setState",state:t,setStateOptions:i})}cancel(t){var s,r;const i=(s=_(this,yt))==null?void 0:s.promise;return(r=_(this,yt))==null||r.cancel(t),i?i.then(wi).catch(wi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(_(this,yr))}isActive(){return this.observers.some(t=>xi(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Kh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>$s(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!n_(this.state.dataUpdatedAt,t)}onFocus(){var i;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(i=_(this,yt))==null||i.continue()}onOnline(){var i;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(i=_(this,yt))==null||i.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),_(this,yi).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(i=>i!==t),this.observers.length||(_(this,yt)&&(_(this,Cr)?_(this,yt).cancel({revert:!0}):_(this,yt).cancelRetry()),this.scheduleGc()),_(this,yi).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ye(this,Fi,hs).call(this,{type:"invalidate"})}async fetch(t,i){var c,h,d,u,f,v,g,b,p,w,R,x;if(this.state.fetchStatus!=="idle"&&((c=_(this,yt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(i!=null&&i.cancelRefetch))this.cancel({silent:!0});else if(_(this,yt))return _(this,yt).continueRetry(),_(this,yt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const y=this.observers.find(C=>C.options.queryFn);y&&this.setOptions(y.options)}const s=new AbortController,r=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(G(this,Cr,!0),s.signal)})},n=()=>{const y=a_(this.options,i),L=(()=>{const z={client:_(this,wr),queryKey:this.queryKey,meta:this.meta};return r(z),z})();return G(this,Cr,!1),this.options.persister?this.options.persister(y,L,this):y(L)},l=(()=>{const y={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:_(this,wr),state:this.state,fetchFn:n};return r(y),y})();(h=this.options.behavior)==null||h.onFetch(l,this),G(this,an,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&ye(this,Fi,hs).call(this,{type:"fetch",meta:(u=l.fetchOptions)==null?void 0:u.meta}),G(this,yt,h_({initialPromise:i==null?void 0:i.initialPromise,fn:l.fetchFn,onCancel:y=>{y instanceof rh&&y.revert&&this.setState({..._(this,an),fetchStatus:"idle"}),s.abort()},onFail:(y,C)=>{ye(this,Fi,hs).call(this,{type:"failed",failureCount:y,error:C})},onPause:()=>{ye(this,Fi,hs).call(this,{type:"pause"})},onContinue:()=>{ye(this,Fi,hs).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const y=await _(this,yt).start();if(y===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(y),(v=(f=_(this,yi).config).onSuccess)==null||v.call(f,y,this),(b=(g=_(this,yi).config).onSettled)==null||b.call(g,y,this.state.error,this),y}catch(y){if(y instanceof rh){if(y.silent)return _(this,yt).promise;if(y.revert){if(this.state.data===void 0)throw y;return this.state.data}}throw ye(this,Fi,hs).call(this,{type:"error",error:y}),(w=(p=_(this,yi).config).onError)==null||w.call(p,y,this),(x=(R=_(this,yi).config).onSettled)==null||x.call(R,this.state.data,y,this),y}finally{this.scheduleGc()}}},yr=new WeakMap,an=new WeakMap,yi=new WeakMap,wr=new WeakMap,yt=new WeakMap,uo=new WeakMap,Cr=new WeakMap,Fi=new WeakSet,hs=function(t){const i=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...u_(s.data,this.options),fetchMeta:t.meta??null};case"success":const r={...s,...mu(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return G(this,an,t.manual?r:void 0),r;case"error":const n=t.error;return{...s,error:n,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=i(this.state),zt.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),_(this,yi).notify({query:this,type:"updated",action:t})})},Ou);function u_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:l_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function mu(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function bu(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,i=t!==void 0,s=i?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:i?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:i?"success":"pending",fetchStatus:"idle"}}var Jt,He,fo,qt,kr,ln,fs,Fs,_o,hn,cn,xr,Er,Ws,un,Ve,Kn,nh,oh,ah,lh,hh,ch,uh,d_,Iu,wy=(Iu=class extends xo{constructor(t,i){super();ee(this,Ve);ee(this,Jt);ee(this,He);ee(this,fo);ee(this,qt);ee(this,kr);ee(this,ln);ee(this,fs);ee(this,Fs);ee(this,_o);ee(this,hn);ee(this,cn);ee(this,xr);ee(this,Er);ee(this,Ws);ee(this,un,new Set);this.options=i,G(this,Jt,t),G(this,Fs,null),G(this,fs,sh()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(_(this,He).addObserver(this),Su(_(this,He),this.options)?ye(this,Ve,Kn).call(this):this.updateResult(),ye(this,Ve,lh).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return dh(_(this,He),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return dh(_(this,He),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ye(this,Ve,hh).call(this),ye(this,Ve,ch).call(this),_(this,He).removeObserver(this)}setOptions(t){const i=this.options,s=_(this,He);if(this.options=_(this,Jt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof xi(this.options.enabled,_(this,He))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ye(this,Ve,uh).call(this),_(this,He).setOptions(this.options),i._defaulted&&!eh(this.options,i)&&_(this,Jt).getQueryCache().notify({type:"observerOptionsUpdated",query:_(this,He),observer:this});const r=this.hasListeners();r&&yu(_(this,He),s,this.options,i)&&ye(this,Ve,Kn).call(this),this.updateResult(),r&&(_(this,He)!==s||xi(this.options.enabled,_(this,He))!==xi(i.enabled,_(this,He))||$s(this.options.staleTime,_(this,He))!==$s(i.staleTime,_(this,He)))&&ye(this,Ve,nh).call(this);const n=ye(this,Ve,oh).call(this);r&&(_(this,He)!==s||xi(this.options.enabled,_(this,He))!==xi(i.enabled,_(this,He))||n!==_(this,Ws))&&ye(this,Ve,ah).call(this,n)}getOptimisticResult(t){const i=_(this,Jt).getQueryCache().build(_(this,Jt),t),s=this.createResult(i,t);return ky(this,s)&&(G(this,qt,s),G(this,ln,this.options),G(this,kr,_(this,He).state)),s}getCurrentResult(){return _(this,qt)}trackResult(t,i){return new Proxy(t,{get:(s,r)=>(this.trackProp(r),i==null||i(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&_(this,fs).status==="pending"&&_(this,fs).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){_(this,un).add(t)}getCurrentQuery(){return _(this,He)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=_(this,Jt).defaultQueryOptions(t),s=_(this,Jt).getQueryCache().build(_(this,Jt),i);return s.fetch().then(()=>this.createResult(s,i))}fetch(t){return ye(this,Ve,Kn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),_(this,qt)))}createResult(t,i){var J;const s=_(this,He),r=this.options,n=_(this,qt),o=_(this,kr),l=_(this,ln),h=t!==s?t.state:_(this,fo),{state:d}=t;let u={...d},f=!1,v;if(i._optimisticResults){const ae=this.hasListeners(),X=!ae&&Su(t,i),N=ae&&yu(t,s,i,r);(X||N)&&(u={...u,...u_(d.data,t.options)}),i._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:p}=u;v=u.data;let w=!1;if(i.placeholderData!==void 0&&v===void 0&&p==="pending"){let ae;n!=null&&n.isPlaceholderData&&i.placeholderData===(l==null?void 0:l.placeholderData)?(ae=n.data,w=!0):ae=typeof i.placeholderData=="function"?i.placeholderData((J=_(this,cn))==null?void 0:J.state.data,_(this,cn)):i.placeholderData,ae!==void 0&&(p="success",v=ih(n==null?void 0:n.data,ae,i),f=!0)}if(i.select&&v!==void 0&&!w)if(n&&v===(o==null?void 0:o.data)&&i.select===_(this,_o))v=_(this,hn);else try{G(this,_o,i.select),v=i.select(v),v=ih(n==null?void 0:n.data,v,i),G(this,hn,v),G(this,Fs,null)}catch(ae){G(this,Fs,ae)}_(this,Fs)&&(g=_(this,Fs),v=_(this,hn),b=Date.now(),p="error");const R=u.fetchStatus==="fetching",x=p==="pending",y=p==="error",C=x&&R,L=v!==void 0,Y={status:p,fetchStatus:u.fetchStatus,isPending:x,isSuccess:p==="success",isError:y,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:u.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>h.dataUpdateCount||u.errorUpdateCount>h.errorUpdateCount,isFetching:R,isRefetching:R&&!x,isLoadingError:y&&!L,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:y&&L,isStale:jh(t,i),refetch:this.refetch,promise:_(this,fs),isEnabled:xi(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const ae=Y.data!==void 0,X=Y.status==="error"&&!ae,N=T=>{X?T.reject(Y.error):ae&&T.resolve(Y.data)},B=()=>{const T=G(this,fs,Y.promise=sh());N(T)},M=_(this,fs);switch(M.status){case"pending":t.queryHash===s.queryHash&&N(M);break;case"fulfilled":(X||Y.data!==M.value)&&B();break;case"rejected":(!X||Y.error!==M.reason)&&B();break}}return Y}updateResult(){const t=_(this,qt),i=this.createResult(_(this,He),this.options);if(G(this,kr,_(this,He).state),G(this,ln,this.options),_(this,kr).data!==void 0&&G(this,cn,_(this,He)),eh(i,t))return;G(this,qt,i);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!_(this,un).size)return!0;const o=new Set(n??_(this,un));return this.options.throwOnError&&o.add("error"),Object.keys(_(this,qt)).some(l=>{const c=l;return _(this,qt)[c]!==t[c]&&o.has(c)})};ye(this,Ve,d_).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ye(this,Ve,lh).call(this)}},Jt=new WeakMap,He=new WeakMap,fo=new WeakMap,qt=new WeakMap,kr=new WeakMap,ln=new WeakMap,fs=new WeakMap,Fs=new WeakMap,_o=new WeakMap,hn=new WeakMap,cn=new WeakMap,xr=new WeakMap,Er=new WeakMap,Ws=new WeakMap,un=new WeakMap,Ve=new WeakSet,Kn=function(t){ye(this,Ve,uh).call(this);let i=_(this,He).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(wi)),i},nh=function(){ye(this,Ve,hh).call(this);const t=$s(this.options.staleTime,_(this,He));if(wn||_(this,qt).isStale||!Zl(t))return;const s=n_(_(this,qt).dataUpdatedAt,t)+1;G(this,xr,fr.setTimeout(()=>{_(this,qt).isStale||this.updateResult()},s))},oh=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(_(this,He)):this.options.refetchInterval)??!1},ah=function(t){ye(this,Ve,ch).call(this),G(this,Ws,t),!(wn||xi(this.options.enabled,_(this,He))===!1||!Zl(_(this,Ws))||_(this,Ws)===0)&&G(this,Er,fr.setInterval(()=>{(this.options.refetchIntervalInBackground||qh.isFocused())&&ye(this,Ve,Kn).call(this)},_(this,Ws)))},lh=function(){ye(this,Ve,nh).call(this),ye(this,Ve,ah).call(this,ye(this,Ve,oh).call(this))},hh=function(){_(this,xr)&&(fr.clearTimeout(_(this,xr)),G(this,xr,void 0))},ch=function(){_(this,Er)&&(fr.clearInterval(_(this,Er)),G(this,Er,void 0))},uh=function(){const t=_(this,Jt).getQueryCache().build(_(this,Jt),this.options);if(t===_(this,He))return;const i=_(this,He);G(this,He,t),G(this,fo,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},d_=function(t){zt.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(_(this,qt))}),_(this,Jt).getQueryCache().notify({query:_(this,He),type:"observerResultsUpdated"})})},Iu);function Cy(e,t){return xi(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Su(e,t){return Cy(e,t)||e.state.data!==void 0&&dh(e,t,t.refetchOnMount)}function dh(e,t,i){if(xi(t.enabled,e)!==!1&&$s(t.staleTime,e)!=="static"){const s=typeof i=="function"?i(e):i;return s==="always"||s!==!1&&jh(e,t)}return!1}function yu(e,t,i,s){return(e!==t||xi(s.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&jh(e,i)}function jh(e,t){return xi(t.enabled,e)!==!1&&e.isStaleByTime($s(t.staleTime,e))}function ky(e,t){return!eh(e.getCurrentResult(),t)}function wu(e){return{onFetch:(t,i)=>{var d,u,f,v,g;const s=t.options,r=(f=(u=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:u.fetchMore)==null?void 0:f.direction,n=((v=t.state.data)==null?void 0:v.pages)||[],o=((g=t.state.data)==null?void 0:g.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const h=async()=>{let b=!1;const p=x=>{vy(x,()=>t.signal,()=>b=!0)},w=a_(t.options,t.fetchOptions),R=async(x,y,C)=>{if(b)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const z=(()=>{const X={client:t.client,queryKey:t.queryKey,pageParam:y,direction:C?"backward":"forward",meta:t.options.meta};return p(X),X})(),Y=await w(z),{maxPages:J}=t.options,ae=C?_y:fy;return{pages:ae(x.pages,Y,J),pageParams:ae(x.pageParams,y,J)}};if(r&&n.length){const x=r==="backward",y=x?xy:Cu,C={pages:n,pageParams:o},L=y(s,C);l=await R(C,L,x)}else{const x=e??n.length;do{const y=c===0?o[0]??s.initialPageParam:Cu(s,l);if(c>0&&y==null)break;l=await R(l,y),c++}while(c<x)}return l};t.options.persister?t.fetchFn=()=>{var b,p;return(p=(b=t.options).persister)==null?void 0:p.call(b,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=h}}}function Cu(e,{pages:t,pageParams:i}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,i[s],i):void 0}function xy(e,{pages:t,pageParams:i}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,i[0],i):void 0}var vo,$i,Ht,Pr,Zi,Bs,Nu,Ey=(Nu=class extends c_{constructor(t){super();ee(this,Zi);ee(this,vo);ee(this,$i);ee(this,Ht);ee(this,Pr);G(this,vo,t.client),this.mutationId=t.mutationId,G(this,Ht,t.mutationCache),G(this,$i,[]),this.state=t.state||Py(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){_(this,$i).includes(t)||(_(this,$i).push(t),this.clearGcTimeout(),_(this,Ht).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){G(this,$i,_(this,$i).filter(i=>i!==t)),this.scheduleGc(),_(this,Ht).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){_(this,$i).length||(this.state.status==="pending"?this.scheduleGc():_(this,Ht).remove(this))}continue(){var t;return((t=_(this,Pr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,h,d,u,f,v,g,b,p,w,R,x,y,C,L,z;const i=()=>{ye(this,Zi,Bs).call(this,{type:"continue"})},s={client:_(this,vo),meta:this.options.meta,mutationKey:this.options.mutationKey};G(this,Pr,h_({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(Y,J)=>{ye(this,Zi,Bs).call(this,{type:"failed",failureCount:Y,error:J})},onPause:()=>{ye(this,Zi,Bs).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>_(this,Ht).canRun(this)}));const r=this.state.status==="pending",n=!_(this,Pr).canStart();try{if(r)i();else{ye(this,Zi,Bs).call(this,{type:"pending",variables:t,isPaused:n}),_(this,Ht).config.onMutate&&await _(this,Ht).config.onMutate(t,this,s);const J=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,t,s));J!==this.state.context&&ye(this,Zi,Bs).call(this,{type:"pending",context:J,variables:t,isPaused:n})}const Y=await _(this,Pr).start();return await((h=(c=_(this,Ht).config).onSuccess)==null?void 0:h.call(c,Y,t,this.state.context,this,s)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,Y,t,this.state.context,s)),await((v=(f=_(this,Ht).config).onSettled)==null?void 0:v.call(f,Y,null,this.state.variables,this.state.context,this,s)),await((b=(g=this.options).onSettled)==null?void 0:b.call(g,Y,null,t,this.state.context,s)),ye(this,Zi,Bs).call(this,{type:"success",data:Y}),Y}catch(Y){try{await((w=(p=_(this,Ht).config).onError)==null?void 0:w.call(p,Y,t,this.state.context,this,s))}catch(J){Promise.reject(J)}try{await((x=(R=this.options).onError)==null?void 0:x.call(R,Y,t,this.state.context,s))}catch(J){Promise.reject(J)}try{await((C=(y=_(this,Ht).config).onSettled)==null?void 0:C.call(y,void 0,Y,this.state.variables,this.state.context,this,s))}catch(J){Promise.reject(J)}try{await((z=(L=this.options).onSettled)==null?void 0:z.call(L,void 0,Y,t,this.state.context,s))}catch(J){Promise.reject(J)}throw ye(this,Zi,Bs).call(this,{type:"error",error:Y}),Y}finally{_(this,Ht).runNext(this)}}},vo=new WeakMap,$i=new WeakMap,Ht=new WeakMap,Pr=new WeakMap,Zi=new WeakSet,Bs=function(t){const i=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=i(this.state),zt.batch(()=>{_(this,$i).forEach(s=>{s.onMutationUpdate(t)}),_(this,Ht).notify({mutation:this,type:"updated",action:t})})},Nu);function Py(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _s,Wi,po,Fu,Ry=(Fu=class extends xo{constructor(t={}){super();ee(this,_s);ee(this,Wi);ee(this,po);this.config=t,G(this,_s,new Set),G(this,Wi,new Map),G(this,po,0)}build(t,i,s){const r=new Ey({client:t,mutationCache:this,mutationId:++Po(this,po)._,options:t.defaultMutationOptions(i),state:s});return this.add(r),r}add(t){_(this,_s).add(t);const i=No(t);if(typeof i=="string"){const s=_(this,Wi).get(i);s?s.push(t):_(this,Wi).set(i,[t])}this.notify({type:"added",mutation:t})}remove(t){if(_(this,_s).delete(t)){const i=No(t);if(typeof i=="string"){const s=_(this,Wi).get(i);if(s)if(s.length>1){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}else s[0]===t&&_(this,Wi).delete(i)}}this.notify({type:"removed",mutation:t})}canRun(t){const i=No(t);if(typeof i=="string"){const s=_(this,Wi).get(i),r=s==null?void 0:s.find(n=>n.state.status==="pending");return!r||r===t}else return!0}runNext(t){var s;const i=No(t);if(typeof i=="string"){const r=(s=_(this,Wi).get(i))==null?void 0:s.find(n=>n!==t&&n.state.isPaused);return(r==null?void 0:r.continue())??Promise.resolve()}else return Promise.resolve()}clear(){zt.batch(()=>{_(this,_s).forEach(t=>{this.notify({type:"removed",mutation:t})}),_(this,_s).clear(),_(this,Wi).clear()})}getAll(){return Array.from(_(this,_s))}find(t){const i={exact:!0,...t};return this.getAll().find(s=>vu(i,s))}findAll(t={}){return this.getAll().filter(i=>vu(t,i))}notify(t){zt.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return zt.batch(()=>Promise.all(t.map(i=>i.continue().catch(wi))))}},_s=new WeakMap,Wi=new WeakMap,po=new WeakMap,Fu);function No(e){var t;return(t=e.options.scope)==null?void 0:t.id}var es,Wu,Dy=(Wu=class extends xo{constructor(t={}){super();ee(this,es);this.config=t,G(this,es,new Map)}build(t,i,s){const r=i.queryKey,n=i.queryHash??Uh(r,i);let o=this.get(n);return o||(o=new yy({client:t,queryKey:r,queryHash:n,options:t.defaultQueryOptions(i),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){_(this,es).has(t.queryHash)||(_(this,es).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=_(this,es).get(t.queryHash);i&&(t.destroy(),i===t&&_(this,es).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){zt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return _(this,es).get(t)}getAll(){return[..._(this,es).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(s=>_u(i,s))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(s=>_u(t,s)):i}notify(t){zt.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){zt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){zt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},es=new WeakMap,Wu),rt,Hs,zs,dn,fn,Us,_n,vn,Hu,f_=(Hu=class{constructor(e={}){ee(this,rt);ee(this,Hs);ee(this,zs);ee(this,dn);ee(this,fn);ee(this,Us);ee(this,_n);ee(this,vn);G(this,rt,e.queryCache||new Dy),G(this,Hs,e.mutationCache||new Ry),G(this,zs,e.defaultOptions||{}),G(this,dn,new Map),G(this,fn,new Map),G(this,Us,0)}mount(){Po(this,Us)._++,_(this,Us)===1&&(G(this,_n,qh.subscribe(async e=>{e&&(await this.resumePausedMutations(),_(this,rt).onFocus())})),G(this,vn,ra.subscribe(async e=>{e&&(await this.resumePausedMutations(),_(this,rt).onOnline())})))}unmount(){var e,t;Po(this,Us)._--,_(this,Us)===0&&((e=_(this,_n))==null||e.call(this),G(this,_n,void 0),(t=_(this,vn))==null||t.call(this),G(this,vn,void 0))}isFetching(e){return _(this,rt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return _(this,Hs).findAll({...e,status:"pending"}).length}getQueryData(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=_(this,rt).get(t.queryHash))==null?void 0:i.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=_(this,rt).build(this,t),s=i.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime($s(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return _(this,rt).findAll(e).map(({queryKey:t,state:i})=>{const s=i.data;return[t,s]})}setQueryData(e,t,i){const s=this.defaultQueryOptions({queryKey:e}),r=_(this,rt).get(s.queryHash),n=r==null?void 0:r.state.data,o=cy(t,n);if(o!==void 0)return _(this,rt).build(this,s).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return zt.batch(()=>_(this,rt).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,i)]))}getQueryState(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=_(this,rt).get(t.queryHash))==null?void 0:i.state}removeQueries(e){const t=_(this,rt);zt.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=_(this,rt);return zt.batch(()=>(i.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},s=zt.batch(()=>_(this,rt).findAll(e).map(r=>r.cancel(i)));return Promise.all(s).then(wi).catch(wi)}invalidateQueries(e,t={}){return zt.batch(()=>(_(this,rt).findAll(e).forEach(i=>{i.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const i={...t,cancelRefetch:t.cancelRefetch??!0},s=zt.batch(()=>_(this,rt).findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let n=r.fetch(void 0,i);return i.throwOnError||(n=n.catch(wi)),r.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(wi)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=_(this,rt).build(this,t);return i.isStaleByTime($s(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(wi).catch(wi)}fetchInfiniteQuery(e){return e.behavior=wu(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(wi).catch(wi)}ensureInfiniteQueryData(e){return e.behavior=wu(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ra.isOnline()?_(this,Hs).resumePausedMutations():Promise.resolve()}getQueryCache(){return _(this,rt)}getMutationCache(){return _(this,Hs)}getDefaultOptions(){return _(this,zs)}setDefaultOptions(e){G(this,zs,e)}setQueryDefaults(e,t){_(this,dn).set(no(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[..._(this,dn).values()],i={};return t.forEach(s=>{oo(e,s.queryKey)&&Object.assign(i,s.defaultOptions)}),i}setMutationDefaults(e,t){_(this,fn).set(no(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[..._(this,fn).values()],i={};return t.forEach(s=>{oo(e,s.mutationKey)&&Object.assign(i,s.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={..._(this,zs).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uh(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Kh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{..._(this,zs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){_(this,rt).clear(),_(this,Hs).clear()}},rt=new WeakMap,Hs=new WeakMap,zs=new WeakMap,dn=new WeakMap,fn=new WeakMap,Us=new WeakMap,_n=new WeakMap,vn=new WeakMap,Hu);const __=Symbol("QueryClient"),Ty=()=>{const e=Qu(__);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},My=e=>{ov(__,e)},By=Symbol("isRestoring"),Ly=()=>{try{return Qu(By)??{current:!1}}catch{return{current:!1}}};function Ay(){return Ly()}function Oy(e){return Ty()}var Iy=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Ny=["difference","intersection","symmetricDifference","union"],ku=!1,pn,Hi,Ks,la,Cn,v_,p_;const ha=class ha extends Set{constructor(i){super();ee(this,Cn);ee(this,pn,new Map);ee(this,Hi,F(0));ee(this,Ks,F(0));ee(this,la,Ss||-1);if(i){for(var s of i)super.add(s);_(this,Ks).v=super.size}ku||ye(this,Cn,p_).call(this)}has(i){var s=super.has(i),r=_(this,pn),n=r.get(i);if(n===void 0){if(!s)return a(_(this,Hi)),!1;n=ye(this,Cn,v_).call(this,!0),r.set(i,n)}return a(n),s}add(i){return super.has(i)||(super.add(i),m(_(this,Ks),super.size),Xs(_(this,Hi))),this}delete(i){var s=super.delete(i),r=_(this,pn),n=r.get(i);return n!==void 0&&(r.delete(i),m(n,!1)),s&&(m(_(this,Ks),super.size),Xs(_(this,Hi))),s}clear(){if(super.size!==0){super.clear();var i=_(this,pn);for(var s of i.values())m(s,!1);i.clear(),m(_(this,Ks),0),Xs(_(this,Hi))}}keys(){return this.values()}values(){return a(_(this,Hi)),super.values()}entries(){return a(_(this,Hi)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return a(_(this,Ks))}};pn=new WeakMap,Hi=new WeakMap,Ks=new WeakMap,la=new WeakMap,Cn=new WeakSet,v_=function(i){return Ss===_(this,la)?F(i):Zs(i)},p_=function(){ku=!0;var i=ha.prototype,s=Set.prototype;for(const r of Iy)i[r]=function(...n){return a(_(this,Hi)),s[r].apply(this,n)};for(const r of Ny)i[r]=function(...n){a(_(this,Hi));var o=s[r].apply(this,n);return new ha(o)}};let fh=ha;function Fy(e){const t=Array.isArray(e)?[]:{},i=new fh,s=new Proxy(t,{set(n,o,l,c){if(i.delete(o),o in n)return Reflect.set(n,o,l,c);let h=F(l);return Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:()=>a(h)&&Hy(a(h))?a(h)():a(h),set:d=>{m(h,d)}}),!0},has:(n,o)=>i.has(o)?!1:o in n,ownKeys(n){return Reflect.ownKeys(n).filter(o=>!i.has(o))},getOwnPropertyDescriptor(n,o){if(!i.has(o))return Reflect.getOwnPropertyDescriptor(n,o)},deleteProperty(n,o){return o in n?(n[o]=void 0,i.add(o),Array.isArray(n)&&n.length--,!0):!1}});function r(n){const o=Object.keys(s),l=Object.keys(n),c=o.filter(h=>!l.includes(h));for(const h of c)delete s[h];for(const h of l)s[h]=Wy(()=>n[h])}return r(e),[s,r]}const g_=Symbol("LazyValue");function Wy(e){return e[g_]=!0,e}function Hy(e){return!!e[g_]}function zy(e,t){switch(e){case"post":ss(t);break;case"pre":Ov(t);break}}const Xa=(e,t,i)=>{let s=!1,r=Array.isArray(e)?[]:void 0;zy(t,()=>{const n=Array.isArray(e)?e.map(l=>l()):e();if(!s){s=!0,r=n;return}const o=tr(()=>i(n,r));return r=n,o})};function Uy(e,t,i){const s=_e(()=>Oy()),r=Ay(),n=_e(()=>{const d=a(s).defaultQueryOptions(e());return d._optimisticResults=r.current?"isRestoring":"optimistic",d});let o=F(Xe(new t(a(s),a(n))));Xa(()=>a(s),"pre",()=>{m(o,new t(a(s),a(n)),!0)});function l(){const d=a(o).getOptimisticResult(a(n));return a(n).notifyOnChangeProps?d:a(o).trackResult(d)}const[c,h]=Fy(l());return ss(()=>{const d=r.current?()=>{}:a(o).subscribe(()=>h(l()));return a(o).updateResult(),d}),Xa(()=>a(n),"pre",()=>{a(o).setOptions(a(n))}),Xa(()=>[a(n),a(o)],"pre",()=>{h(l())}),c}function na(e,t){return Uy(e,wy)}function Ky(e,t){ct(t,!0);const i=ws(t,"client",19,()=>new f_);En(()=>{i().mount()}),My(i()),up(()=>{i().unmount()});var s=ys(),r=_t(s);Zv(r,()=>t.children),O(e,s),ut()}var qy=W('<div class="branch-error svelte-1ogsozk"> </div>'),jy=W('<div class="branch-loading svelte-1ogsozk">Loading...</div>'),Vy=W('<div class="branch-empty svelte-1ogsozk">No branches match</div>'),Yy=W('<span class="branch-check svelte-1ogsozk">✓</span>'),Gy=W('<span class="branch-check branch-check--empty svelte-1ogsozk"></span>'),Xy=W('<span class="branch-spinner svelte-1ogsozk">…</span>'),Qy=W('<li role="option"><!> <span class="branch-option-name svelte-1ogsozk"> </span> <!></li>'),Jy=W('<ul class="branch-list svelte-1ogsozk"></ul>'),$y=W('<div class="branch-dropdown svelte-1ogsozk" role="listbox" tabindex="-1" aria-label="Branches"><div class="branch-filter-wrap svelte-1ogsozk"><input type="text" class="branch-filter svelte-1ogsozk" placeholder="Filter branches..." aria-label="Filter branches"/></div> <!> <!></div>'),Zy=W('<div class="branch-switcher svelte-1ogsozk"><button class="branch-trigger svelte-1ogsozk" aria-label="Switch branch" aria-haspopup="listbox"><span class="branch-icon svelte-1ogsozk">⑂</span> <span class="branch-name svelte-1ogsozk"> </span> <svg class="branch-caret svelte-1ogsozk" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path d="M1 1l4 4 4-4" stroke="currentColor" fill="none" stroke-width="1.5" stroke-linecap="round"></path></svg></button> <!></div>');function ew(e,t){ct(t,!0);let i=F(!1),s=F(""),r=F(null),n=F(null),o=F(null),l=F(null);const c=na(()=>({queryKey:["branches",t.workspacePath],queryFn:()=>Ph(t.workspacePath),staleTime:3e4,enabled:a(i)}));let h=_e(()=>{const C=c.data??[];if(!a(s).trim())return C;const L=a(s).toLowerCase();return C.filter(z=>z.toLowerCase().includes(L))});function d(){m(i,!0),m(s,""),m(l,null),requestAnimationFrame(()=>{var C;return(C=a(n))==null?void 0:C.focus()})}function u(){m(i,!1),m(s,"")}async function f(C){if(C===t.currentBranch){u();return}m(o,C,!0),m(l,null);try{const L=await Cp(t.workspacePath,C);L.success?(u(),t.onSwitch(C)):m(l,L.error??"Failed to switch branch",!0)}catch{m(l,"Failed to switch branch")}finally{m(o,null)}}function v(C){a(i)&&a(r)&&document.contains(C.target)&&!a(r).contains(C.target)&&u()}function g(C){C.key==="Escape"&&a(i)&&(u(),C.stopPropagation())}var b=Zy();ps("click",Go,v);var p=S(b),w=k(S(p),2),R=S(w),x=k(p,2);{var y=C=>{var L=$y(),z=S(L),Y=S(z);$e(Y,T=>m(n,T),()=>a(n));var J=k(z,2);{var ae=T=>{var j=qy(),D=S(j);le(()=>re(D,a(l))),O(T,j)};ne(J,T=>{a(l)&&T(ae)})}var X=k(J,2);{var N=T=>{var j=jy();O(T,j)},B=T=>{var j=Vy();O(T,j)},M=T=>{var j=Jy();Ot(j,20,()=>a(h),D=>D,(D,P)=>{var U=Qy();let Z;var me=S(U);{var be=ve=>{var Re=Yy();O(ve,Re)},fe=ve=>{var Re=Gy();O(ve,Re)};ne(me,ve=>{P===t.currentBranch?ve(be):ve(fe,!1)})}var ke=k(me,2),Ee=S(ke),Ce=k(ke,2);{var $=ve=>{var Re=Xy();O(ve,Re)};ne(Ce,ve=>{a(o)===P&&ve($)})}le(()=>{Z=Ze(U,1,"branch-option svelte-1ogsozk",null,Z,{"branch-current":P===t.currentBranch,"branch-switching":a(o)===P}),Ne(U,"aria-selected",P===t.currentBranch),re(Ee,P)}),Q("mousedown",U,()=>f(P)),O(D,U)}),O(T,j)};ne(X,T=>{c.isLoading?T(N):a(h).length===0?T(B,1):T(M,!1)})}Q("keydown",L,g),Q("keydown",Y,g),Ei(Y,()=>a(s),T=>m(s,T)),O(C,L)};ne(x,C=>{a(i)&&C(y)})}$e(b,C=>m(r,C),()=>a(r)),le(()=>{Ne(p,"aria-expanded",a(i)),re(R,t.currentBranch)}),Q("click",p,d),O(e,b),ut()}ot(["click","keydown","mousedown"]);var tw=W('<span class="target-branch svelte-1shtc4l" aria-label="target branch"><span class="target-sep svelte-1shtc4l">›</span> <span class="target-name svelte-1shtc4l"> </span></span>'),iw=W('<div class="bar-middle svelte-1shtc4l" aria-label="pull request"><a class="pr-link svelte-1shtc4l" target="_blank" rel="noopener noreferrer"> <svg class="pr-ext-icon svelte-1shtc4l" width="10" height="10" viewBox="0 0 10 10" aria-hidden="true"><path d="M1 9L9 1M9 1H4M9 1V6" stroke="currentColor" fill="none" stroke-width="1.5" stroke-linecap="round"></path></svg></a></div> <span class="diff-stats svelte-1shtc4l"><span class="diff-add svelte-1shtc4l"> </span> <span class="diff-del svelte-1shtc4l"> </span></span>',1),sw=W('<span class="bar-loading svelte-1shtc4l">…</span>'),rw=W('<button class="action-btn action-btn--secondary svelte-1shtc4l"> </button>'),nw=W("<button> </button>"),ow=W("<!> <!>",1),aw=W('<div><div class="bar-left svelte-1shtc4l"><!> <!></div> <!> <div class="bar-right svelte-1shtc4l"><!></div></div>');function lw(e,t){ct(t,!0);let i=F(Xe(t.branchName));ss(()=>{m(i,t.branchName,!0)}),ss(()=>{!t.branchName&&t.workspacePath&&wp(t.workspacePath).then(X=>{X&&m(i,X,!0)})});const s=na(()=>({queryKey:["pr",t.workspacePath,a(i)],queryFn:()=>yp(t.workspacePath,a(i)),staleTime:6e4,refetchOnWindowFocus:!0})),r=na(()=>{var X;return{queryKey:["ci-status",t.workspacePath,a(i)],queryFn:()=>Sp(t.workspacePath,a(i)),staleTime:3e4,refetchOnWindowFocus:!0,enabled:((X=s.data)==null?void 0:X.state)==="OPEN"}});ss(()=>{t.sessionId&&(s.refetch(),r.refetch())});let n=_e(()=>s.data??null),o=_e(()=>r.data??null),l=_e(()=>{var X,N,B,M,T,j;return{commitsAhead:a(n)?1:0,prState:a(n)?a(n).isDraft?"DRAFT":a(n).state:null,ciPassing:((X=a(o))==null?void 0:X.passing)??0,ciFailing:((N=a(o))==null?void 0:N.failing)??0,ciPending:((B=a(o))==null?void 0:B.pending)??0,ciTotal:((M=a(o))==null?void 0:M.total)??0,mergeable:((T=a(n))==null?void 0:T.mergeable)??null,unresolvedCommentCount:((j=a(n))==null?void 0:j.unresolvedCommentCount)??0}}),c=_e(()=>Mh(a(l))),h=_e(()=>dg(a(c),a(l))),d=_e(()=>ff(a(c).color)),u=_e(()=>_f(a(c).color)),f=_e(()=>a(c).type!=="none");function v(X=a(c)){var M,T,j,D;const N={branchName:a(i),baseBranch:((M=a(n))==null?void 0:M.baseRefName)??"",prNumber:((T=a(n))==null?void 0:T.number)??0,unresolvedCommentCount:((j=a(n))==null?void 0:j.unresolvedCommentCount)??0},B=df(X,N);B!==null?t.sessionId&&Qs(B+"\r"):(D=t.onArchive)==null||D.call(t)}function g(X){m(i,X,!0)}var b=aw();let p;var w=S(b),R=S(w);ew(R,{get workspacePath(){return t.workspacePath},get currentBranch(){return a(i)},onSwitch:g});var x=k(R,2);{var y=X=>{var N=tw(),B=k(S(N),2),M=S(B);le(()=>re(M,a(n).baseRefName)),O(X,N)};ne(x,X=>{var N;(N=a(n))!=null&&N.baseRefName&&X(y)})}var C=k(w,2);{var L=X=>{var N=iw(),B=_t(N),M=S(B),T=S(M),j=k(B,2),D=S(j),P=S(D),U=k(D,2),Z=S(U);le(()=>{Ne(M,"href",a(n).url),Ne(M,"aria-label",`PR #${a(n).number??""}: ${a(n).title??""}`),re(T,`PR #${a(n).number??""} `),re(P,`+${a(n).additions??""}`),re(Z,`-${a(n).deletions??""}`)}),O(X,N)};ne(C,X=>{a(n)&&X(L)})}var z=k(C,2),Y=S(z);{var J=X=>{var N=sw();O(X,N)},ae=X=>{var N=ow(),B=_t(N);{var M=D=>{var P=rw(),U=S(P);le(()=>{Ne(P,"aria-label",a(h).label),re(U,a(h).label)}),Q("click",P,()=>v(a(h))),O(D,P)};ne(B,D=>{a(h)&&D(M)})}var T=k(B,2);{var j=D=>{var P=nw();let U,Z;var me=S(P);le(()=>{U=Ze(P,1,"action-btn svelte-1shtc4l",null,U,{"action-btn--dark-text":a(u),"action-btn--disabled":a(c).type==="checks-running"}),P.disabled=a(c).type==="checks-running",Ne(P,"aria-label",a(c).label),Z=xn(P,"",Z,{"--action-color":a(d)}),re(me,a(c).label)}),Q("click",P,()=>v()),O(D,P)};ne(T,D=>{a(f)&&D(j)})}O(X,N)};ne(Y,X=>{s.isLoading?X(J):X(ae,!1)})}le(()=>{var X,N;return p=Ze(b,1,"pr-top-bar svelte-1shtc4l",null,p,{"bar-merged":((X=a(n))==null?void 0:X.state)==="MERGED","bar-conflicts":((N=a(n))==null?void 0:N.mergeable)==="CONFLICTING"})}),O(e,b),ut()}ot(["click"]);var hw=W('<button role="tab"><span class="tab-icon svelte-3dfyyn" aria-hidden="true"> </span> <span class="tab-name svelte-3dfyyn"> </span> <span class="tab-close svelte-3dfyyn" role="button">×</span></button>'),cw=W('<div class="new-menu svelte-3dfyyn" role="menu" tabindex="-1"><button class="new-menu-item svelte-3dfyyn" role="menuitem"><span class="new-menu-icon svelte-3dfyyn">🤖</span> New Claude Session</button> <button class="new-menu-item svelte-3dfyyn" role="menuitem"><span class="new-menu-icon svelte-3dfyyn">🖥</span> New Terminal</button></div>'),uw=W('<div class="session-tab-bar svelte-3dfyyn" role="tablist" aria-label="Sessions"><div class="tabs-scroll svelte-3dfyyn"></div> <div class="new-btn-wrap svelte-3dfyyn"><button class="tab-new svelte-3dfyyn" aria-label="New session" aria-haspopup="menu">+</button> <!></div></div>');function dw(e,t){ct(t,!0);let i=F(!1),s=F(null);function r(R){return R.type==="terminal"?"🖥":"🤖"}function n(R,x){R.stopPropagation(),t.onCloseSession(x)}function o(R,x){(R.key==="Enter"||R.key===" ")&&(R.stopPropagation(),t.onCloseSession(x))}function l(){m(i,!a(i))}function c(){m(i,!1),t.onNewSession()}function h(){m(i,!1),t.onNewTerminal()}function d(R){var x;a(i)&&a(s)&&document.contains(R.target)&&!((x=a(s).closest(".new-btn-wrap"))!=null&&x.contains(R.target))&&m(i,!1)}function u(R){var x;R.key==="Escape"&&a(i)&&(m(i,!1),(x=a(s))==null||x.focus())}var f=uw();ps("click",Go,d);var v=S(f);Ot(v,21,()=>t.sessions,R=>R.id,(R,x)=>{const y=_e(()=>a(x).id===t.activeSessionId);var C=hw();let L;var z=S(C),Y=S(z),J=k(z,2),ae=S(J),X=k(J,2);le(N=>{L=Ze(C,1,"tab svelte-3dfyyn",null,L,{"tab--active":a(y)}),Ne(C,"aria-selected",a(y)),Ne(C,"aria-label",a(x).displayName||a(x).id),Ne(C,"tabindex",a(y)?0:-1),re(Y,N),re(ae,a(x).displayName||a(x).repoName||a(x).id),Ne(X,"aria-label",`Close ${(a(x).displayName||a(x).id)??""}`)},[()=>r(a(x))]),Q("click",C,()=>t.onSelectSession(a(x).id)),Q("click",X,N=>n(N,a(x).id)),Q("keydown",X,N=>o(N,a(x).id)),O(R,C)});var g=k(v,2),b=S(g);$e(b,R=>m(s,R),()=>a(s));var p=k(b,2);{var w=R=>{var x=cw(),y=S(x),C=k(y,2);Q("keydown",x,u),Q("click",y,c),Q("click",C,h),O(R,x)};ne(p,R=>{a(i)&&R(w)})}le(()=>Ne(b,"aria-expanded",a(i))),Q("click",b,l),Q("keydown",b,u),O(e,f),ut()}ot(["click","keydown"]);var fw=W('<div class="non-git-notice svelte-bvvs2r"><span class="non-git-msg svelte-bvvs2r">Not a git repository</span></div>'),_w=W('<div class="pr-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-title svelte-bvvs2r"></div> <div class="skeleton-line skeleton-meta svelte-bvvs2r"></div></div>'),vw=W('<div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>'),pw=W('<div class="section-message svelte-bvvs2r">Could not load pull requests</div>'),gw=W('<div class="section-message info svelte-bvvs2r">Install GitHub CLI for PR tracking — <a href="https://cli.github.com" target="_blank" rel="noopener noreferrer" class="svelte-bvvs2r">cli.github.com</a></div>'),mw=W('<div class="section-message svelte-bvvs2r">No open pull requests</div>'),bw=W('<input class="pr-search svelte-bvvs2r" type="text" placeholder="Filter PRs by title, number, or branch..."/>'),Sw=W('<button class="pr-action-pill pr-conflict-pill svelte-bvvs2r" title="Open worktree and fix merge conflicts">Fix Conflicts</button>'),yw=W('<a class="pr-action-pill pr-merge-pill svelte-bvvs2r" target="_blank" rel="noopener noreferrer" title="Ready to merge on GitHub">Merge</a>'),ww=W("<button> </button>"),Cw=W('<div class="pr-row svelte-bvvs2r"><div class="pr-row-left svelte-bvvs2r"><div class="pr-row-title-line svelte-bvvs2r"><span></span> <a class="pr-title-link svelte-bvvs2r" target="_blank" rel="noopener noreferrer"> </a></div> <div class="pr-row-meta svelte-bvvs2r"><span class="pr-num svelte-bvvs2r"> </span> <span class="pr-sep svelte-bvvs2r">·</span> <span class="pr-role svelte-bvvs2r"> </span> <span class="pr-sep svelte-bvvs2r">·</span> <span class="pr-time svelte-bvvs2r"> </span></div></div> <div class="pr-row-actions svelte-bvvs2r"><button class="pr-session-btn svelte-bvvs2r" title="Open session on this branch">+</button> <!> <!> <!></div></div>'),kw=W('<!> <div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>',1),xw=W('<div class="activity-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-activity svelte-bvvs2r"></div></div>'),Ew=W('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),Pw=W('<div class="section-message svelte-bvvs2r">No recent commits (24h)</div>'),Rw=W('<span class="commit-branch svelte-bvvs2r"> </span>'),Dw=W('<div class="activity-row svelte-bvvs2r"><span class="commit-hash svelte-bvvs2r"> </span> <span class="commit-msg svelte-bvvs2r"> </span> <!> <span class="commit-time svelte-bvvs2r"> </span></div>'),Tw=W('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),Mw=W('<section class="dashboard-section dashboard-section--scroll svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">OPEN PULL REQUESTS</div> <!></section> <section class="dashboard-section dashboard-section--scroll svelte-bvvs2r"><div class="section-heading svelte-bvvs2r">RECENT ACTIVITY</div> <!></section>',1),Bw=W('<button class="cta-btn svelte-bvvs2r">+ New Worktree</button>'),Lw=W('<div class="repo-dashboard svelte-bvvs2r"><!> <div class="cta-row svelte-bvvs2r"><button class="cta-btn svelte-bvvs2r">+ Start Session</button> <!></div></div>');function Aw(e,t){ct(t,!0);const i=na(()=>({queryKey:["dashboard",t.workspacePath],queryFn:()=>bp(t.workspacePath),staleTime:6e4,refetchOnWindowFocus:!0}));let s=_e(()=>i.data),r=_e(()=>i.isLoading),n=_e(()=>i.isError);function o(C){return C.state!=="OPEN"?"dot dot-muted":C.reviewDecision==="CHANGES_REQUESTED"?"dot dot-error":"dot dot-success"}function l(C){const L=C.state==="OPEN"?"OPEN":C.state==="MERGED"?"MERGED":"CLOSED";return Mh({commitsAhead:1,prState:L,ciFailing:0,ciPending:0,ciTotal:0,mergeable:C.mergeable??null,unresolvedCommentCount:0})}function c(C){return C.role==="author"?"by you":"review requested"}function h(C){return!C.branches||C.branches.length===0?"":"("+C.branches.join(", ")+")"}let d=F(""),u=_e(()=>a(s)?a(s).prs.length>5:!1),f=_e(()=>()=>{if(!a(s))return[];const C=a(d).toLowerCase().trim();return C?a(s).prs.filter(L=>L.title.toLowerCase().includes(C)||String(L.number).includes(C)||L.headRefName.toLowerCase().includes(C)):a(s).prs});var v=Lw(),g=S(v);{var b=C=>{var L=fw();O(C,L)},p=C=>{var L=Mw(),z=_t(L),Y=k(S(z),2);{var J=U=>{var Z=vw(),me=S(Z);Ot(me,20,()=>[1,2],Zn,(be,fe)=>{var ke=_w();O(be,ke)}),O(U,Z)},ae=U=>{var Z=pw();O(U,Z)},X=U=>{var Z=gw();O(U,Z)},N=U=>{var Z=mw();O(U,Z)},B=U=>{var Z=kw(),me=_t(Z);{var be=Ee=>{var Ce=bw();Ei(Ce,()=>a(d),$=>m(d,$)),O(Ee,Ce)};ne(me,Ee=>{a(u)&&Ee(be)})}var fe=k(me,2),ke=S(fe);Ot(ke,21,()=>a(f)(),Ee=>Ee.number,(Ee,Ce)=>{const $=_e(()=>l(a(Ce))),ve=_e(()=>ff(a($).color)),Re=_e(()=>_f(a($).color));var Ye=Cw(),Fe=S(Ye),Te=S(Fe),ge=S(Te),Qe=k(ge,2),Le=S(Qe),Be=k(Te,2),A=S(Be),ie=S(A),de=k(A,4),he=S(de),Se=k(de,4),se=S(Se),Ie=k(Fe,2),ze=S(Ie),I=k(ze,2);{var K=pe=>{var we=Sw();Q("click",we,()=>t.onFixConflicts(a(Ce))),O(pe,we)};ne(I,pe=>{a(Ce).mergeable==="CONFLICTING"&&pe(K)})}var H=k(I,2);{var E=pe=>{var we=yw();le(()=>Ne(we,"href",a(Ce).url)),O(pe,we)};ne(H,pe=>{a(Ce).mergeable==="MERGEABLE"&&a(Ce).state==="OPEN"&&pe(E)})}var V=k(H,2);{var ce=pe=>{var we=ww();let xe,Ue;var Ft=S(we);le(()=>{xe=Ze(we,1,"pr-action-pill svelte-bvvs2r",null,xe,{"dark-text":a(Re)}),Ne(we,"title",a($).label),Ue=xn(we,"",Ue,{"--pill-color":a(ve)}),re(Ft,a($).label)}),Q("click",we,()=>t.onPrAction(a(Ce))),O(pe,we)};ne(V,pe=>{a($).type!=="none"&&a($).label&&pe(ce)})}le((pe,we,xe)=>{Ze(ge,1,pe,"svelte-bvvs2r"),Ne(Qe,"href",a(Ce).url),re(Le,a(Ce).title),re(ie,`#${a(Ce).number??""}`),re(he,we),re(se,xe)},[()=>Fd(o(a(Ce))),()=>c(a(Ce)),()=>ug(a(Ce).updatedAt)]),Q("click",ze,()=>t.onOpenPrSession(a(Ce))),O(Ee,Ye)}),O(U,Z)};ne(Y,U=>{a(r)?U(J):a(n)?U(ae,1):a(s)&&!a(s).hasGhCli?U(X,2):a(s)&&a(s).prs.length===0?U(N,3):a(s)&&U(B,4)})}var M=k(z,2),T=k(S(M),2);{var j=U=>{var Z=Ew(),me=S(Z);Ot(me,20,()=>[1,2,3],Zn,(be,fe)=>{var ke=xw();O(be,ke)}),O(U,Z)},D=U=>{var Z=Pw();O(U,Z)},P=U=>{var Z=Tw(),me=S(Z);Ot(me,21,()=>a(s).activity,be=>be.hash,(be,fe)=>{var ke=Dw(),Ee=S(ke),Ce=S(Ee),$=k(Ee,2),ve=S($),Re=k($,2);{var Ye=ge=>{var Qe=Rw(),Le=S(Qe);le(Be=>re(Le,Be),[()=>h(a(fe))]),O(ge,Qe)};ne(Re,ge=>{a(fe).branches.length>0&&ge(Ye)})}var Fe=k(Re,2),Te=S(Fe);le(()=>{re(Ce,a(fe).shortHash),re(ve,a(fe).message),re(Te,a(fe).timeAgo)}),O(be,ke)}),O(U,Z)};ne(T,U=>{a(r)?U(j):a(s)&&a(s).activity.length===0?U(D,1):a(s)&&U(P,2)})}O(C,L)};ne(g,C=>{a(s)&&!a(s).isGitRepo?C(b):C(p,!1)})}var w=k(g,2),R=S(w),x=k(R,2);{var y=C=>{var L=Bw();Q("click",L,function(...z){var Y;(Y=t.onNewWorktree)==null||Y.apply(this,z)}),O(C,L)};ne(x,C=>{(!a(s)||a(s).isGitRepo)&&C(y)})}Q("click",R,function(...C){var L;(L=t.onNewSession)==null||L.apply(this,C)}),O(e,v),ut()}ot(["click"]);var Ow=W('<div class="empty-icon svelte-1luen49" aria-hidden="true"> </div>'),Iw=W('<p class="empty-description svelte-1luen49"> </p>'),Nw=W('<button class="empty-action svelte-1luen49"> </button>'),Fw=W('<div class="empty-state svelte-1luen49"><!> <div class="empty-heading svelte-1luen49"> </div> <!> <!></div>');function Ww(e,t){var i=Fw(),s=S(i);{var r=u=>{var f=Ow(),v=S(f);le(()=>re(v,t.icon)),O(u,f)};ne(s,u=>{t.icon&&u(r)})}var n=k(s,2),o=S(n),l=k(n,2);{var c=u=>{var f=Iw(),v=S(f);le(()=>re(v,t.description)),O(u,f)};ne(l,u=>{t.description&&u(c)})}var h=k(l,2);{var d=u=>{var f=Nw(),v=S(f);le(()=>re(v,t.actionLabel)),Q("click",f,function(...g){var b;(b=t.onAction)==null||b.apply(this,g)}),O(u,f)};ne(h,u=>{t.actionLabel&&t.onAction&&u(d)})}le(()=>re(o,t.heading)),O(e,i)}ot(["click"]);var Hw=W("<button><!></button>"),zw=W("<button><!></button>"),Uw=W('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function Kw(e,t){ct(t,!0),ws(t,"useTmux",3,!1);let i=ws(t,"inCopyMode",3,!1);const s=[{html:"Tab",key:" ",label:"Tab"},{html:"&#8679;Tab",key:"\x1B[Z",label:"Shift+Tab"},{html:"&#8593;",key:"\x1B[A",label:"Up arrow",extraClass:"tb-arrow"},{html:"Esc",key:"\x1B",label:"Escape"},{html:"&#128247;",id:"upload-image-btn",label:"Upload image"},{html:"^V",id:"paste-btn",label:"Paste from clipboard"},{html:"^C",key:"",label:"Ctrl+C"},{html:"&#8592;",key:"\x1B[D",label:"Left arrow",extraClass:"tb-arrow"},{html:"&#8595;",key:"\x1B[B",label:"Down arrow",extraClass:"tb-arrow"},{html:"&#8594;",key:"\x1B[C",label:"Right arrow",extraClass:"tb-arrow"},{html:"&#8679;&#9166;",key:"\x1B[13;2u",label:"Shift+Enter (newline)",extraClass:"tb-newline"},{html:"&#9166;",key:"\r",label:"Enter",extraClass:"tb-enter"}],r=[{html:"Sel",key:" ",label:"Start selection"},{html:"w",key:"w",label:"Word forward"},{html:"b",key:"b",label:"Word backward"},{html:"&#8592;",key:"h",label:"Left",extraClass:"tb-arrow"},{html:"&#8595;",key:"j",label:"Down",extraClass:"tb-arrow"},{html:"&#8593;",key:"k",label:"Up",extraClass:"tb-arrow"},{html:"&#8594;",key:"l",label:"Right",extraClass:"tb-arrow"},{html:"$",key:"$",label:"End of line"},{html:"0",key:"0",label:"Start of line"},{html:"PgUp",key:"\x1B[5~",label:"Page up"},{html:"Copy",key:"\r",label:"Copy and exit",extraClass:"tb-enter",exitsCopyMode:!0},{html:"Exit",key:"q",label:"Cancel",exitsCopyMode:!0}];function n(u){var f;if(u.id==="upload-image-btn"){t.onUploadImage(),Tt&&t.onRefocusMobileInput();return}if(u.id==="paste-btn"){(f=navigator.clipboard)!=null&&f.readText?navigator.clipboard.readText().then(v=>{v&&t.onSendKey(v)}).catch(()=>{t.onUploadImage()}):t.onUploadImage(),Tt&&t.onRefocusMobileInput();return}u.key&&((u.key==="\r"||u.key==="\x1B[13;2u")&&t.onFlushComposedText(),t.onSendKey(u.key),(u.key==="\r"||u.key==="\x1B[13;2u")&&t.onClearInput(),Tt&&t.onRefocusMobileInput())}function o(u){var f;t.onSendKey(u.key),u.exitsCopyMode&&((f=t.onExitCopyMode)==null||f.call(t)),Tt&&t.onRefocusMobileInput()}function l(u){u.preventDefault();const f=u.target.closest("button");if(!f)return;if(i()){const g=r.find(b=>f.dataset.key===b.key);g&&o(g);return}const v=s.find(g=>g.id===f.id||g.key&&f.dataset.key===g.key);v&&n(v)}var c=ys(),h=_t(c);{var d=u=>{var f=Uw(),v=S(f),g=S(v);{var b=w=>{var R=ys(),x=_t(R);Ot(x,17,()=>r,y=>y.label,(y,C)=>{var L=Hw(),z=S(L);nc(z,()=>a(C).html),le(()=>{Ze(L,1,`tb-btn ${a(C).extraClass??""??""}`,"svelte-k7we1m"),Ne(L,"data-key",a(C).key),Ne(L,"aria-label",a(C).label)}),O(y,L)}),O(w,R)},p=w=>{var R=ys(),x=_t(R);Ot(x,17,()=>s,y=>y.label,(y,C)=>{var L=zw(),z=S(L);nc(z,()=>a(C).html),le(()=>{Ze(L,1,`tb-btn ${a(C).extraClass??""??""}`,"svelte-k7we1m"),Ne(L,"id",a(C).id),Ne(L,"data-key",a(C).key),Ne(L,"aria-label",a(C).label)}),O(y,L)}),O(w,R)};ne(g,w=>{i()?w(b):w(p,!1)})}Q("mousedown",f,l),O(u,f)};ne(h,u=>{Tt&&u(d)})}O(e,c),ut()}ot(["mousedown"]);var qw=W('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">&#9776;</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function jw(e,t){let i=ws(t,"hidden",3,!1);var s=qw();let r;var n=S(s),o=k(n,2),l=S(o);le(()=>{r=Ze(s,1,"mobile-header svelte-wp0i5g",null,r,{hidden:i()}),re(l,t.title)}),Q("click",n,function(...c){var h;(h=t.onMenuClick)==null||h.apply(this,c)}),O(e,s)}ot(["click"]);var Vw=W('<div class="update-toast-actions svelte-1trivgv"><button class="update-toast-btn svelte-1trivgv"> </button> <button class="update-toast-dismiss svelte-1trivgv" aria-label="Dismiss">&times;</button></div>'),Yw=W('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function Gw(e,t){ct(t,!0);let i=F(!1),s=F(""),r=F("Update Now"),n=F(!1),o=F(!0);En(async()=>{try{const f=await Ud();f.updateAvailable&&(m(s,`Update available: v${f.current} → v${f.latest}`),m(r,"Update Now"),m(n,!1),m(o,!0),m(i,!0))}catch{}});async function l(){m(n,!0),m(r,"Updating…");try{(await Kd()).restarting?(m(s,"Updated! Restarting server…"),m(o,!1),setTimeout(()=>{location.reload()},5e3)):(m(s,"Updated! Please restart the server manually."),m(o,!1))}catch{m(s,"Update failed. Please try again."),m(n,!1),m(r,"Retry"),m(o,!0)}}function c(){m(i,!1)}var h=ys(),d=_t(h);{var u=f=>{var v=Yw(),g=S(v),b=S(g),p=S(b),w=k(b,2);{var R=x=>{var y=Vw(),C=S(y),L=S(C),z=k(C,2);le(()=>{C.disabled=a(n),re(L,a(r))}),Q("click",C,l),Q("click",z,c),O(x,y)};ne(w,x=>{a(o)&&x(R)})}le(()=>re(p,a(s))),O(f,v)};ne(d,f=>{a(i)&&f(u)})}O(e,h),ut()}ot(["click"]);var Xw=W('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),Qw=W('<div class="image-toast svelte-1y8sviv"><div class="image-toast-content svelte-1y8sviv"><span class="image-toast-text svelte-1y8sviv"> </span> <div class="image-toast-actions svelte-1y8sviv"><!> <button class="image-toast-dismiss svelte-1y8sviv" aria-label="Dismiss">&times;</button></div></div></div>');function Jw(e,t){ct(t,!0);let i=F(!1),s=F(""),r=F(!1),n=F(null),o=null;function l(p,w,R){o&&(clearTimeout(o),o=null),m(s,p,!0),m(r,w,!0),m(n,R??null,!0),m(i,!0)}function c(){m(i,!1),m(n,null),o&&(clearTimeout(o),o=null)}function h(p){o&&clearTimeout(o),o=setTimeout(()=>{a(n)||c()},p)}function d(){a(n)&&Qs(a(n)),c()}function u(){c()}var f={show:l,hide:c,autoDismiss:h},v=ys(),g=_t(v);{var b=p=>{var w=Qw(),R=S(w),x=S(R),y=S(x),C=k(x,2),L=S(C);{var z=J=>{var ae=Xw();Q("click",ae,d),O(J,ae)};ne(L,J=>{a(r)&&J(z)})}var Y=k(L,2);le(()=>re(y,a(s))),Q("click",Y,u),O(p,w)};ne(g,p=>{a(i)&&p(b)})}return O(e,v),ut(f)}ot(["click"]);var $w=W('<span class="dialog-title-repo svelte-thtd9b"> </span>'),Zw=W('<li class="branch-create-new svelte-thtd9b" role="option" aria-selected="false"> </li>'),e0=W('<li role="option" aria-selected="false" class="svelte-thtd9b"> </li>'),t0=W('<ul class="branch-dropdown svelte-thtd9b"><!> <!></ul>'),i0=W('<div class="dialog-field svelte-thtd9b"><div class="dialog-label-row svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-branch">Branch name</label> <button type="button" class="branch-refresh svelte-thtd9b" aria-label="Fetch latest remote branches" title="Fetch latest remote branches"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 0 1-13.66 5.66M4 12a8 8 0 0 1 13.66-5.66M17 3.5v4h-4M7 20.5v-4h4" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"></path></svg></button></div> <div class="branch-input-wrap svelte-thtd9b"><input id="ns-branch" type="text" class="dialog-input svelte-thtd9b" placeholder="e.g. feat/my-feature" autocomplete="off"/> <!></div></div>'),s0=W('<div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-continue" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-continue" class="dialog-label-inline svelte-thtd9b">Continue existing session</label></div>'),r0=W('<dialog class="dialog svelte-thtd9b"><div class="dialog-content svelte-thtd9b"><h2 class="dialog-title svelte-thtd9b"> <!></h2> <div class="dialog-tabs svelte-thtd9b"><button>Repo Session</button> <button>Worktree</button></div> <div class="dialog-body svelte-thtd9b"><div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-agent">Coding agent</label> <select id="ns-agent" class="dialog-select svelte-thtd9b"><option>Claude</option><option>Codex</option></select></div> <!> <!> <div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-yolo" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-yolo" class="dialog-label-inline svelte-thtd9b">Yolo mode (skip permission checks)</label></div> <div class="dialog-field dialog-field--inline svelte-thtd9b"><input id="ns-tmux" type="checkbox" class="dialog-checkbox svelte-thtd9b"/> <label for="ns-tmux" class="dialog-label-inline svelte-thtd9b">Launch in tmux</label></div> <div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-args">Extra args (optional)</label> <input id="ns-args" type="text" class="dialog-input svelte-thtd9b" placeholder="e.g. --verbose" autocomplete="off"/></div></div> <div class="dialog-footer svelte-thtd9b"><button class="btn btn-ghost svelte-thtd9b">Cancel</button> <button class="btn btn-primary svelte-thtd9b"> </button></div></div></dialog>');function n0(e,t){ct(t,!0);let i=ws(t,"preselectedRepo",3,null);const s=Th();let r,n=F("repos"),o=F(""),l=F(""),c=F(""),h=F(""),d=F("claude"),u=F(!1),f=F(!1),v=F(!1),g=F(Xe([])),b=F(!1),p=F(!1),w=F(!1),R=0,x=_e(()=>{if(!a(c).trim())return[];const H=a(c).toLowerCase();return a(g).filter(E=>E.toLowerCase().includes(H)).slice(0,10)}),y=_e(()=>a(g).some(H=>H===a(c)));async function C(H,E={}){const V=++R;if(H){E.preserveExisting||m(g,[],!0),E.refresh?m(w,!0):m(p,!0);try{const ce=await Ph(H,E.refresh?{refresh:!0}:{});if(V!==R||H!==a(o))return;m(g,ce,!0),a(c).trim()&&m(b,!0)}catch{if(V!==R||H!==a(o))return;E.preserveExisting||m(g,[],!0)}finally{V===R&&(m(p,!1),m(w,!1))}}}async function L(){!a(o)||a(w)||await C(a(o),{refresh:!0,preserveExisting:!0})}function z(){R+=1,m(c,""),m(g,[],!0),m(b,!1),m(p,!1),m(w,!1)}function Y(){m(b,a(c).trim().length>0)}function J(H){m(c,H,!0),m(b,!1)}function ae(){m(o,""),m(l,""),m(h,""),m(u,!1),m(f,!1),m(v,!1),z()}async function X(H,E){ae(),m(n,"repos"),await uf(),m(d,s.defaultAgent,!0),E!=null&&E.agent&&m(d,E.agent,!0),m(u,s.defaultYolo,!0),m(f,s.defaultContinue,!0),m(v,s.launchInTmux,!0),(E==null?void 0:E.yolo)!==void 0&&m(u,E.yolo,!0),(E==null?void 0:E.useTmux)!==void 0&&m(v,E.useTmux,!0);const V=H??i();V&&(m(o,V.path,!0),m(l,V.name,!0),E!=null&&E.branchName&&(m(n,"worktrees"),await C(V.path))),E!=null&&E.branchName&&m(c,E.branchName,!0),E!=null&&E.claudeArgs&&m(h,E.claudeArgs,!0),r.showModal()}function N(){r.close()}async function B(){var pe,we;const H=a(o);if(!H)return;const E=a(h).trim().split(/\s+/).filter(Boolean),V=Math.max(80,Math.floor((window.innerWidth-60)/8)),ce=Math.max(24,Math.floor((window.innerHeight-120)/17));try{let xe;a(n)==="repos"?xe=await kp({repoPath:H,repoName:a(l)||H.split("/").filter(Boolean).pop(),continue:a(f),yolo:a(u),claudeArgs:E.length>0?E:void 0,agent:a(d),useTmux:a(v),cols:V,rows:ce,allowMultiple:!0}):xe=await Br({repoPath:H,repoName:a(l)||H.split("/").filter(Boolean).pop(),branchName:a(c).trim()||void 0,yolo:a(u),claudeArgs:E.length>0?E:void 0,agent:a(d),useTmux:a(v),cols:V,rows:ce}),r.close(),await Mt(),xe!=null&&xe.id&&((pe=t.onSessionCreated)==null||pe.call(t,xe.id))}catch(xe){if(xe instanceof Error&&"sessionId"in xe){const Ue=xe;r.close(),await Mt(),Ue.sessionId&&((we=t.onSessionCreated)==null||we.call(t,Ue.sessionId))}}}function M(H){H.target===r&&r.close()}function T(H){a(b)&&H.key==="Escape"&&(m(b,!1),H.stopPropagation())}var j={open:X,close:N},D=r0(),P=S(D),U=S(P),Z=S(U),me=k(Z);{var be=H=>{var E=$w(),V=S(E);le(()=>re(V,`— ${a(l)??""}`)),O(H,E)};ne(me,H=>{a(l)&&H(be)})}var fe=k(U,2),ke=S(fe);let Ee;var Ce=k(ke,2);let $;var ve=k(fe,2),Re=S(ve),Ye=k(S(Re),2),Fe=S(Ye);Fe.value=Fe.__value="claude";var Te=k(Fe);Te.value=Te.__value="codex";var ge=k(Re,2);{var Qe=H=>{var E=i0(),V=S(E),ce=k(S(V),2),pe=S(ce);let we;var xe=k(V,2),Ue=S(xe),Ft=k(Ue,2);{var ii=De=>{var Yt=t0(),si=S(Yt);{var fi=Ut=>{var ri=Zw(),vi=S(ri);le(Ps=>re(vi,`Create new: ${Ps??""}`),[()=>a(c).trim()]),Q("mousedown",ri,()=>J(a(c).trim())),O(Ut,ri)},_i=_e(()=>!a(y)&&a(c).trim());ne(si,Ut=>{a(_i)&&Ut(fi)})}var ir=k(si,2);Ot(ir,16,()=>a(x),Ut=>Ut,(Ut,ri)=>{var vi=e0(),Ps=S(vi);le(()=>re(Ps,ri)),Q("mousedown",vi,()=>J(ri)),O(Ut,vi)}),O(De,Yt)},Mi=_e(()=>a(b)&&(a(x).length>0||a(c).trim()&&!a(y)));ne(Ft,De=>{a(Mi)&&De(ii)})}le(()=>{ce.disabled=!a(o)||a(p)||a(w),we=Ze(pe,0,"svelte-thtd9b",null,we,{spinning:a(p)||a(w)})}),Q("click",ce,L),Q("input",Ue,Y),ps("focus",Ue,()=>{a(c).trim()&&m(b,!0)}),Ei(Ue,()=>a(c),De=>m(c,De)),O(H,E)};ne(ge,H=>{a(n)==="worktrees"&&H(Qe)})}var Le=k(ge,2);{var Be=H=>{var E=s0(),V=S(E);zi(V,()=>a(f),ce=>m(f,ce)),O(H,E)};ne(Le,H=>{a(n)==="repos"&&H(Be)})}var A=k(Le,2),ie=S(A),de=k(A,2),he=S(de),Se=k(de,2),se=k(S(Se),2),Ie=k(ve,2),ze=S(Ie),I=k(ze,2),K=S(I);return $e(D,H=>r=H,()=>r),le(()=>{re(Z,`${a(n)==="repos"?"New Session":"New Worktree"} `),Ee=Ze(ke,1,"dialog-tab svelte-thtd9b",null,Ee,{active:a(n)==="repos"}),$=Ze(Ce,1,"dialog-tab svelte-thtd9b",null,$,{active:a(n)==="worktrees"}),I.disabled=!a(o),re(K,a(n)==="repos"?"Start Session":"Create Worktree")}),Q("click",D,M),Q("keydown",D,T),Q("click",ke,()=>{m(n,"repos")}),Q("click",Ce,()=>{m(n,"worktrees"),a(o)&&a(g).length===0&&C(a(o))}),Xo(Ye,()=>a(d),H=>m(d,H)),zi(ie,()=>a(u),H=>m(u,H)),zi(he,()=>a(v),H=>m(v,H)),Ei(se,()=>a(h),H=>m(h,H)),Q("click",ze,()=>r.close()),Q("click",I,B),O(e,D),ut(j)}ot(["click","keydown","input","mousedown"]);var o0=W('<p class="error-msg svelte-fdtoa4"> </p>'),a0=W('<span class="version-status svelte-fdtoa4">Up to date</span>'),l0=W('<div class="version-update-row svelte-fdtoa4"><span class="version-update-text svelte-fdtoa4"> </span> <button class="btn btn-primary btn-sm svelte-fdtoa4"> </button></div>'),h0=W('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),c0=W('<p class="version-status-msg svelte-fdtoa4"> </p>'),u0=W('<dialog class="dialog svelte-fdtoa4"><div class="dialog-content svelte-fdtoa4"><div class="dialog-header svelte-fdtoa4"><h2 class="dialog-title svelte-fdtoa4">Settings</h2> <button class="close-btn svelte-fdtoa4" aria-label="Close settings">&#10005;</button></div> <div class="dialog-body svelte-fdtoa4"><!> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Default Coding Agent</h3> <p class="section-desc svelte-fdtoa4">CLI used when creating new sessions.</p> <select class="agent-select svelte-fdtoa4"><option>Claude</option><option>Codex</option></select></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Session Defaults</h3> <p class="section-desc svelte-fdtoa4">Default options for new sessions. Override per-session via Customize.</p> <div class="devtools-row svelte-fdtoa4"><input id="default-continue" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-continue" class="devtools-label svelte-fdtoa4">Continue existing session</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-yolo" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-yolo" class="devtools-label svelte-fdtoa4">YOLO mode (skip permission checks)</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-tmux" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-tmux" class="devtools-label svelte-fdtoa4">Launch in tmux</label></div> <div class="devtools-row svelte-fdtoa4"><input id="default-notifications" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="default-notifications" class="devtools-label svelte-fdtoa4">Enable notifications for new sessions</label></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Developer Tools</h3> <div class="devtools-row svelte-fdtoa4"><input id="devtools-toggle" type="checkbox" class="dialog-checkbox svelte-fdtoa4"/> <label for="devtools-toggle" class="devtools-label svelte-fdtoa4">Enable mobile debug panel</label></div></section> <section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Version</h3> <div class="version-row svelte-fdtoa4"><span class="version-current svelte-fdtoa4"><!></span> <!></div> <!> <!></section></div> <div class="dialog-footer svelte-fdtoa4"><button class="btn btn-ghost svelte-fdtoa4">Close</button></div></div></dialog>');function d0(e,t){ct(t,!0);let i,s=F(!1);const r=Th();let n=F(""),o=F(""),l=F(null),c=F(!1),h=F(!1),d=F(!1),u=F(!1),f=F("");async function v(){m(n,""),m(f,""),m(h,!1),m(u,!1),m(s,localStorage.getItem("devtools-enabled")==="true"),await uf(),i.showModal(),y()}function g(){i.close()}async function b(){const E=r.defaultAgent;m(n,"");try{await Rp(r.defaultAgent)}catch{r.defaultAgent=E,m(n,"Failed to update default agent.")}}async function p(){const E=r.defaultContinue;m(n,"");try{await Tp(r.defaultContinue)}catch{r.defaultContinue=E,m(n,"Failed to update continue default.")}}async function w(){const E=r.defaultYolo;m(n,"");try{await Bp(r.defaultYolo)}catch{r.defaultYolo=E,m(n,"Failed to update yolo default.")}}async function R(){const E=r.launchInTmux;m(n,"");try{await Ap(r.launchInTmux)}catch(V){r.launchInTmux=E,m(n,V instanceof Error?V.message:"Failed to update tmux setting.",!0)}}async function x(){const E=r.defaultNotifications;m(n,"");try{await Ip(r.defaultNotifications)}catch{r.defaultNotifications=E,m(n,"Failed to update notifications default.")}}async function y(){m(d,!0),m(f,"");try{const E=await Ud();m(o,E.current,!0),m(l,E.latest,!0),m(c,E.updateAvailable,!0),m(h,!0)}catch{m(f,"Failed to check for updates.")}finally{m(d,!1)}}async function C(){m(u,!0),m(f,"");try{(await Kd()).restarting?(m(f,"Updated! Restarting server…"),setTimeout(()=>{location.reload()},5e3)):m(f,"Updated! Please restart the server manually."),m(c,!1)}catch{m(f,"Update failed. Please try again."),m(u,!1)}}function L(){localStorage.setItem("devtools-enabled",a(s)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function z(){i.close(),await Mt()}function Y(E){E.target===i&&z()}var J={open:v,close:g},ae=u0(),X=S(ae),N=S(X),B=k(S(N),2),M=k(N,2),T=S(M);{var j=E=>{var V=o0(),ce=S(V);le(()=>re(ce,a(n))),O(E,V)};ne(T,E=>{a(n)&&E(j)})}var D=k(T,2),P=k(S(D),4),U=S(P);U.value=U.__value="claude";var Z=k(U);Z.value=Z.__value="codex";var me=k(D,2),be=k(S(me),4),fe=S(be),ke=k(be,2),Ee=S(ke),Ce=k(ke,2),$=S(Ce),ve=k(Ce,2),Re=S(ve),Ye=k(me,2),Fe=k(S(Ye),2),Te=S(Fe),ge=k(Ye,2),Qe=k(S(ge),2),Le=S(Qe),Be=S(Le);{var A=E=>{var V=Mr();le(()=>re(V,`v${a(o)??""}`)),O(E,V)},ie=E=>{var V=Mr("...");O(E,V)};ne(Be,E=>{a(o)?E(A):E(ie,!1)})}var de=k(Le,2);{var he=E=>{var V=a0();O(E,V)};ne(de,E=>{a(h)&&!a(c)&&!a(u)&&E(he)})}var Se=k(Qe,2);{var se=E=>{var V=l0(),ce=S(V),pe=S(ce),we=k(ce,2),xe=S(we);le(()=>{re(pe,`v${a(o)??""} → v${a(l)??""}`),we.disabled=a(u),re(xe,a(u)?"Updating…":"Update Now")}),Q("click",we,C),O(E,V)},Ie=E=>{var V=h0(),ce=S(V);le(()=>{V.disabled=a(d),re(ce,a(d)?"Checking…":"Check for updates")}),Q("click",V,y),O(E,V)};ne(Se,E=>{a(c)?E(se):a(h)||E(Ie,1)})}var ze=k(Se,2);{var I=E=>{var V=c0(),ce=S(V);le(()=>re(ce,a(f))),O(E,V)};ne(ze,E=>{a(f)&&E(I)})}var K=k(M,2),H=S(K);return $e(ae,E=>i=E,()=>i),Q("click",ae,Y),Q("click",B,z),Q("change",P,b),Xo(P,()=>r.defaultAgent,E=>r.defaultAgent=E),Q("change",fe,p),zi(fe,()=>r.defaultContinue,E=>r.defaultContinue=E),Q("change",Ee,w),zi(Ee,()=>r.defaultYolo,E=>r.defaultYolo=E),Q("change",$,R),zi($,()=>r.launchInTmux,E=>r.launchInTmux=E),Q("change",Re,x),zi(Re,()=>r.defaultNotifications,E=>r.defaultNotifications=E),Q("change",Te,L),zi(Te,()=>a(s),E=>m(s,E)),Q("click",H,z),O(e,ae),ut(J)}ot(["click","change"]);var f0=W('<p class="confirm-msg svelte-15sco2n">Are you sure you want to delete the worktree <strong class="wt-name svelte-15sco2n"> </strong>?</p> <p class="wt-path svelte-15sco2n"> </p> <p class="warning-msg svelte-15sco2n">This action cannot be undone.</p>',1),_0=W('<p class="error-msg svelte-15sco2n"> </p>'),v0=W('<dialog class="dialog svelte-15sco2n"><div class="dialog-content svelte-15sco2n"><h2 class="dialog-title svelte-15sco2n">Delete Worktree</h2> <div class="dialog-body svelte-15sco2n"><!> <!></div> <div class="dialog-footer svelte-15sco2n"><button class="btn btn-ghost svelte-15sco2n">Cancel</button> <button class="btn btn-danger svelte-15sco2n"> </button></div></div></dialog>');function p0(e,t){ct(t,!0);let i,s=F(null),r=F(""),n=F(!1);function o(z){m(s,z,!0),m(r,""),m(n,!1),i.showModal()}function l(){i.close()}async function c(){if(!(!a(s)||a(n))){m(n,!0),m(r,""),lg(a(s).path);try{await zd(a(s).path,a(s).repoPath),i.close(),await Mt()}catch(z){m(r,z instanceof Error?z.message:"Failed to delete worktree.",!0),m(n,!1)}finally{a(s)&&hg(a(s).path)}}}function h(){i.close()}function d(z){z.target===i&&i.close()}var u={open:o,close:l},f=v0(),v=S(f),g=k(S(v),2),b=S(g);{var p=z=>{var Y=f0(),J=_t(Y),ae=k(S(J)),X=S(ae),N=k(J,2),B=S(N);le(()=>{re(X,a(s).displayName||a(s).name),re(B,a(s).path)}),O(z,Y)};ne(b,z=>{a(s)&&z(p)})}var w=k(b,2);{var R=z=>{var Y=_0(),J=S(Y);le(()=>re(J,a(r))),O(z,Y)};ne(w,z=>{a(r)&&z(R)})}var x=k(g,2),y=S(x),C=k(y,2),L=S(C);return $e(f,z=>i=z,()=>i),le(()=>{y.disabled=a(n),C.disabled=a(n),re(L,a(n)?"Deleting...":"Delete")}),Q("click",f,d),Q("click",y,h),Q("click",C,c),O(e,f),ut(u)}ot(["click"]);var g0=W('<div class="loading-placeholder svelte-15gfcbp">Loading...</div>'),m0=W('<div class="empty-placeholder svelte-15gfcbp"><!></div>'),b0=W('<span class="spinner svelte-15gfcbp">...</span>'),S0=W("<span>&#9654;</span>"),y0=W('<button class="expand-btn svelte-15gfcbp"><!></button>'),w0=W('<span class="expand-spacer svelte-15gfcbp"></span>'),C0=W('<span class="git-badge svelte-15gfcbp" aria-label="Git repository">git</span>'),k0=W('<div role="treeitem"><!> <input type="checkbox" class="node-checkbox svelte-15gfcbp"/> <span class="node-name svelte-15gfcbp"> </span> <!></div>'),x0=W('<div class="truncated-notice svelte-15gfcbp"> </div>'),E0=W("<!> <!>",1),P0=W('<div class="file-browser svelte-15gfcbp"><div class="filter-row svelte-15gfcbp"><input type="text" class="filter-input svelte-15gfcbp" placeholder="Filter..." aria-label="Filter directories" autocomplete="off" spellcheck="false"/></div> <div class="tree-container svelte-15gfcbp" role="tree" aria-label="File browser" tabindex="0"><!></div></div>');function R0(e,t){ct(t,!0);let i=ws(t,"selectedPaths",31,()=>Xe([])),s=F(Xe([])),r=F(""),n=F(-1),o=F(!0),l=F(null),c=F(void 0);En(()=>{h()});async function h(){m(o,!0),m(l,null);try{const D=await cc();m(s,D.entries.map(P=>d(P,0)),!0),D.truncated&&m(l,{shown:D.entries.length,total:D.total},!0)}catch{m(s,[],!0)}finally{m(o,!1)}}function d(D,P){return{name:D.name,path:D.path,isGitRepo:D.isGitRepo,hasChildren:D.hasChildren,children:null,expanded:!1,selected:!1,loading:!1,depth:P,truncatedInfo:null}}async function u(D){if(D.expanded){D.expanded=!1;return}if(D.children===null){D.loading=!0;try{const P=await cc(D.path);D.children=P.entries.map(U=>d(U,D.depth+1)),D.truncatedInfo=P.truncated?{shown:P.entries.length,total:P.total}:null}catch{D.children=[]}finally{D.loading=!1}}D.expanded=!0}function f(D){D.selected=!D.selected,v()}function v(){i(g(a(s)))}function g(D){const P=[];for(const U of D)U.selected&&P.push(U.path),U.children&&P.push(...g(U.children));return P}function b(D,P){return D.toLowerCase().includes(P.toLowerCase())}function p(D,P){var U;return!!(!P||D.expanded||b(D.name,P)||(U=D.children)!=null&&U.some(Z=>p(Z,P)))}function w(D,P){const U=[];for(const Z of D)p(Z,P)&&(U.push(Z),Z.expanded&&Z.children&&U.push(...w(Z.children,P)));return U}let R=_e(()=>w(a(s),a(r)));function x(D){var U;if(D.key==="ArrowDown"){D.preventDefault(),m(n,Math.min(a(n)+1,a(R).length-1),!0);return}if(D.key==="ArrowUp"){D.preventDefault(),m(n,Math.max(a(n)-1,0),!0);return}const P=a(n)>=0?a(R)[a(n)]:void 0;if(P){if(D.key==="ArrowRight"){if(D.preventDefault(),P.hasChildren&&!P.expanded)u(P);else if(P.expanded&&((U=P.children)!=null&&U.length)){const Z=a(R).indexOf(P.children[0]);Z>=0&&m(n,Z,!0)}return}if(D.key==="ArrowLeft"){if(D.preventDefault(),P.expanded)P.expanded=!1;else{const Z=P.depth-1;for(let me=a(n)-1;me>=0;me--)if(a(R)[me].depth===Z){m(n,me,!0);break}}return}if(D.key===" "){D.preventDefault(),f(P);return}}}function y(D,P){const U=P.target;U.closest(".expand-btn")||U.closest(".node-checkbox")||(D.hasChildren&&!D.expanded?u(D):f(D))}function C(){m(r,""),m(n,-1),L(a(s)),i([]),z(a(s))}function L(D){for(const P of D)P.selected=!1,P.children&&L(P.children)}function z(D){for(const P of D)P.expanded=!1,P.children&&z(P.children)}var Y={reset:C},J=P0(),ae=S(J),X=S(ae),N=k(ae,2),B=S(N);{var M=D=>{var P=g0();O(D,P)},T=D=>{var P=m0(),U=S(P);{var Z=be=>{var fe=Mr();le(()=>re(fe,`No matches for "${a(r)??""}"`)),O(be,fe)},me=be=>{var fe=Mr("No directories found");O(be,fe)};ne(U,be=>{a(r)?be(Z):be(me,!1)})}O(D,P)},j=D=>{var P=E0(),U=_t(P);Ot(U,19,()=>a(R),be=>be.path,(be,fe,ke)=>{var Ee=k0();let Ce;var $=S(Ee);{var ve=Le=>{var Be=y0(),A=S(Be);{var ie=he=>{var Se=b0();O(he,Se)},de=he=>{var Se=S0();let se;le(()=>se=Ze(Se,1,"arrow svelte-15gfcbp",null,se,{expanded:a(fe).expanded})),O(he,Se)};ne(A,he=>{a(fe).loading?he(ie):he(de,!1)})}le(()=>Ne(Be,"aria-label",a(fe).expanded?"Collapse":"Expand")),Q("click",Be,()=>u(a(fe))),O(Le,Be)},Re=Le=>{var Be=w0();O(Le,Be)};ne($,Le=>{a(fe).hasChildren?Le(ve):Le(Re,!1)})}var Ye=k($,2),Fe=k(Ye,2),Te=S(Fe),ge=k(Fe,2);{var Qe=Le=>{var Be=C0();O(Le,Be)};ne(ge,Le=>{a(fe).isGitRepo&&Le(Qe)})}le(()=>{Ce=Ze(Ee,1,"tree-row svelte-15gfcbp",null,Ce,{focused:a(ke)===a(n),selected:a(fe).selected}),xn(Ee,`padding-left: ${12+a(fe).depth*20}px`),Ne(Ee,"aria-expanded",a(fe).hasChildren?a(fe).expanded:void 0),Ne(Ee,"aria-selected",a(fe).selected),Ne(Ee,"aria-level",a(fe).depth+1),lp(Ye,a(fe).selected),Ne(Ye,"aria-label",`Select ${a(fe).name??""}`),re(Te,a(fe).name)}),Q("click",Ee,Le=>y(a(fe),Le)),Q("change",Ye,()=>f(a(fe))),Q("click",Ye,Le=>Le.stopPropagation()),O(be,Ee)});var Z=k(U,2);{var me=be=>{var fe=x0(),ke=S(fe);le(()=>re(ke,`Showing ${a(l).shown??""} of ${a(l).total??""} directories. Use the filter to narrow results.`)),O(be,fe)};ne(Z,be=>{a(l)&&be(me)})}O(D,P)};ne(B,D=>{a(o)?D(M):a(R).length===0?D(T,1):D(j,!1)})}return $e(N,D=>m(c,D),()=>a(c)),Ei(X,()=>a(r),D=>m(r,D)),Q("keydown",N,x),O(e,J),ut(Y)}ot(["keydown","click","change"]);var D0=W('<p class="error-msg svelte-4yj2yx"> </p>'),T0=W('<dialog class="dialog svelte-4yj2yx"><div class="dialog-content svelte-4yj2yx"><div class="dialog-header svelte-4yj2yx"><h2 class="dialog-title svelte-4yj2yx">Add Workspace</h2> <button class="close-btn svelte-4yj2yx" aria-label="Close">&#10005;</button></div> <div class="dialog-body svelte-4yj2yx"><p class="dialog-desc svelte-4yj2yx">Browse for folders on your machine. Git repos get PR tracking and branch management.</p> <!> <!></div> <div class="dialog-footer svelte-4yj2yx"><span class="selected-count svelte-4yj2yx"><!></span> <div class="footer-actions svelte-4yj2yx"><button class="btn btn-ghost svelte-4yj2yx">Cancel</button> <button class="btn btn-primary svelte-4yj2yx"><!></button></div></div></div></dialog>');function M0(e,t){ct(t,!0);let i,s=F(void 0),r=F(Xe([])),n=F(""),o=F(!1);function l(){var M;m(r,[],!0),m(n,""),m(o,!1),(M=a(s))==null||M.reset(),i.showModal()}function c(){i.close()}async function h(){if(a(r).length!==0){m(o,!0),m(n,"");try{const M=await mp(a(r));if(M.errors.length>0&&M.added.length===0){m(n,M.errors.map(T=>`${T.path}: ${T.error}`).join("; "),!0),m(o,!1);return}M.added.length>0&&t.onWorkspacesAdded(M.added.map(T=>T.path)),M.errors.length>0&&console.warn("Some workspaces failed to add:",M.errors),c()}catch{m(n,"Failed to add workspaces.")}finally{m(o,!1)}}}function d(M){M.target===i&&c()}var u={open:l,close:c},f=T0(),v=S(f),g=S(v),b=k(S(g),2),p=k(g,2),w=k(S(p),2);$e(R0(w,{get selectedPaths(){return a(r)},set selectedPaths(M){m(r,M,!0)}}),M=>m(s,M,!0),()=>a(s));var R=k(w,2);{var x=M=>{var T=D0(),j=S(T);le(()=>re(j,a(n))),O(M,T)};ne(R,M=>{a(n)&&M(x)})}var y=k(p,2),C=S(y),L=S(C);{var z=M=>{var T=Mr();le(()=>re(T,`${a(r).length??""} selected`)),O(M,T)};ne(L,M=>{a(r).length>0&&M(z)})}var Y=k(C,2),J=S(Y),ae=k(J,2),X=S(ae);{var N=M=>{var T=Mr("Adding...");O(M,T)},B=M=>{var T=Mr();le(()=>re(T,`Add Workspace${a(r).length>1?"s":""}`)),O(M,T)};ne(X,M=>{a(o)?M(N):M(B,!1)})}return $e(f,M=>i=M,()=>i),le(()=>ae.disabled=a(r).length===0||a(o)),Q("click",f,d),Q("click",b,c),Q("click",J,c),Q("click",ae,h),O(e,f),ut(u)}ot(["click"]);var B0=W('<p class="error-msg svelte-1n78dcx"> </p>'),L0=W("<option> </option>"),A0=W("<option> </option>"),O0=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. focus on security, error handling"></textarea>'),I0=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. include test plan section"></textarea>'),N0=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. prefix with dy/, use conventional commits style"></textarea>'),F0=W('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. use TypeScript, follow CLAUDE.md"></textarea>'),W0=W('<span class="save-success svelte-1n78dcx">Saved</span>'),H0=W('<dialog class="dialog svelte-1n78dcx"><div class="dialog-content svelte-1n78dcx"><div class="dialog-header svelte-1n78dcx"><h2 class="dialog-title svelte-1n78dcx"><span class="gear-icon svelte-1n78dcx">&#9881;</span> </h2> <button class="close-btn svelte-1n78dcx" aria-label="Close settings">&#10005;</button></div> <div class="dialog-body svelte-1n78dcx"><!> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">GIT SETTINGS</h3> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-default-branch">Branch new worktrees from</label> <select id="ws-default-branch" class="field-select svelte-1n78dcx"><option>-- auto --</option><!><!></select></div> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-remote">Remote origin</label> <input id="ws-remote" type="text" class="field-input svelte-1n78dcx" placeholder="origin"/></div> <div class="field-group svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-branch-prefix">Branch prefix</label> <input id="ws-branch-prefix" type="text" class="field-input svelte-1n78dcx" placeholder="e.g. dy/"/></div></section> <div class="divider svelte-1n78dcx"></div> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">SESSION DEFAULTS</h3> <div class="inline-row svelte-1n78dcx"><label class="field-label svelte-1n78dcx" for="ws-agent">Default agent</label> <select id="ws-agent" class="field-select field-select-inline svelte-1n78dcx"><option>Claude</option><option>Codex</option></select></div> <div class="checkbox-row svelte-1n78dcx"><label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>Continue</span></label> <label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>YOLO</span></label> <label class="checkbox-label svelte-1n78dcx"><input type="checkbox" class="dialog-checkbox svelte-1n78dcx"/> <span>Tmux</span></label></div></section> <div class="divider svelte-1n78dcx"></div> <section class="settings-section svelte-1n78dcx"><h3 class="section-label svelte-1n78dcx">PROMPTS</h3> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Code review preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Create PR preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> Branch rename preferences</button> <!></div> <div class="prompt-group svelte-1n78dcx"><button class="prompt-toggle svelte-1n78dcx"><span class="prompt-arrow svelte-1n78dcx"> </span> General preferences</button> <!></div></section></div> <div class="dialog-footer svelte-1n78dcx"><button class="btn btn-danger svelte-1n78dcx">Remove Workspace</button> <div class="footer-right svelte-1n78dcx"><!> <button class="btn btn-primary svelte-1n78dcx"> </button></div></div></div></dialog>');function z0(e,t){ct(t,!0);let i,s=F(""),r=F(""),n=F(!1),o=F(""),l=F(!1),c=F(Xe([])),h=F(""),d=F(""),u=F(""),f=F("claude"),v=F(!1),g=F(!1),b=F(!1),p=F(""),w=F(""),R=F(""),x=F(""),y=F(!1),C=F(!1),L=F(!1),z=F(!1);async function Y(oe,qe){m(s,oe,!0),m(r,qe,!0),m(o,""),m(l,!1),m(n,!1),m(h,""),m(d,""),m(u,""),m(f,"claude"),m(v,!1),m(g,!1),m(b,!1),m(p,""),m(w,""),m(R,""),m(x,""),i.showModal();try{const[St,Kr]=await Promise.all([cl(oe),Ph(oe).catch(()=>[])]);m(c,Kr,!0),ae(St)}catch{m(o,"Failed to load workspace settings.")}}function J(){i.close()}function ae(oe){m(h,oe.defaultBranch??"",!0),m(d,oe.remote??"",!0),m(u,oe.branchPrefix??"",!0),m(f,oe.defaultAgent??"claude",!0),m(v,oe.defaultContinue??!1,!0),m(g,oe.defaultYolo??!1,!0),m(b,oe.launchInTmux??!1,!0),m(p,oe.promptCodeReview??"",!0),m(w,oe.promptCreatePr??"",!0),m(R,oe.promptBranchRename??"",!0),m(x,oe.promptGeneral??"",!0)}async function X(){m(n,!0),m(o,""),m(l,!1);try{const oe={defaultAgent:a(f),defaultContinue:a(v),defaultYolo:a(g),launchInTmux:a(b)};a(h)&&(oe.defaultBranch=a(h)),a(d)&&(oe.remote=a(d)),a(u)&&(oe.branchPrefix=a(u)),a(p)&&(oe.promptCodeReview=a(p)),a(w)&&(oe.promptCreatePr=a(w)),a(R)&&(oe.promptBranchRename=a(R)),a(x)&&(oe.promptGeneral=a(x)),await Fp(a(s),oe),m(l,!0),setTimeout(()=>{m(l,!1)},2e3)}catch(oe){m(o,oe instanceof Error?oe.message:"Failed to save settings.",!0)}finally{m(n,!1)}}function N(){i.close(),t.onRemoveWorkspace(a(s))}function B(oe){oe.target===i&&i.close()}var M={open:Y,close:J},T=H0(),j=S(T),D=S(j),P=S(D),U=k(S(P)),Z=k(P,2),me=k(D,2),be=S(me);{var fe=oe=>{var qe=B0(),St=S(qe);le(()=>re(St,a(o))),O(oe,qe)};ne(be,oe=>{a(o)&&oe(fe)})}var ke=k(be,2),Ee=k(S(ke),2),Ce=k(S(Ee),2),$=S(Ce);$.value=$.__value="";var ve=k($);Ot(ve,17,()=>a(c),Zn,(oe,qe)=>{var St=L0(),Kr=S(St),Gh={};le(()=>{re(Kr,a(qe)),Gh!==(Gh=a(qe))&&(St.value=(St.__value=a(qe))??"")}),O(oe,St)});var Re=k(ve);{var Ye=oe=>{var qe=A0(),St=S(qe),Kr={};le(()=>{re(St,a(h)),Kr!==(Kr=a(h))&&(qe.value=(qe.__value=a(h))??"")}),O(oe,qe)},Fe=_e(()=>a(h)&&!a(c).includes(a(h)));ne(Re,oe=>{a(Fe)&&oe(Ye)})}var Te=k(Ee,2),ge=k(S(Te),2),Qe=k(Te,2),Le=k(S(Qe),2),Be=k(ke,4),A=k(S(Be),2),ie=k(S(A),2),de=S(ie);de.value=de.__value="claude";var he=k(de);he.value=he.__value="codex";var Se=k(A,2),se=S(Se),Ie=S(se),ze=k(se,2),I=S(ze),K=k(ze,2),H=S(K),E=k(Be,4),V=k(S(E),2),ce=S(V),pe=S(ce),we=S(pe),xe=k(ce,2);{var Ue=oe=>{var qe=O0();Ne(qe,"rows",3),Ei(qe,()=>a(p),St=>m(p,St)),O(oe,qe)};ne(xe,oe=>{a(y)&&oe(Ue)})}var Ft=k(V,2),ii=S(Ft),Mi=S(ii),De=S(Mi),Yt=k(ii,2);{var si=oe=>{var qe=I0();Ne(qe,"rows",3),Ei(qe,()=>a(w),St=>m(w,St)),O(oe,qe)};ne(Yt,oe=>{a(C)&&oe(si)})}var fi=k(Ft,2),_i=S(fi),ir=S(_i),Ut=S(ir),ri=k(_i,2);{var vi=oe=>{var qe=N0();Ne(qe,"rows",3),Ei(qe,()=>a(R),St=>m(R,St)),O(oe,qe)};ne(ri,oe=>{a(L)&&oe(vi)})}var Ps=k(fi,2),Ur=S(Ps),wa=S(Ur),je=S(wa),tt=k(Ur,2);{var Gt=oe=>{var qe=F0();Ne(qe,"rows",3),Ei(qe,()=>a(x),St=>m(x,St)),O(oe,qe)};ne(tt,oe=>{a(z)&&oe(Gt)})}var Ca=k(me,2),Eo=S(Ca),ka=k(Eo,2),Yh=S(ka);{var m_=oe=>{var qe=W0();O(oe,qe)};ne(Yh,oe=>{a(l)&&oe(m_)})}var xa=k(Yh,2),b_=S(xa);return $e(T,oe=>i=oe,()=>i),le(()=>{re(U,` ${a(r)??""}`),Ne(ce,"aria-expanded",a(y)),re(we,a(y)?"▾":"▸"),Ne(ii,"aria-expanded",a(C)),re(De,a(C)?"▾":"▸"),Ne(_i,"aria-expanded",a(L)),re(Ut,a(L)?"▾":"▸"),Ne(Ur,"aria-expanded",a(z)),re(je,a(z)?"▾":"▸"),xa.disabled=a(n),re(b_,a(n)?"Saving…":"Save")}),Q("click",T,B),Q("click",Z,()=>i.close()),Xo(Ce,()=>a(h),oe=>m(h,oe)),Ei(ge,()=>a(d),oe=>m(d,oe)),Ei(Le,()=>a(u),oe=>m(u,oe)),Xo(ie,()=>a(f),oe=>m(f,oe)),zi(Ie,()=>a(v),oe=>m(v,oe)),zi(I,()=>a(g),oe=>m(g,oe)),zi(H,()=>a(b),oe=>m(b,oe)),Q("click",ce,()=>{m(y,!a(y))}),Q("click",ii,()=>{m(C,!a(C))}),Q("click",_i,()=>{m(L,!a(L))}),Q("click",Ur,()=>{m(z,!a(z))}),Q("click",Eo,N),Q("click",xa,X),O(e,T),ut(M)}ot(["click"]);var U0=W('<div class="sidebar-overlay svelte-13zv0lp"></div>'),K0=W("<!> <!> <!> <!>",1),q0=W('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!></div></div> <!> <!> <!> <!> <!> <!> <!>',1);function j0(e,t){ct(t,!0);const i=new f_({defaultOptions:{queries:{staleTime:60*1e3,gcTime:600*1e3,refetchOnWindowFocus:!0}}}),s=qd(),r=Qd(),n=Dh(),o=Th();function l(A,ie){n.activeSessionId=A;const de=n.sessions.find(he=>he.id===A);de&&(r.activeWorkspacePath=de.repoPath),vc(A),ci()}Zp(l);let c=F(void 0),h=F(void 0),d=F(void 0),u=F(void 0),f=F(void 0),v=F(void 0),g=F(void 0),b=F(!1);En(()=>{zp();let A,ie;if(Tt&&window.visualViewport){const Se=window.visualViewport;let se=null;const Ie=()=>{const ze=window.innerHeight-Se.height;m(b,ze>50),a(g)&&(a(g).style.height=a(b)?Se.height+"px":""),window.scrollTo(0,0),se&&clearTimeout(se),se=setTimeout(()=>{var I;return(I=a(c))==null?void 0:I.fitTerm()},100)};Se.addEventListener("resize",Ie),Se.addEventListener("scroll",Ie),A=()=>{Se.removeEventListener("resize",Ie),Se.removeEventListener("scroll",Ie),se&&clearTimeout(se)}}const de=navigator.platform.toUpperCase().includes("MAC");let he;{const Se=se=>{var I;const Ie=(I=document.activeElement)==null?void 0:I.tagName;if(!(Ie==="INPUT"||Ie==="TEXTAREA"||!(de?se.metaKey:se.ctrlKey))){if(se.key==="t"&&!se.shiftKey){se.preventDefault(),ae();return}if(se.key==="w"&&!se.shiftKey){se.preventDefault(),n.activeSessionId&&U(n.activeSessionId);return}if(!se.shiftKey&&se.key>="1"&&se.key<="9"){const K=a(x);if(K.length===0)return;se.preventDefault();const H=parseInt(se.key,10),E=H===9?K[K.length-1]:K[H-1];E&&J(E.id);return}if(se.shiftKey&&se.key==="["){const K=a(x);if(K.length===0)return;se.preventDefault();const H=K.findIndex(V=>V.id===n.activeSessionId),E=H<=0?K[K.length-1]:K[H-1];E&&J(E.id);return}if(se.shiftKey&&se.key==="]"){const K=a(x);if(K.length===0)return;se.preventDefault();const H=K.findIndex(V=>V.id===n.activeSessionId),E=H===-1||H===K.length-1?K[0]:K[H+1];E&&J(E.id);return}}};document.addEventListener("keydown",Se),he=()=>document.removeEventListener("keydown",Se)}if(Tt){let Ie=0,ze=0,I=!1;const K=V=>{const ce=V.touches[0];ce&&ce.clientX<=30&&!r.sidebarOpen&&(Ie=ce.clientX,ze=ce.clientY,I=!0)},H=V=>{if(!I)return;const ce=V.touches[0];if(!ce)return;const pe=ce.clientX-Ie,we=Math.abs(ce.clientY-ze);if(we>pe&&(we>8||pe>8)){I=!1;return}pe>=50&&(I=!1,fc())},E=()=>{I=!1};document.addEventListener("touchstart",K,{passive:!0}),document.addEventListener("touchmove",H,{passive:!0}),document.addEventListener("touchend",E),ie=()=>{document.removeEventListener("touchstart",K),document.removeEventListener("touchmove",H),document.removeEventListener("touchend",E)}}return()=>{he==null||he(),A==null||A(),ie==null||ie()}}),ss(()=>{s.authenticated&&Mt().then(()=>{const ie=new URLSearchParams(window.location.search).get("session");ie&&(window.history.replaceState({},"","/"),l(ie)),!n.activeSessionId&&!ie&&n.sessions.length===1&&J(n.sessions[0].id);for(const de of n.sessions)Tn(de.id,o.defaultNotifications);ig().then(()=>{sg(ag())})})}),ss(()=>{s.authenticated&&lf(A=>{A.type==="worktrees-changed"?Mt():A.type==="session-idle-changed"&&A.sessionId?og(A.sessionId,A.idle??!1):A.type==="session-ended"&&(i.invalidateQueries({queryKey:["pr"]}),i.invalidateQueries({queryKey:["ci-status"]}))})});let p=_e(()=>r.activeWorkspacePath?n.workspaces.find(A=>A.path===r.activeWorkspacePath):void 0),w=_e(()=>r.activeWorkspacePath?of(r.activeWorkspacePath):[]),R=_e(()=>n.activeSessionId?n.sessions.find(A=>A.id===n.activeSessionId):void 0),x=_e(()=>a(R)?a(w).filter(A=>A.repoPath===a(R).repoPath):a(w)),y=_e(()=>!!a(R)&&!!r.activeWorkspacePath&&(a(R).repoPath===r.activeWorkspacePath||a(R).repoPath.startsWith(r.activeWorkspacePath+"/"))),C=_e(()=>{var A,ie;return((A=a(R))==null?void 0:A.displayName)||((ie=a(p))==null?void 0:ie.name)||"Claude Remote CLI"}),L=_e(()=>{var A;return((A=a(R))==null?void 0:A.useTmux)??!1}),z=F(!1),Y=_e(()=>a(p)?a(y)?"session":"dashboard":"empty");function J(A){var de;n.activeSessionId=A;const ie=n.sessions.find(he=>he.id===A);if(ie){const he=n.workspaces.find(Se=>ie.repoPath===Se.path||ie.repoPath.startsWith(Se.path+"/"));r.activeWorkspacePath=(he==null?void 0:he.path)??ie.repoPath}vc(A),ci(),(de=a(c))==null||de.focusTerm(),cg(A)}function ae(A,ie){var de,he,Se;A?(de=a(d))==null||de.open({name:A.name,path:A.path},ie):a(p)?(he=a(d))==null||he.open({name:a(p).name,path:a(p).path},ie):(Se=a(d))==null||Se.open(void 0,ie)}function X(A){var ie,de;A?(ie=a(v))==null||ie.open(A.path,A.name):(de=a(u))==null||de.open()}async function N(A){var ie,de;try{let he=o.defaultYolo,Se=o.defaultAgent,se=o.launchInTmux;try{const K=await cl(A.path);K.defaultYolo!==void 0&&(he=K.defaultYolo),K.defaultAgent&&(Se=K.defaultAgent),K.launchInTmux!==void 0&&(se=K.launchInTmux)}catch{}const{branchName:Ie,worktreePath:ze}=await Ba(A.path),I=await Br({repoPath:A.path,repoName:A.name,worktreePath:ze,branchName:Ie,yolo:he,agent:Se,useTmux:se,needsBranchRename:!0});await Mt(),n.activeSessionId=I.id,r.activeWorkspacePath=A.path,Tn(I.id,o.defaultNotifications),ci(),(ie=a(c))==null||ie.focusTerm()}catch{(de=a(d))==null||de.open({name:A.name,path:A.path})}}async function B(A){if(!a(p))return;const ie=a(p).path,de=n.sessions.find(se=>se.branchName===A.headRefName&&se.repoPath.startsWith(ie)),he=n.worktrees.find(se=>se.branchName===A.headRefName&&se.repoPath===ie);let Se=`Merge the branch "${A.baseRefName}" into this branch and resolve all merge conflicts. Use \`git merge ${A.baseRefName}\` and fix any conflicts in the working tree. After resolving, verify the build passes.`;try{const se=await cl(ie);se.promptFixConflicts&&(Se=se.promptFixConflicts.replace(/\{baseRefName\}/g,A.baseRefName).replace(/\{headRefName\}/g,A.headRefName))}catch{}try{let se,Ie;if(de)se=de.repoPath,Ie=de.branchName;else if(he)se=he.path,Ie=he.branchName;else{const I=await Ba(ie,A.headRefName);se=I.worktreePath,Ie=I.branchName}const ze=await Br({repoPath:ie,repoName:a(p).name,worktreePath:se,branchName:Ie,allowMultiple:!0});await Mt(),n.activeSessionId=ze.id,r.activeWorkspacePath=ie,Tn(ze.id,o.defaultNotifications),ci(),setTimeout(()=>{Qs(Se+"\r")},1500)}catch(se){console.error("Failed to start conflict resolution:",se)}}async function M(A,ie){if(!a(p))return;const de=a(p).path,he=n.sessions.find(se=>se.branchName===A.headRefName&&se.repoPath.startsWith(de)),Se=n.worktrees.find(se=>se.branchName===A.headRefName&&se.repoPath===de);try{let se,Ie;if(he)se=he.repoPath,Ie=he.branchName;else if(Se)se=Se.path,Ie=Se.branchName;else{const I=await Ba(de,A.headRefName);se=I.worktreePath,Ie=I.branchName}const ze=await Br({repoPath:de,repoName:a(p).name,worktreePath:se,branchName:Ie,allowMultiple:!0});await Mt(),n.activeSessionId=ze.id,r.activeWorkspacePath=de,Tn(ze.id,o.defaultNotifications),ci(),ie&&setTimeout(()=>{Qs(ie+"\r")},1500)}catch(se){console.error("Failed to open PR branch session:",se)}}function T(A){const ie=A.state==="OPEN"?"OPEN":A.state==="MERGED"?"MERGED":"CLOSED",de=Mh({commitsAhead:1,prState:ie,ciFailing:0,ciPending:0,ciTotal:0,mergeable:A.mergeable??null,unresolvedCommentCount:0}),he=df(de,{branchName:A.headRefName,baseBranch:A.baseRefName,prNumber:A.number});he&&M(A,he)}function j(A){M(A)}function D(A){var ie;(ie=a(f))==null||ie.open(A)}function P(A){var ie;n.activeSessionId=A,Tn(A,o.defaultNotifications),ci(),(ie=a(c))==null||ie.focusTerm()}function U(A){var ie;if(fetch(`/sessions/${A}`,{method:"DELETE"}).then(()=>Mt()),n.activeSessionId===A){const de=a(x).filter(he=>he.id!==A);n.activeSessionId=((ie=de[0])==null?void 0:ie.id)??null}}function Z(A,ie,de){var he,Se;(he=a(h))==null||he.show(A,ie,de),ie||(Se=a(h))==null||Se.autoDismiss(3e3)}function me(A){Qs(A)}function be(){}function fe(){}function ke(){const A=document.createElement("input");A.type="file",A.accept="image/*",A.onchange=()=>{var de,he;const ie=(de=A.files)==null?void 0:de[0];ie&&((he=a(c))==null||he.handleImageUpload(ie,ie.type))},A.click()}function Ee(){var A;(A=a(c))==null||A.focusTerm()}function Ce(A){m(z,A,!0)}function $(){var A;(A=a(c))==null||A.exitCopyMode()}let ve=F(void 0);function Re(){var A;(A=a(ve))==null||A.open()}async function Ye(A){await Mt(),A.length>0&&(r.activeWorkspacePath=A[0])}async function Fe(){const A=n.activeSessionId;if(!A)return;const ie=n.sessions.find(de=>de.id===A);if(ie){if(await xp(A),ie.type==="worktree"){const de=n.workspaces.find(he=>ie.repoPath===he.path||ie.repoPath.startsWith(he.path+"/"));if(de&&ie.repoPath!==de.path)try{await zd(ie.repoPath,de.path)}catch{}}n.activeSessionId=null,await Mt()}}var Te=ys(),ge=_t(Te);{var Qe=A=>{},Le=A=>{vg(A,{})},Be=A=>{Ky(A,{get client(){return i},children:(ie,de)=>{var he=q0(),Se=_t(he),se=S(Se);{var Ie=De=>{var Yt=U0();Q("click",Yt,function(...si){ci==null||ci.apply(this,si)}),O(De,Yt)};ne(se,De=>{r.sidebarOpen&&De(Ie)})}var ze=k(se,2);jg(ze,{onSelectSession:J,onOpenSettings:X,onNewWorktree:N,onNewSession:De=>ae(De),onNewTerminal:De=>ae(De,{agent:"claude"}),onAddWorkspace:Re,onDeleteSession:U,onDeleteWorktree:D});var I=k(ze,2),K=S(I);jw(K,{get title(){return a(C)},get onMenuClick(){return fc},get hidden(){return a(b)}});var H=k(K,2);{var E=De=>{Ww(De,{heading:"Add a workspace to get started",description:"Point to any folder on your machine. Git repos get PR tracking and branch management.",actionLabel:"+ Add Workspace",onAction:Re})},V=De=>{{let Yt=_e(()=>r.activeWorkspacePath??""),si=_e(()=>{var fi;return((fi=a(p))==null?void 0:fi.name)??""});Aw(De,{get workspacePath(){return a(Yt)},get workspaceName(){return a(si)},onNewSession:()=>ae(),onNewWorktree:()=>{a(p)&&N(a(p))},onFixConflicts:B,onPrAction:T,onOpenPrSession:j})}},ce=De=>{var Yt=K0(),si=_t(Yt);{let Ut=_e(()=>r.activeWorkspacePath??""),ri=_e(()=>{var vi;return((vi=a(R))==null?void 0:vi.branchName)??""});lw(si,{get workspacePath(){return a(Ut)},get branchName(){return a(ri)},get sessionId(){return n.activeSessionId},onArchive:Fe})}var fi=k(si,2);dw(fi,{get sessions(){return a(x)},get activeSessionId(){return n.activeSessionId},onSelectSession:J,onCloseSession:U,onNewSession:()=>ae(),onNewTerminal:()=>ae(void 0,{agent:"claude"})});var _i=k(fi,2);$e(oy(_i,{get sessionId(){return n.activeSessionId},onImageUpload:Z,get useTmux(){return a(L)},onCopyModeChange:Ce}),Ut=>m(c,Ut,!0),()=>a(c));var ir=k(_i,2);Kw(ir,{onSendKey:me,onFlushComposedText:be,onClearInput:fe,onUploadImage:ke,onRefocusMobileInput:Ee,get useTmux(){return a(L)},get inCopyMode(){return a(z)},onExitCopyMode:$}),O(De,Yt)};ne(H,De=>{a(Y)==="empty"?De(E):a(Y)==="dashboard"?De(V,1):a(Y)==="session"&&De(ce,2)})}$e(Se,De=>m(g,De),()=>a(g));var pe=k(Se,2);$e(n0(pe,{onSessionCreated:P}),De=>m(d,De,!0),()=>a(d));var we=k(pe,2);$e(d0(we,{}),De=>m(u,De,!0),()=>a(u));var xe=k(we,2);$e(p0(xe,{}),De=>m(f,De,!0),()=>a(f));var Ue=k(xe,2);$e(M0(Ue,{onWorkspacesAdded:Ye}),De=>m(ve,De,!0),()=>a(ve));var Ft=k(Ue,2);$e(z0(Ft,{onRemoveWorkspace:async De=>{await fetch("/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:De})}),await Mt(),r.activeWorkspacePath===De&&(r.activeWorkspacePath=null)}}),De=>m(v,De,!0),()=>a(v));var ii=k(Ft,2);Gw(ii,{});var Mi=k(ii,2);$e(Jw(Mi,{}),De=>m(h,De,!0),()=>a(h)),O(ie,he)},$$slots:{default:!0}})};ne(ge,A=>{s.checking?A(Qe):s.authenticated?A(Be,!1):A(Le,1)})}O(e,Te),ut()}ot(["click"]);Yv(j0,{target:document.getElementById("app")});