claude-remote-cli 3.3.6 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +0,0 @@
1
- var C_=Object.defineProperty;var $h=e=>{throw TypeError(e)};var k_=(e,t,i)=>t in e?C_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Mi=(e,t,i)=>k_(e,typeof t!="symbol"?t+"":t,i),Ma=(e,t,i)=>t.has(e)||$h("Cannot "+i);var _=(e,t,i)=>(Ma(e,t,"read from private field"),i?i.call(e):t.get(e)),ee=(e,t,i)=>t.has(e)?$h("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),V=(e,t,i,s)=>(Ma(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),ke=(e,t,i)=>(Ma(e,t,"access private method"),i);var Mo=(e,t,i,s)=>({set _(r){V(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 tl=!1;var yh=Array.isArray,x_=Array.prototype.indexOf,Sn=Array.prototype.includes,_a=Array.from,E_=Object.defineProperty,Qr=Object.getOwnPropertyDescriptor,P_=Object.getOwnPropertyDescriptors,R_=Object.prototype,D_=Array.prototype,qu=Object.getPrototypeOf,Zh=Object.isExtensible;const T_=()=>{};function M_(e){for(var t=0;t<e.length;t++)e[t]()}function ju(){var e,t,i=new Promise((s,r)=>{e=s,t=r});return{promise:i,resolve:e,reject:t}}function B_(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 Ft=2,So=4,yo=8,Vu=1<<24,Ps=16,ji=32,Ur=64,il=128,Ei=512,Rt=1024,Wt=2048,qi=4096,di=8192,ws=16384,Ir=32768,Nr=65536,ec=1<<17,Yu=1<<18,Pn=1<<19,Gu=1<<20,bs=1<<25,Fr=65536,sl=1<<21,wh=1<<22,Qs=1<<23,Mr=Symbol("$state"),L_=Symbol("legacy props"),A_=Symbol(""),ur=new class extends Error{constructor(){super(...arguments);Mi(this,"name","StaleReactionError");Mi(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var Ru;const O_=!!((Ru=globalThis.document)!=null&&Ru.contentType)&&globalThis.document.contentType.includes("xml");function Ch(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function I_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function N_(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function F_(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function W_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function H_(e){throw new Error("https://svelte.dev/e/effect_orphan")}function z_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function U_(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function K_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function q_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function j_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function V_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Y_=1,G_=2,Xu=4,X_=8,Q_=16,J_=1,$_=4,Z_=8,ev=16,tv=1,iv=2,Bt=Symbol(),Qu="http://www.w3.org/1999/xhtml",sv="http://www.w3.org/2000/svg",rv="http://www.w3.org/1998/Math/MathML";function nv(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function ov(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Ju(e){return e===this.v}function av(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function $u(e){return!av(e,this.v)}let lv=!1,mt=null;function yn(e){mt=e}function Zu(e){return td().get(e)}function hv(e,t){return td().set(e,t),t}function ut(e,t=!1,i){mt={p:mt,i:!1,c:null,e:null,s:e,x:null,l:null}}function dt(e){var t=mt,i=t.e;if(i!==null){t.e=null;for(var s of i)Cd(s)}return e!==void 0&&(t.x=e),t.i=!0,mt=t.p,e??{}}function ed(){return!0}function td(e){return mt===null&&Ch(),mt.c??(mt.c=new Map(cv(mt)||void 0))}function cv(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let dr=[];function id(){var e=dr;dr=[],M_(e)}function ss(e){if(dr.length===0&&!Yn){var t=dr;queueMicrotask(()=>{t===dr&&id()})}dr.push(e)}function uv(){for(;dr.length>0;)id()}function sd(e){var t=qe;if(t===null)return Fe.f|=Qs,e;if((t.f&Ir)===0&&(t.f&So)===0)throw e;Ys(e,t)}function Ys(e,t){for(;t!==null;){if((t.f&il)!==0){if((t.f&Ir)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const dv=-7169;function ct(e,t){e.f=e.f&dv|t}function kh(e){(e.f&Ei)!==0||e.deps===null?ct(e,Rt):ct(e,qi)}function rd(e){if(e!==null)for(const t of e)(t.f&Ft)===0||(t.f&Fr)===0||(t.f^=Fr,rd(t.deps))}function nd(e,t,i){(e.f&Wt)!==0?t.add(e):(e.f&qi)!==0&&i.add(e),rd(e.deps),ct(e,Rt)}const Bo=new Set;let De=null,Jo=null,Ot=null,ei=[],va=null,rl=!1,Yn=!1;var Zr,en,gr,tn,co,uo,mr,_s,sn,fi,nl,ol,al,od;const Qh=class Qh{constructor(){ee(this,fi);Mi(this,"current",new Map);Mi(this,"previous",new Map);ee(this,Zr,new Set);ee(this,en,new Set);ee(this,gr,0);ee(this,tn,0);ee(this,co,null);ee(this,uo,new Set);ee(this,mr,new Set);ee(this,_s,new Map);Mi(this,"is_fork",!1);ee(this,sn,!1)}skip_effect(t){_(this,_s).has(t)||_(this,_s).set(t,{d:[],m:[]})}unskip_effect(t){var i=_(this,_s).get(t);if(i){_(this,_s).delete(t);for(var s of i.d)ct(s,Wt),Ui(s);for(s of i.m)ct(s,qi),Ui(s)}}process(t){var r;ei=[],this.apply();var i=[],s=[];for(const n of t)ke(this,fi,ol).call(this,n,i,s);if(ke(this,fi,nl).call(this)){ke(this,fi,al).call(this,s),ke(this,fi,al).call(this,i);for(const[n,o]of _(this,_s))cd(n,o)}else{for(const n of _(this,Zr))n();_(this,Zr).clear(),_(this,gr)===0&&ke(this,fi,od).call(this),Jo=this,De=null,tc(s),tc(i),Jo=null,(r=_(this,co))==null||r.resolve()}Ot=null}capture(t,i){i!==Bt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&Qs)===0&&(this.current.set(t,t.v),Ot==null||Ot.set(t,t.v))}activate(){De=this,this.apply()}deactivate(){De===this&&(De=null,Ot=null)}flush(){if(this.activate(),ei.length>0){if(ad(),De!==null&&De!==this)return}else _(this,gr)===0&&this.process([]);this.deactivate()}discard(){for(const t of _(this,en))t(this);_(this,en).clear()}increment(t){V(this,gr,_(this,gr)+1),t&&V(this,tn,_(this,tn)+1)}decrement(t){V(this,gr,_(this,gr)-1),t&&V(this,tn,_(this,tn)-1),!_(this,sn)&&(V(this,sn,!0),ss(()=>{V(this,sn,!1),ke(this,fi,nl).call(this)?ei.length>0&&this.flush():this.revive()}))}revive(){for(const t of _(this,uo))_(this,mr).delete(t),ct(t,Wt),Ui(t);for(const t of _(this,mr))ct(t,qi),Ui(t);this.flush()}oncommit(t){_(this,Zr).add(t)}ondiscard(t){_(this,en).add(t)}settled(){return(_(this,co)??V(this,co,ju())).promise}static ensure(){if(De===null){const t=De=new Qh;Bo.add(De),Yn||ss(()=>{De===t&&t.flush()})}return De}apply(){}};Zr=new WeakMap,en=new WeakMap,gr=new WeakMap,tn=new WeakMap,co=new WeakMap,uo=new WeakMap,mr=new WeakMap,_s=new WeakMap,sn=new WeakMap,fi=new WeakSet,nl=function(){return this.is_fork||_(this,tn)>0},ol=function(t,i,s){t.f^=Rt;for(var r=t.first;r!==null;){var n=r.f,o=(n&(ji|Ur))!==0,l=o&&(n&Rt)!==0,c=l||(n&di)!==0||_(this,_s).has(r);if(!c&&r.fn!==null){o?r.f^=Rt:(n&So)!==0?i.push(r):Co(r)&&((n&Ps)!==0&&_(this,mr).add(r),Cn(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}}},al=function(t){for(var i=0;i<t.length;i+=1)nd(t[i],_(this,uo),_(this,mr))},od=function(){var r;if(Bo.size>1){this.previous.clear();var t=Ot,i=!0;for(const n of Bo){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=ei;ei=[];const c=new Set,h=new Map;for(const d of o)ld(d,l,c,h);if(ei.length>0){De=n,n.apply();for(const d of ei)ke(r=n,fi,ol).call(r,d,[],[]);n.deactivate()}ei=s}}De=null,Ot=t}Bo.delete(this)};let Js=Qh;function fv(e){var t=Yn;Yn=!0;try{for(var i;;){if(uv(),ei.length===0&&(De==null||De.flush(),ei.length===0))return va=null,i;ad()}}finally{Yn=t}}function ad(){rl=!0;var e=null;try{for(var t=0;ei.length>0;){var i=Js.ensure();if(t++>1e3){var s,r;_v()}i.process(ei),$s.clear()}}finally{ei=[],rl=!1,va=null}}function _v(){try{z_()}catch(e){Ys(e,va)}}let Ai=null;function tc(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var s=e[i++];if((s.f&(ws|di))===0&&Co(s)&&(Ai=new Set,Cn(s),s.deps===null&&s.first===null&&s.nodes===null&&s.teardown===null&&s.ac===null&&Pd(s),(Ai==null?void 0:Ai.size)>0)){$s.clear();for(const r of Ai){if((r.f&(ws|di))!==0)continue;const n=[r];let o=r.parent;for(;o!==null;)Ai.has(o)&&(Ai.delete(o),n.push(o)),o=o.parent;for(let l=n.length-1;l>=0;l--){const c=n[l];(c.f&(ws|di))===0&&Cn(c)}}Ai.clear()}}Ai=null}}function ld(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&Ft)!==0?ld(r,t,i,s):(n&(wh|Ps))!==0&&(n&Wt)===0&&hd(r,t,s)&&(ct(r,Wt),Ui(r))}}function hd(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(Sn.call(t,r))return!0;if((r.f&Ft)!==0&&hd(r,t,i))return i.set(r,!0),!0}return i.set(e,!1),!1}function Ui(e){var t=va=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(So|yo|Vu))!==0&&(e.f&Ir)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var s=t.f;if(rl&&t===qe&&(s&Ps)!==0&&(s&Yu)===0&&(s&Ir)!==0)return;if((s&(Ur|ji))!==0){if((s&Rt)===0)return;t.f^=Rt}}ei.push(t)}function cd(e,t){if(!((e.f&ji)!==0&&(e.f&Rt)!==0)){(e.f&Wt)!==0?t.d.push(e):(e.f&qi)!==0&&t.m.push(e),ct(e,Rt);for(var i=e.first;i!==null;)cd(i,t),i=i.next}}function vv(e){let t=0,i=sr(0),s;return()=>{Ph()&&(a(i),ma(()=>(t===0&&(s=nr(()=>e(()=>Zs(i)))),t+=1,()=>{ss(()=>{t-=1,t===0&&(s==null||s(),s=void 0,Zs(i))})})))}}var pv=Nr|Pn;function gv(e,t,i,s){new mv(e,t,i,s)}var bi,bh,Qi,br,$t,Ji,hi,Ii,vs,Sr,Ns,rn,nn,on,ps,ca,bt,bv,Sv,yv,ll,Uo,Ko,hl;class mv{constructor(t,i,s,r){ee(this,bt);Mi(this,"parent");Mi(this,"is_pending",!1);Mi(this,"transform_error");ee(this,bi);ee(this,bh,null);ee(this,Qi);ee(this,br);ee(this,$t);ee(this,Ji,null);ee(this,hi,null);ee(this,Ii,null);ee(this,vs,null);ee(this,Sr,0);ee(this,Ns,0);ee(this,rn,!1);ee(this,nn,new Set);ee(this,on,new Set);ee(this,ps,null);ee(this,ca,vv(()=>(V(this,ps,sr(_(this,Sr))),()=>{V(this,ps,null)})));var n;V(this,bi,t),V(this,Qi,i),V(this,br,o=>{var l=qe;l.b=this,l.f|=il,s(o)}),this.parent=qe.b,this.transform_error=r??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),V(this,$t,ba(()=>{ke(this,bt,ll).call(this)},pv))}defer_effect(t){nd(t,_(this,nn),_(this,on))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!_(this,Qi).pending}update_pending_count(t){ke(this,bt,hl).call(this,t),V(this,Sr,_(this,Sr)+t),!(!_(this,ps)||_(this,rn))&&(V(this,rn,!0),ss(()=>{V(this,rn,!1),_(this,ps)&&wn(_(this,ps),_(this,Sr))}))}get_effect_pending(){return _(this,ca).call(this),a(_(this,ps))}error(t){var i=_(this,Qi).onerror;let s=_(this,Qi).failed;if(!i&&!s)throw t;_(this,Ji)&&(si(_(this,Ji)),V(this,Ji,null)),_(this,hi)&&(si(_(this,hi)),V(this,hi,null)),_(this,Ii)&&(si(_(this,Ii)),V(this,Ii,null));var r=!1,n=!1;const o=()=>{if(r){ov();return}r=!0,n&&V_(),_(this,Ii)!==null&&Lr(_(this,Ii),()=>{V(this,Ii,null)}),ke(this,bt,Ko).call(this,()=>{Js.ensure(),ke(this,bt,ll).call(this)})},l=c=>{try{n=!0,i==null||i(c,o),n=!1}catch(h){Ys(h,_(this,$t)&&_(this,$t).parent)}s&&V(this,Ii,ke(this,bt,Ko).call(this,()=>{Js.ensure();try{return wi(()=>{var h=qe;h.b=this,h.f|=il,s(_(this,bi),()=>c,()=>o)})}catch(h){return Ys(h,_(this,$t).parent),null}}))};ss(()=>{var c;try{c=this.transform_error(t)}catch(h){Ys(h,_(this,$t)&&_(this,$t).parent);return}c!==null&&typeof c=="object"&&typeof c.then=="function"?c.then(l,h=>Ys(h,_(this,$t)&&_(this,$t).parent)):l(c)})}}bi=new WeakMap,bh=new WeakMap,Qi=new WeakMap,br=new WeakMap,$t=new WeakMap,Ji=new WeakMap,hi=new WeakMap,Ii=new WeakMap,vs=new WeakMap,Sr=new WeakMap,Ns=new WeakMap,rn=new WeakMap,nn=new WeakMap,on=new WeakMap,ps=new WeakMap,ca=new WeakMap,bt=new WeakSet,bv=function(){try{V(this,Ji,wi(()=>_(this,br).call(this,_(this,bi))))}catch(t){this.error(t)}},Sv=function(t){const i=_(this,Qi).failed;i&&V(this,Ii,wi(()=>{i(_(this,bi),()=>t,()=>()=>{})}))},yv=function(){const t=_(this,Qi).pending;t&&(this.is_pending=!0,V(this,hi,wi(()=>t(_(this,bi)))),ss(()=>{var i=V(this,vs,document.createDocumentFragment()),s=Cs();i.append(s),V(this,Ji,ke(this,bt,Ko).call(this,()=>(Js.ensure(),wi(()=>_(this,br).call(this,s))))),_(this,Ns)===0&&(_(this,bi).before(i),V(this,vs,null),Lr(_(this,hi),()=>{V(this,hi,null)}),ke(this,bt,Uo).call(this))}))},ll=function(){try{if(this.is_pending=this.has_pending_snippet(),V(this,Ns,0),V(this,Sr,0),V(this,Ji,wi(()=>{_(this,br).call(this,_(this,bi))})),_(this,Ns)>0){var t=V(this,vs,document.createDocumentFragment());Td(_(this,Ji),t);const i=_(this,Qi).pending;V(this,hi,wi(()=>i(_(this,bi))))}else ke(this,bt,Uo).call(this)}catch(i){this.error(i)}},Uo=function(){this.is_pending=!1;for(const t of _(this,nn))ct(t,Wt),Ui(t);for(const t of _(this,on))ct(t,qi),Ui(t);_(this,nn).clear(),_(this,on).clear()},Ko=function(t){var i=qe,s=Fe,r=mt;os(_(this,$t)),Di(_(this,$t)),yn(_(this,$t).ctx);try{return t()}catch(n){return sd(n),null}finally{os(i),Di(s),yn(r)}},hl=function(t){var i;if(!this.has_pending_snippet()){this.parent&&ke(i=this.parent,bt,hl).call(i,t);return}V(this,Ns,_(this,Ns)+t),_(this,Ns)===0&&(ke(this,bt,Uo).call(this),_(this,hi)&&Lr(_(this,hi),()=>{V(this,hi,null)}),_(this,vs)&&(_(this,bi).before(_(this,vs)),V(this,vs,null)))};function wv(e,t,i,s){const r=pa;var n=e.filter(u=>!u.settled);if(i.length===0&&n.length===0){s(t.map(r));return}var o=qe,l=Cv(),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&ws)===0&&Ys(f,o)}cl()}if(i.length===0){c.then(()=>h(t.map(r)));return}function d(){l(),Promise.all(i.map(u=>xv(u))).then(u=>h([...t.map(r),...u])).catch(u=>Ys(u,o))}c?c.then(d):d()}function Cv(){var e=qe,t=Fe,i=mt,s=De;return function(n=!0){os(e),Di(t),yn(i),n&&(s==null||s.activate())}}function cl(e=!0){os(null),Di(null),yn(null),e&&(De==null||De.deactivate())}function kv(){var e=qe.b,t=De,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function pa(e){var t=Ft|Wt,i=Fe!==null&&(Fe.f&Ft)!==0?Fe:null;return qe!==null&&(qe.f|=Pn),{ctx:mt,deps:null,effects:null,equals:Ju,f:t,fn:e,reactions:null,rv:0,v:Bt,wv:0,parent:i??qe,ac:null}}function xv(e,t,i){qe===null&&I_();var r=void 0,n=sr(Bt),o=!Fe,l=new Map;return Hv(()=>{var f;var c=ju();r=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(cl)}catch(v){c.reject(v),cl()}var h=De;if(o){var d=kv();(f=l.get(h))==null||f.reject(ur),l.delete(h),l.set(h,c)}const u=(v,p=void 0)=>{if(h.activate(),p)p!==ur&&(n.f|=Qs,wn(n,p));else{(n.f&Qs)!==0&&(n.f^=Qs),wn(n,v);for(const[b,g]of l){if(l.delete(b),b===h)break;g.reject(ur)}}d&&d()};c.promise.then(u,v=>u(null,v||"unknown"))}),Rh(()=>{for(const c of l.values())c.reject(ur)}),new Promise(c=>{function h(d){function u(){d===r?c(n):h(r)}d.then(u,u)}h(r)})}function fe(e){const t=pa(e);return Md(t),t}function ud(e){const t=pa(e);return t.equals=$u,t}function Ev(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)si(t[i])}}function Pv(e){for(var t=e.parent;t!==null;){if((t.f&Ft)===0)return(t.f&ws)===0?t:null;t=t.parent}return null}function xh(e){var t,i=qe;os(Pv(e));try{e.f&=~Fr,Ev(e),t=Od(e)}finally{os(i)}return t}function dd(e){var t=xh(e);if(!e.equals(t)&&(e.wv=Ld(),(!(De!=null&&De.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){ct(e,Rt);return}rr||(Ot!==null?(Ph()||De!=null&&De.is_fork)&&Ot.set(e,t):kh(e))}function Rv(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(ur),s.teardown=T_,s.ac=null,eo(s,0),Dh(s))}function fd(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&Cn(t)}let ul=new Set;const $s=new Map;let _d=!1;function sr(e,t){var i={f:0,v:e,reactions:null,equals:Ju,rv:0,wv:0};return i}function F(e,t){const i=sr(e);return Md(i),i}function Dv(e,t=!1,i=!0){const s=sr(e);return t||(s.equals=$u),s}function m(e,t,i=!1){Fe!==null&&(!Ki||(Fe.f&ec)!==0)&&ed()&&(Fe.f&(Ft|Ps|wh|ec))!==0&&(Pi===null||!Sn.call(Pi,e))&&j_();let s=i?Je(t):t;return wn(e,s)}function wn(e,t){if(!e.equals(t)){var i=e.v;rr?$s.set(e,t):$s.set(e,i),e.v=t;var s=Js.ensure();if(s.capture(e,i),(e.f&Ft)!==0){const r=e;(e.f&Wt)!==0&&xh(r),kh(r)}e.wv=Ld(),vd(e,Wt),qe!==null&&(qe.f&Rt)!==0&&(qe.f&(ji|Ur))===0&&(mi===null?Uv([e]):mi.push(e)),!s.is_fork&&ul.size>0&&!_d&&Tv()}return t}function Tv(){_d=!1;for(const e of ul)(e.f&Rt)!==0&&ct(e,qi),Co(e)&&Cn(e);ul.clear()}function Mv(e,t=1){var i=a(e),s=t===1?i++:i--;return m(e,i),s}function Zs(e){m(e,e.v+1)}function vd(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&Wt)===0;if(l&&ct(n,t),(o&Ft)!==0){var c=n;Ot==null||Ot.delete(c),(o&Fr)===0&&(o&Ei&&(n.f|=Fr),vd(c,qi))}else l&&((o&Ps)!==0&&Ai!==null&&Ai.add(n),Ui(n))}}function Je(e){if(typeof e!="object"||e===null||Mr in e)return e;const t=qu(e);if(t!==R_&&t!==D_)return e;var i=new Map,s=yh(e),r=F(0),n=ks,o=l=>{if(ks===n)return l();var c=Fe,h=ks;Di(null),nc(n);var d=l();return Di(c),nc(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)&&K_();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(Bt));i.set(c,d),Zs(r)}}else m(h,Bt),Zs(r);return!0},get(l,c,h){var v;if(c===Mr)return e;var d=i.get(c),u=c in l;if(d===void 0&&(!u||(v=Qr(l,c))!=null&&v.writable)&&(d=o(()=>{var p=Je(u?l[c]:Bt),b=F(p);return b}),i.set(c,d)),d!==void 0){var f=a(d);return f===Bt?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!==Bt)return{enumerable:!0,configurable:!0,value:f,writable:!0}}return h},has(l,c){var f;if(c===Mr)return!0;var h=i.get(c),d=h!==void 0&&h.v!==Bt||Reflect.has(l,c);if(h!==void 0||qe!==null&&(!d||(f=Qr(l,c))!=null&&f.writable)){h===void 0&&(h=o(()=>{var v=d?Je(l[c]):Bt,p=F(v);return p}),i.set(c,h));var u=a(h);if(u===Bt)return!1}return d},set(l,c,h,d){var C;var u=i.get(c),f=c in l;if(s&&c==="length")for(var v=h;v<u.v;v+=1){var p=i.get(v+"");p!==void 0?m(p,Bt):v in l&&(p=o(()=>F(Bt)),i.set(v+"",p))}if(u===void 0)(!f||(C=Qr(l,c))!=null&&C.writable)&&(u=o(()=>F(void 0)),m(u,Je(h)),i.set(c,u));else{f=u.v!==Bt;var b=o(()=>Je(h));m(u,b)}var g=Reflect.getOwnPropertyDescriptor(l,c);if(g!=null&&g.set&&g.set.call(d,h),!f){if(s&&typeof c=="string"){var y=i.get("length"),R=Number(c);Number.isInteger(R)&&R>=y.v&&m(y,R+1)}Zs(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!==Bt});for(var[h,d]of i)d.v!==Bt&&!(h in l)&&c.push(h);return c},setPrototypeOf(){q_()}})}function ic(e){try{if(e!==null&&typeof e=="object"&&Mr in e)return e[Mr]}catch{}return e}function Bv(e,t){return Object.is(ic(e),ic(t))}var $o,pd,gd,md,bd;function Lv(){if($o===void 0){$o=window,pd=document,gd=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;md=Qr(t,"firstChild").get,bd=Qr(t,"nextSibling").get,Zh(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Zh(i)&&(i.__t=void 0)}}function Cs(e=""){return document.createTextNode(e)}function Br(e){return md.call(e)}function wo(e){return bd.call(e)}function S(e,t){return Br(e)}function vt(e,t=!1){{var i=Br(e);return i instanceof Comment&&i.data===""?wo(i):i}}function k(e,t=1,i=!1){let s=e;for(;t--;)s=wo(s);return s}function Av(e){e.textContent=""}function Sd(){return!1}function yd(e,t,i){return document.createElementNS(t??Qu,e,void 0)}function Ov(e,t){{const i=document.body;e.autofocus=!0,ss(()=>{document.activeElement===i&&e.focus()})}}let sc=!1;function Iv(){sc||(sc=!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 ga(e){var t=Fe,i=qe;Di(null),os(null);try{return e()}finally{Di(t),os(i)}}function Eh(e,t,i,s=i){e.addEventListener(t,()=>ga(i));const r=e.__on_r;r?e.__on_r=()=>{r(),s(!0)}:e.__on_r=()=>s(!0),Iv()}function wd(e){qe===null&&(Fe===null&&H_(),W_()),rr&&F_()}function Nv(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function hs(e,t,i){var s=qe;s!==null&&(s.f&di)!==0&&(e|=di);var r={ctx:mt,deps:null,nodes:null,f:e|Wt|Ei,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{Cn(r)}catch(l){throw si(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&Pn)===0&&(n=n.first,(e&Ps)!==0&&(e&Nr)!==0&&n!==null&&(n.f|=Nr)),n!==null&&(n.parent=s,s!==null&&Nv(n,s),Fe!==null&&(Fe.f&Ft)!==0&&(e&Ur)===0)){var o=Fe;(o.effects??(o.effects=[])).push(n)}return r}function Ph(){return Fe!==null&&!Ki}function Rh(e){const t=hs(yo,null,!1);return ct(t,Rt),t.teardown=e,t}function rs(e){wd();var t=qe.f,i=!Fe&&(t&ji)!==0&&(t&Ir)===0;if(i){var s=mt;(s.e??(s.e=[])).push(e)}else return Cd(e)}function Cd(e){return hs(So|Gu,e,!1)}function Fv(e){return wd(),hs(yo|Gu,e,!0)}function Wv(e){Js.ensure();const t=hs(Ur|Pn,e,!0);return(i={})=>new Promise(s=>{i.outro?Lr(t,()=>{si(t),s(void 0)}):(si(t),s(void 0))})}function kd(e){return hs(So,e,!1)}function Hv(e){return hs(wh|Pn,e,!0)}function ma(e,t=0){return hs(yo|t,e,!0)}function he(e,t=[],i=[],s=[]){wv(s,t,i,r=>{hs(yo,()=>e(...r.map(a)),!0)})}function ba(e,t=0){var i=hs(Ps|t,e,!0);return i}function wi(e){return hs(ji|Pn,e,!0)}function xd(e){var t=e.teardown;if(t!==null){const i=rr,s=Fe;rc(!0),Di(null);try{t.call(null)}finally{rc(i),Di(s)}}}function Dh(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const r=i.ac;r!==null&&ga(()=>{r.abort(ur)});var s=i.next;(i.f&Ur)!==0?i.parent=null:si(i,t),i=s}}function zv(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&ji)===0&&si(t),t=i}}function si(e,t=!0){var i=!1;(t||(e.f&Yu)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Ed(e.nodes.start,e.nodes.end),i=!0),Dh(e,t&&!i),eo(e,0),ct(e,ws);var s=e.nodes&&e.nodes.t;if(s!==null)for(const n of s)n.stop();xd(e);var r=e.parent;r!==null&&r.first!==null&&Pd(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Ed(e,t){for(;e!==null;){var i=e===t?null:wo(e);e.remove(),e=i}}function Pd(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 Lr(e,t,i=!0){var s=[];Rd(e,s,!0);var r=()=>{i&&si(e),t&&t()},n=s.length;if(n>0){var o=()=>--n||r();for(var l of s)l.out(o)}else r()}function Rd(e,t,i){if((e.f&di)===0){e.f^=di;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&Nr)!==0||(r.f&ji)!==0&&(e.f&Ps)!==0;Rd(r,t,o?i:!1),r=n}}}function Th(e){Dd(e,!0)}function Dd(e,t){if((e.f&di)!==0){e.f^=di,(e.f&Rt)===0&&(ct(e,Wt),Ui(e));for(var i=e.first;i!==null;){var s=i.next,r=(i.f&Nr)!==0||(i.f&ji)!==0;Dd(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 Td(e,t){if(e.nodes)for(var i=e.nodes.start,s=e.nodes.end;i!==null;){var r=i===s?null:wo(i);t.append(i),i=r}}let qo=!1,rr=!1;function rc(e){rr=e}let Fe=null,Ki=!1;function Di(e){Fe=e}let qe=null;function os(e){qe=e}let Pi=null;function Md(e){Fe!==null&&(Pi===null?Pi=[e]:Pi.push(e))}let ti=null,li=0,mi=null;function Uv(e){mi=e}let Bd=1,fr=0,ks=fr;function nc(e){ks=e}function Ld(){return++Bd}function Co(e){var t=e.f;if((t&Wt)!==0)return!0;if(t&Ft&&(e.f&=~Fr),(t&qi)!==0){for(var i=e.deps,s=i.length,r=0;r<s;r++){var n=i[r];if(Co(n)&&dd(n),n.wv>e.wv)return!0}(t&Ei)!==0&&Ot===null&&ct(e,Rt)}return!1}function Ad(e,t,i=!0){var s=e.reactions;if(s!==null&&!(Pi!==null&&Sn.call(Pi,e)))for(var r=0;r<s.length;r++){var n=s[r];(n.f&Ft)!==0?Ad(n,t,!1):t===n&&(i?ct(n,Wt):(n.f&Rt)!==0&&ct(n,qi),Ui(n))}}function Od(e){var b;var t=ti,i=li,s=mi,r=Fe,n=Pi,o=mt,l=Ki,c=ks,h=e.f;ti=null,li=0,mi=null,Fe=(h&(ji|Ur))===0?e:null,Pi=null,yn(e.ctx),Ki=!1,ks=++fr,e.ac!==null&&(ga(()=>{e.ac.abort(ur)}),e.ac=null);try{e.f|=sl;var d=e.fn,u=d();e.f|=Ir;var f=e.deps,v=De==null?void 0:De.is_fork;if(ti!==null){var p;if(v||eo(e,li),f!==null&&li>0)for(f.length=li+ti.length,p=0;p<ti.length;p++)f[li+p]=ti[p];else e.deps=f=ti;if(Ph()&&(e.f&Ei)!==0)for(p=li;p<f.length;p++)((b=f[p]).reactions??(b.reactions=[])).push(e)}else!v&&f!==null&&li<f.length&&(eo(e,li),f.length=li);if(ed()&&mi!==null&&!Ki&&f!==null&&(e.f&(Ft|qi|Wt))===0)for(p=0;p<mi.length;p++)Ad(mi[p],e);if(r!==null&&r!==e){if(fr++,r.deps!==null)for(let g=0;g<i;g+=1)r.deps[g].rv=fr;if(t!==null)for(const g of t)g.rv=fr;mi!==null&&(s===null?s=mi:s.push(...mi))}return(e.f&Qs)!==0&&(e.f^=Qs),u}catch(g){return sd(g)}finally{e.f^=sl,ti=t,li=i,mi=s,Fe=r,Pi=n,yn(o),Ki=l,ks=c}}function Kv(e,t){let i=t.reactions;if(i!==null){var s=x_.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&Ft)!==0&&(ti===null||!Sn.call(ti,t))){var n=t;(n.f&Ei)!==0&&(n.f^=Ei,n.f&=~Fr),kh(n),Rv(n),eo(n,0)}}function eo(e,t){var i=e.deps;if(i!==null)for(var s=t;s<i.length;s++)Kv(e,i[s])}function Cn(e){var t=e.f;if((t&ws)===0){ct(e,Rt);var i=qe,s=qo;qe=e,qo=!0;try{(t&(Ps|Vu))!==0?zv(e):Dh(e),xd(e);var r=Od(e);e.teardown=typeof r=="function"?r:null,e.wv=Bd;var n;tl&&lv&&(e.f&Wt)!==0&&e.deps}finally{qo=s,qe=i}}}async function qv(){await Promise.resolve(),fv()}function a(e){var t=e.f,i=(t&Ft)!==0;if(Fe!==null&&!Ki){var s=qe!==null&&(qe.f&ws)!==0;if(!s&&(Pi===null||!Sn.call(Pi,e))){var r=Fe.deps;if((Fe.f&sl)!==0)e.rv<fr&&(e.rv=fr,ti===null&&r!==null&&r[li]===e?li++:ti===null?ti=[e]:ti.push(e));else{(Fe.deps??(Fe.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[Fe]:Sn.call(n,Fe)||n.push(Fe)}}}if(rr&&$s.has(e))return $s.get(e);if(i){var o=e;if(rr){var l=o.v;return((o.f&Rt)===0&&o.reactions!==null||Nd(o))&&(l=xh(o)),$s.set(o,l),l}var c=(o.f&Ei)===0&&!Ki&&Fe!==null&&(qo||(Fe.f&Ei)!==0),h=(o.f&Ir)===0;Co(o)&&(c&&(o.f|=Ei),dd(o)),c&&!h&&(fd(o),Id(o))}if(Ot!=null&&Ot.has(e))return Ot.get(e);if((e.f&Qs)!==0)throw e.v;return e.v}function Id(e){if(e.f|=Ei,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&Ft)!==0&&(t.f&Ei)===0&&(fd(t),Id(t))}function Nd(e){if(e.v===Bt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if($s.has(t)||(t.f&Ft)!==0&&Nd(t))return!0;return!1}function nr(e){var t=Ki;try{return Ki=!0,e()}finally{Ki=t}}const jv=["touchstart","touchmove"];function Vv(e){return jv.includes(e)}const _r=Symbol("events"),Fd=new Set,dl=new Set;function Yv(e,t,i,s={}){function r(n){if(s.capture||fl.call(t,n),!n.cancelBubble)return ga(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?ss(()=>{t.addEventListener(e,r,s)}):t.addEventListener(e,r,s),r}function Ss(e,t,i,s,r){var n={capture:s,passive:r},o=Yv(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Rh(()=>{t.removeEventListener(e,o,n)})}function Q(e,t,i){(t[_r]??(t[_r]={}))[e]=i}function at(e){for(var t=0;t<e.length;t++)Fd.add(e[t]);for(var i of dl)i(e)}let oc=null;function fl(e){var g,y;var t=this,i=t.ownerDocument,s=e.type,r=((g=e.composedPath)==null?void 0:g.call(e))||[],n=r[0]||e.target;oc=e;var o=0,l=oc===e&&e[_r];if(l){var c=r.indexOf(l);if(c!==-1&&(t===document||t===window)){e[_r]=t;return}var h=r.indexOf(t);if(h===-1)return;c<=h&&(o=c)}if(n=r[o]||e.target,n!==t){E_(e,"currentTarget",{configurable:!0,get(){return n||i}});var d=Fe,u=qe;Di(null),os(null);try{for(var f,v=[];n!==null;){var p=n.assignedSlot||n.parentNode||n.host||null;try{var b=(y=n[_r])==null?void 0:y[s];b!=null&&(!n.disabled||e.target===n)&&b.call(n,e)}catch(R){f?v.push(R):f=R}if(e.cancelBubble||p===t||p===null)break;n=p}if(f){for(let R of v)queueMicrotask(()=>{throw R});throw f}}finally{e[_r]=t,delete e.currentTarget,Di(d),os(u)}}}var Du;const Ba=((Du=globalThis==null?void 0:globalThis.window)==null?void 0:Du.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Gv(e){return(Ba==null?void 0:Ba.createHTML(e))??e}function Xv(e){var t=yd("template");return t.innerHTML=Gv(e.replaceAll("<!>","<!---->")),t.content}function to(e,t){var i=qe;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function H(e,t){var i=(t&tv)!==0,s=(t&iv)!==0,r,n=!e.startsWith("<!>");return()=>{r===void 0&&(r=Xv(n?e:"<!>"+e),i||(r=Br(r)));var o=s||gd?document.importNode(r,!0):r.cloneNode(!0);if(i){var l=Br(o),c=o.lastChild;to(l,c)}else to(o,o);return o}}function Ar(e=""){{var t=Cs(e+"");return to(t,t),t}}function xs(){var e=document.createDocumentFragment(),t=document.createComment(""),i=Cs();return e.append(t,i),to(t,i),e}function I(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 Qv(e,t){return Jv(e,t)}const Lo=new Map;function Jv(e,{target:t,anchor:i,props:s={},events:r,context:n,intro:o=!0,transformError:l}){Lv();var c=void 0,h=Wv(()=>{var d=i??t.appendChild(Cs());gv(d,{pending:()=>{}},v=>{ut({});var p=mt;n&&(p.c=n),r&&(s.$$events=r),c=e(v,s)||{},dt()},l);var u=new Set,f=v=>{for(var p=0;p<v.length;p++){var b=v[p];if(!u.has(b)){u.add(b);var g=Vv(b);for(const C of[t,document]){var y=Lo.get(C);y===void 0&&(y=new Map,Lo.set(C,y));var R=y.get(b);R===void 0?(C.addEventListener(b,fl,{passive:g}),y.set(b,1)):y.set(b,R+1)}}}};return f(_a(Fd)),dl.add(f),()=>{var g;for(var v of u)for(const y of[t,document]){var p=Lo.get(y),b=p.get(v);--b==0?(y.removeEventListener(v,fl),p.delete(v),p.size===0&&Lo.delete(y)):p.set(v,b)}dl.delete(f),d!==i&&((g=d.parentNode)==null||g.removeChild(d))}});return $v.set(c,h),c}let $v=new WeakMap;var Ni,$i,ci,yr,fo,_o,ua;class Wd{constructor(t,i=!0){Mi(this,"anchor");ee(this,Ni,new Map);ee(this,$i,new Map);ee(this,ci,new Map);ee(this,yr,new Set);ee(this,fo,!0);ee(this,_o,()=>{var t=De;if(_(this,Ni).has(t)){var i=_(this,Ni).get(t),s=_(this,$i).get(i);if(s)Th(s),_(this,yr).delete(i);else{var r=_(this,ci).get(i);r&&(_(this,$i).set(i,r.effect),_(this,ci).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,ci).get(o);l&&(si(l.effect),_(this,ci).delete(o))}for(const[n,o]of _(this,$i)){if(n===i||_(this,yr).has(n))continue;const l=()=>{if(Array.from(_(this,Ni).values()).includes(n)){var h=document.createDocumentFragment();Td(o,h),h.append(Cs()),_(this,ci).set(n,{effect:o,fragment:h})}else si(o);_(this,yr).delete(n),_(this,$i).delete(n)};_(this,fo)||!s?(_(this,yr).add(n),Lr(o,l,!1)):l()}}});ee(this,ua,t=>{_(this,Ni).delete(t);const i=Array.from(_(this,Ni).values());for(const[s,r]of _(this,ci))i.includes(s)||(si(r.effect),_(this,ci).delete(s))});this.anchor=t,V(this,fo,i)}ensure(t,i){var s=De,r=Sd();if(i&&!_(this,$i).has(t)&&!_(this,ci).has(t))if(r){var n=document.createDocumentFragment(),o=Cs();n.append(o),_(this,ci).set(t,{effect:wi(()=>i(o)),fragment:n})}else _(this,$i).set(t,wi(()=>i(this.anchor)));if(_(this,Ni).set(s,t),r){for(const[l,c]of _(this,$i))l===t?s.unskip_effect(c):s.skip_effect(c);for(const[l,c]of _(this,ci))l===t?s.unskip_effect(c.effect):s.skip_effect(c.effect);s.oncommit(_(this,_o)),s.ondiscard(_(this,ua))}else _(this,_o).call(this)}}Ni=new WeakMap,$i=new WeakMap,ci=new WeakMap,yr=new WeakMap,fo=new WeakMap,_o=new WeakMap,ua=new WeakMap;function ae(e,t,i=!1){var s=new Wd(e),r=i?Nr:0;function n(o,l){s.ensure(o,l)}ba(()=>{var o=!1;t((l,c=0)=>{o=!0,n(c,l)}),o||n(!1,null)},r)}function io(e,t){return t}function Zv(e,t,i){for(var s=[],r=t.length,n,o=t.length,l=0;l<r;l++){let u=t[l];Lr(u,()=>{if(n){if(n.pending.delete(u),n.done.add(u),n.pending.size===0){var f=e.outrogroups;_l(_a(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;Av(d),d.append(h),e.items.clear()}_l(t,!c)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function _l(e,t=!0){for(var i=0;i<e.length;i++)si(e[i],t)}var ac;function Nt(e,t,i,s,r,n=null){var o=e,l=new Map,c=(t&Xu)!==0;if(c){var h=e;o=h.appendChild(Cs())}var d=null,u=ud(()=>{var y=i();return yh(y)?y:y==null?[]:_a(y)}),f,v=!0;function p(){g.fallback=d,ep(g,f,o,t,s),d!==null&&(f.length===0?(d.f&bs)===0?Th(d):(d.f^=bs,Hn(d,null,o)):Lr(d,()=>{d=null}))}var b=ba(()=>{f=a(u);for(var y=f.length,R=new Set,C=De,w=Sd(),x=0;x<y;x+=1){var M=f[x],N=s(M,x),j=v?null:l.get(N);j?(j.v&&wn(j.v,M),j.i&&wn(j.i,x),w&&C.unskip_effect(j.e)):(j=tp(l,v?o:ac??(ac=Cs()),M,N,x,r,t,i),v||(j.e.f|=bs),l.set(N,j)),R.add(N)}if(y===0&&n&&!d&&(v?d=wi(()=>n(o)):(d=wi(()=>n(ac??(ac=Cs()))),d.f|=bs)),y>R.size&&N_(),!v)if(w){for(const[J,oe]of l)R.has(J)||C.skip_effect(oe.e);C.oncommit(p),C.ondiscard(()=>{})}else p();a(u)}),g={effect:b,items:l,outrogroups:null,fallback:d};v=!1}function Bn(e){for(;e!==null&&(e.f&ji)===0;)e=e.next;return e}function ep(e,t,i,s,r){var oe,Y,W,O,B,T,q,D,E;var n=(s&X_)!==0,o=t.length,l=e.items,c=Bn(e.effect.first),h,d=null,u,f=[],v=[],p,b,g,y;if(n)for(y=0;y<o;y+=1)p=t[y],b=r(p,y),g=l.get(b).e,(g.f&bs)===0&&((Y=(oe=g.nodes)==null?void 0:oe.a)==null||Y.measure(),(u??(u=new Set)).add(g));for(y=0;y<o;y+=1){if(p=t[y],b=r(p,y),g=l.get(b).e,e.outrogroups!==null)for(const $ of e.outrogroups)$.pending.delete(g),$.done.delete(g);if((g.f&bs)!==0)if(g.f^=bs,g===c)Hn(g,null,i);else{var R=d?d.next:c;g===e.effect.last&&(e.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),Ms(e,d,g),Ms(e,g,R),Hn(g,R,i),d=g,f=[],v=[],c=Bn(d.next);continue}if((g.f&di)!==0&&(Th(g),n&&((O=(W=g.nodes)==null?void 0:W.a)==null||O.unfix(),(u??(u=new Set)).delete(g))),g!==c){if(h!==void 0&&h.has(g)){if(f.length<v.length){var C=v[0],w;d=C.prev;var x=f[0],M=f[f.length-1];for(w=0;w<f.length;w+=1)Hn(f[w],C,i);for(w=0;w<v.length;w+=1)h.delete(v[w]);Ms(e,x.prev,M.next),Ms(e,d,x),Ms(e,M,C),c=C,d=M,y-=1,f=[],v=[]}else h.delete(g),Hn(g,c,i),Ms(e,g.prev,g.next),Ms(e,g,d===null?e.effect.first:d.next),Ms(e,d,g),d=g;continue}for(f=[],v=[];c!==null&&c!==g;)(h??(h=new Set)).add(c),v.push(c),c=Bn(c.next);if(c===null)continue}(g.f&bs)===0&&f.push(g),d=g,c=Bn(g.next)}if(e.outrogroups!==null){for(const $ of e.outrogroups)$.pending.size===0&&(_l(_a($.done)),(B=e.outrogroups)==null||B.delete($));e.outrogroups.size===0&&(e.outrogroups=null)}if(c!==null||h!==void 0){var N=[];if(h!==void 0)for(g of h)(g.f&di)===0&&N.push(g);for(;c!==null;)(c.f&di)===0&&c!==e.fallback&&N.push(c),c=Bn(c.next);var j=N.length;if(j>0){var J=(s&Xu)!==0&&o===0?i:null;if(n){for(y=0;y<j;y+=1)(q=(T=N[y].nodes)==null?void 0:T.a)==null||q.measure();for(y=0;y<j;y+=1)(E=(D=N[y].nodes)==null?void 0:D.a)==null||E.fix()}Zv(e,N,J)}}n&&ss(()=>{var $,X;if(u!==void 0)for(g of u)(X=($=g.nodes)==null?void 0:$.a)==null||X.apply()})}function tp(e,t,i,s,r,n,o,l){var c=(o&Y_)!==0?(o&Q_)===0?Dv(i,!1,!1):sr(i):null,h=(o&G_)!==0?sr(r):null;return{v:c,i:h,e:wi(()=>(n(t,c??i,h??r,l),()=>{e.delete(s)}))}}function Hn(e,t,i){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end,n=t&&(t.f&bs)===0?t.nodes.start:i;s!==null;){var o=wo(s);if(n.before(s),s===r)return;s=o}}function Ms(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function lc(e,t,i=!1,s=!1,r=!1){var n=e,o="";he(()=>{var l=qe;if(o!==(o=t()??"")&&(l.nodes!==null&&(Ed(l.nodes.start,l.nodes.end),l.nodes=null),o!=="")){var c=i?sv:s?rv:void 0,h=yd(i?"svg":s?"math":"template",c);h.innerHTML=o;var d=i||s?h:h.content;if(to(Br(d),d.lastChild),i||s)for(;Br(d);)n.before(Br(d));else n.before(d)}})}function ip(e,t,...i){var s=new Wd(e);ba(()=>{const r=t()??null;s.ensure(r,r&&(n=>r(n,...i)))},Nr)}function Hd(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=Hd(e[t]))&&(s&&(s+=" "),s+=i)}else for(i in e)e[i]&&(s&&(s+=" "),s+=i);return s}function sp(){for(var e,t,i=0,s="",r=arguments.length;i<r;i++)(e=arguments[i])&&(t=Hd(e))&&(s&&(s+=" "),s+=t);return s}function zd(e){return typeof e=="object"?sp(e):e??""}const hc=[...`
2
- \r\f \v\uFEFF`];function rp(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||hc.includes(s[o-1]))&&(l===s.length||hc.includes(s[l]))?s=(o===0?"":s.substring(0,o))+s.substring(l+1):o=l}}return s===""?null:s}function cc(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 La(e){return e[0]!=="-"||e[1]!=="-"?e.toLowerCase():e}function np(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(La)),r&&c.push(...Object.keys(r).map(La));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=La(e.substring(h,d).trim());if(!c.includes(v)){f!==";"&&u++;var p=e.substring(h,u).trim();i+=" "+p+";"}}h=u+1,d=-1}}}}return s&&(i+=cc(s)),r&&(i+=cc(r,!0)),i=i.trim(),i===""?null:i}return e==null?null:String(e)}function Qe(e,t,i,s,r,n){var o=e.__className;if(o!==i||o===void 0){var l=rp(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 Aa(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 Rn(e,t,i,s){var r=e.__style;if(r!==t){var n=np(t,s);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else s&&(Array.isArray(s)?(Aa(e,i==null?void 0:i[0],s[0]),Aa(e,i==null?void 0:i[1],s[1],"important")):Aa(e,i,s));return s}function Ud(e,t,i=!1){if(e.multiple){if(t==null)return;if(!yh(t))return nv();for(var s of e.options)s.selected=t.includes(Gn(s));return}for(s of e.options){var r=Gn(s);if(Bv(r,t)){s.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function op(e){var t=new MutationObserver(()=>{Ud(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Rh(()=>{t.disconnect()})}function Zo(e,t,i=t){var s=new WeakSet,r=!0;Eh(e,"change",n=>{var o=n?"[selected]":":checked",l;if(e.multiple)l=[].map.call(e.querySelectorAll(o),Gn);else{var c=e.querySelector(o)??e.querySelector("option:not([disabled])");l=c&&Gn(c)}i(l),De!==null&&s.add(De)}),kd(()=>{var n=t();if(e===document.activeElement){var o=Jo??De;if(s.has(o))return}if(Ud(e,n,r),r&&n===void 0){var l=e.querySelector(":checked");l!==null&&(n=Gn(l),i(n))}e.__value=n,r=!1}),op(e)}function Gn(e){return"__value"in e?e.__value:e.value}const ap=Symbol("is custom element"),lp=Symbol("is html"),hp=O_?"progress":"PROGRESS";function cp(e,t){var i=Mh(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==hp)||(e.value=t??"")}function up(e,t){var i=Mh(e);i.checked!==(i.checked=t??void 0)&&(e.checked=t)}function Ne(e,t,i,s){var r=Mh(e);r[t]!==(r[t]=i)&&(t==="loading"&&(e[A_]=i),i==null?e.removeAttribute(t):typeof i!="string"&&dp(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function Mh(e){return e.__attributes??(e.__attributes={[ap]:e.nodeName.includes("-"),[lp]:e.namespaceURI===Qu})}var uc=new Map;function dp(e){var t=e.getAttribute("is")||e.nodeName,i=uc.get(t);if(i)return i;uc.set(t,i=[]);for(var s,r=e,n=Element.prototype;n!==r;){s=P_(r);for(var o in s)s[o].set&&i.push(o);r=qu(r)}return i}function xi(e,t,i=t){var s=new WeakSet;Eh(e,"input",async r=>{var n=r?e.defaultValue:e.value;if(n=Oa(e)?Ia(n):n,i(n),De!==null&&s.add(De),await qv(),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))}}}),nr(t)==null&&e.value&&(i(Oa(e)?Ia(e.value):e.value),De!==null&&s.add(De)),ma(()=>{var r=t();if(e===document.activeElement){var n=Jo??De;if(s.has(n))return}Oa(e)&&r===Ia(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}function zi(e,t,i=t){Eh(e,"change",s=>{var r=s?e.defaultChecked:e.checked;i(r)}),nr(t)==null&&i(e.checked),ma(()=>{var s=t();e.checked=!!s})}function Oa(e){var t=e.type;return t==="number"||t==="range"}function Ia(e){return e===""?null:+e}function dc(e,t){return e===t||(e==null?void 0:e[Mr])===t}function et(e={},t,i,s){return kd(()=>{var r,n;return ma(()=>{r=n,n=[],nr(()=>{e!==i(...n)&&(t(e,...n),r&&dc(i(...r),e)&&t(null,...r))})}),()=>{ss(()=>{n&&dc(i(...n),e)&&t(null,...n)})}}),e}let Ao=!1;function fp(e){var t=Ao;try{return Ao=!1,[e(),Ao]}finally{Ao=t}}function as(e,t,i,s){var R;var r=(i&Z_)!==0,n=(i&ev)!==0,o=s,l=!0,c=()=>(l&&(l=!1,o=n?nr(s):s),o),h;if(r){var d=Mr in e||L_ in e;h=((R=Qr(e,t))==null?void 0:R.set)??(d&&t in e?C=>e[t]=C:void 0)}var u,f=!1;r?[u,f]=fp(()=>e[t]):u=e[t],u===void 0&&s!==void 0&&(u=c(),h&&(U_(),h(u)));var v;if(v=()=>{var C=e[t];return C===void 0?c():(l=!0,C)},(i&$_)===0)return v;if(h){var p=e.$$legacy;return(function(C,w){return arguments.length>0?((!w||p||f)&&h(w?v():C),C):v()})}var b=!1,g=((i&J_)!==0?pa:ud)(()=>(b=!1,v()));r&&a(g);var y=qe;return(function(C,w){if(arguments.length>0){const x=w?a(g):r?Je(C):C;return m(g,x),b=!0,o!==void 0&&(o=x),C}return rr&&b||(y.f&ws)!==0?g.v:a(g)})}function Dn(e){mt===null&&Ch(),rs(()=>{const t=nr(e);if(typeof t=="function")return t})}function _p(e){mt===null&&Ch(),Dn(()=>()=>nr(e))}const vp="5";var Tu;typeof window<"u"&&((Tu=window.__svelte??(window.__svelte={})).v??(Tu.v=new Set)).add(vp);class Kd extends Error{constructor(i){super("conflict");Mi(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function Dt(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function pp(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 gp(){return(await fetch("/sessions")).ok}async function mp(){return Dt(await fetch("/sessions"))}async function bp(){return Dt(await fetch("/worktrees"))}async function Sp(){return(await Dt(await fetch("/workspaces"))).workspaces}async function fc(e,t){const i=new URLSearchParams;return e&&i.set("path",e),Dt(await fetch("/workspaces/browse?"+i.toString()))}async function yp(e){return Dt(await fetch("/workspaces/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:e})}))}async function wp(e){var i,s;const t=await Dt(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 Cp(e,t){const i=await fetch("/workspaces/ci-status?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function kp(e,t){const i=await fetch("/workspaces/pr?path="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t));return i.ok?i.json():null}async function xp(e){return(await Dt(await fetch("/workspaces/current-branch?path="+encodeURIComponent(e)))).branch}async function Na(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 Ep(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 Bh(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),Dt(await fetch("/branches?"+i.toString()))}async function Gs(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 Kd(i.sessionId??"")}return Dt(t)}async function Pp(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 Kd(i.sessionId??"")}return Dt(t)}async function Rp(e){await fetch("/sessions/"+e,{method:"DELETE"})}async function qd(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 Dp(e,t,i){return Dt(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function jd(){return Dt(await fetch("/version"))}async function Vd(){return Dt(await fetch("/update",{method:"POST"}))}async function Tp(){return(await Dt(await fetch("/config/defaultAgent"))).defaultAgent}async function Mp(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 Sa(e){return(await Dt(await fetch(`/config/${e}`)))[e]}async function ya(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 Bp=()=>Sa("defaultContinue"),Lp=e=>ya("defaultContinue",e),Ap=()=>Sa("defaultYolo"),Op=e=>ya("defaultYolo",e),Ip=()=>Sa("launchInTmux"),Np=e=>ya("launchInTmux",e),Fp=()=>Sa("defaultNotifications"),Wp=e=>ya("defaultNotifications",e);async function Hp(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 vl(e){return Dt(await fetch("/workspaces/settings?path="+encodeURIComponent(e)))}async function zp(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 Up(){return Dt(await fetch("/sessions/meta"))}async function Kp(e,t){const i="/sessions/"+encodeURIComponent(e)+"/meta?refresh=true";return Dt(await fetch(i))}let ea=F(!1),pl=F(null),gl=F(!0);function Yd(){return{get authenticated(){return a(ea)},get pinError(){return a(pl)},get checking(){return a(gl)}}}async function qp(){m(gl,!0);try{m(ea,await gp(),!0)}catch{m(ea,!1)}finally{m(gl,!1)}}async function jp(e){m(pl,null);try{await pp(e),m(ea,!0)}catch(t){m(pl,t instanceof Error?t.message:"Authentication failed",!0)}}const Gd="claude-remote-sidebar-width",Xd="claude-remote-sidebar-collapsed",ml="claude-remote-active-workspace",Qd=240,Jd=180,$d=500,Vp=44;function Yp(){try{const e=localStorage.getItem(Gd);if(e){const t=parseInt(e,10);if(t>=Jd&&t<=$d)return t}}catch{}return Qd}function Gp(){try{return localStorage.getItem(Xd)==="true"}catch{return!1}}function Xp(){try{return localStorage.getItem(ml)}catch{return null}}let ta=F(!1),bl=F(Je(Yp())),Xn=F(Je(Gp())),_c=F(""),vc=F(Je(Xp()));function Zd(){return{get sidebarOpen(){return a(ta)},set sidebarOpen(e){m(ta,e,!0)},get sidebarWidth(){return a(bl)},set sidebarWidth(e){m(bl,e,!0)},get sidebarCollapsed(){return a(Xn)},set sidebarCollapsed(e){m(Xn,e,!0)},get searchQuery(){return a(_c)},set searchQuery(e){m(_c,e,!0)},get activeWorkspacePath(){return a(vc)},set activeWorkspacePath(e){m(vc,e,!0);try{e===null?localStorage.removeItem(ml):localStorage.setItem(ml,e)}catch{}}}}function pc(){m(ta,!0)}function ui(){m(ta,!1)}function gc(){try{localStorage.setItem(Gd,String(a(bl)))}catch{}}function Fa(){m(Xn,!a(Xn));try{localStorage.setItem(Xd,String(a(Xn)))}catch{}}const ef="claude-remote-collapsed-workspaces";function Qp(){try{const e=localStorage.getItem(ef);if(e)return new Set(JSON.parse(e))}catch{}return new Set}let cr=F(Je(Qp()));function Jp(){try{localStorage.setItem(ef,JSON.stringify([...a(cr)]))}catch{}}function $p(e){a(cr).has(e)?a(cr).delete(e):a(cr).add(e),m(cr,new Set(a(cr)),!0),Jp()}function Zp(e){return a(cr).has(e)}let tf=F(0);setInterval(()=>{Mv(tf)},3e4);function eg(){return a(tf)}let Qn=null,tg=null;function ig(e){Qn=e,"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("message",t=>{const i=t.data;i.type==="notification-click"&&i.sessionId&&Qn&&Qn(i.sessionId,i.sessionType||"repo")})}function sg(){return document.hidden||!document.hasFocus()}function rg(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(),Qn&&Qn(e.id,e.type),t.close()}}function sf(){return"serviceWorker"in navigator&&"PushManager"in window}async function ng(){if(sf())try{tg=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function og(e){if(sf())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await Hp(i.toJSON(),e)}catch{}}const rf="claude-remote-notifications",Sl="claude-remote-active-session";function ag(){try{return localStorage.getItem(Sl)}catch{return null}}function nf(e){try{e===null?localStorage.removeItem(Sl):localStorage.setItem(Sl,e)}catch{}}let so=F(Je([])),of=F(Je([])),af=F(Je([])),Jr=F(Je(ag())),Wr=Je({}),ro=Je({}),wa=Je({}),Jn=F(Je(new Map)),Es=F(Je({}));try{const e=localStorage.getItem(rf);e&&m(Es,JSON.parse(e),!0)}catch{}function lf(){try{localStorage.setItem(rf,JSON.stringify(a(Es)))}catch{}}function Lh(){return{get sessions(){return a(so)},get worktrees(){return a(of)},get workspaces(){return a(af)},get activeSessionId(){return a(Jr)},set activeSessionId(e){m(Jr,e,!0),nf(e)},get attentionSessions(){return Wr},get loadingItems(){return wa},get notificationSessions(){return a(Es)}}}async function kt(){try{const[e,t,i]=await Promise.all([mp(),bp(),Sp()]);m(so,e,!0),m(of,t,!0),m(af,i,!0);const s=new Set(a(so).map(n=>n.id));a(Jr)!==null&&!s.has(a(Jr))&&(m(Jr,null),nf(null));let r=!1;for(const n of Object.keys(Wr))s.has(n)||delete Wr[n];for(const n of Object.keys(ro))s.has(n)||delete ro[n];for(const n of Object.keys(a(Es)))s.has(n)||(delete a(Es)[n],r=!0);r&&lf();try{const n=await Up(),o=new Map;for(const[l,c]of Object.entries(n))o.set(l,c);m(Jn,o,!0)}catch{}}catch{}}function hf(e){return a(so).filter(t=>t.repoPath===e||t.repoPath.startsWith(e+"/"))}const lg=3e4;function hg(e,t){const i=a(so).find(s=>s.id===e);if(i&&(i.idle=t),t&&e!==a(Jr)&&(i==null?void 0:i.type)!=="terminal"){const s=ro[e];if(s&&Date.now()-s<lg)return;delete ro[e],Wr[e]=!0,i&&a(Es)[e]&&sg()&&rg(i)}else delete Wr[e]}function mc(e){delete Wr[e],ro[e]=Date.now()}function Ln(e,t){e in a(Es)||(a(Es)[e]=t,lf())}function cg(){return Object.entries(a(Es)).filter(([,e])=>e).map(([e])=>e)}function Wa(e){return Wr[e.id]?"attention":e.idle?"idle":"running"}function Yr(e){wa[e]=!0}function Gr(e){delete wa[e]}function Oi(e){return!!wa[e]}function bc(e){return a(Jn).get(e)}async function ug(e){try{const t=await Kp(e,{refresh:!0});a(Jn).set(e,t),m(Jn,new Map(a(Jn)),!0)}catch{}}const cf=location.protocol==="https:"?"wss:":"ws:";let or=null,ii=null,vi=null;const Sc=30;let $n=null,$r=0;function uf(e){or&&(or.close(),or=null);const t=cf+"//"+location.host+"/ws/events";or=new WebSocket(t),or.onmessage=i=>{try{e(JSON.parse(i.data))}catch{}},or.onclose=()=>{setTimeout(()=>uf(e),3e3)},or.onerror=()=>{}}function df(e,t,i,s){$n&&(clearTimeout($n),$n=null),$r=0,vi&&(vi.onopen=null,vi.onmessage=null,vi.onclose=null,vi.onerror=null,vi.close(),vi=null),ii&&(ii.onclose=null,ii.close(),ii=null);const r=cf+"//"+location.host+"/ws/"+e,n=new WebSocket(r);vi=n,n.onopen=()=>{vi=null,ii=n,$r=0,i()},n.onmessage=o=>{t.write(o.data)},n.onclose=o=>{if(vi===n&&(vi=null),!(vi!==n&&ii!==n)){if(o.code===1e3){t.write(`\r
3
- [Session ended]\r
4
- `),ii=null,s();return}ii=null,$r===0&&t.write(`\r
5
- [Reconnecting...]\r
6
- `),ff(e,t,i,s)}},n.onerror=()=>{}}function ff(e,t,i,s){if($r>=Sc){t.write(`\r
7
- [Gave up reconnecting after `+Sc+` attempts]\r
8
- `);return}const r=Math.min(1e3*2**$r,1e4);$r++,$n=setTimeout(async()=>{$n=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(),df(e,t,i,s)}catch{ff(e,t,i,s)}},r)}function er(e){ii&&ii.readyState===WebSocket.OPEN&&ii.send(e)}function Ha(e,t){ii&&ii.readyState===WebSocket.OPEN&&ii.send(JSON.stringify({type:"resize",cols:e,rows:t}))}const Bi=Je({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Ah(){return Bi}async function _f(){const[e,t,i,s,r]=await Promise.all([Bp().catch(()=>Bi.defaultContinue),Ap().catch(()=>Bi.defaultYolo),Ip().catch(()=>Bi.launchInTmux),Tp().catch(()=>Bi.defaultAgent),Fp().catch(()=>Bi.defaultNotifications)]);Bi.defaultContinue=e,Bi.defaultYolo=t,Bi.launchInTmux=i,Bi.defaultAgent=s,Bi.defaultNotifications=r}function dg(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 yc(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 Lt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);function Oh(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 fg(e,t){return e.type==="resolve-comments"?{type:"review-pr",color:"muted",label:"Review PR"}:null}function vf(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 pf(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 gf(e){return e==="success"||e==="warning"}var _g=H('<p class="error svelte-1qp96yb"> </p>'),vg=H('<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 pg(e,t){ut(t,!0);const i=Yd();let s=F("");async function r(){const f=a(s).trim();f&&(await jp(f),i.pinError&&m(s,""))}function n(f){f.key==="Enter"&&r()}var o=vg(),l=S(o),c=k(S(l),4);Ov(c);var h=k(c,2),d=k(h,2);{var u=f=>{var v=_g(),p=S(v);he(()=>re(p,i.pinError)),I(f,v)};ae(d,f=>{i.pinError&&f(u)})}Q("keydown",c,n),xi(c,()=>a(s),f=>m(s,f)),Q("click",h,r),I(e,o),dt()}at(["keydown","click"]);var gg=H('<li role="menuitem"> </li>'),mg=H('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),bg=H('<button class="context-menu-trigger svelte-1nmhce7" aria-label="Actions" aria-haspopup="true">&middot;&middot;&middot;</button> <!>',1);function wc(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(),g=a(r).getBoundingClientRect();let y=b.bottom+4,R=b.right-g.width;y+g.height>window.innerHeight-8&&(y=b.top-g.height-4),R<8&&(R=8),a(r).style.top=y+"px",a(r).style.left=R+"px"}function c(b,g){g.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=bg();Ss("keydown",pd,h);var f=vt(u);et(f,b=>m(s,b),()=>a(s));var v=k(f,2);{var p=b=>{var g=mg(),y=vt(g),R=k(y,2);Nt(R,21,()=>t.items,io,(C,w)=>{var x=gg();let M;var N=S(x);he(()=>{M=Qe(x,1,"context-menu-item svelte-1nmhce7",null,M,{"context-menu-item--danger":a(w).danger,"context-menu-item--disabled":a(w).disabled}),Ne(x,"tabindex",a(w).disabled?-1:0),re(N,a(w).label)}),Q("click",x,j=>c(a(w),j)),Q("keydown",x,j=>j.key==="Enter"&&c(a(w),j)),I(C,x)}),et(R,C=>m(r,C),()=>a(r)),Q("click",y,d),Q("click",R,C=>C.stopPropagation()),I(b,g)};ae(v,b=>{a(i)&&b(p)})}he(()=>Ne(f,"aria-expanded",a(i))),Q("click",f,n),I(e,u)}at(["click","keydown"]);var Sg=H('<span class="collapse-count svelte-168i8d5"> </span>'),yg=H('<span class="terminal-icon svelte-168i8d5">&gt;_</span>'),wg=H("<span></span>"),Cg=H('<span class="session-count-badge svelte-168i8d5"> </span>'),kg=H('<span class="diff-badge svelte-168i8d5"><span class="diff-add svelte-168i8d5"> </span> <span class="diff-del svelte-168i8d5"> </span></span>'),xg=H('<span class="secondary-worktree svelte-168i8d5"> </span>'),Eg=H('<span class="secondary-pr svelte-168i8d5"> </span>'),Pg=H('<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>'),Rg=H('<li><div class="session-row-primary svelte-168i8d5"><span class="dot dot-inactive svelte-168i8d5"></span> <span class="session-name svelte-168i8d5"> </span></div></li>'),Dg=H('<span class="diff-badge svelte-168i8d5"><span class="diff-add svelte-168i8d5"> </span> <span class="diff-del svelte-168i8d5"> </span></span>'),Tg=H('<span class="secondary-pr svelte-168i8d5"> </span>'),Mg=H('<li><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>'),Bg=H('<ul class="session-list svelte-168i8d5"><!> <!></ul>'),Lg=H('<div><span class="add-worktree-btn svelte-168i8d5"> </span></div>'),Ag=H('<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 Og(e,t){ut(t,!0);const i=Lh();let s=as(t,"inactiveWorktrees",19,()=>[]),r=fe(()=>[...t.sessionGroups.values()].flat());const n=["#d97757","#4ade80","#60a5fa","#a78bfa","#f472b6","#fb923c","#34d399","#f87171"];function o(G){let ve=0;for(let Le=0;Le<G.length;Le++)ve=(ve<<5)-ve+G.charCodeAt(Le)|0;return n[Math.abs(ve)%n.length]??"#d97757"}let l=fe(()=>o(t.workspace.name)),c=fe(()=>t.workspace.name.charAt(0).toUpperCase()),h=fe(()=>Zp(t.workspace.path)),d=fe(()=>a(r).length+s().length);function u(G){return"status-dot status-dot--"+Wa(G)}function f(G){return G.displayName||G.branchName||G.repoName||G.id}let v=fe(()=>a(r).some(G=>Wa(G)==="attention")),p=fe(()=>Oi(`new-worktree:${t.workspace.path}`)),b=fe(eg);function g(G){return a(b),yc(G.lastActivity)}function y(G){return a(b),yc(G.lastActivity)}async function R(G){const ve=prompt("Rename session:",f(G));ve&&ve.trim()&&(await fetch(`/sessions/${G.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:ve.trim()})}),await kt())}function C(G){return[{label:"Rename",action:()=>R(G)},{label:"Kill",action:()=>{var ve;return(ve=t.onDeleteSession)==null?void 0:ve.call(t,G.id)},danger:!0}]}function w(G){return[{label:"Resume",action:async()=>{if(!Oi(G.path)){Yr(G.path);try{const ve=await Gs({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:G.path,branchName:G.branchName||G.name});await kt(),t.onSelectSession(ve.id)}catch{}finally{Gr(G.path)}}}},{label:"Resume (YOLO)",action:async()=>{if(!Oi(G.path)){Yr(G.path);try{const ve=await Gs({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:G.path,branchName:G.branchName||G.name,yolo:!0});await kt(),t.onSelectSession(ve.id)}catch{}finally{Gr(G.path)}}}},{label:"Delete Worktree",action:()=>{var ve;return(ve=t.onDeleteWorktree)==null?void 0:ve.call(t,G)},danger:!0}]}var x=Ag();let M;var N=S(x);let j;var J=S(N),oe=S(J);let Y;var W=S(oe),O=k(oe,2);let B;var T=S(O),q=k(O,2),D=S(q),E=k(q,2);{var $=G=>{var ve=Sg(),Le=S(ve);he(()=>re(Le,a(d))),I(G,ve)};ae(E,G=>{a(h)&&a(d)>0&&G($)})}var X=k(J,2),ce=S(X),be=k(ce,2),ge=k(be,2),xe=k(N,2);{var Pe=G=>{var ve=Bg(),Le=S(ve);Nt(Le,17,()=>[...t.sessionGroups.entries()],([Be,pe])=>Be,(Be,pe)=>{var We=fe(()=>B_(a(pe),2));let He=()=>a(We)[0],Ue=()=>a(We)[1];const L=fe(()=>Ue().sort((U,se)=>se.lastActivity.localeCompare(U.lastActivity))[0]),te=fe(()=>Ue().length),_e=fe(()=>He()===t.workspace.path),ue=fe(()=>a(te)>0),Se=fe(()=>Ue().some(U=>Wa(U)==="attention"));var ne=xs(),Ae=vt(ne);{var Ke=U=>{const se=fe(()=>bc(a(L).id)),P=fe(()=>a(se)&&(a(se).additions>0||a(se).deletions>0));var A=Pg();let Z;var me=S(A),Ce=S(me);{var ye=Ye=>{var it=yg();I(Ye,it)},Te=Ye=>{var it=wg();he(Qt=>Qe(it,1,Qt,"svelte-168i8d5"),[()=>zd(u(a(L)))]),I(Ye,it)};ae(Ce,Ye=>{a(L).type==="terminal"?Ye(ye):Ye(Te,!1)})}var Ze=k(Ce,2);let Ht;var Vi=S(Ze),Me=k(Ze,2);{var Mt=Ye=>{var it=Cg(),Qt=S(it);he(()=>re(Qt,a(te))),I(Ye,it)};ae(Me,Ye=>{a(te)>1&&Ye(Mt)})}var ri=k(Me,2);{var _i=Ye=>{var it=kg(),Qt=S(it),Do=S(Qt),Da=k(Qt,2),To=S(Da);he(()=>{re(Do,`+${a(se).additions??""}`),re(To,`-${a(se).deletions??""}`)}),I(Ye,it)};ae(ri,Ye=>{a(P)&&Ye(_i)})}var Gt=k(me,2),Ts=S(Gt);{var cs=Ye=>{var it=xg(),Qt=S(it);he(()=>re(Qt,a(L).worktreeName)),I(Ye,it)},ni=fe(()=>a(L).worktreeName&&a(L).worktreeName!==f(a(L)));ae(Ts,Ye=>{a(ni)&&Ye(cs)})}var Xt=k(Ts,2);{var us=Ye=>{var it=Eg(),Qt=S(it);he(()=>re(Qt,`PR #${a(se).prNumber??""}`)),I(Ye,it)};ae(Xt,Ye=>{var it;(it=a(se))!=null&&it.prNumber&&Ye(us)})}var Ti=k(Xt,2),Pa=S(Ti),Ra=k(Ti,2);{let Ye=fe(()=>C(a(L)));wc(Ra,{get items(){return a(Ye)}})}he((Ye,it,Qt)=>{Z=Qe(A,1,"session-row svelte-168i8d5",null,Z,Ye),Ht=Qe(Ze,1,"session-name svelte-168i8d5",null,Ht,{bold:a(Se)}),re(Vi,it),re(Pa,Qt)},[()=>({terminal:a(L).type==="terminal",selected:Ue().some(Ye=>i.activeSessionId===Ye.id),attention:a(Se)}),()=>f(a(L)),()=>g(a(L))]),Q("click",A,()=>t.onSelectSession(a(L).id)),I(U,A)},z=U=>{const se=fe(()=>`repo-session:${t.workspace.path}`);var P=Rg();let A;var Z=S(P),me=k(S(Z),2),Ce=S(me);he((ye,Te)=>{A=Qe(P,1,"session-row inactive svelte-168i8d5",null,A,ye),re(Ce,Te)},[()=>({loading:Oi(a(se))}),()=>Oi(a(se))?"starting...":t.workspace.name]),Q("click",P,async()=>{if(!Oi(a(se))){Yr(a(se));try{const ye=await Gs({repoPath:t.workspace.path,repoName:t.workspace.name});await kt(),t.onSelectSession(ye.id)}catch{}finally{Gr(a(se))}}}),I(U,P)};ae(Ae,U=>{a(ue)&&a(L)?U(Ke):a(_e)&&U(z,1)})}I(Be,ne)});var je=k(Le,2);Nt(je,17,s,Be=>Be.path,(Be,pe)=>{const We=fe(()=>bc(a(pe).path)),He=fe(()=>a(We)&&(a(We).additions>0||a(We).deletions>0));var Ue=Mg();let L;var te=S(Ue),_e=k(S(te),2),ue=S(_e),Se=k(_e,2);{var ne=A=>{var Z=Dg(),me=S(Z),Ce=S(me),ye=k(me,2),Te=S(ye);he(()=>{re(Ce,`+${a(We).additions??""}`),re(Te,`-${a(We).deletions??""}`)}),I(A,Z)};ae(Se,A=>{a(He)&&A(ne)})}var Ae=k(te,2),Ke=S(Ae);{var z=A=>{var Z=Tg(),me=S(Z);he(()=>re(me,`PR #${a(We).prNumber??""}`)),I(A,Z)};ae(Ke,A=>{var Z;(Z=a(We))!=null&&Z.prNumber&&A(z)})}var U=k(Ke,2),se=S(U),P=k(U,2);{let A=fe(()=>w(a(pe)));wc(P,{get items(){return a(A)}})}he((A,Z,me)=>{L=Qe(Ue,1,"session-row inactive svelte-168i8d5",null,L,A),re(ue,Z),re(se,me)},[()=>({loading:Oi(a(pe).path)}),()=>Oi(a(pe).path)?"resuming...":a(pe).branchName||a(pe).displayName||a(pe).name,()=>y(a(pe))]),Q("click",Ue,async()=>{if(!Oi(a(pe).path)){Yr(a(pe).path);try{const A=await Gs({repoPath:t.workspace.path,repoName:t.workspace.name,worktreePath:a(pe).path,branchName:a(pe).branchName||a(pe).name});await kt(),t.onSelectSession(A.id)}catch{}finally{Gr(a(pe).path)}}}),I(Be,Ue)}),I(G,ve)};ae(xe,G=>{!a(h)&&(a(r).length>0||s().length>0)&&G(Pe)})}var Re=k(xe,2);{var we=G=>{var ve=Lg();let Le;var je=S(ve),Be=S(je);he(()=>{Le=Qe(ve,1,"add-worktree-row svelte-168i8d5",null,Le,{disabled:a(p)}),re(Be,a(p)?"creating...":"+ new worktree")}),Q("click",ve,()=>{a(p)||t.onNewWorktree(t.workspace)}),I(G,ve)};ae(Re,G=>{a(h)||G(we)})}he(()=>{M=Qe(x,1,"workspace-item svelte-168i8d5",null,M,{active:t.isActive}),j=Qe(N,1,"workspace-header svelte-168i8d5",null,j,{attention:a(v)}),Y=Qe(oe,1,"collapse-chevron svelte-168i8d5",null,Y,{collapsed:a(h)}),re(W,a(h)?"›":"⌄"),B=Rn(O,"",B,{background:a(l)}),re(T,a(c)),re(D,t.workspace.name)}),Q("click",N,()=>t.onSelectWorkspace(t.workspace.path)),Q("click",oe,G=>{G.stopPropagation(),$p(t.workspace.path)}),Q("click",ce,G=>{G.stopPropagation(),t.onNewSession(t.workspace)}),Q("click",be,G=>{G.stopPropagation(),t.onNewTerminal(t.workspace)}),Q("click",ge,G=>{G.stopPropagation(),t.onOpenSettings(t.workspace)}),I(e,x),dt()}at(["click"]);var Ig=H('<strong class="svelte-itm1qs"> </strong>'),Ng=H("<span> </span>"),Fg=H('<li role="option"><!> <span class="dropdown-path svelte-itm1qs"> </span></li>'),Wg=H('<ul class="dropdown svelte-itm1qs" role="listbox"></ul>'),Hg=H('<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 zg(e,t){ut(t,!0);let i=F(""),s=F(0),r=F(void 0),n=fe(()=>{if(!a(i).trim())return[];const g=a(i).toLowerCase();return t.workspaces.filter(y=>y.name.toLowerCase().includes(g))}),o=fe(()=>a(i).trim().length>0&&a(n).length>0);rs(()=>{a(n).length,m(s,0)});function l(g){m(i,g.target.value,!0)}function c(g){var y;if(g.key==="Escape"){m(i,""),(y=a(r))==null||y.blur();return}if(a(o)){if(g.key==="ArrowDown")g.preventDefault(),m(s,Math.min(a(s)+1,a(n).length-1),!0);else if(g.key==="ArrowUp")g.preventDefault(),m(s,Math.max(a(s)-1,0),!0);else if(g.key==="Enter"){g.preventDefault();const R=a(n)[a(s)];R&&h(R)}}}function h(g){var y;t.onSelect(g.path),m(i,""),(y=a(r))==null||y.blur()}function d(g,y){if(!y)return[{text:g,bold:!1}];const R=g.toLowerCase(),C=y.toLowerCase(),w=R.indexOf(C);return w===-1?[{text:g,bold:!1}]:[{text:g.slice(0,w),bold:!1},{text:g.slice(w,w+C.length),bold:!0},{text:g.slice(w+C.length),bold:!1}].filter(x=>x.text.length>0)}var u=Hg(),f=S(u),v=k(S(f),2);Ne(v,"spellcheck",!1),et(v,g=>m(r,g),()=>a(r));var p=k(f,2);{var b=g=>{var y=Wg();Nt(y,23,()=>a(n),R=>R.path,(R,C,w)=>{var x=Fg();let M;var N=S(x);Nt(N,17,()=>d(a(C).name,a(i)),io,(oe,Y)=>{var W=xs(),O=vt(W);{var B=q=>{var D=Ig(),E=S(D);he(()=>re(E,a(Y).text)),I(q,D)},T=q=>{var D=Ng(),E=S(D);he(()=>re(E,a(Y).text)),I(q,D)};ae(O,q=>{a(Y).bold?q(B):q(T,!1)})}I(oe,W)});var j=k(N,2),J=S(j);he(()=>{M=Qe(x,1,"dropdown-item svelte-itm1qs",null,M,{focused:a(w)===a(s)}),Ne(x,"aria-selected",a(w)===a(s)),re(J,a(C).path)}),Q("click",x,()=>h(a(C))),Ss("mouseenter",x,()=>{m(s,a(w),!0)}),I(R,x)}),I(g,y)};ae(p,g=>{a(o)&&g(b)})}he(()=>cp(v,a(i))),Q("input",v,l),Q("keydown",v,c),I(e,u),dt()}at(["input","keydown","click"]);var Ug=H('<span class="sidebar-label svelte-owj5vn">Workspaces</span>'),Kg=H('<div class="empty-state svelte-owj5vn"><span>No workspaces</span></div>'),qg=H('<!> <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),jg=H('<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 Vg(e,t){ut(t,!0);const i=Zd(),s=Lh();let r=fe(()=>i.sidebarCollapsed?Vp:i.sidebarWidth);function n(w){i.activeWorkspacePath=w,s.activeSessionId=null}function o(w){i.activeWorkspacePath=w,ui()}function l(w){w.preventDefault();const x=w.clientX,M=i.sidebarWidth,N=J=>{const oe=Math.min($d,Math.max(Jd,M+(J.clientX-x)));i.sidebarWidth=oe},j=()=>{document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect="",gc()};document.addEventListener("mousemove",N),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function c(w){w.preventDefault(),i.sidebarWidth=Qd,gc()}var h=jg();let d,u;var f=S(h),v=S(f),p=S(v),b=k(v,2);{var g=w=>{var x=Ug();I(w,x)};ae(b,w=>{i.sidebarCollapsed||w(g)})}var y=k(b,2),R=k(f,2);{var C=w=>{var x=qg(),M=vt(x);zg(M,{get workspaces(){return s.workspaces},onSelect:o});var N=k(M,2),j=S(N);Nt(j,17,()=>s.workspaces,B=>B.path,(B,T)=>{const q=fe(()=>hf(a(T).path)),D=fe(()=>new Set(a(q).map(X=>X.repoPath))),E=fe(()=>s.worktrees.filter(X=>X.repoPath===a(T).path&&X.path.startsWith(a(T).path+"/")&&!a(D).has(X.path))),$=fe(()=>(()=>{const X=new Map;X.set(a(T).path,[]);for(const ce of a(q)){const be=X.get(ce.repoPath);be?be.push(ce):X.set(ce.repoPath,[ce])}return X})());{let X=fe(()=>i.activeWorkspacePath===a(T).path&&!s.activeSessionId);Og(B,{get workspace(){return a(T)},get sessionGroups(){return a($)},get inactiveWorktrees(){return a(E)},get isActive(){return a(X)},onSelectWorkspace:n,get onSelectSession(){return t.onSelectSession},get onNewWorktree(){return t.onNewWorktree},get onNewSession(){return t.onNewSession},get onNewTerminal(){return t.onNewTerminal},onOpenSettings:ce=>t.onOpenSettings(ce),onDeleteSession:ce=>{var be;return(be=t.onDeleteSession)==null?void 0:be.call(t,ce)},onDeleteWorktree:ce=>{var be;return(be=t.onDeleteWorktree)==null?void 0:be.call(t,ce)}})}});var J=k(j,2);{var oe=B=>{var T=Kg();I(B,T)};ae(J,B=>{s.workspaces.length===0&&B(oe)})}var Y=k(N,2),W=k(Y,2),O=k(W,2);Q("click",Y,function(...B){var T;(T=t.onAddWorkspace)==null||T.apply(this,B)}),Q("click",W,()=>t.onOpenSettings()),Q("mousedown",O,l),Q("dblclick",O,c),I(w,x)};ae(R,w=>{i.sidebarCollapsed||w(C)})}he(()=>{d=Qe(h,1,"sidebar svelte-owj5vn",null,d,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),u=Rn(h,"",u,{width:`${a(r)??""}px`,"min-width":`${a(r)??""}px`}),Ne(v,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),re(p,i.sidebarCollapsed?"»":"«")}),Q("click",v,function(...w){Fa==null||Fa.apply(this,w)}),Q("click",y,function(...w){ui==null||ui.apply(this,w)}),I(e,h),dt()}at(["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 mf=Object.defineProperty,Yg=Object.getOwnPropertyDescriptor,Gg=(e,t)=>{for(var i in t)mf(e,i,{get:t[i],enumerable:!0})},lt=(e,t,i,s)=>{for(var r=s>1?void 0:s?Yg(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&&mf(t,i,r),r},de=(e,t)=>(i,s)=>t(i,s,e),Cc="Terminal input",yl={get:()=>Cc,set:e=>Cc=e},kc="Too much output to announce, navigate to rows manually to read",wl={get:()=>kc,set:e=>kc=e};function Xg(e){return e.replace(/\r?\n/g,"\r")}function Qg(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Jg(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function $g(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");bf(r,t,i,s)}}function bf(e,t,i,s){e=Xg(e),e=Qg(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Sf(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 xc(e,t,i,s,r){Sf(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Is(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ca(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 Zg=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}},em=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 p=0,b;for(;(b=this.interim[++p]&63)&&p<4;)v<<=6,v|=b;let g=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=g-p;for(;h<y;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,f=!0;break}else this.interim[p++]=b,v<<=6,v|=b&63}f||(g===2?v<128?h--:t[s++]=v:g===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}},yf="",Xs=" ",ko=class wf{constructor(){this.fg=0,this.bg=0,this.extended=new ia}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 wf;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}},ia=class Cf{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 Cf(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ri=class kf extends ko{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ia,this.combinedData=""}static fromCharData(t){let i=new kf;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?Is(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()]}},Ec="di$target",Cl="di$dependencies",za=new Map;function tm(e){return e[Cl]||[]}function Tt(e){if(za.has(e))return za.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");im(t,i,r)};return t._id=e,za.set(e,t),t}function im(e,t,i){t[Ec]===t?t[Cl].push({id:e,index:i}):(t[Cl]=[{id:e,index:i}],t[Ec]=t)}var Vt=Tt("BufferService"),xf=Tt("CoreMouseService"),Kr=Tt("CoreService"),sm=Tt("CharsetService"),Ih=Tt("InstantiationService"),Ef=Tt("LogService"),Yt=Tt("OptionsService"),Pf=Tt("OscLinkService"),rm=Tt("UnicodeService"),xo=Tt("DecorationService"),kl=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 Ri,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}},p=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let b=new URL(f);["http:","https:"].includes(b.protocol)||(p=!0)}catch{p=!0}p||s.push({text:f,range:v,activate:(b,g)=>r?r.activate(b,g,v):nm(b,g),hover:(b,g)=>{var y;return(y=r==null?void 0:r.hover)==null?void 0:y.call(r,b,g,v)},leave:(b,g)=>{var y;return(y=r==null?void 0:r.leave)==null?void 0:y.call(r,b,g,v)}})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(c=u,l=n.extended.urlId):(c=-1,l=-1)}}t(s)}};kl=lt([de(0,Vt),de(1,Yt),de(2,Pf)],kl);function nm(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 ka=Tt("CharSizeService"),Rs=Tt("CoreBrowserService"),Nh=Tt("MouseService"),Ds=Tt("RenderService"),om=Tt("SelectionService"),Rf=Tt("CharacterJoinerService"),Tn=Tt("ThemeService"),Df=Tt("LinkProviderService"),am=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Pc.isErrorNoTelemetry(e)?new Pc(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)}},lm=new am;function jo(e){hm(e)||lm.onUnexpectedError(e)}var xl="Canceled";function hm(e){return e instanceof cm?!0:e instanceof Error&&e.name===xl&&e.message===xl}var cm=class extends Error{constructor(){super(xl),this.name=this.message}};function um(e){return new Error(`Illegal argument: ${e}`)}var Pc=class El extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof El)return t;let i=new El;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Pl=class Tf extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Tf.prototype)}};function oi(e,t=0){return e[e.length-(1+t)]}var dm;(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})(dm||(dm={}));function fm(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Mf;(e=>{function t(w){return w&&typeof w=="object"&&typeof w[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(w){yield w}e.single=r;function n(w){return t(w)?w:r(w)}e.wrap=n;function o(w){return w||i}e.from=o;function*l(w){for(let x=w.length-1;x>=0;x--)yield w[x]}e.reverse=l;function c(w){return!w||w[Symbol.iterator]().next().done===!0}e.isEmpty=c;function h(w){return w[Symbol.iterator]().next().value}e.first=h;function d(w,x){let M=0;for(let N of w)if(x(N,M++))return!0;return!1}e.some=d;function u(w,x){for(let M of w)if(x(M))return M}e.find=u;function*f(w,x){for(let M of w)x(M)&&(yield M)}e.filter=f;function*v(w,x){let M=0;for(let N of w)yield x(N,M++)}e.map=v;function*p(w,x){let M=0;for(let N of w)yield*x(N,M++)}e.flatMap=p;function*b(...w){for(let x of w)yield*x}e.concat=b;function g(w,x,M){let N=M;for(let j of w)N=x(N,j);return N}e.reduce=g;function*y(w,x,M=w.length){for(x<0&&(x+=w.length),M<0?M+=w.length:M>w.length&&(M=w.length);x<M;x++)yield w[x]}e.slice=y;function R(w,x=Number.POSITIVE_INFINITY){let M=[];if(x===0)return[M,w];let N=w[Symbol.iterator]();for(let j=0;j<x;j++){let J=N.next();if(J.done)return[M,e.empty()];M.push(J.value)}return[M,{[Symbol.iterator](){return N}}]}e.consume=R;async function C(w){let x=[];for await(let M of w)x.push(M);return Promise.resolve(x)}e.asyncToArray=C})(Mf||(Mf={}));function Hr(e){if(Mf.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 _m(...e){return tt(()=>Hr(e))}function tt(e){return{dispose:fm(()=>{e()})}}var Bf=class Lf{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{Hr(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?Lf.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)}};Bf.DISABLE_DISPOSED_WARNING=!1;var tr=Bf,Ie=class{constructor(){this._store=new tr,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)}};Ie.None=Object.freeze({dispose(){}});var kn=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}},ys=typeof window=="object"?window:globalThis,Rl=class Dl{constructor(t){this.element=t,this.next=Dl.Undefined,this.prev=Dl.Undefined}};Rl.Undefined=new Rl(void 0);var st=Rl,Rc=class{constructor(){this._first=st.Undefined,this._last=st.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===st.Undefined}clear(){let e=this._first;for(;e!==st.Undefined;){let t=e.next;e.prev=st.Undefined,e.next=st.Undefined,e=t}this._first=st.Undefined,this._last=st.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new st(e);if(this._first===st.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!==st.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==st.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==st.Undefined&&e.next!==st.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===st.Undefined&&e.next===st.Undefined?(this._first=st.Undefined,this._last=st.Undefined):e.next===st.Undefined?(this._last=this._last.prev,this._last.next=st.Undefined):e.prev===st.Undefined&&(this._first=this._first.next,this._first.prev=st.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==st.Undefined;)yield e.element,e=e.next}},vm=globalThis.performance&&typeof globalThis.performance.now=="function",pm=class Af{static create(t){return new Af(t)}constructor(t){this._now=vm&&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}},It;(e=>{e.None=()=>Ie.None;function t(W,O){return u(W,()=>{},0,void 0,!0,void 0,O)}e.defer=t;function i(W){return(O,B=null,T)=>{let q=!1,D;return D=W(E=>{if(!q)return D?D.dispose():q=!0,O.call(B,E)},null,T),q&&D.dispose(),D}}e.once=i;function s(W,O,B){return h((T,q=null,D)=>W(E=>T.call(q,O(E)),null,D),B)}e.map=s;function r(W,O,B){return h((T,q=null,D)=>W(E=>{O(E),T.call(q,E)},null,D),B)}e.forEach=r;function n(W,O,B){return h((T,q=null,D)=>W(E=>O(E)&&T.call(q,E),null,D),B)}e.filter=n;function o(W){return W}e.signal=o;function l(...W){return(O,B=null,T)=>{let q=_m(...W.map(D=>D(E=>O.call(B,E))));return d(q,T)}}e.any=l;function c(W,O,B,T){let q=B;return s(W,D=>(q=O(q,D),q),T)}e.reduce=c;function h(W,O){let B,T={onWillAddFirstListener(){B=W(q.fire,q)},onDidRemoveLastListener(){B==null||B.dispose()}},q=new ie(T);return O==null||O.add(q),q.event}function d(W,O){return O instanceof Array?O.push(W):O&&O.add(W),W}function u(W,O,B=100,T=!1,q=!1,D,E){let $,X,ce,be=0,ge,xe={leakWarningThreshold:D,onWillAddFirstListener(){$=W(Re=>{be++,X=O(X,Re),T&&!ce&&(Pe.fire(X),X=void 0),ge=()=>{let we=X;X=void 0,ce=void 0,(!T||be>1)&&Pe.fire(we),be=0},typeof B=="number"?(clearTimeout(ce),ce=setTimeout(ge,B)):ce===void 0&&(ce=0,queueMicrotask(ge))})},onWillRemoveListener(){q&&be>0&&(ge==null||ge())},onDidRemoveLastListener(){ge=void 0,$.dispose()}},Pe=new ie(xe);return E==null||E.add(Pe),Pe.event}e.debounce=u;function f(W,O=0,B){return e.debounce(W,(T,q)=>T?(T.push(q),T):[q],O,void 0,!0,void 0,B)}e.accumulate=f;function v(W,O=(T,q)=>T===q,B){let T=!0,q;return n(W,D=>{let E=T||!O(D,q);return T=!1,q=D,E},B)}e.latch=v;function p(W,O,B){return[e.filter(W,O,B),e.filter(W,T=>!O(T),B)]}e.split=p;function b(W,O=!1,B=[],T){let q=B.slice(),D=W(X=>{q?q.push(X):$.fire(X)});T&&T.add(D);let E=()=>{q==null||q.forEach(X=>$.fire(X)),q=null},$=new ie({onWillAddFirstListener(){D||(D=W(X=>$.fire(X)),T&&T.add(D))},onDidAddFirstListener(){q&&(O?setTimeout(E):E())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return T&&T.add($),$.event}e.buffer=b;function g(W,O){return(B,T,q)=>{let D=O(new R);return W(function(E){let $=D.evaluate(E);$!==y&&B.call(T,$)},void 0,q)}}e.chain=g;let y=Symbol("HaltChainable");class R{constructor(){this.steps=[]}map(O){return this.steps.push(O),this}forEach(O){return this.steps.push(B=>(O(B),B)),this}filter(O){return this.steps.push(B=>O(B)?B:y),this}reduce(O,B){let T=B;return this.steps.push(q=>(T=O(T,q),T)),this}latch(O=(B,T)=>B===T){let B=!0,T;return this.steps.push(q=>{let D=B||!O(q,T);return B=!1,T=q,D?q:y}),this}evaluate(O){for(let B of this.steps)if(O=B(O),O===y)break;return O}}function C(W,O,B=T=>T){let T=(...$)=>E.fire(B(...$)),q=()=>W.on(O,T),D=()=>W.removeListener(O,T),E=new ie({onWillAddFirstListener:q,onDidRemoveLastListener:D});return E.event}e.fromNodeEventEmitter=C;function w(W,O,B=T=>T){let T=(...$)=>E.fire(B(...$)),q=()=>W.addEventListener(O,T),D=()=>W.removeEventListener(O,T),E=new ie({onWillAddFirstListener:q,onDidRemoveLastListener:D});return E.event}e.fromDOMEventEmitter=w;function x(W){return new Promise(O=>i(W)(O))}e.toPromise=x;function M(W){let O=new ie;return W.then(B=>{O.fire(B)},()=>{O.fire(void 0)}).finally(()=>{O.dispose()}),O.event}e.fromPromise=M;function N(W,O){return W(B=>O.fire(B))}e.forward=N;function j(W,O,B){return O(B),W(T=>O(T))}e.runAndSubscribe=j;class J{constructor(O,B){this._observable=O,this._counter=0,this._hasChanged=!1;let T={onWillAddFirstListener:()=>{O.addObserver(this)},onDidRemoveLastListener:()=>{O.removeObserver(this)}};this.emitter=new ie(T),B&&B.add(this.emitter)}beginUpdate(O){this._counter++}handlePossibleChange(O){}handleChange(O,B){this._hasChanged=!0}endUpdate(O){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function oe(W,O){return new J(W,O).emitter.event}e.fromObservable=oe;function Y(W){return(O,B,T)=>{let q=0,D=!1,E={beginUpdate(){q++},endUpdate(){q--,q===0&&(W.reportChanges(),D&&(D=!1,O.call(B)))},handlePossibleChange(){},handleChange(){D=!0}};W.addObserver(E),W.reportChanges();let $={dispose(){W.removeObserver(E)}};return T instanceof tr?T.add($):Array.isArray(T)&&T.push($),$}}e.fromObservableLight=Y})(It||(It={}));var Tl=class Ml{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Ml._idPool++}`,Ml.all.add(this)}start(t){this._stopWatch=new pm,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}}};Tl.all=new Set,Tl._idPool=0;var gm=Tl,mm=-1,Of=class If{constructor(t,i,s=(If._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 ym(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}};Of._idPool=1;var bm=Of,Sm=class Nf{constructor(t){this.value=t}static create(){let t=new Error;return new Nf(t.stack??"")}print(){console.warn(this.value.split(`
28
- `).slice(2).join(`
29
- `))}},ym=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},wm=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Cm=0,Ua=class{constructor(e){this.value=e,this.id=Cm++}},km=2,xm,ie=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new bm((e==null?void 0:e.onListenerError)??jo,((i=this._options)==null?void 0:i.leakWarningThreshold)??mm):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new gm(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 wm(`${u}. HINT: Stack shows most frequent listener (${f[1]}-times)`,f[0]);return(((o=this._options)==null?void 0:o.onListenerError)||jo)(v),Ie.None}if(this._disposed)return Ie.None;t&&(e=e.bind(t));let s=new Ua(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Sm.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof Ua?(this._deliveryQueue??(this._deliveryQueue=new Em),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=tt(()=>{r==null||r(),this._removeListener(s)});return i instanceof tr?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*km<=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)||jo;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 Ua)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}},Em=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}},Bl=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new ie,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new ie,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}};Bl.INSTANCE=new Bl;var Fh=Bl;function Pm(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Fh.INSTANCE.onDidChangeZoomLevel;function Rm(e){return Fh.INSTANCE.getZoomFactor(e)}Fh.INSTANCE.onDidChangeFullscreen;var Mn=typeof navigator=="object"?navigator.userAgent:"",Ll=Mn.indexOf("Firefox")>=0,Dm=Mn.indexOf("AppleWebKit")>=0,Wh=Mn.indexOf("Chrome")>=0,Tm=!Wh&&Mn.indexOf("Safari")>=0;Mn.indexOf("Electron/")>=0;Mn.indexOf("Android")>=0;var Ka=!1;if(typeof ys.matchMedia=="function"){let e=ys.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ys.matchMedia("(display-mode: fullscreen)");Ka=e.matches,Pm(ys,e,({matches:i})=>{Ka&&t.matches||(Ka=i)})}var Xr="en",Al=!1,Ol=!1,Vo=!1,Ff=!1,Oo,Yo=Xr,Dc=Xr,Mm,Li,Or=globalThis,At,Mu;typeof Or.vscode<"u"&&typeof Or.vscode.process<"u"?At=Or.vscode.process:typeof process<"u"&&typeof((Mu=process==null?void 0:process.versions)==null?void 0:Mu.node)=="string"&&(At=process);var Bu,Bm=typeof((Bu=At==null?void 0:At.versions)==null?void 0:Bu.electron)=="string",Lm=Bm&&(At==null?void 0:At.type)==="renderer",Lu;if(typeof At=="object"){Al=At.platform==="win32",Ol=At.platform==="darwin",Vo=At.platform==="linux",Vo&&At.env.SNAP&&At.env.SNAP_REVISION,At.env.CI||At.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Oo=Xr,Yo=Xr;let e=At.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Oo=t.userLocale,Dc=t.osLocale,Yo=t.resolvedLanguage||Xr,Mm=(Lu=t.languagePack)==null?void 0:Lu.translationsConfigFile}catch{}Ff=!0}else typeof navigator=="object"&&!Lm?(Li=navigator.userAgent,Al=Li.indexOf("Windows")>=0,Ol=Li.indexOf("Macintosh")>=0,(Li.indexOf("Macintosh")>=0||Li.indexOf("iPad")>=0||Li.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Vo=Li.indexOf("Linux")>=0,(Li==null?void 0:Li.indexOf("Mobi"))>=0,Yo=globalThis._VSCODE_NLS_LANGUAGE||Xr,Oo=navigator.language.toLowerCase(),Dc=Oo):console.error("Unable to resolve platform.");var Wf=Al,ns=Ol,Am=Vo,Tc=Ff,ls=Li,Bs=Yo,Om;(e=>{function t(){return Bs}e.value=t;function i(){return Bs.length===2?Bs==="en":Bs.length>=3?Bs[0]==="e"&&Bs[1]==="n"&&Bs[2]==="-":!1}e.isDefaultVariant=i;function s(){return Bs==="en"}e.isDefault=s})(Om||(Om={}));var Im=typeof Or.postMessage=="function"&&!Or.importScripts;(()=>{if(Im){let e=[];Or.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}),Or.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var Nm=!!(ls&&ls.indexOf("Chrome")>=0);ls&&ls.indexOf("Firefox")>=0;!Nm&&ls&&ls.indexOf("Safari")>=0;ls&&ls.indexOf("Edg/")>=0;ls&&ls.indexOf("Android")>=0;var jr=typeof navigator=="object"?navigator:{};Tc||document.queryCommandSupported&&document.queryCommandSupported("copy")||jr&&jr.clipboard&&jr.clipboard.writeText,Tc||jr&&jr.clipboard&&jr.clipboard.readText;var Hh=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}},qa=new Hh,Mc=new Hh,Bc=new Hh,Fm=new Array(230),Hf;(e=>{function t(l){return qa.keyCodeToStr(l)}e.toString=t;function i(l){return qa.strToKeyCode(l)}e.fromString=i;function s(l){return Mc.keyCodeToStr(l)}e.toUserSettingsUS=s;function r(l){return Bc.keyCodeToStr(l)}e.toUserSettingsGeneral=r;function n(l){return Mc.strToKeyCode(l)||Bc.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 qa.keyCodeToStr(l)}e.toElectronAccelerator=o})(Hf||(Hf={}));var Wm=class zf{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 zf&&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 Hm([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Hm=class{constructor(e){if(e.length===0)throw um("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 zm(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Hf.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Ll)switch(t){case 59:return 85;case 60:if(Am)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ns)return 57;break}else if(Dm&&(ns&&t===93||!ns&&t===92))return 57;return Fm[t]||0}var Um=ns?256:2048,Km=512,qm=1024,jm=ns?2048:256,Lc=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=zm(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|=Um),this.altKey&&(t|=Km),this.shiftKey&&(t|=qm),this.metaKey&&(t|=jm),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Wm(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ac=new WeakMap;function Vm(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 Ym=class{static getSameOriginWindowChain(e){let t=Ac.get(e);if(!t){t=[],Ac.set(e,t);let i=e,s;do s=Vm(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}}},Io=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=Ym.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Oc=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(Wh){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?Ll&&!ns?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Tm&&Wf?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?Ll&&!ns?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()}},Uf=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Gm;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Xm?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:It.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Uf})})(Gm||(Gm={}));var Xm=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?Uf:(this._emitter||(this._emitter=new ie),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},zh=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 Pl("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Pl("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Qm=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 Pl("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=tt(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Jm;(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})(Jm||(Jm={}));var Ic=class gi{static fromArray(t){return new gi(i=>{i.emitMany(t)})}static fromPromise(t){return new gi(async i=>{i.emitMany(await t)})}static fromPromises(t){return new gi(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new gi(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 ie,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 It.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 gi(async s=>{for await(let r of t)s.emitOne(i(r))})}map(t){return gi.map(this,t)}static filter(t,i){return new gi(async s=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return gi.filter(this,t)}static coalesce(t){return gi.filter(t,i=>!!i)}coalesce(){return gi.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return gi.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())}};Ic.EMPTY=Ic.fromArray([]);var{getWindow:is,getWindowId:$m,onDidRegisterWindow:Zm}=(function(){let e=new Map,t={window:ys,disposables:new tr};e.set(ys.vscodeWindowId,t);let i=new ie,s=new ie,r=new ie;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 Ie.None;let l=new tr,c={window:o,disposables:l.add(new tr)};return e.set(o.vscodeWindowId,c),l.add(tt(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),l.add(Ee(o,Ct.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:ys},getDocument(o){return is(o).document}}})(),eb=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 Ee(e,t,i,s){return new eb(e,t,i,s)}var Nc=function(e,t,i,s){return Ee(e,t,i,s)},Uh,tb=class extends Qm{constructor(e){super(),this.defaultTarget=e&&is(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},Fc=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){jo(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(Fc.sort),o.shift().execute();s.set(n,!1)};Uh=(n,o,l=0)=>{let c=$m(n),h=new Fc(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 ib(e){let t=e.getBoundingClientRect(),i=is(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Ct={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"},sb=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=Jt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Jt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Jt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Jt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Jt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Jt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Jt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Jt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Jt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Jt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Jt(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=Jt(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=Jt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Jt(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 Jt(e){return typeof e=="number"?`${e}px`:e}function Zn(e){return new sb(e)}var Kf=class{constructor(){this._hooks=new tr,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(tt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=is(e)}this._hooks.add(Ee(n,Ct.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(Ee(n,Ct.POINTER_UP,o=>this.stopMonitoring(!0)))}};function rb(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 Xi;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(Xi||(Xi={}));var zn=class zt extends Ie{constructor(){super(),this.dispatched=!1,this.targets=new Rc,this.ignoreTargets=new Rc,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(It.runAndSubscribe(Zm,({window:t,disposables:i})=>{i.add(Ee(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ee(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ee(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ys,disposables:this._store}))}static addTarget(t){if(!zt.isTouchDevice())return Ie.None;zt.INSTANCE||(zt.INSTANCE=new zt);let i=zt.INSTANCE.targets.push(t);return tt(i)}static ignoreTarget(t){if(!zt.isTouchDevice())return Ie.None;zt.INSTANCE||(zt.INSTANCE=new zt);let i=zt.INSTANCE.ignoreTargets.push(t);return tt(i)}static isTouchDevice(){return"ontouchstart"in ys||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(Xi.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<zt.HOLD_DELAY&&Math.abs(c.initialPageX-oi(c.rollingPageX))<30&&Math.abs(c.initialPageY-oi(c.rollingPageY))<30){let d=this.newGestureEvent(Xi.Tap,c.initialTarget);d.pageX=oi(c.rollingPageX),d.pageY=oi(c.rollingPageY),this.dispatchEvent(d)}else if(h>=zt.HOLD_DELAY&&Math.abs(c.initialPageX-oi(c.rollingPageX))<30&&Math.abs(c.initialPageY-oi(c.rollingPageY))<30){let d=this.newGestureEvent(Xi.Contextmenu,c.initialTarget);d.pageX=oi(c.rollingPageX),d.pageY=oi(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=oi(c.rollingPageX),u=oi(c.rollingPageY),f=oi(c.rollingTimestamps)-c.rollingTimestamps[0],v=d-c.rollingPageX[0],p=u-c.rollingPageY[0],b=[...this.targets].filter(g=>c.initialTarget instanceof Node&&g.contains(c.initialTarget));this.inertia(t,b,s,Math.abs(v)/f,v>0?1:-1,d,Math.abs(p)/f,p>0?1:-1,u)}this.dispatchEvent(this.newGestureEvent(Xi.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===Xi.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>zt.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===Xi.Change||t.type===Xi.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=Uh(t,()=>{let d=Date.now(),u=d-s,f=0,v=0,p=!0;r+=zt.SCROLL_FRICTION*u,l+=zt.SCROLL_FRICTION*u,r>0&&(p=!1,f=n*r*u),l>0&&(p=!1,v=c*l*u);let b=this.newGestureEvent(Xi.Change);b.translationX=f,b.translationY=v,i.forEach(g=>g.dispatchEvent(b)),p||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(Xi.Change,o.initialTarget);l.translationX=n.pageX-oi(o.rollingPageX),l.translationY=n.pageY-oi(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)}};zn.SCROLL_FRICTION=-.005,zn.HOLD_DELAY=700,zn.CLEAR_TAP_COUNT_TIME=400,lt([rb],zn,"isTouchDevice",1);var nb=zn,Kh=class extends Ie{onclick(e,t){this._register(Ee(e,Ct.CLICK,i=>t(new Io(is(e),i))))}onmousedown(e,t){this._register(Ee(e,Ct.MOUSE_DOWN,i=>t(new Io(is(e),i))))}onmouseover(e,t){this._register(Ee(e,Ct.MOUSE_OVER,i=>t(new Io(is(e),i))))}onmouseleave(e,t){this._register(Ee(e,Ct.MOUSE_LEAVE,i=>t(new Io(is(e),i))))}onkeydown(e,t){this._register(Ee(e,Ct.KEY_DOWN,i=>t(new Lc(i))))}onkeyup(e,t){this._register(Ee(e,Ct.KEY_UP,i=>t(new Lc(i))))}oninput(e,t){this._register(Ee(e,Ct.INPUT,t))}onblur(e,t){this._register(Ee(e,Ct.BLUR,t))}onfocus(e,t){this._register(Ee(e,Ct.FOCUS,t))}onchange(e,t){this._register(Ee(e,Ct.CHANGE,t))}ignoreGesture(e){return nb.ignoreTarget(e)}},Wc=11,ob=class extends Kh{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=Wc+"px",this.domNode.style.height=Wc+"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 Kf),this._register(Nc(this.bgDomNode,Ct.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Nc(this.domNode,Ct.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new tb),this._pointerdownScheduleRepeatTimer=this._register(new zh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,is(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()}},ab=class Il{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 Il(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 Il(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}}},lb=class extends Ie{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new ab(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 zc(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=zc.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)))}},Hc=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function ja(e,t){let i=t-e;return function(s){return e+i*ub(s)}}function hb(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var zc=class Nl{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),hb(ja(t,r),ja(n,i),.33)}return ja(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 Hc(s,r,!1)}return new Hc(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Nl.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new Nl(t,i,r,s)}};function cb(e){return Math.pow(e,3)}function ub(e){return 1-cb(1-e)}var db=class extends Ie{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 zh)}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":"")))}},fb=140,qf=class extends Kh{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 db(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Kf),this._shouldRender=!0,this.domNode=Zn(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(Ee(this.domNode.domNode,Ct.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new ob(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=Zn(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(Ee(this.slider.domNode,Ct.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=ib(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(Wf&&o>fb){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()}},jf=class Fl{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 Fl(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=Fl._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)}},_b=class extends qf{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new jf(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}},vb=class extends qf{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new jf(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}},pb=500,Uc=50,gb=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},Wl=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(Wh){let i=is(t.browserEvent),s=Rm(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 gb(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}};Wl.INSTANCE=new Wl;var mb=Wl,bb=class extends Kh{constructor(e,t,i){super(),this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new ie),this.onWillScroll=this._onWillScroll.event,this._options=yb(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 vb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new _b(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=Zn(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Zn(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Zn(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 zh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Hr(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,ns&&(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 Oc(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Hr(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new Oc(i))};this._mouseWheelToDispose.push(Ee(this._listenOnDomNode,Ct.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=mb.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=!ns&&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=Uc*n,u=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(h,u)}if(o){let d=Uc*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(),pb)}},Sb=class extends bb{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 yb(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,ns&&(t.className+=" mac"),t}var Hl=class extends Ie{constructor(e,t,i,s,r,n,o,l){super(),this._bufferService=i,this._optionsService=o,this._renderService=l,this._onRequestScrollLines=this._register(new ie),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new lb({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>Uh(s.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Sb(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(It.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(tt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(tt(()=>this._styleElement.remove())),this._register(It.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}};Hl=lt([de(2,Vt),de(3,Rs),de(4,xf),de(5,Tn),de(6,Yt),de(7,Ds)],Hl);var zl=class extends Ie{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(tt(()=>{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()}};zl=lt([de(1,Vt),de(2,Rs),de(3,xo),de(4,Ds)],zl);var wb=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)}},Yi={full:0,left:0,center:0,right:0},Ls={full:0,left:0,center:0,right:0},An={full:0,left:0,center:0,right:0},sa=class extends Ie{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 wb,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(tt(()=>{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);Ls.full=this._canvas.width,Ls.left=e,Ls.center=t,Ls.right=e,this._refreshDrawHeightConstants(),An.full=1,An.left=1,An.center=1+Ls.left,An.right=1+Ls.left+Ls.center}_refreshDrawHeightConstants(){Yi.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);Yi.left=t,Yi.center=t,Yi.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Yi.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(An[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Yi[e.position||"full"]/2),Ls[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Yi[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}))}};sa=lt([de(2,Vt),de(3,xo),de(4,Ds),de(5,Yt),de(6,Tn),de(7,Rs)],sa);var K;(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=""))(K||(K={}));var Go;(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="Ÿ"))(Go||(Go={}));var Vf;(e=>e.ST=`${K.ESC}\\`)(Vf||(Vf={}));var Ul=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(`${K.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)}}};Ul=lt([de(2,Vt),de(3,Yt),de(4,Kr),de(5,Ds)],Ul);var xt=0,Et=0,Pt=0,ot=0,Kc={css:"#00000000",rgba:0},_t;(e=>{function t(r,n,o,l){return l!==void 0?`#${ar(r)}${ar(n)}${ar(o)}${ar(l)}`:`#${ar(r)}${ar(n)}${ar(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})(_t||(_t={}));var $e;(e=>{function t(c,h){if(ot=(h.rgba&255)/255,ot===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,p=c.rgba>>16&255,b=c.rgba>>8&255;xt=v+Math.round((d-v)*ot),Et=p+Math.round((u-p)*ot),Pt=b+Math.round((f-b)*ot);let g=_t.toCss(xt,Et,Pt),y=_t.toRgba(xt,Et,Pt);return{css:g,rgba:y}}e.blend=t;function i(c){return(c.rgba&255)===255}e.isOpaque=i;function s(c,h,d){let u=Xo.ensureContrastRatio(c.rgba,h.rgba,d);if(u)return _t.toColor(u>>24&255,u>>16&255,u>>8&255)}e.ensureContrastRatio=s;function r(c){let h=(c.rgba|255)>>>0;return[xt,Et,Pt]=Xo.toChannels(h),{css:_t.toCss(xt,Et,Pt),rgba:h}}e.opaque=r;function n(c,h){return ot=Math.round(h*255),[xt,Et,Pt]=Xo.toChannels(c.rgba),{css:_t.toCss(xt,Et,Pt,ot),rgba:_t.toRgba(xt,Et,Pt,ot)}}e.opacity=n;function o(c,h){return ot=c.rgba&255,n(c,ot*h/255)}e.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=l})($e||($e={}));var rt;(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 xt=parseInt(r.slice(1,2).repeat(2),16),Et=parseInt(r.slice(2,3).repeat(2),16),Pt=parseInt(r.slice(3,4).repeat(2),16),_t.toColor(xt,Et,Pt);case 5:return xt=parseInt(r.slice(1,2).repeat(2),16),Et=parseInt(r.slice(2,3).repeat(2),16),Pt=parseInt(r.slice(3,4).repeat(2),16),ot=parseInt(r.slice(4,5).repeat(2),16),_t.toColor(xt,Et,Pt,ot);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 xt=parseInt(n[1]),Et=parseInt(n[2]),Pt=parseInt(n[3]),ot=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),_t.toColor(xt,Et,Pt,ot);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),[xt,Et,Pt,ot]=t.getImageData(0,0,1,1).data,ot!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_t.toRgba(xt,Et,Pt,ot),css:r}}e.toColor=s})(rt||(rt={}));var qt;(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})(qt||(qt={}));var Xo;(e=>{function t(o,l){if(ot=(l&255)/255,ot===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 xt=u+Math.round((c-u)*ot),Et=f+Math.round((h-f)*ot),Pt=v+Math.round((d-v)*ot),_t.toRgba(xt,Et,Pt)}e.blend=t;function i(o,l,c){let h=qt.relativeLuminance(o>>8),d=qt.relativeLuminance(l>>8);if(ds(h,d)<c){if(d<h){let v=s(o,l,c),p=ds(h,qt.relativeLuminance(v>>8));if(p<c){let b=r(o,l,c),g=ds(h,qt.relativeLuminance(b>>8));return p>g?v:b}return v}let u=r(o,l,c),f=ds(h,qt.relativeLuminance(u>>8));if(f<c){let v=s(o,l,c),p=ds(h,qt.relativeLuminance(v>>8));return f>p?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,p=l>>8&255,b=ds(qt.relativeLuminance2(f,v,p),qt.relativeLuminance2(h,d,u));for(;b<c&&(f>0||v>0||p>0);)f-=Math.max(0,Math.ceil(f*.1)),v-=Math.max(0,Math.ceil(v*.1)),p-=Math.max(0,Math.ceil(p*.1)),b=ds(qt.relativeLuminance2(f,v,p),qt.relativeLuminance2(h,d,u));return(f<<24|v<<16|p<<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,p=l>>8&255,b=ds(qt.relativeLuminance2(f,v,p),qt.relativeLuminance2(h,d,u));for(;b<c&&(f<255||v<255||p<255);)f=Math.min(255,f+Math.ceil((255-f)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),b=ds(qt.relativeLuminance2(f,v,p),qt.relativeLuminance2(h,d,u));return(f<<24|v<<16|p<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Xo||(Xo={}));function ar(e){let t=e.toString(16);return t.length<2?"0"+t:t}function ds(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Cb=class extends ko{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()]}},ra=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Ri}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||Xs.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++)ra._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||Xs.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}};ra=lt([de(0,Vt)],ra);function kb(e){return 57508<=e&&e<=57558}function xb(e){return 9472<=e&&e<=9631}function Eb(e){return kb(e)||xb(e)}function Pb(){return{css:{canvas:No(),cell:No()},device:{canvas:No(),cell:No(),char:{width:0,height:0,left:0,top:0}}}}function No(){return{width:0,height:0}}var Kl=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 Ri,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,p=e.getNoBgTrimmedLength();i&&p<n+1&&(p=n+1);let b,g=0,y="",R=0,C=0,w=0,x=0,M=!1,N=0,j=!1,J=0,oe=0,Y=[],W=h!==-1&&d!==-1;for(let O=0;O<p;O++){e.loadCell(O,this._workCell);let B=this._workCell.getWidth();if(B===0)continue;let T=!1,q=O>=oe,D=O,E=this._workCell;if(f.length>0&&O===f[0][0]&&q){let pe=f.shift(),We=this._isCellInSelection(pe[0],t);for(R=pe[0]+1;R<pe[1];R++)q&&(q=We===this._isCellInSelection(R,t));q&&(q=!i||n<pe[0]||n>=pe[1]),q?(T=!0,E=new Cb(this._workCell,e.translateToString(!0,pe[0],pe[1]),pe[1]-pe[0]),D=pe[1]-1,B=E.getWidth()):oe=pe[1]}let $=this._isCellInSelection(O,t),X=i&&O===n,ce=W&&O>=h&&O<=d,be=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,pe=>{be=!0});let ge=E.getChars()||Xs;if(ge===" "&&(E.isUnderline()||E.isOverline())&&(ge=" "),J=B*l-c.get(ge,E.isBold(),E.isItalic()),!b)b=this._document.createElement("span");else if(g&&($&&j||!$&&!j&&E.bg===C)&&($&&j&&v.selectionForeground||E.fg===w)&&E.extended.ext===x&&ce===M&&J===N&&!X&&!T&&!be&&q){E.isInvisible()?y+=Xs:y+=ge,g++;continue}else g&&(b.textContent=y),b=this._document.createElement("span"),g=0,y="";if(C=E.bg,w=E.fg,x=E.extended.ext,M=ce,N=J,j=$,T&&n>=O&&n<=D&&(n=O),!this._coreService.isCursorHidden&&X&&this._coreService.isCursorInitialized){if(Y.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&Y.push("xterm-cursor-blink"),Y.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":Y.push("xterm-cursor-outline");break;case"block":Y.push("xterm-cursor-block");break;case"bar":Y.push("xterm-cursor-bar");break;case"underline":Y.push("xterm-cursor-underline");break}}if(E.isBold()&&Y.push("xterm-bold"),E.isItalic()&&Y.push("xterm-italic"),E.isDim()&&Y.push("xterm-dim"),E.isInvisible()?y=Xs:y=E.getChars()||Xs,E.isUnderline()&&(Y.push(`xterm-underline-${E.extended.underlineStyle}`),y===" "&&(y=" "),!E.isUnderlineColorDefault()))if(E.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${ko.toColorRGB(E.getUnderlineColor()).join(",")})`;else{let pe=E.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&E.isBold()&&pe<8&&(pe+=8),b.style.textDecorationColor=v.ansi[pe].css}E.isOverline()&&(Y.push("xterm-overline"),y===" "&&(y=" ")),E.isStrikethrough()&&Y.push("xterm-strikethrough"),ce&&(b.style.textDecoration="underline");let xe=E.getFgColor(),Pe=E.getFgColorMode(),Re=E.getBgColor(),we=E.getBgColorMode(),G=!!E.isInverse();if(G){let pe=xe;xe=Re,Re=pe;let We=Pe;Pe=we,we=We}let ve,Le,je=!1;this._decorationService.forEachDecorationAtCell(O,t,void 0,pe=>{pe.options.layer!=="top"&&je||(pe.backgroundColorRGB&&(we=50331648,Re=pe.backgroundColorRGB.rgba>>8&16777215,ve=pe.backgroundColorRGB),pe.foregroundColorRGB&&(Pe=50331648,xe=pe.foregroundColorRGB.rgba>>8&16777215,Le=pe.foregroundColorRGB),je=pe.options.layer==="top")}),!je&&$&&(ve=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,Re=ve.rgba>>8&16777215,we=50331648,je=!0,v.selectionForeground&&(Pe=50331648,xe=v.selectionForeground.rgba>>8&16777215,Le=v.selectionForeground)),je&&Y.push("xterm-decoration-top");let Be;switch(we){case 16777216:case 33554432:Be=v.ansi[Re],Y.push(`xterm-bg-${Re}`);break;case 50331648:Be=_t.toColor(Re>>16,Re>>8&255,Re&255),this._addStyle(b,`background-color:#${qc((Re>>>0).toString(16),"0",6)}`);break;case 0:default:G?(Be=v.foreground,Y.push("xterm-bg-257")):Be=v.background}switch(ve||E.isDim()&&(ve=$e.multiplyOpacity(Be,.5)),Pe){case 16777216:case 33554432:E.isBold()&&xe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(xe+=8),this._applyMinimumContrast(b,Be,v.ansi[xe],E,ve,void 0)||Y.push(`xterm-fg-${xe}`);break;case 50331648:let pe=_t.toColor(xe>>16&255,xe>>8&255,xe&255);this._applyMinimumContrast(b,Be,pe,E,ve,Le)||this._addStyle(b,`color:#${qc(xe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(b,Be,v.foreground,E,ve,Le)||G&&Y.push("xterm-fg-257")}Y.length&&(b.className=Y.join(" "),Y.length=0),!X&&!T&&!be&&q?g++:b.textContent=y,J!==this.defaultSpacing&&(b.style.letterSpacing=`${J}px`),u.push(b),O=D}return b&&g&&(b.textContent=y),u}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Eb(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=$e.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]}};Kl=lt([de(1,Rf),de(2,Yt),de(3,Rs),de(4,Kr),de(5,xo),de(6,Tn)],Kl);function qc(e,t,i){for(;e.length<i;)e=t+e;return e}var Rb=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}},Db=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 Tb(){return new Db}var Va="xterm-dom-renderer-owner-",pi="xterm-rows",Fo="xterm-fg-",jc="xterm-bg-",On="xterm-focus",Wo="xterm-selection",Mb=1,ql=class extends Ie{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=Mb++,this._rowElements=[],this._selectionRenderModel=Tb(),this.onRequestRedraw=this._register(new ie).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(pi),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(Wo),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Pb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(Kl,document),this._element.classList.add(Va+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(tt(()=>{this._element.classList.remove(Va+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Rb(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} .${pi} 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} .${pi} { 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} .${pi} .xterm-dim { color: ${$e.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} .${pi}.${On} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${pi}.${On} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${pi}.${On} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${pi} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Wo} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Wo} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Wo} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,o]of e.ansi.entries())t+=`${this._terminalSelector} .${Fo}${n} { color: ${o.css}; }${this._terminalSelector} .${Fo}${n}.xterm-dim { color: ${$e.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${jc}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Fo}257 { color: ${$e.opaque(e.background).css}; }${this._terminalSelector} .${Fo}257.xterm-dim { color: ${$e.multiplyOpacity($e.opaque(e.background),.5).css}; }${this._terminalSelector} .${jc}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(On),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(On),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`.${Va}${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 p=v+l.ydisp,b=this._rowElements[v],g=l.lines.get(p);if(!b||!g)break;b.replaceChildren(...this._rowFactory.createRow(g,p,p===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))}}};ql=lt([de(7,Ih),de(8,ka),de(9,Yt),de(10,Vt),de(11,Kr),de(12,Rs),de(13,Tn)],ql);var jl=class extends Ie{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new ie),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Lb(this._optionsService))}catch{this._measureStrategy=this._register(new Bb(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())}};jl=lt([de(2,Yt)],jl);var Yf=class extends Ie{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)}},Bb=class extends Yf{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}},Lb=class extends Yf{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}},Ab=class extends Ie{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 Ob(this._window)),this._onDprChange=this._register(new ie),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new ie),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(It.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ee(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ee(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}},Ob=class extends Ie{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new kn),this._onDprChange=this._register(new ie),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(tt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ee(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)}},Ib=class extends Ie{constructor(){super(),this.linkProviders=[],this._register(tt(()=>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 qh(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 Nb(e,t,i,s,r,n,o,l,c){if(!n)return;let h=qh(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 Vl=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Nb(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=qh(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])}}};Vl=lt([de(0,Ds),de(1,ka)],Vl);var Fb=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=[]}},Gf={};Gg(Gf,{getSafariVersion:()=>Hb,isChromeOS:()=>$f,isFirefox:()=>Xf,isIpad:()=>zb,isIphone:()=>Ub,isLegacyEdge:()=>Wb,isLinux:()=>jh,isMac:()=>na,isNode:()=>xa,isSafari:()=>Qf,isWindows:()=>Jf});var xa=typeof process<"u"&&"title"in process,Eo=xa?"node":navigator.userAgent,Po=xa?"node":navigator.platform,Xf=Eo.includes("Firefox"),Wb=Eo.includes("Edge"),Qf=/^((?!chrome|android).)*safari/i.test(Eo);function Hb(){if(!Qf)return 0;let e=Eo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var na=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Po),zb=Po==="iPad",Ub=Po==="iPhone",Jf=["Windows","Win16","Win32","WinCE"].includes(Po),jh=Po.indexOf("Linux")>=0,$f=/\bCrOS\b/.test(Eo),Zf=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()}},Kb=class extends Zf{_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())}}},qb=class extends Zf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},oa=!xa&&"requestIdleCallback"in window?qb:Kb,jb=class{constructor(){this._queue=new oa}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Yl=class extends Ie{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 kn),this._pausedResizeTask=new jb,this._observerDisposable=this._register(new kn),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 ie),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new ie),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new ie),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new ie),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Fb((h,d)=>this._renderRows(h,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Vb(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(tt(()=>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=tt(()=>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()}};Yl=lt([de(2,Yt),de(3,ka),de(4,Kr),de(5,xo),de(6,Vt),de(7,Rs),de(8,Tn)],Yl);var Vb=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 Yb(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return Qb(r,n,e,t,i,s)+Ea(n,t,i,s)+Jb(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",oo(Math.abs(r-e),no(o,s));o=n>t?"D":"C";let l=Math.abs(n-t),c=Xb(n>t?e:r,i)+(l-1)*i.cols+1+Gb(n>t?r:e);return oo(c,no(o,s))}function Gb(e,t){return e-1}function Xb(e,t){return t.cols-e}function Qb(e,t,i,s,r,n){return Ea(t,s,r,n).length===0?"":oo(t_(e,t,e,t-zr(t,r),!1,r).length,no("D",n))}function Ea(e,t,i,s){let r=e-zr(e,i),n=t-zr(t,i),o=Math.abs(r-n)-$b(e,t,i);return oo(o,no(e_(e,t),s))}function Jb(e,t,i,s,r,n){let o;Ea(t,s,r,n).length>0?o=s-zr(s,r):o=t;let l=s,c=Zb(e,t,i,s,r,n);return oo(t_(e,o,i,l,c==="C",r).length,no(c,n))}function $b(e,t,i){var o;let s=0,r=e-zr(e,i),n=t-zr(t,i);for(let l=0;l<Math.abs(r-n);l++){let c=e_(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+c*l))!=null&&o.isWrapped&&s++}return s}function zr(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 Zb(e,t,i,s,r,n){let o;return Ea(i,s,r,n).length>0?o=s-zr(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function e_(e,t){return e>t?"A":"B"}function t_(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 no(e,t){let i=t?"O":"[";return K.ESC+i+e}function oo(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var eS=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 Vc(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 Ya=50,tS=15,iS=50,sS=500,rS=" ",nS=new RegExp(rS,"g"),Gl=class extends Ie{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 Ri,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new ie),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new ie),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new ie),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new ie),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 eS(this._bufferService),this._activeSelectionMode=0,this._register(tt(()=>{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(nS," ")).join(Jf?`\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())),jh&&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=Vc(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=qh(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,-Ya),Ya),t/=Ya,t/Math.abs(t)+Math.round(t*(tS-1)))}shouldForceSelection(e){return na?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(),iS)}_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&&!(na&&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<sS&&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=Yb(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 g=e[0],y=e[0];n.getWidth(g)===0&&(d++,g--),n.getWidth(y)===2&&(u++,y++);let R=n.getString(y).length;for(R>1&&(v+=R-1,c+=R-1);g>0&&l>0&&!this._isCharWordSeparator(n.loadCell(g-1,this._workCell));){n.loadCell(g-1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,g--):C>1&&(f+=C-1,l-=C-1),l--,g--}for(;y<n.length&&c+1<o.length&&!this._isCharWordSeparator(n.loadCell(y+1,this._workCell));){n.loadCell(y+1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===2?(u++,y++):C>1&&(v+=C-1,c+=C-1),c++,y++}}c++;let p=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&&p===0&&n.getCodePoint(0)!==32){let g=r.lines.get(e[1]-1);if(g&&n.isWrapped&&g.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let R=this._bufferService.cols-y.start;p-=R,b+=R}}}if(s&&p+b===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let g=r.lines.get(e[1]+1);if(g!=null&&g.isWrapped&&g.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(b+=y.length)}}return{start:p,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=Vc(i,this._bufferService.cols)}};Gl=lt([de(3,Vt),de(4,Kr),de(5,Nh),de(6,Yt),de(7,Ds),de(8,Rs)],Gl);var Yc=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={}}},Gc=class{constructor(){this._color=new Yc,this._css=new Yc}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()}},pt=Object.freeze((()=>{let e=[rt.toColor("#2e3436"),rt.toColor("#cc0000"),rt.toColor("#4e9a06"),rt.toColor("#c4a000"),rt.toColor("#3465a4"),rt.toColor("#75507b"),rt.toColor("#06989a"),rt.toColor("#d3d7cf"),rt.toColor("#555753"),rt.toColor("#ef2929"),rt.toColor("#8ae234"),rt.toColor("#fce94f"),rt.toColor("#729fcf"),rt.toColor("#ad7fa8"),rt.toColor("#34e2e2"),rt.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:_t.toCss(s,r,n),rgba:_t.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:_t.toCss(s,s,s),rgba:_t.toRgba(s,s,s)})}return e})()),lr=rt.toColor("#ffffff"),Un=rt.toColor("#000000"),Xc=rt.toColor("#ffffff"),Qc=Un,In={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},oS=lr,Xl=class extends Ie{constructor(e){super(),this._optionsService=e,this._contrastCache=new Gc,this._halfContrastCache=new Gc,this._onChangeColors=this._register(new ie),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:lr,background:Un,cursor:Xc,cursorAccent:Qc,selectionForeground:void 0,selectionBackgroundTransparent:In,selectionBackgroundOpaque:$e.blend(Un,In),selectionInactiveBackgroundTransparent:In,selectionInactiveBackgroundOpaque:$e.blend(Un,In),scrollbarSliderBackground:$e.opacity(lr,.2),scrollbarSliderHoverBackground:$e.opacity(lr,.4),scrollbarSliderActiveBackground:$e.opacity(lr,.5),overviewRulerBorder:lr,ansi:pt.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=Xe(e.foreground,lr),t.background=Xe(e.background,Un),t.cursor=$e.blend(t.background,Xe(e.cursor,Xc)),t.cursorAccent=$e.blend(t.background,Xe(e.cursorAccent,Qc)),t.selectionBackgroundTransparent=Xe(e.selectionBackground,In),t.selectionBackgroundOpaque=$e.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Xe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=$e.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Xe(e.selectionForeground,Kc):void 0,t.selectionForeground===Kc&&(t.selectionForeground=void 0),$e.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=$e.opacity(t.selectionBackgroundTransparent,.3)),$e.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=$e.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Xe(e.scrollbarSliderBackground,$e.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Xe(e.scrollbarSliderHoverBackground,$e.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Xe(e.scrollbarSliderActiveBackground,$e.opacity(t.foreground,.5)),t.overviewRulerBorder=Xe(e.overviewRulerBorder,oS),t.ansi=pt.slice(),t.ansi[0]=Xe(e.black,pt[0]),t.ansi[1]=Xe(e.red,pt[1]),t.ansi[2]=Xe(e.green,pt[2]),t.ansi[3]=Xe(e.yellow,pt[3]),t.ansi[4]=Xe(e.blue,pt[4]),t.ansi[5]=Xe(e.magenta,pt[5]),t.ansi[6]=Xe(e.cyan,pt[6]),t.ansi[7]=Xe(e.white,pt[7]),t.ansi[8]=Xe(e.brightBlack,pt[8]),t.ansi[9]=Xe(e.brightRed,pt[9]),t.ansi[10]=Xe(e.brightGreen,pt[10]),t.ansi[11]=Xe(e.brightYellow,pt[11]),t.ansi[12]=Xe(e.brightBlue,pt[12]),t.ansi[13]=Xe(e.brightMagenta,pt[13]),t.ansi[14]=Xe(e.brightCyan,pt[14]),t.ansi[15]=Xe(e.brightWhite,pt[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]=Xe(e.extendedAnsi[s],pt[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()}}};Xl=lt([de(0,Yt)],Xl);function Xe(e,t){if(e!==void 0)try{return rt.toColor(e)}catch{}return t}var aS=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)}},lS=class{constructor(){this._services=new aS,this._services.set(Ih,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=tm(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)}},hS={trace:0,debug:1,info:2,warn:3,error:4,off:5},cS="xterm.js: ",Ql=class extends Ie{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=hS[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?"":cS)+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)}};Ql=lt([de(0,Yt)],Ql);var Jc=class extends Ie{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new ie),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new ie),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new ie),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}},Oe=3,ft=Object.freeze(new ko),Ho=0,Ga=2,Kn=class i_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Oe);let r=i||Ri.fromCharData([0,yf,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*Oe+0],s=i&2097151;return[this._data[t*Oe+1],i&2097152?this._combined[t]:s?Is(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Oe+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Oe+0]=t|2097152|i[2]<<22):this._data[t*Oe+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Oe+0]>>22}hasWidth(t){return this._data[t*Oe+0]&12582912}getFg(t){return this._data[t*Oe+1]}getBg(t){return this._data[t*Oe+2]}hasContent(t){return this._data[t*Oe+0]&4194303}getCodePoint(t){let i=this._data[t*Oe+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Oe+0]&2097152}getString(t){let i=this._data[t*Oe+0];return i&2097152?this._combined[t]:i&2097151?Is(i&2097151):""}isProtected(t){return this._data[t*Oe+2]&536870912}loadCell(t,i){return Ho=t*Oe,i.content=this._data[Ho+0],i.fg=this._data[Ho+1],i.bg=this._data[Ho+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*Oe+0]=i.content,this._data[t*Oe+1]=i.fg,this._data[t*Oe+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*Oe+0]=i|s<<22,this._data[t*Oe+1]=r.fg,this._data[t*Oe+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*Oe+0];r&2097152?this._combined[t]+=Is(i):r&2097151?(this._combined[t]=Is(r&2097151)+Is(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*Oe+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 Ri;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 Ri;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*Ga<this._data.buffer.byteLength;let s=t*Oe;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*Ga<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ga<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 i_(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*Oe+0]&4194303)return t+(this._data[t*Oe+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Oe+0]&4194303||this._data[t*Oe+2]&50331648)return t+(this._data[t*Oe+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<Oe;h++)this._data[(s+c)*Oe+h]=o[(i+c)*Oe+h];o[(i+c)*Oe+2]&268435456&&(this._extendedAttrs[s+c]=t._extendedAttrs[i+c])}else for(let c=0;c<r;c++){for(let h=0;h<Oe;h++)this._data[(s+c)*Oe+h]=o[(i+c)*Oe+h];o[(i+c)*Oe+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*Oe+0],l=o&2097151,c=o&2097152?this._combined[i]:l?Is(l):Xs;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 uS(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=ao(d,u,t),v=1,p=0;for(;v<d.length;){let g=ao(d,v,t),y=g-p,R=i-f,C=Math.min(y,R);d[u].copyCellsFrom(d[v],p,f,C,!1),f+=C,f===i&&(u++,f=0),p+=C,p===g&&(v++,p=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 g=d.length-1;g>0&&(g>u||d[g].getTrimmedLength()===0);g--)b++;b>0&&(o.push(l+d.length-b),o.push(b)),l+=d.length-1}return o}function dS(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 fS(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 _S(e,t,i){let s=[],r=e.map((c,h)=>ao(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=ao(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 ao(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 s_=class r_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=r_._nextId++,this._onDispose=this.register(new ie),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Hr(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};s_._nextId=1;var vS=s_,St={},hr=St.B;St[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:"≥","{":"π","|":"≠","}":"£","~":"·"};St.A={"#":"£"};St.B=void 0;St[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};St.C=St[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};St.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};St.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};St.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};St.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};St.E=St[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};St.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};St.H=St[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};St["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var $c=4294967295,Zc=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=ft.clone(),this.savedCharset=hr,this.markers=[],this._nullCell=Ri.fromCharData([0,yf,1,0]),this._whitespaceCell=Ri.fromCharData([0,Xs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new oa,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Jc(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 ia),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 ia),this._whitespaceCell}getBlankLine(e,t){return new Kn(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>$c?$c:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=ft);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 Jc(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(ft),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 Kn(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 Kn(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=uS(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(ft),i);if(s.length>0){let r=dS(this.lines,s);fS(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(ft),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Kn(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(ft),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 C=this.ybase+this.y;if(C>=o&&C<o+c.length)continue}let h=c[c.length-1].getTrimmedLength(),d=_S(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 C=0;C<u;C++){let w=this.getBlankLine(ft,!0);v.push(w)}v.length>0&&(r.push({start:o+c.length+n,newLines:v}),n+=v.length),c.push(...v);let p=d.length-1,b=d[p];b===0&&(p--,b=d[p]);let g=c.length-u-1,y=h;for(;g>=0;){let C=Math.min(y,b);if(c[p]===void 0)break;if(c[p].copyCellsFrom(c[g],y-C,b-C,C,!0),b-=C,b===0&&(p--,b=d[p]),y-=C,y===0){g--;let w=Math.max(g,0);y=ao(c,w,this._cols)}}for(let C=0;C<c.length;C++)d[C]<e&&c[C].setCell(d[C],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 g=u.newLines.length-1;g>=0;g--)this.lines.set(b--,u.newLines[g]);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 p=Math.max(0,c+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}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 vS(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)}},pS=class extends Ie{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new ie),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 Zc(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Zc(!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)}},n_=2,o_=1,Jl=class extends Ie{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new ie),this.onResize=this._onResize.event,this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,n_),this.rows=Math.max(e.rawOptions.rows||0,o_),this.buffers=this._register(new pS(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))}};Jl=lt([de(0,Yt)],Jl);var Vr={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:na,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},gS=["normal","bold","100","200","300","400","500","600","700","800","900"],mS=class extends Ie{constructor(e){super(),this._onOptionChange=this._register(new ie),this.onOptionChange=this._onOptionChange.event;let t={...Vr};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(tt(()=>{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 Vr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Vr))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=Vr[e]),!bS(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Vr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=gS.includes(t)?t:Vr[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 bS(e){return e==="block"||e==="underline"||e==="bar"}function qn(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]&&qn(e[s],t-1);return i}var eu=Object.freeze({insertMode:!1}),tu=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),$l=class extends Ie{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 ie),this.onData=this._onData.event,this._onUserInput=this._register(new ie),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new ie),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new ie),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=qn(eu),this.decPrivateModes=qn(tu)}reset(){this.modes=qn(eu),this.decPrivateModes=qn(tu)}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))}};$l=lt([de(0,Vt),de(1,Ef),de(2,Yt)],$l);var iu={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 Xa(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 Qa=String.fromCharCode,su={DEFAULT:e=>{let t=[Xa(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Qa(t[0])}${Qa(t[1])}${Qa(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Xa(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Xa(e,!0)};${e.x};${e.y}${t}`}},Zl=class extends Ie{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 ie),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(iu))this.addProtocol(s,iu[s]);for(let s of Object.keys(su))this.addEncoding(s,su[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)}};Zl=lt([de(0,Vt),de(1,Kr),de(2,Yt)],Zl);var Ja=[[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]],SS=[[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]],gt;function yS(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 wS=class{constructor(){if(this.version="6",!gt){gt=new Uint8Array(65536),gt.fill(1),gt[0]=0,gt.fill(0,1,32),gt.fill(0,127,160),gt.fill(2,4352,4448),gt[9001]=2,gt[9002]=2,gt.fill(2,11904,42192),gt[12351]=1,gt.fill(2,44032,55204),gt.fill(2,63744,64256),gt.fill(2,65040,65050),gt.fill(2,65072,65136),gt.fill(2,65280,65377),gt.fill(2,65504,65511);for(let e=0;e<Ja.length;++e)gt.fill(0,Ja[e][0],Ja[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?gt[e]:yS(e,SS)?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=vr.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return vr.createPropertyValue(0,i,s)}},vr=class Qo{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new ie,this.onChange=this._onChange.event;let t=new wS;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=Qo.extractWidth(l);Qo.extractShouldJoin(l)&&(c-=Qo.extractWidth(s)),i+=c,s=l}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},CS=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 ru(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 Nn=2147483647,kS=256,a_=class eh{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>kS)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 eh;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 eh(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>Nn?Nn: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>Nn?Nn: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,Nn):t}},Fn=[],xS=class{constructor(){this._state=0,this._active=Fn,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=Fn}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=Fn,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Fn,!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",Ca(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=Fn,this._id=-1,this._state=0}}},ai=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+=Ca(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}},Wn=[],ES=class{constructor(){this._handlers=Object.create(null),this._active=Wn,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Wn}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=Wn,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Wn,!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",Ca(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=Wn,this._ident=0}},jn=new a_;jn.addParam(0);var nu=class{constructor(e){this._handler=e,this._data="",this._params=jn,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():jn,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ca(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=jn,this._data="",this._hitLimit=!1,i));return this._params=jn,this._data="",this._hitLimit=!1,t}},PS=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}},Ci=160,RS=(function(){let e=new PS(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(Ci,0,2,0),e.add(Ci,8,5,8),e.add(Ci,6,0,6),e.add(Ci,11,0,11),e.add(Ci,13,13,13),e})(),DS=class extends Ie{constructor(e=RS){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 a_,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(tt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new xS),this._dcsParser=this._register(new ES),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:Ci)],r>>4){case 2:for(let f=l+1;;++f){if(f>=t||(s=e[f])<32||s>126&&s<Ci){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ci){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ci){this._printHandler(e,l,f),l=f-1;break}if(++f>=t||(s=e[f])<32||s>126&&s<Ci){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<Ci){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<Ci){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}}},TS=/^([\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})$/,MS=/^[\da-f]+$/;function ou(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=TS.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),MS.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 $a(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 BS(e,t=16){let[i,s,r]=e;return`rgb:${$a(i,t)}/${$a(s,t)}/${$a(r,t)}`}var LS={"(":0,")":1,"*":2,"+":3,"-":1,".":2},As=131072,au=10;function lu(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 hu=5e3,cu=0,AS=class extends Ie{constructor(e,t,i,s,r,n,o,l,c=new DS){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 Zg,this._utf8Decoder=new em,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=ft.clone(),this._eraseAttrDataInternal=ft.clone(),this._onRequestBell=this._register(new ie),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new ie),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new ie),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new ie),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new ie),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new ie),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new ie),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new ie),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new ie),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new ie),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new ie),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new ie),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new ie),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 th(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(K.BEL,()=>this.bell()),this._parser.setExecuteHandler(K.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(K.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(K.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(K.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(K.BS,()=>this.backspace()),this._parser.setExecuteHandler(K.HT,()=>this.tab()),this._parser.setExecuteHandler(K.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(K.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Go.IND,()=>this.index()),this._parser.setExecuteHandler(Go.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Go.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ai(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new ai(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new ai(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new ai(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new ai(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new ai(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new ai(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new ai(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new ai(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new ai(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new ai(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new ai(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 St)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 nu((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"),hu))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${hu} 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>As&&(n=this._parseStack.position+As)}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<As&&(this._parseBuffer=new Uint32Array(Math.min(e.length,As))),o||this._dirtyRowTracker.clearRange(),e.length>As)for(let h=n;h<e.length;h+=As){let d=h+As<e.length?h+As: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 y=n[String.fromCharCode(s)];y&&(s=y.charCodeAt(0))}let p=this._unicodeService.charProperties(s,f);r=vr.extractWidth(p);let b=vr.extractShouldJoin(p),g=b?vr.extractWidth(f):0;if(f=p,o&&this._onA11yChar.fire(Is(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-g>l){if(c){let y=u,R=this._activeBuffer.x-g;for(this._activeBuffer.x=g,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),g>0&&u instanceof Kn&&u.copyCellsFrom(y,R,0,g,!1);R<l;)y.setCellFromCodepoint(R++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(b&&this._activeBuffer.x){let y=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-y,s,r);for(let R=r-g;--R>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(h&&(u.insertCells(this._activeBuffer.x,r-g,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=>lu(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new nu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new ai(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(ft));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=vr.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(K.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(K.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(K.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(K.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(K.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,hr),this._charsetService.setgCharset(1,hr),this._charsetService.setgCharset(2,hr),this._charsetService.setgCharset(3,hr);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,g)=>(o.triggerDataEvent(`${K.ESC}[${t?"":"?"}${b};${g}$y`),!0),v=b=>b?1:2,p=e.params[0];return t?p===2?f(p,4):p===4?f(p,v(o.modes.insertMode)):p===12?f(p,3):p===20?f(p,v(u.convertEol)):f(p,0):p===1?f(p,v(s.applicationCursorKeys)):p===3?f(p,u.windowOptions.setWinLines?c===80?2:c===132?1:0:0):p===6?f(p,v(s.origin)):p===7?f(p,v(s.wraparound)):p===8?f(p,3):p===9?f(p,v(r==="X10")):p===12?f(p,v(u.cursorBlink)):p===25?f(p,v(!o.isCursorHidden)):p===45?f(p,v(s.reverseWraparound)):p===66?f(p,v(s.applicationKeypad)):p===67?f(p,4):p===1e3?f(p,v(r==="VT200")):p===1002?f(p,v(r==="DRAG")):p===1003?f(p,v(r==="ANY")):p===1004?f(p,v(s.sendFocus)):p===1005?f(p,4):p===1006?f(p,v(n==="SGR")):p===1015?f(p,4):p===1016?f(p,v(n==="SGR_PIXELS")):p===1048?f(p,1):p===47||p===1047||p===1049?f(p,v(h===d)):p===2004?f(p,v(s.bracketedPasteMode)):p===2026?f(p,v(s.synchronizedOutput)):f(p,0)}_updateAttrColor(e,t,i,s,r){return t===2?(e|=50331648,e&=-16777216,e|=ko.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=ft.fg,e.bg=ft.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|=ft.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=ft.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|=ft.fg&16777215,s.bg&=-67108864,s.bg|=ft.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${K.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${K.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(`${K.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=ft.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(!lu(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(`${K.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>au&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>au&&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(uu(n))if(r==="?")t.push({type:0,index:n});else{let o=ou(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=ou(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]);uu(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,hr),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(LS[e[0]],St[e[1]]||hr),!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=ft.clone(),this._eraseAttrDataInternal=ft.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 Ri;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(`${K.ESC}${o}${K.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)}},th=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&&(cu=e,e=t,t=cu),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};th=lt([de(0,Vt)],th);function uu(e){return 0<=e&&e<256}var OS=5e7,du=12,IS=50,NS=class extends Ie{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 ie),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>OS)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>=du?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>=du)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>IS&&(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()}},ih=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)))}};ih=lt([de(0,Vt)],ih);var fu=!1,FS=class extends Ie{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new kn),this._onBinary=this._register(new ie),this.onBinary=this._onBinary.event,this._onData=this._register(new ie),this.onData=this._onData.event,this._onLineFeed=this._register(new ie),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new ie),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new ie),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new ie),this._instantiationService=new lS,this.optionsService=this._register(new mS(e)),this._instantiationService.setService(Yt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Jl)),this._instantiationService.setService(Vt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Ql)),this._instantiationService.setService(Ef,this._logService),this.coreService=this._register(this._instantiationService.createInstance($l)),this._instantiationService.setService(Kr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Zl)),this._instantiationService.setService(xf,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(vr)),this._instantiationService.setService(rm,this.unicodeService),this._charsetService=this._instantiationService.createInstance(CS),this._instantiationService.setService(sm,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(ih),this._instantiationService.setService(Pf,this._oscLinkService),this._inputHandler=this._register(new AS(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(It.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(It.forward(this._bufferService.onResize,this._onResize)),this._register(It.forward(this.coreService.onData,this._onData)),this._register(It.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 NS((t,i)=>this._inputHandler.parse(t,i))),this._register(It.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new ie),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&&!fu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),fu=!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,n_),t=Math.max(t,o_),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(ru.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ru(this._bufferService),!1))),this._windowsWrappingHeuristics.value=tt(()=>{for(let t of e)t.dispose()})}}},WS={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 HS(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=K.ESC+"OA":r.key=K.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=K.ESC+"OD":r.key=K.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=K.ESC+"OC":r.key=K.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=K.ESC+"OB":r.key=K.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":K.DEL,e.altKey&&(r.key=K.ESC+r.key);break;case 9:if(e.shiftKey){r.key=K.ESC+"[Z";break}r.key=K.HT,r.cancel=!0;break;case 13:r.key=e.altKey?K.ESC+K.CR:K.CR,r.cancel=!0;break;case 27:r.key=K.ESC,e.altKey&&(r.key=K.ESC+K.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=K.ESC+"[1;"+(n+1)+"D":t?r.key=K.ESC+"OD":r.key=K.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=K.ESC+"[1;"+(n+1)+"C":t?r.key=K.ESC+"OC":r.key=K.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=K.ESC+"[1;"+(n+1)+"A":t?r.key=K.ESC+"OA":r.key=K.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=K.ESC+"[1;"+(n+1)+"B":t?r.key=K.ESC+"OB":r.key=K.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=K.ESC+"[2~");break;case 46:n?r.key=K.ESC+"[3;"+(n+1)+"~":r.key=K.ESC+"[3~";break;case 36:n?r.key=K.ESC+"[1;"+(n+1)+"H":t?r.key=K.ESC+"OH":r.key=K.ESC+"[H";break;case 35:n?r.key=K.ESC+"[1;"+(n+1)+"F":t?r.key=K.ESC+"OF":r.key=K.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=K.ESC+"[5;"+(n+1)+"~":r.key=K.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=K.ESC+"[6;"+(n+1)+"~":r.key=K.ESC+"[6~";break;case 112:n?r.key=K.ESC+"[1;"+(n+1)+"P":r.key=K.ESC+"OP";break;case 113:n?r.key=K.ESC+"[1;"+(n+1)+"Q":r.key=K.ESC+"OQ";break;case 114:n?r.key=K.ESC+"[1;"+(n+1)+"R":r.key=K.ESC+"OR";break;case 115:n?r.key=K.ESC+"[1;"+(n+1)+"S":r.key=K.ESC+"OS";break;case 116:n?r.key=K.ESC+"[15;"+(n+1)+"~":r.key=K.ESC+"[15~";break;case 117:n?r.key=K.ESC+"[17;"+(n+1)+"~":r.key=K.ESC+"[17~";break;case 118:n?r.key=K.ESC+"[18;"+(n+1)+"~":r.key=K.ESC+"[18~";break;case 119:n?r.key=K.ESC+"[19;"+(n+1)+"~":r.key=K.ESC+"[19~";break;case 120:n?r.key=K.ESC+"[20;"+(n+1)+"~":r.key=K.ESC+"[20~";break;case 121:n?r.key=K.ESC+"[21;"+(n+1)+"~":r.key=K.ESC+"[21~";break;case 122:n?r.key=K.ESC+"[23;"+(n+1)+"~":r.key=K.ESC+"[23~";break;case 123:n?r.key=K.ESC+"[24;"+(n+1)+"~":r.key=K.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=K.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=K.DEL:e.keyCode===219?r.key=K.ESC:e.keyCode===220?r.key=K.FS:e.keyCode===221&&(r.key=K.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let l=(o=WS[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(l)r.key=K.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=K.ESC+h}else if(e.keyCode===32)r.key=K.ESC+(e.ctrlKey?K.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let c=e.code.slice(3,4);e.shiftKey||(c=c.toLowerCase()),r.key=K.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=K.US),e.key==="@"&&(r.key=K.NUL));break}return r}var ht=0,zS=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new oa,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new oa,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||(ht=this._search(t),ht===-1)||this._getKey(this._array[ht])!==t)return!1;do if(this._array[ht]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ht),!0;while(++ht<this._array.length&&this._getKey(this._array[ht])===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&&(ht=this._search(e),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===e))do yield this._array[ht];while(++ht<this._array.length&&this._getKey(this._array[ht])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ht=this._search(e),!(ht<0||ht>=this._array.length)&&this._getKey(this._array[ht])===e))do t(this._array[ht]);while(++ht<this._array.length&&this._getKey(this._array[ht])===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}},Za=0,_u=0,US=class extends Ie{constructor(){super(),this._decorations=new zS(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new ie),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new ie),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(tt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new KS(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=>{Za=r.options.x??0,_u=Za+(r.options.width??1),e>=Za&&e<_u&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},KS=class extends tr{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new ie),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new ie),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=rt.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=rt.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},qS=1e3,jS=class{constructor(e,t=qS){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)}},vu=20,aa=class extends Ie{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 jS(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(Ee(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(tt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<vu+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
35
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===vu+1&&(this._liveRegion.textContent+=wl.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})`}};aa=lt([de(1,Ih),de(2,Rs),de(3,Ds)],aa);var sh=class extends Ie{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 ie),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ie),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(tt(()=>{var n;Hr(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(Ee(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ee(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ee(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ee(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&&VS(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,Hr(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}}};sh=lt([de(1,Nh),de(2,Ds),de(3,Vt),de(4,Df)],sh);function VS(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 YS=class extends FS{constructor(e={}){super(e),this._linkifier=this._register(new kn),this.browser=Gf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new kn),this._onCursorMove=this._register(new ie),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ie),this.onKey=this._onKey.event,this._onRender=this._register(new ie),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ie),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ie),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ie),this.onBell=this._onBell.event,this._onFocus=this._register(new ie),this._onBlur=this._register(new ie),this._onA11yCharEmitter=this._register(new ie),this._onA11yTabEmitter=this._register(new ie),this._onWillOpen=this._register(new ie),this._setup(),this._decorationService=this._instantiationService.createInstance(US),this._instantiationService.setService(xo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Ib),this._instantiationService.setService(Df,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(kl)),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(It.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(It.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(It.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(It.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(tt(()=>{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=$e.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${K.ESC}]${s};${BS(r)}${Vf.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=_t.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=_t.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(aa,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(K.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(K.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(Ee(this.element,"copy",t=>{this.hasSelection()&&Jg(t,this._selectionService)}));let e=t=>$g(t,this.textarea,this.coreService,this.optionsService);this._register(Ee(this.textarea,"paste",e)),this._register(Ee(this.element,"paste",e)),Xf?this._register(Ee(this.element,"mousedown",t=>{t.button===2&&xc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ee(this.element,"contextmenu",t=>{xc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jh&&this._register(Ee(this.element,"auxclick",t=>{t.button===1&&Sf(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ee(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ee(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ee(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ee(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ee(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ee(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ee(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(Ee(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",yl.get()),$f||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(Ab,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Rs,this._coreBrowserService),this._register(Ee(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(Ee(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(jl,this._document,this._helperContainer),this._instantiationService.setService(ka,this._charSizeService),this._themeService=this._instantiationService.createInstance(Xl),this._instantiationService.setService(Tn,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ra),this._instantiationService.setService(Rf,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Yl,this.rows,this.screenElement)),this._instantiationService.setService(Ds,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(Ul,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Vl),this._instantiationService.setService(Nh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(sh,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(Hl,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(Gl,this.element,this.screenElement,s)),this._instantiationService.setService(om,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(It.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(zl,this.screenElement)),this._register(Ee(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(aa,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ql,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 p=n.deltaY;if(p===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=p<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(Ee(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(Ee(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=K.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){bf(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=HS(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===K.ETX||i.key===K.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)&&(GS(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(ft));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(K.ESC+"[I"):this.coreService.triggerDataEvent(K.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(`${K.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(`${K.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function GS(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var XS=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)}},QS=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 Ri)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},pu=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 QS(t)}getNullCell(){return new Ri}},JS=class extends Ie{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ie),this.onBufferChange=this._onBufferChange.event,this._normal=new pu(this._core.buffers.normal,"normal"),this._alternate=new pu(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)}},$S=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)}},ZS=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}},ey=["cols","rows"],Gi=0,ty=class extends Ie{constructor(e){super(),this._core=this._register(new YS(e)),this._addonManager=this._register(new XS),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(ey.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 $S(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new ZS(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 JS(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 yl.get()},set promptLabel(e){yl.set(e)},get tooMuchOutput(){return wl.get()},set tooMuchOutput(e){wl.set(e)}}}_verifyIntegers(...e){for(Gi of e)if(Gi===1/0||isNaN(Gi)||Gi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Gi of e)if(Gi&&(Gi===1/0||isNaN(Gi)||Gi%1!==0||Gi<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 iy=2,sy=1,ry=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(iy,Math.floor(d/e.css.cell.width)),rows:Math.max(sy,Math.floor(h/e.css.cell.height))}}},ny=H('<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>'),oy=H('<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 ay(e,t){ut(t,!0);let i=as(t,"useTmux",3,!1),s=as(t,"companionMode",3,!1),r,n=F(null),o,l=!1;function c(){return a(n)}function h(){var z;(z=a(n))==null||z.focus()}function d(){if(!a(n))return;const z=a(n).buffer.active,U=z.viewportY>=z.baseY,se=z.viewportY;o==null||o.fit(),U?a(n).scrollToBottom():a(n).scrollToLine(se),Ha(a(n).cols,a(n).rows),T()}Dn(()=>{const z=new ty({cursorBlink:!0,fontSize:Lt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new ry,z.loadAddon(o),z.open(r),Lt){const P=r.querySelector(".xterm-viewport");P&&(P.style.touchAction="none",P.style.overflowY="hidden");const A=r.querySelector(".xterm-screen");if(A){A.addEventListener("wheel",me=>{me.stopImmediatePropagation(),me.preventDefault()},{capture:!0,passive:!1});const Z=me=>{z.modes.mouseTrackingMode!=="none"&&me.stopImmediatePropagation()};for(const me of["mousedown","mouseup","mousemove"])A.addEventListener(me,Z,{capture:!0})}}o.fit(),z.onData(P=>er(P));{const P=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");z.attachCustomKeyEventHandler(A=>!P&&A.type==="keydown"&&A.ctrlKey&&!A.shiftKey&&!A.altKey&&!A.metaKey&&(A.key==="v"||A.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(Z=>{let me=null,Ce=null;for(const ye of Z){for(const Te of ye.types)if(Te.startsWith("image/")){Ce=Te,me=ye;break}if(me)break}me&&Ce?me.getType(Ce).then(ye=>ve(ye,Ce)):navigator.clipboard.readText().then(ye=>{ye&&z.paste(ye)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(Z=>{Z&&z.paste(Z)}).catch(()=>{})}),!1):!0)}z.parser.registerOscHandler(52,P=>{var me;const A=P.indexOf(";");if(A===-1)return!0;const Z=P.slice(A+1);if(!Z||Z==="?")return!0;try{const Ce=Uint8Array.from(atob(Z),Te=>Te.charCodeAt(0)),ye=new TextDecoder("utf-8").decode(Ce);(me=navigator.clipboard)==null||me.writeText(ye).catch(()=>{})}catch{}return!0}),z.onScroll(T),z.onWriteParsed(T);let U=null;const se=new ResizeObserver(()=>{U&&clearTimeout(U),U=setTimeout(()=>{const P=z.buffer.active,A=P.viewportY>=P.baseY,Z=P.viewportY;o.fit(),A?z.scrollToBottom():z.scrollToLine(Z),Ha(z.cols,z.rows),T()},Lt?150:0)});return se.observe(r),Lt&&(document.addEventListener("touchmove",ge,{passive:!1}),document.addEventListener("touchend",xe),document.addEventListener("touchcancel",xe)),m(n,z,!0),()=>{U&&clearTimeout(U),J&&clearTimeout(J),se.disconnect(),z.dispose(),m(n,null),y=!1,u=!1,Lt&&(document.removeEventListener("touchmove",ge),document.removeEventListener("touchend",xe),document.removeEventListener("touchcancel",xe))}}),rs(()=>{t.sessionId&&a(n)&&!s()&&(a(n).write("\x1B[?1049l"),a(n).clear(),df(t.sessionId,a(n),()=>{a(n)&&Ha(a(n).cols,a(n).rows)},()=>{}))});let u=!1,f=0,v=0,p=F(0),b=F(0),g=F(!1),y=!1,R=0,C=0,w=!1,x=0,M=0,N=F(!1),j=F(!1),J=null,oe=0,Y=0;const W=500,O=10;let B=!1;function T(){B||(B=!0,requestAnimationFrame(q))}function q(){if(B=!1,!a(n))return;const z=a(n).buffer.active,U=z.baseY+a(n).rows,se=z.viewportY,P=we;if(!P)return;const A=P.clientHeight;if(U<=a(n).rows){m(g,!1);return}m(g,!0),m(p,Math.max(Lt?44:20,a(n).rows/U*A),!0),m(b,se/(U-a(n).rows)*(A-a(p)))}function D(z){if(!a(n)||!we)return;const U=we.getBoundingClientRect(),P=a(n).buffer.active.baseY+a(n).rows;if(P<=a(n).rows)return;const A=we.clientHeight,Z=Math.max(Lt?44:20,a(n).rows/P*A),me=A-Z,Ce=z-U.top-Z/2,ye=Math.max(0,Math.min(1,Ce/me)),Te=Math.round(ye*(P-a(n).rows));a(n).scrollToLine(Te)}function E(z){const U=z.touches[0];U&&(u=!0,f=U.clientY,v=a(b))}function $(){var z;a(j)&&(m(j,!1),(z=t.onCopyModeChange)==null||z.call(t,!1))}function X(){var se;if(J=null,y=!1,navigator.vibrate&&navigator.vibrate(50),i()){m(j,!0),(se=t.onCopyModeChange)==null||se.call(t,!0),er("[");return}m(N,!0);const z=r.querySelector(".xterm-screen");z&&(z.style.userSelect="text",z.style.webkitUserSelect="text"),r.querySelectorAll("canvas").forEach(P=>{P.style.pointerEvents="none"});const U=r.querySelector(".xterm-rows");if(U){const P=document.createRange();P.selectNodeContents(U);const A=window.getSelection();A==null||A.removeAllRanges(),A==null||A.addRange(P)}}function ce(){var U;m(N,!1);const z=r.querySelector(".xterm-screen");z&&(z.style.userSelect="",z.style.webkitUserSelect=""),r.querySelectorAll("canvas").forEach(se=>{se.style.pointerEvents=""}),(U=window.getSelection())==null||U.removeAllRanges()}function be(z){var se;if(a(N)){const P=((se=window.getSelection())==null?void 0:se.toString())??"";P.trim().length>0&&(navigator.clipboard.writeText(P).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),ce();return}if(a(j)||z.target.closest(".terminal-scrollbar")||z.target.closest(".scroll-fabs")||!a(n))return;const U=z.touches[0];U&&(R=U.clientY,M=U.clientY,C=a(n).buffer.active.viewportY,w=!1,x=0,y=!0,oe=U.clientX,Y=U.clientY,J&&clearTimeout(J),J=setTimeout(()=>{X()},W))}function ge(z){const U=z.touches[0];if(U){if(u){if(!a(n)||!we)return;z.preventDefault();const se=U.clientY-f,A=a(n).buffer.active.baseY+a(n).rows;if(A<=a(n).rows)return;const Z=we.clientHeight,me=Math.max(44,a(n).rows/A*Z),Ce=Z-me,Te=Math.max(0,Math.min(Ce,v+se))/Ce,Ze=Math.round(Te*(A-a(n).rows));a(n).scrollToLine(Ze);return}if(y&&a(n)&&!a(N)){if(J){const P=Math.abs(U.clientX-oe),A=Math.abs(U.clientY-Y);(P>O||A>O)&&(clearTimeout(J),J=null)}if(a(n).rows===0||r.clientHeight===0)return;const se=R-U.clientY;if(Math.abs(se)>5){w=!0,z.preventDefault();const P=r.clientHeight/a(n).rows;if(a(n).buffer.active.type==="alternate"){const A=M-U.clientY;M=U.clientY;const Z=A/P;x+=Z;const me=Math.trunc(x);if(me!==0){x-=me;const Ce=me>0?65:64,ye=Math.max(1,Math.round(a(n).cols/2)),Te=Math.max(1,Math.round(a(n).rows/2)),Ze=`\x1B[<${Ce};${ye};${Te}M`,Ht=Math.min(Math.abs(me),5);for(let Vi=0;Vi<Ht;Vi++)er(Ze)}}else{const A=se/P,Z=a(n).buffer.active.baseY,me=Math.max(0,Math.min(Z,Math.round(C+A)));a(n).scrollToLine(me)}}}}}function xe(){J&&(clearTimeout(J),J=null),u=!1,y=!1,w=!1,x=0}function Pe(z){z.target!==G&&D(z.clientY)}function Re(z){var P,A,Z;z.preventDefault();const U=z.target.closest("button");if(!U)return;const se=U.dataset.dir;se==="up"?(P=a(n))==null||P.scrollPages(-1):se==="down"?(A=a(n))==null||A.scrollPages(1):se==="bottom"&&((Z=a(n))==null||Z.scrollToBottom())}let we,G;async function ve(z,U){var P;if(l||!t.sessionId)return;l=!0,(P=t.onImageUpload)==null||P.call(t,"Pasting image…",!1);const se=new FileReader;se.onload=async()=>{var Z,me,Ce;const A=se.result.split(",")[1];try{const ye=await Dp(t.sessionId,A,U);ye.clipboardSet?(Z=t.onImageUpload)==null||Z.call(t,"Image pasted",!1):(me=t.onImageUpload)==null||me.call(t,ye.path,!0,ye.path)}catch(ye){const Te=ye instanceof Error?ye.message:"Image upload failed";(Ce=t.onImageUpload)==null||Ce.call(t,Te,!1)}finally{l=!1}},se.readAsDataURL(z)}function Le(z){var U;if((U=z.clipboardData)!=null&&U.items){for(const se of z.clipboardData.items)if(se.type.startsWith("image/")){z.preventDefault(),z.stopPropagation();const P=se.getAsFile();P&&ve(P,se.type);return}}}let je=F(!1);function Be(z){var U;(U=z.dataTransfer)!=null&&U.types.includes("Files")&&(z.preventDefault(),m(je,!0))}function pe(){m(je,!1)}function We(z){var se;if(z.preventDefault(),m(je,!1),!((se=z.dataTransfer)!=null&&se.files.length))return;const U=z.dataTransfer.files[0];U.type.startsWith("image/")&&ve(U,U.type)}function He(z){var U;u||w||z.target.closest(".terminal-scrollbar")||a(N)||((U=a(n))==null||U.focus(),z.preventDefault())}var Ue={getTerm:c,focusTerm:h,fitTerm:d,exitCopyMode:$,handleImageUpload:ve},L=oy();let te;var _e=S(L);et(_e,z=>r=z,()=>r);var ue=k(_e,2);Ne(ue,"aria-valuenow",0);var Se=S(ue);let ne;et(Se,z=>G=z,()=>G),et(ue,z=>we=z,()=>we);var Ae=k(ue,2);{var Ke=z=>{var U=ny();Q("mousedown",U,Re),I(z,U)};ae(Ae,z=>{Lt&&a(g)&&z(Ke)})}return he(()=>{te=Qe(L,1,"terminal-wrapper svelte-5qgfij",null,te,{"drag-over":a(je),"selection-mode":a(N)}),ne=Rn(Se,"",ne,{display:a(g)?"block":"none",height:a(p)+"px",top:a(b)+"px"})}),Q("touchstart",L,function(...z){var U;(U=Lt?be:void 0)==null||U.apply(this,z)}),Q("touchend",L,function(...z){var U;(U=Lt?He:void 0)==null||U.apply(this,z)}),Ss("paste",_e,Le),Ss("dragover",_e,Be),Ss("dragleave",_e,pe),Ss("drop",_e,We),Q("click",ue,Pe),Q("touchstart",Se,E),I(e,L),dt(Ue)}at(["touchstart","touchend","click","mousedown"]);var Ro=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(){}},ly={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fs,Sh,Au,hy=(Au=class{constructor(){ee(this,Fs,ly);ee(this,Sh,!1)}setTimeoutProvider(e){V(this,Fs,e)}setTimeout(e,t){return _(this,Fs).setTimeout(e,t)}clearTimeout(e){_(this,Fs).clearTimeout(e)}setInterval(e,t){return _(this,Fs).setInterval(e,t)}clearInterval(e){_(this,Fs).clearInterval(e)}},Fs=new WeakMap,Sh=new WeakMap,Au),pr=new hy;function cy(e){setTimeout(e,0)}var xn=typeof window>"u"||"Deno"in globalThis;function yi(){}function uy(e,t){return typeof e=="function"?e(t):e}function rh(e){return typeof e=="number"&&e>=0&&e!==1/0}function l_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ir(e,t){return typeof e=="function"?e(t):e}function ki(e,t){return typeof e=="function"?e(t):e}function gu(e,t){const{type:i="all",exact:s,fetchStatus:r,predicate:n,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==Vh(o,t.options))return!1}else if(!ho(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 mu(e,t){const{exact:i,status:s,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(lo(t.options.mutationKey)!==lo(n))return!1}else if(!ho(t.options.mutationKey,n))return!1}return!(s&&t.state.status!==s||r&&!r(t))}function Vh(e,t){return((t==null?void 0:t.queryKeyHashFn)||lo)(e)}function lo(e){return JSON.stringify(e,(t,i)=>oh(i)?Object.keys(i).sort().reduce((s,r)=>(s[r]=i[r],s),{}):i)}function ho(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>ho(e[i],t[i])):!1}var dy=Object.prototype.hasOwnProperty;function h_(e,t,i=0){if(e===t)return e;if(i>500)return t;const s=bu(e)&&bu(t);if(!s&&!(oh(e)&&oh(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:dy.call(e,u))&&h++;continue}if(f===null||v===null||typeof f!="object"||typeof v!="object"){c[u]=v;continue}const p=h_(f,v,i+1);c[u]=p,p===f&&h++}return n===l&&h===n?e:c}function nh(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 bu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function oh(e){if(!Su(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!Su(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Su(e){return Object.prototype.toString.call(e)==="[object Object]"}function fy(e){return new Promise(t=>{pr.setTimeout(t,e)})}function ah(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?h_(e,t):t}function _y(e,t,i=0){const s=[...e,t];return i&&s.length>i?s.slice(1):s}function vy(e,t,i=0){const s=[t,...e];return i&&s.length>i?s.slice(0,-1):s}var Yh=Symbol();function c_(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Yh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function py(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 wr,Ws,an,Ou,gy=(Ou=class extends Ro{constructor(){super();ee(this,wr);ee(this,Ws);ee(this,an);V(this,an,t=>{if(!xn&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){_(this,Ws)||this.setEventListener(_(this,an))}onUnsubscribe(){var t;this.hasListeners()||((t=_(this,Ws))==null||t.call(this),V(this,Ws,void 0))}setEventListener(t){var i;V(this,an,t),(i=_(this,Ws))==null||i.call(this),V(this,Ws,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){_(this,wr)!==t&&(V(this,wr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof _(this,wr)=="boolean"?_(this,wr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},wr=new WeakMap,Ws=new WeakMap,an=new WeakMap,Ou),Gh=new gy;function lh(){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 my=cy;function by(){let e=[],t=0,i=l=>{l()},s=l=>{l()},r=my;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 Kt=by(),ln,Hs,hn,Iu,Sy=(Iu=class extends Ro{constructor(){super();ee(this,ln,!0);ee(this,Hs);ee(this,hn);V(this,hn,t=>{if(!xn&&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,Hs)||this.setEventListener(_(this,hn))}onUnsubscribe(){var t;this.hasListeners()||((t=_(this,Hs))==null||t.call(this),V(this,Hs,void 0))}setEventListener(t){var i;V(this,hn,t),(i=_(this,Hs))==null||i.call(this),V(this,Hs,t(this.setOnline.bind(this)))}setOnline(t){_(this,ln)!==t&&(V(this,ln,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return _(this,ln)}},ln=new WeakMap,Hs=new WeakMap,hn=new WeakMap,Iu),la=new Sy;function yy(e){return Math.min(1e3*2**e,3e4)}function u_(e){return(e??"online")==="online"?la.isOnline():!0}var hh=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function d_(e){let t=!1,i=0,s;const r=lh(),n=()=>r.status!=="pending",o=b=>{var g;if(!n()){const y=new hh(b);f(y),(g=e.onCancel)==null||g.call(e,y)}},l=()=>{t=!0},c=()=>{t=!1},h=()=>Gh.isFocused()&&(e.networkMode==="always"||la.isOnline())&&e.canRun(),d=()=>u_(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 g;s=y=>{(n()||h())&&b(y)},(g=e.onPause)==null||g.call(e)}).then(()=>{var b;s=void 0,n()||(b=e.onContinue)==null||b.call(e)}),p=()=>{if(n())return;let b;const g=i===0?e.initialPromise:void 0;try{b=g??e.fn()}catch(y){b=Promise.reject(y)}Promise.resolve(b).then(u).catch(y=>{var M;if(n())return;const R=e.retry??(xn?0:3),C=e.retryDelay??yy,w=typeof C=="function"?C(i,y):C,x=R===!0||typeof R=="number"&&i<R||typeof R=="function"&&R(i,y);if(t||!x){f(y);return}i++,(M=e.onFail)==null||M.call(e,i,y),fy(w).then(()=>h()?void 0:v()).then(()=>{t?f(y):p()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(s==null||s(),r),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?p():v().then(p),r)}}var Cr,Nu,f_=(Nu=class{constructor(){ee(this,Cr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rh(this.gcTime)&&V(this,Cr,pr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(xn?1/0:300*1e3))}clearGcTimeout(){_(this,Cr)&&(pr.clearTimeout(_(this,Cr)),V(this,Cr,void 0))}},Cr=new WeakMap,Nu),kr,cn,Si,xr,wt,vo,Er,Fi,fs,Fu,wy=(Fu=class extends f_{constructor(t){super();ee(this,Fi);ee(this,kr);ee(this,cn);ee(this,Si);ee(this,xr);ee(this,wt);ee(this,vo);ee(this,Er);V(this,Er,!1),V(this,vo,t.defaultOptions),this.setOptions(t.options),this.observers=[],V(this,xr,t.client),V(this,Si,_(this,xr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,V(this,kr,wu(this.options)),this.state=t.state??_(this,kr),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=_(this,wt))==null?void 0:t.promise}setOptions(t){if(this.options={..._(this,vo),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=wu(this.options);i.data!==void 0&&(this.setState(yu(i.data,i.dataUpdatedAt)),V(this,kr,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&_(this,Si).remove(this)}setData(t,i){const s=ah(this.state.data,t,this.options);return ke(this,Fi,fs).call(this,{data:s,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),s}setState(t,i){ke(this,Fi,fs).call(this,{type:"setState",state:t,setStateOptions:i})}cancel(t){var s,r;const i=(s=_(this,wt))==null?void 0:s.promise;return(r=_(this,wt))==null||r.cancel(t),i?i.then(yi).catch(yi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(_(this,kr))}isActive(){return this.observers.some(t=>ki(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Yh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ir(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:!l_(this.state.dataUpdatedAt,t)}onFocus(){var i;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(i=_(this,wt))==null||i.continue()}onOnline(){var i;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(i=_(this,wt))==null||i.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),_(this,Si).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,wt)&&(_(this,Er)?_(this,wt).cancel({revert:!0}):_(this,wt).cancelRetry()),this.scheduleGc()),_(this,Si).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ke(this,Fi,fs).call(this,{type:"invalidate"})}async fetch(t,i){var c,h,d,u,f,v,p,b,g,y,R,C;if(this.state.fetchStatus!=="idle"&&((c=_(this,wt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(i!=null&&i.cancelRefetch))this.cancel({silent:!0});else if(_(this,wt))return _(this,wt).continueRetry(),_(this,wt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(x=>x.options.queryFn);w&&this.setOptions(w.options)}const s=new AbortController,r=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(V(this,Er,!0),s.signal)})},n=()=>{const w=c_(this.options,i),M=(()=>{const N={client:_(this,xr),queryKey:this.queryKey,meta:this.meta};return r(N),N})();return V(this,Er,!1),this.options.persister?this.options.persister(w,M,this):w(M)},l=(()=>{const w={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:_(this,xr),state:this.state,fetchFn:n};return r(w),w})();(h=this.options.behavior)==null||h.onFetch(l,this),V(this,cn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&ke(this,Fi,fs).call(this,{type:"fetch",meta:(u=l.fetchOptions)==null?void 0:u.meta}),V(this,wt,d_({initialPromise:i==null?void 0:i.initialPromise,fn:l.fetchFn,onCancel:w=>{w instanceof hh&&w.revert&&this.setState({..._(this,cn),fetchStatus:"idle"}),s.abort()},onFail:(w,x)=>{ke(this,Fi,fs).call(this,{type:"failed",failureCount:w,error:x})},onPause:()=>{ke(this,Fi,fs).call(this,{type:"pause"})},onContinue:()=>{ke(this,Fi,fs).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const w=await _(this,wt).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(v=(f=_(this,Si).config).onSuccess)==null||v.call(f,w,this),(b=(p=_(this,Si).config).onSettled)==null||b.call(p,w,this.state.error,this),w}catch(w){if(w instanceof hh){if(w.silent)return _(this,wt).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw ke(this,Fi,fs).call(this,{type:"error",error:w}),(y=(g=_(this,Si).config).onError)==null||y.call(g,w,this),(C=(R=_(this,Si).config).onSettled)==null||C.call(R,this.state.data,w,this),w}finally{this.scheduleGc()}}},kr=new WeakMap,cn=new WeakMap,Si=new WeakMap,xr=new WeakMap,wt=new WeakMap,vo=new WeakMap,Er=new WeakMap,Fi=new WeakSet,fs=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,...__(s.data,this.options),fetchMeta:t.meta??null};case"success":const r={...s,...yu(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return V(this,cn,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),Kt.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),_(this,Si).notify({query:this,type:"updated",action:t})})},Fu);function __(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:u_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function yu(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function wu(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 Zt,ze,po,jt,Pr,un,gs,zs,go,dn,fn,Rr,Dr,Us,_n,Ge,Vn,ch,uh,dh,fh,_h,vh,ph,v_,Wu,Cy=(Wu=class extends Ro{constructor(t,i){super();ee(this,Ge);ee(this,Zt);ee(this,ze);ee(this,po);ee(this,jt);ee(this,Pr);ee(this,un);ee(this,gs);ee(this,zs);ee(this,go);ee(this,dn);ee(this,fn);ee(this,Rr);ee(this,Dr);ee(this,Us);ee(this,_n,new Set);this.options=i,V(this,Zt,t),V(this,zs,null),V(this,gs,lh()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(_(this,ze).addObserver(this),Cu(_(this,ze),this.options)?ke(this,Ge,Vn).call(this):this.updateResult(),ke(this,Ge,fh).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return gh(_(this,ze),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return gh(_(this,ze),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ke(this,Ge,_h).call(this),ke(this,Ge,vh).call(this),_(this,ze).removeObserver(this)}setOptions(t){const i=this.options,s=_(this,ze);if(this.options=_(this,Zt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ki(this.options.enabled,_(this,ze))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ke(this,Ge,ph).call(this),_(this,ze).setOptions(this.options),i._defaulted&&!nh(this.options,i)&&_(this,Zt).getQueryCache().notify({type:"observerOptionsUpdated",query:_(this,ze),observer:this});const r=this.hasListeners();r&&ku(_(this,ze),s,this.options,i)&&ke(this,Ge,Vn).call(this),this.updateResult(),r&&(_(this,ze)!==s||ki(this.options.enabled,_(this,ze))!==ki(i.enabled,_(this,ze))||ir(this.options.staleTime,_(this,ze))!==ir(i.staleTime,_(this,ze)))&&ke(this,Ge,ch).call(this);const n=ke(this,Ge,uh).call(this);r&&(_(this,ze)!==s||ki(this.options.enabled,_(this,ze))!==ki(i.enabled,_(this,ze))||n!==_(this,Us))&&ke(this,Ge,dh).call(this,n)}getOptimisticResult(t){const i=_(this,Zt).getQueryCache().build(_(this,Zt),t),s=this.createResult(i,t);return xy(this,s)&&(V(this,jt,s),V(this,un,this.options),V(this,Pr,_(this,ze).state)),s}getCurrentResult(){return _(this,jt)}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,gs).status==="pending"&&_(this,gs).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){_(this,_n).add(t)}getCurrentQuery(){return _(this,ze)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=_(this,Zt).defaultQueryOptions(t),s=_(this,Zt).getQueryCache().build(_(this,Zt),i);return s.fetch().then(()=>this.createResult(s,i))}fetch(t){return ke(this,Ge,Vn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),_(this,jt)))}createResult(t,i){var J;const s=_(this,ze),r=this.options,n=_(this,jt),o=_(this,Pr),l=_(this,un),h=t!==s?t.state:_(this,po),{state:d}=t;let u={...d},f=!1,v;if(i._optimisticResults){const oe=this.hasListeners(),Y=!oe&&Cu(t,i),W=oe&&ku(t,s,i,r);(Y||W)&&(u={...u,...__(d.data,t.options)}),i._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:g}=u;v=u.data;let y=!1;if(i.placeholderData!==void 0&&v===void 0&&g==="pending"){let oe;n!=null&&n.isPlaceholderData&&i.placeholderData===(l==null?void 0:l.placeholderData)?(oe=n.data,y=!0):oe=typeof i.placeholderData=="function"?i.placeholderData((J=_(this,fn))==null?void 0:J.state.data,_(this,fn)):i.placeholderData,oe!==void 0&&(g="success",v=ah(n==null?void 0:n.data,oe,i),f=!0)}if(i.select&&v!==void 0&&!y)if(n&&v===(o==null?void 0:o.data)&&i.select===_(this,go))v=_(this,dn);else try{V(this,go,i.select),v=i.select(v),v=ah(n==null?void 0:n.data,v,i),V(this,dn,v),V(this,zs,null)}catch(oe){V(this,zs,oe)}_(this,zs)&&(p=_(this,zs),v=_(this,dn),b=Date.now(),g="error");const R=u.fetchStatus==="fetching",C=g==="pending",w=g==="error",x=C&&R,M=v!==void 0,j={status:g,fetchStatus:u.fetchStatus,isPending:C,isSuccess:g==="success",isError:w,isInitialLoading:x,isLoading:x,data:v,dataUpdatedAt:u.dataUpdatedAt,error:p,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&&!C,isLoadingError:w&&!M,isPaused:u.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&M,isStale:Xh(t,i),refetch:this.refetch,promise:_(this,gs),isEnabled:ki(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const oe=j.data!==void 0,Y=j.status==="error"&&!oe,W=T=>{Y?T.reject(j.error):oe&&T.resolve(j.data)},O=()=>{const T=V(this,gs,j.promise=lh());W(T)},B=_(this,gs);switch(B.status){case"pending":t.queryHash===s.queryHash&&W(B);break;case"fulfilled":(Y||j.data!==B.value)&&O();break;case"rejected":(!Y||j.error!==B.reason)&&O();break}}return j}updateResult(){const t=_(this,jt),i=this.createResult(_(this,ze),this.options);if(V(this,Pr,_(this,ze).state),V(this,un,this.options),_(this,Pr).data!==void 0&&V(this,fn,_(this,ze)),nh(i,t))return;V(this,jt,i);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!_(this,_n).size)return!0;const o=new Set(n??_(this,_n));return this.options.throwOnError&&o.add("error"),Object.keys(_(this,jt)).some(l=>{const c=l;return _(this,jt)[c]!==t[c]&&o.has(c)})};ke(this,Ge,v_).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ke(this,Ge,fh).call(this)}},Zt=new WeakMap,ze=new WeakMap,po=new WeakMap,jt=new WeakMap,Pr=new WeakMap,un=new WeakMap,gs=new WeakMap,zs=new WeakMap,go=new WeakMap,dn=new WeakMap,fn=new WeakMap,Rr=new WeakMap,Dr=new WeakMap,Us=new WeakMap,_n=new WeakMap,Ge=new WeakSet,Vn=function(t){ke(this,Ge,ph).call(this);let i=_(this,ze).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(yi)),i},ch=function(){ke(this,Ge,_h).call(this);const t=ir(this.options.staleTime,_(this,ze));if(xn||_(this,jt).isStale||!rh(t))return;const s=l_(_(this,jt).dataUpdatedAt,t)+1;V(this,Rr,pr.setTimeout(()=>{_(this,jt).isStale||this.updateResult()},s))},uh=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(_(this,ze)):this.options.refetchInterval)??!1},dh=function(t){ke(this,Ge,vh).call(this),V(this,Us,t),!(xn||ki(this.options.enabled,_(this,ze))===!1||!rh(_(this,Us))||_(this,Us)===0)&&V(this,Dr,pr.setInterval(()=>{(this.options.refetchIntervalInBackground||Gh.isFocused())&&ke(this,Ge,Vn).call(this)},_(this,Us)))},fh=function(){ke(this,Ge,ch).call(this),ke(this,Ge,dh).call(this,ke(this,Ge,uh).call(this))},_h=function(){_(this,Rr)&&(pr.clearTimeout(_(this,Rr)),V(this,Rr,void 0))},vh=function(){_(this,Dr)&&(pr.clearInterval(_(this,Dr)),V(this,Dr,void 0))},ph=function(){const t=_(this,Zt).getQueryCache().build(_(this,Zt),this.options);if(t===_(this,ze))return;const i=_(this,ze);V(this,ze,t),V(this,po,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},v_=function(t){Kt.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(_(this,jt))}),_(this,Zt).getQueryCache().notify({query:_(this,ze),type:"observerResultsUpdated"})})},Wu);function ky(e,t){return ki(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Cu(e,t){return ky(e,t)||e.state.data!==void 0&&gh(e,t,t.refetchOnMount)}function gh(e,t,i){if(ki(t.enabled,e)!==!1&&ir(t.staleTime,e)!=="static"){const s=typeof i=="function"?i(e):i;return s==="always"||s!==!1&&Xh(e,t)}return!1}function ku(e,t,i,s){return(e!==t||ki(s.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&Xh(e,i)}function Xh(e,t){return ki(t.enabled,e)!==!1&&e.isStaleByTime(ir(t.staleTime,e))}function xy(e,t){return!nh(e.getCurrentResult(),t)}function xu(e){return{onFetch:(t,i)=>{var d,u,f,v,p;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=((p=t.state.data)==null?void 0:p.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const h=async()=>{let b=!1;const g=C=>{py(C,()=>t.signal,()=>b=!0)},y=c_(t.options,t.fetchOptions),R=async(C,w,x)=>{if(b)return Promise.reject();if(w==null&&C.pages.length)return Promise.resolve(C);const N=(()=>{const Y={client:t.client,queryKey:t.queryKey,pageParam:w,direction:x?"backward":"forward",meta:t.options.meta};return g(Y),Y})(),j=await y(N),{maxPages:J}=t.options,oe=x?vy:_y;return{pages:oe(C.pages,j,J),pageParams:oe(C.pageParams,w,J)}};if(r&&n.length){const C=r==="backward",w=C?Ey:Eu,x={pages:n,pageParams:o},M=w(s,x);l=await R(x,M,C)}else{const C=e??n.length;do{const w=c===0?o[0]??s.initialPageParam:Eu(s,l);if(c>0&&w==null)break;l=await R(l,w),c++}while(c<C)}return l};t.options.persister?t.fetchFn=()=>{var b,g;return(g=(b=t.options).persister)==null?void 0:g.call(b,h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=h}}}function Eu(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 Ey(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 mo,Zi,Ut,Tr,es,Os,Hu,Py=(Hu=class extends f_{constructor(t){super();ee(this,es);ee(this,mo);ee(this,Zi);ee(this,Ut);ee(this,Tr);V(this,mo,t.client),this.mutationId=t.mutationId,V(this,Ut,t.mutationCache),V(this,Zi,[]),this.state=t.state||Ry(),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,Zi).includes(t)||(_(this,Zi).push(t),this.clearGcTimeout(),_(this,Ut).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){V(this,Zi,_(this,Zi).filter(i=>i!==t)),this.scheduleGc(),_(this,Ut).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){_(this,Zi).length||(this.state.status==="pending"?this.scheduleGc():_(this,Ut).remove(this))}continue(){var t;return((t=_(this,Tr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,c,h,d,u,f,v,p,b,g,y,R,C,w,x,M,N;const i=()=>{ke(this,es,Os).call(this,{type:"continue"})},s={client:_(this,mo),meta:this.options.meta,mutationKey:this.options.mutationKey};V(this,Tr,d_({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(j,J)=>{ke(this,es,Os).call(this,{type:"failed",failureCount:j,error:J})},onPause:()=>{ke(this,es,Os).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>_(this,Ut).canRun(this)}));const r=this.state.status==="pending",n=!_(this,Tr).canStart();try{if(r)i();else{ke(this,es,Os).call(this,{type:"pending",variables:t,isPaused:n}),_(this,Ut).config.onMutate&&await _(this,Ut).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&&ke(this,es,Os).call(this,{type:"pending",context:J,variables:t,isPaused:n})}const j=await _(this,Tr).start();return await((h=(c=_(this,Ut).config).onSuccess)==null?void 0:h.call(c,j,t,this.state.context,this,s)),await((u=(d=this.options).onSuccess)==null?void 0:u.call(d,j,t,this.state.context,s)),await((v=(f=_(this,Ut).config).onSettled)==null?void 0:v.call(f,j,null,this.state.variables,this.state.context,this,s)),await((b=(p=this.options).onSettled)==null?void 0:b.call(p,j,null,t,this.state.context,s)),ke(this,es,Os).call(this,{type:"success",data:j}),j}catch(j){try{await((y=(g=_(this,Ut).config).onError)==null?void 0:y.call(g,j,t,this.state.context,this,s))}catch(J){Promise.reject(J)}try{await((C=(R=this.options).onError)==null?void 0:C.call(R,j,t,this.state.context,s))}catch(J){Promise.reject(J)}try{await((x=(w=_(this,Ut).config).onSettled)==null?void 0:x.call(w,void 0,j,this.state.variables,this.state.context,this,s))}catch(J){Promise.reject(J)}try{await((N=(M=this.options).onSettled)==null?void 0:N.call(M,void 0,j,t,this.state.context,s))}catch(J){Promise.reject(J)}throw ke(this,es,Os).call(this,{type:"error",error:j}),j}finally{_(this,Ut).runNext(this)}}},mo=new WeakMap,Zi=new WeakMap,Ut=new WeakMap,Tr=new WeakMap,es=new WeakSet,Os=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),Kt.batch(()=>{_(this,Zi).forEach(s=>{s.onMutationUpdate(t)}),_(this,Ut).notify({mutation:this,type:"updated",action:t})})},Hu);function Ry(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ms,Wi,bo,zu,Dy=(zu=class extends Ro{constructor(t={}){super();ee(this,ms);ee(this,Wi);ee(this,bo);this.config=t,V(this,ms,new Set),V(this,Wi,new Map),V(this,bo,0)}build(t,i,s){const r=new Py({client:t,mutationCache:this,mutationId:++Mo(this,bo)._,options:t.defaultMutationOptions(i),state:s});return this.add(r),r}add(t){_(this,ms).add(t);const i=zo(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,ms).delete(t)){const i=zo(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=zo(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=zo(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(){Kt.batch(()=>{_(this,ms).forEach(t=>{this.notify({type:"removed",mutation:t})}),_(this,ms).clear(),_(this,Wi).clear()})}getAll(){return Array.from(_(this,ms))}find(t){const i={exact:!0,...t};return this.getAll().find(s=>mu(i,s))}findAll(t={}){return this.getAll().filter(i=>mu(t,i))}notify(t){Kt.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return Kt.batch(()=>Promise.all(t.map(i=>i.continue().catch(yi))))}},ms=new WeakMap,Wi=new WeakMap,bo=new WeakMap,zu);function zo(e){var t;return(t=e.options.scope)==null?void 0:t.id}var ts,Uu,Ty=(Uu=class extends Ro{constructor(t={}){super();ee(this,ts);this.config=t,V(this,ts,new Map)}build(t,i,s){const r=i.queryKey,n=i.queryHash??Vh(r,i);let o=this.get(n);return o||(o=new wy({client:t,queryKey:r,queryHash:n,options:t.defaultQueryOptions(i),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){_(this,ts).has(t.queryHash)||(_(this,ts).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=_(this,ts).get(t.queryHash);i&&(t.destroy(),i===t&&_(this,ts).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return _(this,ts).get(t)}getAll(){return[..._(this,ts).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(s=>gu(i,s))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(s=>gu(t,s)):i}notify(t){Kt.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){Kt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Kt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ts=new WeakMap,Uu),nt,Ks,qs,vn,pn,js,gn,mn,Ku,p_=(Ku=class{constructor(e={}){ee(this,nt);ee(this,Ks);ee(this,qs);ee(this,vn);ee(this,pn);ee(this,js);ee(this,gn);ee(this,mn);V(this,nt,e.queryCache||new Ty),V(this,Ks,e.mutationCache||new Dy),V(this,qs,e.defaultOptions||{}),V(this,vn,new Map),V(this,pn,new Map),V(this,js,0)}mount(){Mo(this,js)._++,_(this,js)===1&&(V(this,gn,Gh.subscribe(async e=>{e&&(await this.resumePausedMutations(),_(this,nt).onFocus())})),V(this,mn,la.subscribe(async e=>{e&&(await this.resumePausedMutations(),_(this,nt).onOnline())})))}unmount(){var e,t;Mo(this,js)._--,_(this,js)===0&&((e=_(this,gn))==null||e.call(this),V(this,gn,void 0),(t=_(this,mn))==null||t.call(this),V(this,mn,void 0))}isFetching(e){return _(this,nt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return _(this,Ks).findAll({...e,status:"pending"}).length}getQueryData(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=_(this,nt).get(t.queryHash))==null?void 0:i.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),i=_(this,nt).build(this,t),s=i.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime(ir(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return _(this,nt).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,nt).get(s.queryHash),n=r==null?void 0:r.state.data,o=uy(t,n);if(o!==void 0)return _(this,nt).build(this,s).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return Kt.batch(()=>_(this,nt).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,i)]))}getQueryState(e){var i;const t=this.defaultQueryOptions({queryKey:e});return(i=_(this,nt).get(t.queryHash))==null?void 0:i.state}removeQueries(e){const t=_(this,nt);Kt.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=_(this,nt);return Kt.batch(()=>(i.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},s=Kt.batch(()=>_(this,nt).findAll(e).map(r=>r.cancel(i)));return Promise.all(s).then(yi).catch(yi)}invalidateQueries(e,t={}){return Kt.batch(()=>(_(this,nt).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=Kt.batch(()=>_(this,nt).findAll(e).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let n=r.fetch(void 0,i);return i.throwOnError||(n=n.catch(yi)),r.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(yi)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const i=_(this,nt).build(this,t);return i.isStaleByTime(ir(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(yi).catch(yi)}fetchInfiniteQuery(e){return e.behavior=xu(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(yi).catch(yi)}ensureInfiniteQueryData(e){return e.behavior=xu(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return la.isOnline()?_(this,Ks).resumePausedMutations():Promise.resolve()}getQueryCache(){return _(this,nt)}getMutationCache(){return _(this,Ks)}getDefaultOptions(){return _(this,qs)}setDefaultOptions(e){V(this,qs,e)}setQueryDefaults(e,t){_(this,vn).set(lo(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[..._(this,vn).values()],i={};return t.forEach(s=>{ho(e,s.queryKey)&&Object.assign(i,s.defaultOptions)}),i}setMutationDefaults(e,t){_(this,pn).set(lo(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[..._(this,pn).values()],i={};return t.forEach(s=>{ho(e,s.mutationKey)&&Object.assign(i,s.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={..._(this,qs).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Vh(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===Yh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{..._(this,qs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){_(this,nt).clear(),_(this,Ks).clear()}},nt=new WeakMap,Ks=new WeakMap,qs=new WeakMap,vn=new WeakMap,pn=new WeakMap,js=new WeakMap,gn=new WeakMap,mn=new WeakMap,Ku);const g_=Symbol("QueryClient"),My=()=>{const e=Zu(g_);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},By=e=>{hv(g_,e)},Ly=Symbol("isRestoring"),Ay=()=>{try{return Zu(Ly)??{current:!1}}catch{return{current:!1}}};function Oy(){return Ay()}function Iy(e){return My()}var Ny=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],Fy=["difference","intersection","symmetricDifference","union"],Pu=!1,bn,Hi,Vs,da,En,m_,b_;const fa=class fa extends Set{constructor(i){super();ee(this,En);ee(this,bn,new Map);ee(this,Hi,F(0));ee(this,Vs,F(0));ee(this,da,ks||-1);if(i){for(var s of i)super.add(s);_(this,Vs).v=super.size}Pu||ke(this,En,b_).call(this)}has(i){var s=super.has(i),r=_(this,bn),n=r.get(i);if(n===void 0){if(!s)return a(_(this,Hi)),!1;n=ke(this,En,m_).call(this,!0),r.set(i,n)}return a(n),s}add(i){return super.has(i)||(super.add(i),m(_(this,Vs),super.size),Zs(_(this,Hi))),this}delete(i){var s=super.delete(i),r=_(this,bn),n=r.get(i);return n!==void 0&&(r.delete(i),m(n,!1)),s&&(m(_(this,Vs),super.size),Zs(_(this,Hi))),s}clear(){if(super.size!==0){super.clear();var i=_(this,bn);for(var s of i.values())m(s,!1);i.clear(),m(_(this,Vs),0),Zs(_(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,Vs))}};bn=new WeakMap,Hi=new WeakMap,Vs=new WeakMap,da=new WeakMap,En=new WeakSet,m_=function(i){return ks===_(this,da)?F(i):sr(i)},b_=function(){Pu=!0;var i=fa.prototype,s=Set.prototype;for(const r of Ny)i[r]=function(...n){return a(_(this,Hi)),s[r].apply(this,n)};for(const r of Fy)i[r]=function(...n){a(_(this,Hi));var o=s[r].apply(this,n);return new fa(o)}};let mh=fa;function Wy(e){const t=Array.isArray(e)?[]:{},i=new mh,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)&&zy(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]=Hy(()=>n[h])}return r(e),[s,r]}const S_=Symbol("LazyValue");function Hy(e){return e[S_]=!0,e}function zy(e){return!!e[S_]}function Uy(e,t){switch(e){case"post":rs(t);break;case"pre":Fv(t);break}}const el=(e,t,i)=>{let s=!1,r=Array.isArray(e)?[]:void 0;Uy(t,()=>{const n=Array.isArray(e)?e.map(l=>l()):e();if(!s){s=!0,r=n;return}const o=nr(()=>i(n,r));return r=n,o})};function Ky(e,t,i){const s=fe(()=>Iy()),r=Oy(),n=fe(()=>{const d=a(s).defaultQueryOptions(e());return d._optimisticResults=r.current?"isRestoring":"optimistic",d});let o=F(Je(new t(a(s),a(n))));el(()=>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]=Wy(l());return rs(()=>{const d=r.current?()=>{}:a(o).subscribe(()=>h(l()));return a(o).updateResult(),d}),el(()=>a(n),"pre",()=>{a(o).setOptions(a(n))}),el(()=>[a(n),a(o)],"pre",()=>{h(l())}),c}function ha(e,t){return Ky(e,Cy)}function qy(e,t){ut(t,!0);const i=as(t,"client",19,()=>new p_);Dn(()=>{i().mount()}),By(i()),_p(()=>{i().unmount()});var s=xs(),r=vt(s);ip(r,()=>t.children),I(e,s),dt()}var jy=H('<div class="branch-error svelte-1ogsozk"> </div>'),Vy=H('<div class="branch-loading svelte-1ogsozk">Loading...</div>'),Yy=H('<div class="branch-empty svelte-1ogsozk">No branches match</div>'),Gy=H('<span class="branch-check svelte-1ogsozk">✓</span>'),Xy=H('<span class="branch-check branch-check--empty svelte-1ogsozk"></span>'),Qy=H('<span class="branch-spinner svelte-1ogsozk">…</span>'),Jy=H('<li role="option"><!> <span class="branch-option-name svelte-1ogsozk"> </span> <!></li>'),$y=H('<ul class="branch-list svelte-1ogsozk"></ul>'),Zy=H('<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>'),ew=H('<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 tw(e,t){ut(t,!0);let i=F(!1),s=F(""),r=F(null),n=F(null),o=F(null),l=F(null);const c=ha(()=>({queryKey:["branches",t.workspacePath],queryFn:()=>Bh(t.workspacePath),staleTime:3e4,enabled:a(i)}));let h=fe(()=>{const x=c.data??[];if(!a(s).trim())return x;const M=a(s).toLowerCase();return x.filter(N=>N.toLowerCase().includes(M))});function d(){m(i,!0),m(s,""),m(l,null),requestAnimationFrame(()=>{var x;return(x=a(n))==null?void 0:x.focus()})}function u(){m(i,!1),m(s,"")}async function f(x){if(x===t.currentBranch){u();return}m(o,x,!0),m(l,null);try{const M=await Ep(t.workspacePath,x);M.success?(u(),t.onSwitch(x)):m(l,M.error??"Failed to switch branch",!0)}catch{m(l,"Failed to switch branch")}finally{m(o,null)}}function v(x){a(i)&&a(r)&&document.contains(x.target)&&!a(r).contains(x.target)&&u()}function p(x){x.key==="Escape"&&a(i)&&(u(),x.stopPropagation())}var b=ew();Ss("click",$o,v);var g=S(b),y=k(S(g),2),R=S(y),C=k(g,2);{var w=x=>{var M=Zy(),N=S(M),j=S(N);et(j,T=>m(n,T),()=>a(n));var J=k(N,2);{var oe=T=>{var q=jy(),D=S(q);he(()=>re(D,a(l))),I(T,q)};ae(J,T=>{a(l)&&T(oe)})}var Y=k(J,2);{var W=T=>{var q=Vy();I(T,q)},O=T=>{var q=Yy();I(T,q)},B=T=>{var q=$y();Nt(q,20,()=>a(h),D=>D,(D,E)=>{var $=Jy();let X;var ce=S($);{var be=G=>{var ve=Gy();I(G,ve)},ge=G=>{var ve=Xy();I(G,ve)};ae(ce,G=>{E===t.currentBranch?G(be):G(ge,!1)})}var xe=k(ce,2),Pe=S(xe),Re=k(xe,2);{var we=G=>{var ve=Qy();I(G,ve)};ae(Re,G=>{a(o)===E&&G(we)})}he(()=>{X=Qe($,1,"branch-option svelte-1ogsozk",null,X,{"branch-current":E===t.currentBranch,"branch-switching":a(o)===E}),Ne($,"aria-selected",E===t.currentBranch),re(Pe,E)}),Q("mousedown",$,()=>f(E)),I(D,$)}),I(T,q)};ae(Y,T=>{c.isLoading?T(W):a(h).length===0?T(O,1):T(B,!1)})}Q("keydown",M,p),Q("keydown",j,p),xi(j,()=>a(s),T=>m(s,T)),I(x,M)};ae(C,x=>{a(i)&&x(w)})}et(b,x=>m(r,x),()=>a(r)),he(()=>{Ne(g,"aria-expanded",a(i)),re(R,t.currentBranch)}),Q("click",g,d),I(e,b),dt()}at(["click","keydown","mousedown"]);var iw=H('<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>'),sw=H('<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),rw=H('<span class="bar-loading svelte-1shtc4l">…</span>'),nw=H('<button class="action-btn action-btn--secondary svelte-1shtc4l"> </button>'),ow=H("<button> </button>"),aw=H("<!> <!>",1),lw=H('<div><div class="bar-left svelte-1shtc4l"><!> <!></div> <!> <div class="bar-right svelte-1shtc4l"><!></div></div>');function hw(e,t){ut(t,!0);let i=F(Je(t.branchName));rs(()=>{m(i,t.branchName,!0)}),rs(()=>{!t.branchName&&t.workspacePath&&xp(t.workspacePath).then(Y=>{Y&&m(i,Y,!0)})});const s=ha(()=>({queryKey:["pr",t.workspacePath,a(i)],queryFn:()=>kp(t.workspacePath,a(i)),staleTime:6e4,refetchOnWindowFocus:!0})),r=ha(()=>{var Y;return{queryKey:["ci-status",t.workspacePath,a(i)],queryFn:()=>Cp(t.workspacePath,a(i)),staleTime:3e4,refetchOnWindowFocus:!0,enabled:((Y=s.data)==null?void 0:Y.state)==="OPEN"}});rs(()=>{t.sessionId&&(s.refetch(),r.refetch())});let n=fe(()=>s.data??null),o=fe(()=>r.data??null),l=fe(()=>{var Y,W,O,B,T,q;return{commitsAhead:a(n)?1:0,prState:a(n)?a(n).isDraft?"DRAFT":a(n).state:null,ciPassing:((Y=a(o))==null?void 0:Y.passing)??0,ciFailing:((W=a(o))==null?void 0:W.failing)??0,ciPending:((O=a(o))==null?void 0:O.pending)??0,ciTotal:((B=a(o))==null?void 0:B.total)??0,mergeable:((T=a(n))==null?void 0:T.mergeable)??null,unresolvedCommentCount:((q=a(n))==null?void 0:q.unresolvedCommentCount)??0}}),c=fe(()=>Oh(a(l))),h=fe(()=>fg(a(c),a(l))),d=fe(()=>pf(a(c).color)),u=fe(()=>gf(a(c).color)),f=fe(()=>a(c).type!=="none");function v(Y=a(c)){var B,T,q,D;const W={branchName:a(i),baseBranch:((B=a(n))==null?void 0:B.baseRefName)??"",prNumber:((T=a(n))==null?void 0:T.number)??0,unresolvedCommentCount:((q=a(n))==null?void 0:q.unresolvedCommentCount)??0},O=vf(Y,W);O!==null?t.sessionId&&er(O+"\r"):(D=t.onArchive)==null||D.call(t)}function p(Y){m(i,Y,!0)}var b=lw();let g;var y=S(b),R=S(y);tw(R,{get workspacePath(){return t.workspacePath},get currentBranch(){return a(i)},onSwitch:p});var C=k(R,2);{var w=Y=>{var W=iw(),O=k(S(W),2),B=S(O);he(()=>re(B,a(n).baseRefName)),I(Y,W)};ae(C,Y=>{var W;(W=a(n))!=null&&W.baseRefName&&Y(w)})}var x=k(y,2);{var M=Y=>{var W=sw(),O=vt(W),B=S(O),T=S(B),q=k(O,2),D=S(q),E=S(D),$=k(D,2),X=S($);he(()=>{Ne(B,"href",a(n).url),Ne(B,"aria-label",`PR #${a(n).number??""}: ${a(n).title??""}`),re(T,`PR #${a(n).number??""} `),re(E,`+${a(n).additions??""}`),re(X,`-${a(n).deletions??""}`)}),I(Y,W)};ae(x,Y=>{a(n)&&Y(M)})}var N=k(x,2),j=S(N);{var J=Y=>{var W=rw();I(Y,W)},oe=Y=>{var W=aw(),O=vt(W);{var B=D=>{var E=nw(),$=S(E);he(()=>{Ne(E,"aria-label",a(h).label),re($,a(h).label)}),Q("click",E,()=>v(a(h))),I(D,E)};ae(O,D=>{a(h)&&D(B)})}var T=k(O,2);{var q=D=>{var E=ow();let $,X;var ce=S(E);he(()=>{$=Qe(E,1,"action-btn svelte-1shtc4l",null,$,{"action-btn--dark-text":a(u),"action-btn--disabled":a(c).type==="checks-running"}),E.disabled=a(c).type==="checks-running",Ne(E,"aria-label",a(c).label),X=Rn(E,"",X,{"--action-color":a(d)}),re(ce,a(c).label)}),Q("click",E,()=>v()),I(D,E)};ae(T,D=>{a(f)&&D(q)})}I(Y,W)};ae(j,Y=>{s.isLoading?Y(J):Y(oe,!1)})}he(()=>{var Y,W;return g=Qe(b,1,"pr-top-bar svelte-1shtc4l",null,g,{"bar-merged":((Y=a(n))==null?void 0:Y.state)==="MERGED","bar-conflicts":((W=a(n))==null?void 0:W.mergeable)==="CONFLICTING"})}),I(e,b),dt()}at(["click"]);var cw=H('<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>'),uw=H('<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>'),dw=H('<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 fw(e,t){ut(t,!0);let i=F(!1),s=F(null);function r(R){return R.type==="terminal"?"🖥":"🤖"}function n(R,C){R.stopPropagation(),t.onCloseSession(C)}function o(R,C){(R.key==="Enter"||R.key===" ")&&(R.stopPropagation(),t.onCloseSession(C))}function l(){m(i,!a(i))}function c(){m(i,!1),t.onNewSession()}function h(){m(i,!1),t.onNewTerminal()}function d(R){var C;a(i)&&a(s)&&document.contains(R.target)&&!((C=a(s).closest(".new-btn-wrap"))!=null&&C.contains(R.target))&&m(i,!1)}function u(R){var C;R.key==="Escape"&&a(i)&&(m(i,!1),(C=a(s))==null||C.focus())}var f=dw();Ss("click",$o,d);var v=S(f);Nt(v,21,()=>t.sessions,R=>R.id,(R,C)=>{const w=fe(()=>a(C).id===t.activeSessionId);var x=cw();let M;var N=S(x),j=S(N),J=k(N,2),oe=S(J),Y=k(J,2);he(W=>{M=Qe(x,1,"tab svelte-3dfyyn",null,M,{"tab--active":a(w)}),Ne(x,"aria-selected",a(w)),Ne(x,"aria-label",a(C).displayName||a(C).id),Ne(x,"tabindex",a(w)?0:-1),re(j,W),re(oe,a(C).displayName||a(C).repoName||a(C).id),Ne(Y,"aria-label",`Close ${(a(C).displayName||a(C).id)??""}`)},[()=>r(a(C))]),Q("click",x,()=>t.onSelectSession(a(C).id)),Q("click",Y,W=>n(W,a(C).id)),Q("keydown",Y,W=>o(W,a(C).id)),I(R,x)});var p=k(v,2),b=S(p);et(b,R=>m(s,R),()=>a(s));var g=k(b,2);{var y=R=>{var C=uw(),w=S(C),x=k(w,2);Q("keydown",C,u),Q("click",w,c),Q("click",x,h),I(R,C)};ae(g,R=>{a(i)&&R(y)})}he(()=>Ne(b,"aria-expanded",a(i))),Q("click",b,l),Q("keydown",b,u),I(e,f),dt()}at(["click","keydown"]);var _w=H('<div class="non-git-notice svelte-bvvs2r"><span class="non-git-msg svelte-bvvs2r">Not a git repository</span></div>'),vw=H('<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>'),pw=H('<div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>'),gw=H('<div class="section-message svelte-bvvs2r">Could not load pull requests</div>'),mw=H('<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>'),bw=H('<div class="section-message svelte-bvvs2r">No open pull requests</div>'),Sw=H('<input class="pr-search svelte-bvvs2r" type="text" placeholder="Filter PRs by title, number, or branch..."/>'),yw=H('<button class="pr-action-pill pr-conflict-pill svelte-bvvs2r" title="Open worktree and fix merge conflicts">Fix Conflicts</button>'),ww=H('<a class="pr-action-pill pr-merge-pill svelte-bvvs2r" target="_blank" rel="noopener noreferrer" title="Ready to merge on GitHub">Merge</a>'),Cw=H("<button> </button>"),kw=H('<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>'),xw=H('<!> <div class="scroll-container svelte-bvvs2r"><div class="pr-list svelte-bvvs2r"></div></div>',1),Ew=H('<div class="activity-row skeleton svelte-bvvs2r"><div class="skeleton-line skeleton-activity svelte-bvvs2r"></div></div>'),Pw=H('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),Rw=H('<div class="section-message svelte-bvvs2r">No recent commits (24h)</div>'),Dw=H('<span class="commit-branch svelte-bvvs2r"> </span>'),Tw=H('<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>'),Mw=H('<div class="scroll-container svelte-bvvs2r"><div class="activity-list svelte-bvvs2r"></div></div>'),Bw=H('<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),Lw=H('<button class="cta-btn svelte-bvvs2r"> </button>'),Aw=H('<div class="repo-dashboard svelte-bvvs2r"><!> <div class="cta-row svelte-bvvs2r"><button class="cta-btn svelte-bvvs2r">+ Start Session</button> <!></div></div>');function Ow(e,t){ut(t,!0);let i=as(t,"creatingWorktree",3,!1);const s=ha(()=>({queryKey:["dashboard",t.workspacePath],queryFn:()=>wp(t.workspacePath),staleTime:6e4,refetchOnWindowFocus:!0}));let r=fe(()=>s.data),n=fe(()=>s.isLoading),o=fe(()=>s.isError);function l(M){return M.state!=="OPEN"?"dot dot-muted":M.reviewDecision==="CHANGES_REQUESTED"?"dot dot-error":"dot dot-success"}function c(M){const N=M.state==="OPEN"?"OPEN":M.state==="MERGED"?"MERGED":"CLOSED";return Oh({commitsAhead:1,prState:N,ciFailing:0,ciPending:0,ciTotal:0,mergeable:M.mergeable??null,unresolvedCommentCount:0})}function h(M){return M.role==="author"?"by you":"review requested"}function d(M){return!M.branches||M.branches.length===0?"":"("+M.branches.join(", ")+")"}let u=F(""),f=fe(()=>a(r)?a(r).prs.length>5:!1),v=fe(()=>()=>{if(!a(r))return[];const M=a(u).toLowerCase().trim();return M?a(r).prs.filter(N=>N.title.toLowerCase().includes(M)||String(N.number).includes(M)||N.headRefName.toLowerCase().includes(M)):a(r).prs});var p=Aw(),b=S(p);{var g=M=>{var N=_w();I(M,N)},y=M=>{var N=Bw(),j=vt(N),J=k(S(j),2);{var oe=X=>{var ce=pw(),be=S(ce);Nt(be,20,()=>[1,2],io,(ge,xe)=>{var Pe=vw();I(ge,Pe)}),I(X,ce)},Y=X=>{var ce=gw();I(X,ce)},W=X=>{var ce=mw();I(X,ce)},O=X=>{var ce=bw();I(X,ce)},B=X=>{var ce=xw(),be=vt(ce);{var ge=Re=>{var we=Sw();xi(we,()=>a(u),G=>m(u,G)),I(Re,we)};ae(be,Re=>{a(f)&&Re(ge)})}var xe=k(be,2),Pe=S(xe);Nt(Pe,21,()=>a(v)(),Re=>Re.number,(Re,we)=>{const G=fe(()=>c(a(we))),ve=fe(()=>pf(a(G).color)),Le=fe(()=>gf(a(G).color));var je=kw(),Be=S(je),pe=S(Be),We=S(pe),He=k(We,2),Ue=S(He),L=k(pe,2),te=S(L),_e=S(te),ue=k(te,4),Se=S(ue),ne=k(ue,4),Ae=S(ne),Ke=k(Be,2),z=S(Ke),U=k(z,2);{var se=Ce=>{var ye=yw();Q("click",ye,()=>t.onFixConflicts(a(we))),I(Ce,ye)};ae(U,Ce=>{a(we).mergeable==="CONFLICTING"&&Ce(se)})}var P=k(U,2);{var A=Ce=>{var ye=ww();he(()=>Ne(ye,"href",a(we).url)),I(Ce,ye)};ae(P,Ce=>{a(we).mergeable==="MERGEABLE"&&a(we).state==="OPEN"&&Ce(A)})}var Z=k(P,2);{var me=Ce=>{var ye=Cw();let Te,Ze;var Ht=S(ye);he(()=>{Te=Qe(ye,1,"pr-action-pill svelte-bvvs2r",null,Te,{"dark-text":a(Le)}),Ne(ye,"title",a(G).label),Ze=Rn(ye,"",Ze,{"--pill-color":a(ve)}),re(Ht,a(G).label)}),Q("click",ye,()=>t.onPrAction(a(we))),I(Ce,ye)};ae(Z,Ce=>{a(G).type!=="none"&&a(G).label&&Ce(me)})}he((Ce,ye,Te)=>{Qe(We,1,Ce,"svelte-bvvs2r"),Ne(He,"href",a(we).url),re(Ue,a(we).title),re(_e,`#${a(we).number??""}`),re(Se,ye),re(Ae,Te)},[()=>zd(l(a(we))),()=>h(a(we)),()=>dg(a(we).updatedAt)]),Q("click",z,()=>t.onOpenPrSession(a(we))),I(Re,je)}),I(X,ce)};ae(J,X=>{a(n)?X(oe):a(o)?X(Y,1):a(r)&&!a(r).hasGhCli?X(W,2):a(r)&&a(r).prs.length===0?X(O,3):a(r)&&X(B,4)})}var T=k(j,2),q=k(S(T),2);{var D=X=>{var ce=Pw(),be=S(ce);Nt(be,20,()=>[1,2,3],io,(ge,xe)=>{var Pe=Ew();I(ge,Pe)}),I(X,ce)},E=X=>{var ce=Rw();I(X,ce)},$=X=>{var ce=Mw(),be=S(ce);Nt(be,21,()=>a(r).activity,ge=>ge.hash,(ge,xe)=>{var Pe=Tw(),Re=S(Pe),we=S(Re),G=k(Re,2),ve=S(G),Le=k(G,2);{var je=We=>{var He=Dw(),Ue=S(He);he(L=>re(Ue,L),[()=>d(a(xe))]),I(We,He)};ae(Le,We=>{a(xe).branches.length>0&&We(je)})}var Be=k(Le,2),pe=S(Be);he(()=>{re(we,a(xe).shortHash),re(ve,a(xe).message),re(pe,a(xe).timeAgo)}),I(ge,Pe)}),I(X,ce)};ae(q,X=>{a(n)?X(D):a(r)&&a(r).activity.length===0?X(E,1):a(r)&&X($,2)})}I(M,N)};ae(b,M=>{a(r)&&!a(r).isGitRepo?M(g):M(y,!1)})}var R=k(b,2),C=S(R),w=k(C,2);{var x=M=>{var N=Lw(),j=S(N);he(()=>{N.disabled=i(),re(j,i()?"Creating...":"+ New Worktree")}),Q("click",N,function(...J){var oe;(oe=t.onNewWorktree)==null||oe.apply(this,J)}),I(M,N)};ae(w,M=>{(!a(r)||a(r).isGitRepo)&&M(x)})}Q("click",C,function(...M){var N;(N=t.onNewSession)==null||N.apply(this,M)}),I(e,p),dt()}at(["click"]);var Iw=H('<div class="empty-icon svelte-1luen49" aria-hidden="true"> </div>'),Nw=H('<p class="empty-description svelte-1luen49"> </p>'),Fw=H('<button class="empty-action svelte-1luen49"> </button>'),Ww=H('<div class="empty-state svelte-1luen49"><!> <div class="empty-heading svelte-1luen49"> </div> <!> <!></div>');function Hw(e,t){var i=Ww(),s=S(i);{var r=u=>{var f=Iw(),v=S(f);he(()=>re(v,t.icon)),I(u,f)};ae(s,u=>{t.icon&&u(r)})}var n=k(s,2),o=S(n),l=k(n,2);{var c=u=>{var f=Nw(),v=S(f);he(()=>re(v,t.description)),I(u,f)};ae(l,u=>{t.description&&u(c)})}var h=k(l,2);{var d=u=>{var f=Fw(),v=S(f);he(()=>re(v,t.actionLabel)),Q("click",f,function(...p){var b;(b=t.onAction)==null||b.apply(this,p)}),I(u,f)};ae(h,u=>{t.actionLabel&&t.onAction&&u(d)})}he(()=>re(o,t.heading)),I(e,i)}at(["click"]);var zw=H("<button><!></button>"),Uw=H("<button><!></button>"),Kw=H('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function qw(e,t){ut(t,!0),as(t,"useTmux",3,!1);let i=as(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(),Lt&&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(),Lt&&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(),Lt&&t.onRefocusMobileInput())}function o(u){var f;t.onSendKey(u.key),u.exitsCopyMode&&((f=t.onExitCopyMode)==null||f.call(t)),Lt&&t.onRefocusMobileInput()}function l(u){u.preventDefault();const f=u.target.closest("button");if(!f)return;if(i()){const p=r.find(b=>f.dataset.key===b.key);p&&o(p);return}const v=s.find(p=>p.id===f.id||p.key&&f.dataset.key===p.key);v&&n(v)}var c=xs(),h=vt(c);{var d=u=>{var f=Kw(),v=S(f),p=S(v);{var b=y=>{var R=xs(),C=vt(R);Nt(C,17,()=>r,w=>w.label,(w,x)=>{var M=zw(),N=S(M);lc(N,()=>a(x).html),he(()=>{Qe(M,1,`tb-btn ${a(x).extraClass??""??""}`,"svelte-k7we1m"),Ne(M,"data-key",a(x).key),Ne(M,"aria-label",a(x).label)}),I(w,M)}),I(y,R)},g=y=>{var R=xs(),C=vt(R);Nt(C,17,()=>s,w=>w.label,(w,x)=>{var M=Uw(),N=S(M);lc(N,()=>a(x).html),he(()=>{Qe(M,1,`tb-btn ${a(x).extraClass??""??""}`,"svelte-k7we1m"),Ne(M,"id",a(x).id),Ne(M,"data-key",a(x).key),Ne(M,"aria-label",a(x).label)}),I(w,M)}),I(y,R)};ae(p,y=>{i()?y(b):y(g,!1)})}Q("mousedown",f,l),I(u,f)};ae(h,u=>{Lt&&u(d)})}I(e,c),dt()}at(["mousedown"]);var jw=H('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">&#9776;</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function Vw(e,t){let i=as(t,"hidden",3,!1);var s=jw();let r;var n=S(s),o=k(n,2),l=S(o);he(()=>{r=Qe(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)}),I(e,s)}at(["click"]);var Yw=H('<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>'),Gw=H('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function Xw(e,t){ut(t,!0);let i=F(!1),s=F(""),r=F("Update Now"),n=F(!1),o=F(!0);Dn(async()=>{try{const f=await jd();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 Vd()).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=xs(),d=vt(h);{var u=f=>{var v=Gw(),p=S(v),b=S(p),g=S(b),y=k(b,2);{var R=C=>{var w=Yw(),x=S(w),M=S(x),N=k(x,2);he(()=>{x.disabled=a(n),re(M,a(r))}),Q("click",x,l),Q("click",N,c),I(C,w)};ae(y,C=>{a(o)&&C(R)})}he(()=>re(g,a(s))),I(f,v)};ae(d,f=>{a(i)&&f(u)})}I(e,h),dt()}at(["click"]);var Qw=H('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),Jw=H('<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 $w(e,t){ut(t,!0);let i=F(!1),s=F(""),r=F(!1),n=F(null),o=null;function l(g,y,R){o&&(clearTimeout(o),o=null),m(s,g,!0),m(r,y,!0),m(n,R??null,!0),m(i,!0)}function c(){m(i,!1),m(n,null),o&&(clearTimeout(o),o=null)}function h(g){o&&clearTimeout(o),o=setTimeout(()=>{a(n)||c()},g)}function d(){a(n)&&er(a(n)),c()}function u(){c()}var f={show:l,hide:c,autoDismiss:h},v=xs(),p=vt(v);{var b=g=>{var y=Jw(),R=S(y),C=S(R),w=S(C),x=k(C,2),M=S(x);{var N=J=>{var oe=Qw();Q("click",oe,d),I(J,oe)};ae(M,J=>{a(r)&&J(N)})}var j=k(M,2);he(()=>re(w,a(s))),Q("click",j,u),I(g,y)};ae(p,g=>{a(i)&&g(b)})}return I(e,v),dt(f)}at(["click"]);var Zw=H('<span class="dialog-title-repo svelte-thtd9b"> </span>'),e0=H('<li class="branch-create-new svelte-thtd9b" role="option" aria-selected="false"> </li>'),t0=H('<li role="option" aria-selected="false" class="svelte-thtd9b"> </li>'),i0=H('<ul class="branch-dropdown svelte-thtd9b"><!> <!></ul>'),s0=H('<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>'),r0=H('<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>'),n0=H('<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 o0(e,t){ut(t,!0);let i=as(t,"preselectedRepo",3,null);const s=Ah();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),p=F(Je([])),b=F(!1),g=F(!1),y=F(!1),R=F(!1),C=0,w=fe(()=>{if(!a(c).trim())return[];const P=a(c).toLowerCase();return a(p).filter(A=>A.toLowerCase().includes(P)).slice(0,10)}),x=fe(()=>a(p).some(P=>P===a(c)));async function M(P,A={}){const Z=++C;if(P){A.preserveExisting||m(p,[],!0),A.refresh?m(y,!0):m(g,!0);try{const me=await Bh(P,A.refresh?{refresh:!0}:{});if(Z!==C||P!==a(o))return;m(p,me,!0),a(c).trim()&&m(b,!0)}catch{if(Z!==C||P!==a(o))return;A.preserveExisting||m(p,[],!0)}finally{Z===C&&(m(g,!1),m(y,!1))}}}async function N(){!a(o)||a(y)||await M(a(o),{refresh:!0,preserveExisting:!0})}function j(){C+=1,m(c,""),m(p,[],!0),m(b,!1),m(g,!1),m(y,!1)}function J(){m(b,a(c).trim().length>0)}function oe(P){m(c,P,!0),m(b,!1)}function Y(){m(o,""),m(l,""),m(h,""),m(u,!1),m(f,!1),m(v,!1),j()}async function W(P,A){Y(),m(n,"repos"),await _f(),m(d,s.defaultAgent,!0),A!=null&&A.agent&&m(d,A.agent,!0),m(u,s.defaultYolo,!0),m(f,s.defaultContinue,!0),m(v,s.launchInTmux,!0),(A==null?void 0:A.yolo)!==void 0&&m(u,A.yolo,!0),(A==null?void 0:A.useTmux)!==void 0&&m(v,A.useTmux,!0);const Z=P??i();Z&&(m(o,Z.path,!0),m(l,Z.name,!0),A!=null&&A.branchName&&(m(n,"worktrees"),await M(Z.path))),A!=null&&A.branchName&&m(c,A.branchName,!0),A!=null&&A.claudeArgs&&m(h,A.claudeArgs,!0),r.showModal()}function O(){r.close()}async function B(){var Ce,ye;const P=a(o);if(!P||a(R))return;m(R,!0);const A=a(h).trim().split(/\s+/).filter(Boolean),Z=Math.max(80,Math.floor((window.innerWidth-60)/8)),me=Math.max(24,Math.floor((window.innerHeight-120)/17));try{let Te;a(n)==="repos"?Te=await Pp({repoPath:P,repoName:a(l)||P.split("/").filter(Boolean).pop(),continue:a(f),yolo:a(u),claudeArgs:A.length>0?A:void 0,agent:a(d),useTmux:a(v),cols:Z,rows:me,allowMultiple:!0}):Te=await Gs({repoPath:P,repoName:a(l)||P.split("/").filter(Boolean).pop(),branchName:a(c).trim()||void 0,yolo:a(u),claudeArgs:A.length>0?A:void 0,agent:a(d),useTmux:a(v),cols:Z,rows:me}),r.close(),await kt(),Te!=null&&Te.id&&((Ce=t.onSessionCreated)==null||Ce.call(t,Te.id))}catch(Te){if(Te instanceof Error&&"sessionId"in Te){const Ze=Te;r.close(),await kt(),Ze.sessionId&&((ye=t.onSessionCreated)==null||ye.call(t,Ze.sessionId))}}finally{m(R,!1)}}function T(P){P.target===r&&r.close()}function q(P){a(b)&&P.key==="Escape"&&(m(b,!1),P.stopPropagation())}var D={open:W,close:O},E=n0(),$=S(E),X=S($),ce=S(X),be=k(ce);{var ge=P=>{var A=Zw(),Z=S(A);he(()=>re(Z,`— ${a(l)??""}`)),I(P,A)};ae(be,P=>{a(l)&&P(ge)})}var xe=k(X,2),Pe=S(xe);let Re;var we=k(Pe,2);let G;var ve=k(xe,2),Le=S(ve),je=k(S(Le),2),Be=S(je);Be.value=Be.__value="claude";var pe=k(Be);pe.value=pe.__value="codex";var We=k(Le,2);{var He=P=>{var A=s0(),Z=S(A),me=k(S(Z),2),Ce=S(me);let ye;var Te=k(Z,2),Ze=S(Te),Ht=k(Ze,2);{var Vi=Mt=>{var ri=i0(),_i=S(ri);{var Gt=ni=>{var Xt=e0(),us=S(Xt);he(Ti=>re(us,`Create new: ${Ti??""}`),[()=>a(c).trim()]),Q("mousedown",Xt,()=>oe(a(c).trim())),I(ni,Xt)},Ts=fe(()=>!a(x)&&a(c).trim());ae(_i,ni=>{a(Ts)&&ni(Gt)})}var cs=k(_i,2);Nt(cs,16,()=>a(w),ni=>ni,(ni,Xt)=>{var us=t0(),Ti=S(us);he(()=>re(Ti,Xt)),Q("mousedown",us,()=>oe(Xt)),I(ni,us)}),I(Mt,ri)},Me=fe(()=>a(b)&&(a(w).length>0||a(c).trim()&&!a(x)));ae(Ht,Mt=>{a(Me)&&Mt(Vi)})}he(()=>{me.disabled=!a(o)||a(g)||a(y),ye=Qe(Ce,0,"svelte-thtd9b",null,ye,{spinning:a(g)||a(y)})}),Q("click",me,N),Q("input",Ze,J),Ss("focus",Ze,()=>{a(c).trim()&&m(b,!0)}),xi(Ze,()=>a(c),Mt=>m(c,Mt)),I(P,A)};ae(We,P=>{a(n)==="worktrees"&&P(He)})}var Ue=k(We,2);{var L=P=>{var A=r0(),Z=S(A);zi(Z,()=>a(f),me=>m(f,me)),I(P,A)};ae(Ue,P=>{a(n)==="repos"&&P(L)})}var te=k(Ue,2),_e=S(te),ue=k(te,2),Se=S(ue),ne=k(ue,2),Ae=k(S(ne),2),Ke=k(ve,2),z=S(Ke),U=k(z,2),se=S(U);return et(E,P=>r=P,()=>r),he(()=>{re(ce,`${a(n)==="repos"?"New Session":"New Worktree"} `),Re=Qe(Pe,1,"dialog-tab svelte-thtd9b",null,Re,{active:a(n)==="repos"}),G=Qe(we,1,"dialog-tab svelte-thtd9b",null,G,{active:a(n)==="worktrees"}),z.disabled=a(R),U.disabled=!a(o)||a(R),re(se,a(R)?"Creating...":a(n)==="repos"?"Start Session":"Create Worktree")}),Q("click",E,T),Q("keydown",E,q),Q("click",Pe,()=>{m(n,"repos")}),Q("click",we,()=>{m(n,"worktrees"),a(o)&&a(p).length===0&&M(a(o))}),Zo(je,()=>a(d),P=>m(d,P)),zi(_e,()=>a(u),P=>m(u,P)),zi(Se,()=>a(v),P=>m(v,P)),xi(Ae,()=>a(h),P=>m(h,P)),Q("click",z,()=>r.close()),Q("click",U,B),I(e,E),dt(D)}at(["click","keydown","input","mousedown"]);var a0=H('<p class="error-msg svelte-fdtoa4"> </p>'),l0=H('<span class="version-status svelte-fdtoa4">Up to date</span>'),h0=H('<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>'),c0=H('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),u0=H('<p class="version-status-msg svelte-fdtoa4"> </p>'),d0=H('<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 f0(e,t){ut(t,!0);let i,s=F(!1);const r=Ah();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 _f(),i.showModal(),w()}function p(){i.close()}async function b(){const P=r.defaultAgent;m(n,"");try{await Mp(r.defaultAgent)}catch{r.defaultAgent=P,m(n,"Failed to update default agent.")}}async function g(){const P=r.defaultContinue;m(n,"");try{await Lp(r.defaultContinue)}catch{r.defaultContinue=P,m(n,"Failed to update continue default.")}}async function y(){const P=r.defaultYolo;m(n,"");try{await Op(r.defaultYolo)}catch{r.defaultYolo=P,m(n,"Failed to update yolo default.")}}async function R(){const P=r.launchInTmux;m(n,"");try{await Np(r.launchInTmux)}catch(A){r.launchInTmux=P,m(n,A instanceof Error?A.message:"Failed to update tmux setting.",!0)}}async function C(){const P=r.defaultNotifications;m(n,"");try{await Wp(r.defaultNotifications)}catch{r.defaultNotifications=P,m(n,"Failed to update notifications default.")}}async function w(){m(d,!0),m(f,"");try{const P=await jd();m(o,P.current,!0),m(l,P.latest,!0),m(c,P.updateAvailable,!0),m(h,!0)}catch{m(f,"Failed to check for updates.")}finally{m(d,!1)}}async function x(){m(u,!0),m(f,"");try{(await Vd()).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 M(){localStorage.setItem("devtools-enabled",a(s)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function N(){i.close(),await kt()}function j(P){P.target===i&&N()}var J={open:v,close:p},oe=d0(),Y=S(oe),W=S(Y),O=k(S(W),2),B=k(W,2),T=S(B);{var q=P=>{var A=a0(),Z=S(A);he(()=>re(Z,a(n))),I(P,A)};ae(T,P=>{a(n)&&P(q)})}var D=k(T,2),E=k(S(D),4),$=S(E);$.value=$.__value="claude";var X=k($);X.value=X.__value="codex";var ce=k(D,2),be=k(S(ce),4),ge=S(be),xe=k(be,2),Pe=S(xe),Re=k(xe,2),we=S(Re),G=k(Re,2),ve=S(G),Le=k(ce,2),je=k(S(Le),2),Be=S(je),pe=k(Le,2),We=k(S(pe),2),He=S(We),Ue=S(He);{var L=P=>{var A=Ar();he(()=>re(A,`v${a(o)??""}`)),I(P,A)},te=P=>{var A=Ar("...");I(P,A)};ae(Ue,P=>{a(o)?P(L):P(te,!1)})}var _e=k(He,2);{var ue=P=>{var A=l0();I(P,A)};ae(_e,P=>{a(h)&&!a(c)&&!a(u)&&P(ue)})}var Se=k(We,2);{var ne=P=>{var A=h0(),Z=S(A),me=S(Z),Ce=k(Z,2),ye=S(Ce);he(()=>{re(me,`v${a(o)??""} → v${a(l)??""}`),Ce.disabled=a(u),re(ye,a(u)?"Updating…":"Update Now")}),Q("click",Ce,x),I(P,A)},Ae=P=>{var A=c0(),Z=S(A);he(()=>{A.disabled=a(d),re(Z,a(d)?"Checking…":"Check for updates")}),Q("click",A,w),I(P,A)};ae(Se,P=>{a(c)?P(ne):a(h)||P(Ae,1)})}var Ke=k(Se,2);{var z=P=>{var A=u0(),Z=S(A);he(()=>re(Z,a(f))),I(P,A)};ae(Ke,P=>{a(f)&&P(z)})}var U=k(B,2),se=S(U);return et(oe,P=>i=P,()=>i),Q("click",oe,j),Q("click",O,N),Q("change",E,b),Zo(E,()=>r.defaultAgent,P=>r.defaultAgent=P),Q("change",ge,g),zi(ge,()=>r.defaultContinue,P=>r.defaultContinue=P),Q("change",Pe,y),zi(Pe,()=>r.defaultYolo,P=>r.defaultYolo=P),Q("change",we,R),zi(we,()=>r.launchInTmux,P=>r.launchInTmux=P),Q("change",ve,C),zi(ve,()=>r.defaultNotifications,P=>r.defaultNotifications=P),Q("change",Be,M),zi(Be,()=>a(s),P=>m(s,P)),Q("click",se,N),I(e,oe),dt(J)}at(["click","change"]);var _0=H('<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),v0=H('<p class="error-msg svelte-15sco2n"> </p>'),p0=H('<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 g0(e,t){ut(t,!0);let i,s=F(null),r=F(""),n=F(!1);function o(N){m(s,N,!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,""),Yr(a(s).path);try{await qd(a(s).path,a(s).repoPath),i.close(),await kt()}catch(N){m(r,N instanceof Error?N.message:"Failed to delete worktree.",!0),m(n,!1)}finally{a(s)&&Gr(a(s).path)}}}function h(){i.close()}function d(N){N.target===i&&i.close()}var u={open:o,close:l},f=p0(),v=S(f),p=k(S(v),2),b=S(p);{var g=N=>{var j=_0(),J=vt(j),oe=k(S(J)),Y=S(oe),W=k(J,2),O=S(W);he(()=>{re(Y,a(s).displayName||a(s).name),re(O,a(s).path)}),I(N,j)};ae(b,N=>{a(s)&&N(g)})}var y=k(b,2);{var R=N=>{var j=v0(),J=S(j);he(()=>re(J,a(r))),I(N,j)};ae(y,N=>{a(r)&&N(R)})}var C=k(p,2),w=S(C),x=k(w,2),M=S(x);return et(f,N=>i=N,()=>i),he(()=>{w.disabled=a(n),x.disabled=a(n),re(M,a(n)?"Deleting...":"Delete")}),Q("click",f,d),Q("click",w,h),Q("click",x,c),I(e,f),dt(u)}at(["click"]);var m0=H('<div class="loading-placeholder svelte-15gfcbp">Loading...</div>'),b0=H('<div class="empty-placeholder svelte-15gfcbp"><!></div>'),S0=H('<span class="spinner svelte-15gfcbp">...</span>'),y0=H("<span>&#9654;</span>"),w0=H('<button class="expand-btn svelte-15gfcbp"><!></button>'),C0=H('<span class="expand-spacer svelte-15gfcbp"></span>'),k0=H('<span class="git-badge svelte-15gfcbp" aria-label="Git repository">git</span>'),x0=H('<div role="treeitem"><!> <input type="checkbox" class="node-checkbox svelte-15gfcbp"/> <span class="node-name svelte-15gfcbp"> </span> <!></div>'),E0=H('<div class="truncated-notice svelte-15gfcbp"> </div>'),P0=H("<!> <!>",1),R0=H('<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 D0(e,t){ut(t,!0);let i=as(t,"selectedPaths",31,()=>Je([])),s=F(Je([])),r=F(""),n=F(-1),o=F(!0),l=F(null),c=F(void 0);Dn(()=>{h()});async function h(){m(o,!0),m(l,null);try{const D=await fc();m(s,D.entries.map(E=>d(E,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,E){return{name:D.name,path:D.path,isGitRepo:D.isGitRepo,hasChildren:D.hasChildren,children:null,expanded:!1,selected:!1,loading:!1,depth:E,truncatedInfo:null}}async function u(D){if(D.expanded){D.expanded=!1;return}if(D.children===null){D.loading=!0;try{const E=await fc(D.path);D.children=E.entries.map($=>d($,D.depth+1)),D.truncatedInfo=E.truncated?{shown:E.entries.length,total:E.total}:null}catch{D.children=[]}finally{D.loading=!1}}D.expanded=!0}function f(D){D.selected=!D.selected,v()}function v(){i(p(a(s)))}function p(D){const E=[];for(const $ of D)$.selected&&E.push($.path),$.children&&E.push(...p($.children));return E}function b(D,E){return D.toLowerCase().includes(E.toLowerCase())}function g(D,E){var $;return!!(!E||D.expanded||b(D.name,E)||($=D.children)!=null&&$.some(X=>g(X,E)))}function y(D,E){const $=[];for(const X of D)g(X,E)&&($.push(X),X.expanded&&X.children&&$.push(...y(X.children,E)));return $}let R=fe(()=>y(a(s),a(r)));function C(D){var $;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 E=a(n)>=0?a(R)[a(n)]:void 0;if(E){if(D.key==="ArrowRight"){if(D.preventDefault(),E.hasChildren&&!E.expanded)u(E);else if(E.expanded&&(($=E.children)!=null&&$.length)){const X=a(R).indexOf(E.children[0]);X>=0&&m(n,X,!0)}return}if(D.key==="ArrowLeft"){if(D.preventDefault(),E.expanded)E.expanded=!1;else{const X=E.depth-1;for(let ce=a(n)-1;ce>=0;ce--)if(a(R)[ce].depth===X){m(n,ce,!0);break}}return}if(D.key===" "){D.preventDefault(),f(E);return}}}function w(D,E){const $=E.target;$.closest(".expand-btn")||$.closest(".node-checkbox")||(D.hasChildren&&!D.expanded?u(D):f(D))}function x(){m(r,""),m(n,-1),M(a(s)),i([]),N(a(s))}function M(D){for(const E of D)E.selected=!1,E.children&&M(E.children)}function N(D){for(const E of D)E.expanded=!1,E.children&&N(E.children)}var j={reset:x},J=R0(),oe=S(J),Y=S(oe),W=k(oe,2),O=S(W);{var B=D=>{var E=m0();I(D,E)},T=D=>{var E=b0(),$=S(E);{var X=be=>{var ge=Ar();he(()=>re(ge,`No matches for "${a(r)??""}"`)),I(be,ge)},ce=be=>{var ge=Ar("No directories found");I(be,ge)};ae($,be=>{a(r)?be(X):be(ce,!1)})}I(D,E)},q=D=>{var E=P0(),$=vt(E);Nt($,19,()=>a(R),be=>be.path,(be,ge,xe)=>{var Pe=x0();let Re;var we=S(Pe);{var G=He=>{var Ue=w0(),L=S(Ue);{var te=ue=>{var Se=S0();I(ue,Se)},_e=ue=>{var Se=y0();let ne;he(()=>ne=Qe(Se,1,"arrow svelte-15gfcbp",null,ne,{expanded:a(ge).expanded})),I(ue,Se)};ae(L,ue=>{a(ge).loading?ue(te):ue(_e,!1)})}he(()=>Ne(Ue,"aria-label",a(ge).expanded?"Collapse":"Expand")),Q("click",Ue,()=>u(a(ge))),I(He,Ue)},ve=He=>{var Ue=C0();I(He,Ue)};ae(we,He=>{a(ge).hasChildren?He(G):He(ve,!1)})}var Le=k(we,2),je=k(Le,2),Be=S(je),pe=k(je,2);{var We=He=>{var Ue=k0();I(He,Ue)};ae(pe,He=>{a(ge).isGitRepo&&He(We)})}he(()=>{Re=Qe(Pe,1,"tree-row svelte-15gfcbp",null,Re,{focused:a(xe)===a(n),selected:a(ge).selected}),Rn(Pe,`padding-left: ${12+a(ge).depth*20}px`),Ne(Pe,"aria-expanded",a(ge).hasChildren?a(ge).expanded:void 0),Ne(Pe,"aria-selected",a(ge).selected),Ne(Pe,"aria-level",a(ge).depth+1),up(Le,a(ge).selected),Ne(Le,"aria-label",`Select ${a(ge).name??""}`),re(Be,a(ge).name)}),Q("click",Pe,He=>w(a(ge),He)),Q("change",Le,()=>f(a(ge))),Q("click",Le,He=>He.stopPropagation()),I(be,Pe)});var X=k($,2);{var ce=be=>{var ge=E0(),xe=S(ge);he(()=>re(xe,`Showing ${a(l).shown??""} of ${a(l).total??""} directories. Use the filter to narrow results.`)),I(be,ge)};ae(X,be=>{a(l)&&be(ce)})}I(D,E)};ae(O,D=>{a(o)?D(B):a(R).length===0?D(T,1):D(q,!1)})}return et(W,D=>m(c,D),()=>a(c)),xi(Y,()=>a(r),D=>m(r,D)),Q("keydown",W,C),I(e,J),dt(j)}at(["keydown","click","change"]);var T0=H('<p class="error-msg svelte-4yj2yx"> </p>'),M0=H('<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 B0(e,t){ut(t,!0);let i,s=F(void 0),r=F(Je([])),n=F(""),o=F(!1);function l(){var B;m(r,[],!0),m(n,""),m(o,!1),(B=a(s))==null||B.reset(),i.showModal()}function c(){i.close()}async function h(){if(a(r).length!==0){m(o,!0),m(n,"");try{const B=await yp(a(r));if(B.errors.length>0&&B.added.length===0){m(n,B.errors.map(T=>`${T.path}: ${T.error}`).join("; "),!0),m(o,!1);return}B.added.length>0&&t.onWorkspacesAdded(B.added.map(T=>T.path)),B.errors.length>0&&console.warn("Some workspaces failed to add:",B.errors),c()}catch{m(n,"Failed to add workspaces.")}finally{m(o,!1)}}}function d(B){B.target===i&&c()}var u={open:l,close:c},f=M0(),v=S(f),p=S(v),b=k(S(p),2),g=k(p,2),y=k(S(g),2);et(D0(y,{get selectedPaths(){return a(r)},set selectedPaths(B){m(r,B,!0)}}),B=>m(s,B,!0),()=>a(s));var R=k(y,2);{var C=B=>{var T=T0(),q=S(T);he(()=>re(q,a(n))),I(B,T)};ae(R,B=>{a(n)&&B(C)})}var w=k(g,2),x=S(w),M=S(x);{var N=B=>{var T=Ar();he(()=>re(T,`${a(r).length??""} selected`)),I(B,T)};ae(M,B=>{a(r).length>0&&B(N)})}var j=k(x,2),J=S(j),oe=k(J,2),Y=S(oe);{var W=B=>{var T=Ar("Adding...");I(B,T)},O=B=>{var T=Ar();he(()=>re(T,`Add Workspace${a(r).length>1?"s":""}`)),I(B,T)};ae(Y,B=>{a(o)?B(W):B(O,!1)})}return et(f,B=>i=B,()=>i),he(()=>oe.disabled=a(r).length===0||a(o)),Q("click",f,d),Q("click",b,c),Q("click",J,c),Q("click",oe,h),I(e,f),dt(u)}at(["click"]);var L0=H('<p class="error-msg svelte-1n78dcx"> </p>'),A0=H("<option> </option>"),O0=H("<option> </option>"),I0=H('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. focus on security, error handling"></textarea>'),N0=H('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. include test plan section"></textarea>'),F0=H('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. prefix with dy/, use conventional commits style"></textarea>'),W0=H('<textarea class="prompt-textarea svelte-1n78dcx" placeholder="e.g. use TypeScript, follow CLAUDE.md"></textarea>'),H0=H('<span class="save-success svelte-1n78dcx">Saved</span>'),z0=H('<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 U0(e,t){ut(t,!0);let i,s=F(""),r=F(""),n=F(!1),o=F(""),l=F(!1),c=F(Je([])),h=F(""),d=F(""),u=F(""),f=F("claude"),v=F(!1),p=F(!1),b=F(!1),g=F(""),y=F(""),R=F(""),C=F(""),w=F(!1),x=F(!1),M=F(!1),N=F(!1);async function j(le,Ve){m(s,le,!0),m(r,Ve,!0),m(o,""),m(l,!1),m(n,!1),m(h,""),m(d,""),m(u,""),m(f,"claude"),m(v,!1),m(p,!1),m(b,!1),m(g,""),m(y,""),m(R,""),m(C,""),i.showModal();try{const[yt,qr]=await Promise.all([vl(le),Bh(le).catch(()=>[])]);m(c,qr,!0),oe(yt)}catch{m(o,"Failed to load workspace settings.")}}function J(){i.close()}function oe(le){m(h,le.defaultBranch??"",!0),m(d,le.remote??"",!0),m(u,le.branchPrefix??"",!0),m(f,le.defaultAgent??"claude",!0),m(v,le.defaultContinue??!1,!0),m(p,le.defaultYolo??!1,!0),m(b,le.launchInTmux??!1,!0),m(g,le.promptCodeReview??"",!0),m(y,le.promptCreatePr??"",!0),m(R,le.promptBranchRename??"",!0),m(C,le.promptGeneral??"",!0)}async function Y(){m(n,!0),m(o,""),m(l,!1);try{const le={defaultAgent:a(f),defaultContinue:a(v),defaultYolo:a(p),launchInTmux:a(b)};a(h)&&(le.defaultBranch=a(h)),a(d)&&(le.remote=a(d)),a(u)&&(le.branchPrefix=a(u)),a(g)&&(le.promptCodeReview=a(g)),a(y)&&(le.promptCreatePr=a(y)),a(R)&&(le.promptBranchRename=a(R)),a(C)&&(le.promptGeneral=a(C)),await zp(a(s),le),m(l,!0),setTimeout(()=>{m(l,!1)},2e3)}catch(le){m(o,le instanceof Error?le.message:"Failed to save settings.",!0)}finally{m(n,!1)}}function W(){i.close(),t.onRemoveWorkspace(a(s))}function O(le){le.target===i&&i.close()}var B={open:j,close:J},T=z0(),q=S(T),D=S(q),E=S(D),$=k(S(E)),X=k(E,2),ce=k(D,2),be=S(ce);{var ge=le=>{var Ve=L0(),yt=S(Ve);he(()=>re(yt,a(o))),I(le,Ve)};ae(be,le=>{a(o)&&le(ge)})}var xe=k(be,2),Pe=k(S(xe),2),Re=k(S(Pe),2),we=S(Re);we.value=we.__value="";var G=k(we);Nt(G,17,()=>a(c),io,(le,Ve)=>{var yt=A0(),qr=S(yt),Jh={};he(()=>{re(qr,a(Ve)),Jh!==(Jh=a(Ve))&&(yt.value=(yt.__value=a(Ve))??"")}),I(le,yt)});var ve=k(G);{var Le=le=>{var Ve=O0(),yt=S(Ve),qr={};he(()=>{re(yt,a(h)),qr!==(qr=a(h))&&(Ve.value=(Ve.__value=a(h))??"")}),I(le,Ve)},je=fe(()=>a(h)&&!a(c).includes(a(h)));ae(ve,le=>{a(je)&&le(Le)})}var Be=k(Pe,2),pe=k(S(Be),2),We=k(Be,2),He=k(S(We),2),Ue=k(xe,4),L=k(S(Ue),2),te=k(S(L),2),_e=S(te);_e.value=_e.__value="claude";var ue=k(_e);ue.value=ue.__value="codex";var Se=k(L,2),ne=S(Se),Ae=S(ne),Ke=k(ne,2),z=S(Ke),U=k(Ke,2),se=S(U),P=k(Ue,4),A=k(S(P),2),Z=S(A),me=S(Z),Ce=S(me),ye=k(Z,2);{var Te=le=>{var Ve=I0();Ne(Ve,"rows",3),xi(Ve,()=>a(g),yt=>m(g,yt)),I(le,Ve)};ae(ye,le=>{a(w)&&le(Te)})}var Ze=k(A,2),Ht=S(Ze),Vi=S(Ht),Me=S(Vi),Mt=k(Ht,2);{var ri=le=>{var Ve=N0();Ne(Ve,"rows",3),xi(Ve,()=>a(y),yt=>m(y,yt)),I(le,Ve)};ae(Mt,le=>{a(x)&&le(ri)})}var _i=k(Ze,2),Gt=S(_i),Ts=S(Gt),cs=S(Ts),ni=k(Gt,2);{var Xt=le=>{var Ve=F0();Ne(Ve,"rows",3),xi(Ve,()=>a(R),yt=>m(R,yt)),I(le,Ve)};ae(ni,le=>{a(M)&&le(Xt)})}var us=k(_i,2),Ti=S(us),Pa=S(Ti),Ra=S(Pa),Ye=k(Ti,2);{var it=le=>{var Ve=W0();Ne(Ve,"rows",3),xi(Ve,()=>a(C),yt=>m(C,yt)),I(le,Ve)};ae(Ye,le=>{a(N)&&le(it)})}var Qt=k(ce,2),Do=S(Qt),Da=k(Do,2),To=S(Da);{var y_=le=>{var Ve=H0();I(le,Ve)};ae(To,le=>{a(l)&&le(y_)})}var Ta=k(To,2),w_=S(Ta);return et(T,le=>i=le,()=>i),he(()=>{re($,` ${a(r)??""}`),Ne(Z,"aria-expanded",a(w)),re(Ce,a(w)?"▾":"▸"),Ne(Ht,"aria-expanded",a(x)),re(Me,a(x)?"▾":"▸"),Ne(Gt,"aria-expanded",a(M)),re(cs,a(M)?"▾":"▸"),Ne(Ti,"aria-expanded",a(N)),re(Ra,a(N)?"▾":"▸"),Ta.disabled=a(n),re(w_,a(n)?"Saving…":"Save")}),Q("click",T,O),Q("click",X,()=>i.close()),Zo(Re,()=>a(h),le=>m(h,le)),xi(pe,()=>a(d),le=>m(d,le)),xi(He,()=>a(u),le=>m(u,le)),Zo(te,()=>a(f),le=>m(f,le)),zi(Ae,()=>a(v),le=>m(v,le)),zi(z,()=>a(p),le=>m(p,le)),zi(se,()=>a(b),le=>m(b,le)),Q("click",Z,()=>{m(w,!a(w))}),Q("click",Ht,()=>{m(x,!a(x))}),Q("click",Gt,()=>{m(M,!a(M))}),Q("click",Ti,()=>{m(N,!a(N))}),Q("click",Do,W),Q("click",Ta,Y),I(e,T),dt(B)}at(["click"]);var K0=H('<div class="sidebar-overlay svelte-13zv0lp"></div>'),q0=H("<!> <!> <!> <!>",1),j0=H('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!></div></div> <!> <!> <!> <!> <!> <!> <!>',1);function V0(e,t){ut(t,!0);const i=new p_({defaultOptions:{queries:{staleTime:60*1e3,gcTime:600*1e3,refetchOnWindowFocus:!0}}}),s=Yd(),r=Zd(),n=Lh(),o=Ah();function l(L,te){n.activeSessionId=L;const _e=n.sessions.find(ue=>ue.id===L);_e&&(r.activeWorkspacePath=_e.repoPath),mc(L),ui()}ig(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),p=F(void 0),b=F(!1);Dn(()=>{qp();let L,te;if(Lt&&window.visualViewport){const Se=window.visualViewport;let ne=null;const Ae=()=>{const Ke=window.innerHeight-Se.height;m(b,Ke>50),a(p)&&(a(p).style.height=a(b)?Se.height+"px":""),window.scrollTo(0,0),ne&&clearTimeout(ne),ne=setTimeout(()=>{var z;return(z=a(c))==null?void 0:z.fitTerm()},100)};Se.addEventListener("resize",Ae),Se.addEventListener("scroll",Ae),L=()=>{Se.removeEventListener("resize",Ae),Se.removeEventListener("scroll",Ae),ne&&clearTimeout(ne)}}const _e=navigator.platform.toUpperCase().includes("MAC");let ue;{const Se=ne=>{var z;const Ae=(z=document.activeElement)==null?void 0:z.tagName;if(!(Ae==="INPUT"||Ae==="TEXTAREA"||!(_e?ne.metaKey:ne.ctrlKey))){if(ne.key==="t"&&!ne.shiftKey){ne.preventDefault(),oe();return}if(ne.key==="w"&&!ne.shiftKey){ne.preventDefault(),n.activeSessionId&&$(n.activeSessionId);return}if(!ne.shiftKey&&ne.key>="1"&&ne.key<="9"){const U=a(C);if(U.length===0)return;ne.preventDefault();const se=parseInt(ne.key,10),P=se===9?U[U.length-1]:U[se-1];P&&J(P.id);return}if(ne.shiftKey&&ne.key==="["){const U=a(C);if(U.length===0)return;ne.preventDefault();const se=U.findIndex(A=>A.id===n.activeSessionId),P=se<=0?U[U.length-1]:U[se-1];P&&J(P.id);return}if(ne.shiftKey&&ne.key==="]"){const U=a(C);if(U.length===0)return;ne.preventDefault();const se=U.findIndex(A=>A.id===n.activeSessionId),P=se===-1||se===U.length-1?U[0]:U[se+1];P&&J(P.id);return}}};document.addEventListener("keydown",Se),ue=()=>document.removeEventListener("keydown",Se)}if(Lt){let Ae=0,Ke=0,z=!1;const U=A=>{const Z=A.touches[0];Z&&Z.clientX<=30&&!r.sidebarOpen&&(Ae=Z.clientX,Ke=Z.clientY,z=!0)},se=A=>{if(!z)return;const Z=A.touches[0];if(!Z)return;const me=Z.clientX-Ae,Ce=Math.abs(Z.clientY-Ke);if(Ce>me&&(Ce>8||me>8)){z=!1;return}me>=50&&(z=!1,pc())},P=()=>{z=!1};document.addEventListener("touchstart",U,{passive:!0}),document.addEventListener("touchmove",se,{passive:!0}),document.addEventListener("touchend",P),te=()=>{document.removeEventListener("touchstart",U),document.removeEventListener("touchmove",se),document.removeEventListener("touchend",P)}}return()=>{ue==null||ue(),L==null||L(),te==null||te()}}),rs(()=>{s.authenticated&&kt().then(()=>{const te=new URLSearchParams(window.location.search).get("session");te&&(window.history.replaceState({},"","/"),l(te)),!n.activeSessionId&&!te&&n.sessions.length===1&&J(n.sessions[0].id),!n.activeSessionId&&!te&&n.sessions.length===1&&J(n.sessions[0].id);for(const _e of n.sessions)Ln(_e.id,o.defaultNotifications);ng().then(()=>{og(cg())})})}),rs(()=>{s.authenticated&&uf(L=>{L.type==="worktrees-changed"?kt():L.type==="session-idle-changed"&&L.sessionId?hg(L.sessionId,L.idle??!1):L.type==="session-ended"&&(i.invalidateQueries({queryKey:["pr"]}),i.invalidateQueries({queryKey:["ci-status"]}))})});let g=fe(()=>r.activeWorkspacePath?n.workspaces.find(L=>L.path===r.activeWorkspacePath):void 0),y=fe(()=>r.activeWorkspacePath?hf(r.activeWorkspacePath):[]),R=fe(()=>n.activeSessionId?n.sessions.find(L=>L.id===n.activeSessionId):void 0),C=fe(()=>a(R)?a(y).filter(L=>L.repoPath===a(R).repoPath):a(y)),w=fe(()=>!!a(R)&&!!r.activeWorkspacePath&&(a(R).repoPath===r.activeWorkspacePath||a(R).repoPath.startsWith(r.activeWorkspacePath+"/"))),x=fe(()=>{var L,te;return((L=a(R))==null?void 0:L.displayName)||((te=a(g))==null?void 0:te.name)||"Claude Remote CLI"}),M=fe(()=>{var L;return((L=a(R))==null?void 0:L.useTmux)??!1}),N=F(!1),j=fe(()=>a(g)?a(w)?"session":"dashboard":"empty");function J(L){var _e;n.activeSessionId=L;const te=n.sessions.find(ue=>ue.id===L);if(te){const ue=n.workspaces.find(Se=>te.repoPath===Se.path||te.repoPath.startsWith(Se.path+"/"));r.activeWorkspacePath=(ue==null?void 0:ue.path)??te.repoPath}mc(L),ui(),(_e=a(c))==null||_e.focusTerm(),ug(L)}function oe(L,te){var _e,ue,Se;L?(_e=a(d))==null||_e.open({name:L.name,path:L.path,root:""},te):a(g)?(ue=a(d))==null||ue.open({name:a(g).name,path:a(g).path,root:""},te):(Se=a(d))==null||Se.open(void 0,te)}function Y(L){var te,_e;L?(te=a(v))==null||te.open(L.path,L.name):(_e=a(u))==null||_e.open()}async function W(L){var _e,ue;const te=`new-worktree:${L.path}`;if(!Oi(te)){Yr(te);try{let Se=o.defaultYolo,ne=o.defaultAgent,Ae=o.launchInTmux;try{const se=await vl(L.path);se.defaultYolo!==void 0&&(Se=se.defaultYolo),se.defaultAgent&&(ne=se.defaultAgent),se.launchInTmux!==void 0&&(Ae=se.launchInTmux)}catch{}const{branchName:Ke,worktreePath:z}=await Na(L.path),U=await Gs({repoPath:L.path,repoName:L.name,worktreePath:z,branchName:Ke,yolo:Se,agent:ne,useTmux:Ae,needsBranchRename:!0});await kt(),n.activeSessionId=U.id,r.activeWorkspacePath=L.path,Ln(U.id,o.defaultNotifications),ui(),(_e=a(c))==null||_e.focusTerm()}catch{(ue=a(d))==null||ue.open({name:L.name,path:L.path,root:""})}finally{Gr(te)}}}async function O(L){if(!a(g))return;const te=a(g).path,_e=n.sessions.find(ne=>ne.branchName===L.headRefName&&ne.repoPath.startsWith(te)),ue=n.worktrees.find(ne=>ne.branchName===L.headRefName&&ne.repoPath===te);let Se=`Merge the branch "${L.baseRefName}" into this branch and resolve all merge conflicts. Use \`git merge ${L.baseRefName}\` and fix any conflicts in the working tree. After resolving, verify the build passes.`;try{const ne=await vl(te);ne.promptFixConflicts&&(Se=ne.promptFixConflicts.replace(/\{baseRefName\}/g,L.baseRefName).replace(/\{headRefName\}/g,L.headRefName))}catch{}try{let ne,Ae;if(_e)ne=_e.repoPath,Ae=_e.branchName;else if(ue)ne=ue.path,Ae=ue.branchName;else{const z=await Na(te,L.headRefName);ne=z.worktreePath,Ae=z.branchName}const Ke=await Gs({repoPath:te,repoName:a(g).name,worktreePath:ne,branchName:Ae,allowMultiple:!0});await kt(),n.activeSessionId=Ke.id,r.activeWorkspacePath=te,Ln(Ke.id,o.defaultNotifications),ui(),setTimeout(()=>{er(Se+"\r")},1500)}catch(ne){console.error("Failed to start conflict resolution:",ne)}}async function B(L,te){if(!a(g))return;const _e=a(g).path,ue=n.sessions.find(ne=>ne.branchName===L.headRefName&&ne.repoPath.startsWith(_e)),Se=n.worktrees.find(ne=>ne.branchName===L.headRefName&&ne.repoPath===_e);try{let ne,Ae;if(ue)ne=ue.repoPath,Ae=ue.branchName;else if(Se)ne=Se.path,Ae=Se.branchName;else{const z=await Na(_e,L.headRefName);ne=z.worktreePath,Ae=z.branchName}const Ke=await Gs({repoPath:_e,repoName:a(g).name,worktreePath:ne,branchName:Ae,allowMultiple:!0});await kt(),n.activeSessionId=Ke.id,r.activeWorkspacePath=_e,Ln(Ke.id,o.defaultNotifications),ui(),te&&setTimeout(()=>{er(te+"\r")},1500)}catch(ne){console.error("Failed to open PR branch session:",ne)}}function T(L){const te=L.state==="OPEN"?"OPEN":L.state==="MERGED"?"MERGED":"CLOSED",_e=Oh({commitsAhead:1,prState:te,ciFailing:0,ciPending:0,ciTotal:0,mergeable:L.mergeable??null,unresolvedCommentCount:0}),ue=vf(_e,{branchName:L.headRefName,baseBranch:L.baseRefName,prNumber:L.number});ue&&B(L,ue)}function q(L){B(L)}function D(L){var te;(te=a(f))==null||te.open(L)}function E(L){var te;n.activeSessionId=L,Ln(L,o.defaultNotifications),ui(),(te=a(c))==null||te.focusTerm()}function $(L){var te;if(fetch(`/sessions/${L}`,{method:"DELETE"}).then(()=>kt()),n.activeSessionId===L){const _e=a(C).filter(ue=>ue.id!==L);n.activeSessionId=((te=_e[0])==null?void 0:te.id)??null}}function X(L,te,_e){var ue,Se;(ue=a(h))==null||ue.show(L,te,_e),te||(Se=a(h))==null||Se.autoDismiss(3e3)}function ce(L){er(L)}function be(){}function ge(){}function xe(){const L=document.createElement("input");L.type="file",L.accept="image/*",L.onchange=()=>{var _e,ue;const te=(_e=L.files)==null?void 0:_e[0];te&&((ue=a(c))==null||ue.handleImageUpload(te,te.type))},L.click()}function Pe(){var L;(L=a(c))==null||L.focusTerm()}function Re(L){m(N,L,!0)}function we(){var L;(L=a(c))==null||L.exitCopyMode()}let G=F(void 0);function ve(){var L;(L=a(G))==null||L.open()}async function Le(L){await kt(),L.length>0&&(r.activeWorkspacePath=L[0])}async function je(){const L=n.activeSessionId;if(!L)return;const te=n.sessions.find(_e=>_e.id===L);if(te){if(await Rp(L),te.type==="worktree"){const _e=n.workspaces.find(ue=>te.repoPath===ue.path||te.repoPath.startsWith(ue.path+"/"));if(_e&&te.repoPath!==_e.path)try{await qd(te.repoPath,_e.path)}catch{}}n.activeSessionId=null,await kt()}}var Be=xs(),pe=vt(Be);{var We=L=>{},He=L=>{pg(L,{})},Ue=L=>{qy(L,{get client(){return i},children:(te,_e)=>{var ue=j0(),Se=vt(ue),ne=S(Se);{var Ae=Me=>{var Mt=K0();Q("click",Mt,function(...ri){ui==null||ui.apply(this,ri)}),I(Me,Mt)};ae(ne,Me=>{r.sidebarOpen&&Me(Ae)})}var Ke=k(ne,2);Vg(Ke,{onSelectSession:J,onOpenSettings:Y,onNewWorktree:W,onNewSession:Me=>oe(Me),onNewTerminal:Me=>oe(Me,{agent:"claude"}),onAddWorkspace:ve,onDeleteSession:$,onDeleteWorktree:D});var z=k(Ke,2),U=S(z);Vw(U,{get title(){return a(x)},get onMenuClick(){return pc},get hidden(){return a(b)}});var se=k(U,2);{var P=Me=>{Hw(Me,{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:ve})},A=Me=>{{let Mt=fe(()=>r.activeWorkspacePath??""),ri=fe(()=>{var Gt;return((Gt=a(g))==null?void 0:Gt.name)??""}),_i=fe(()=>Oi(`new-worktree:${r.activeWorkspacePath??""}`));Ow(Me,{get workspacePath(){return a(Mt)},get workspaceName(){return a(ri)},get creatingWorktree(){return a(_i)},onNewSession:()=>oe(),onNewWorktree:()=>{a(g)&&W(a(g))},onFixConflicts:O,onPrAction:T,onOpenPrSession:q})}},Z=Me=>{var Mt=q0(),ri=vt(Mt);{let cs=fe(()=>r.activeWorkspacePath??""),ni=fe(()=>{var Xt;return((Xt=a(R))==null?void 0:Xt.branchName)??""});hw(ri,{get workspacePath(){return a(cs)},get branchName(){return a(ni)},get sessionId(){return n.activeSessionId},onArchive:je})}var _i=k(ri,2);fw(_i,{get sessions(){return a(C)},get activeSessionId(){return n.activeSessionId},onSelectSession:J,onCloseSession:$,onNewSession:()=>oe(),onNewTerminal:()=>oe(void 0,{agent:"claude"})});var Gt=k(_i,2);et(ay(Gt,{get sessionId(){return n.activeSessionId},onImageUpload:X,get useTmux(){return a(M)},onCopyModeChange:Re}),cs=>m(c,cs,!0),()=>a(c));var Ts=k(Gt,2);qw(Ts,{onSendKey:ce,onFlushComposedText:be,onClearInput:ge,onUploadImage:xe,onRefocusMobileInput:Pe,get useTmux(){return a(M)},get inCopyMode(){return a(N)},onExitCopyMode:we}),I(Me,Mt)};ae(se,Me=>{a(j)==="empty"?Me(P):a(j)==="dashboard"?Me(A,1):a(j)==="session"&&Me(Z,2)})}et(Se,Me=>m(p,Me),()=>a(p));var me=k(Se,2);et(o0(me,{onSessionCreated:E}),Me=>m(d,Me,!0),()=>a(d));var Ce=k(me,2);et(f0(Ce,{}),Me=>m(u,Me,!0),()=>a(u));var ye=k(Ce,2);et(g0(ye,{}),Me=>m(f,Me,!0),()=>a(f));var Te=k(ye,2);et(B0(Te,{onWorkspacesAdded:Le}),Me=>m(G,Me,!0),()=>a(G));var Ze=k(Te,2);et(U0(Ze,{onRemoveWorkspace:async Me=>{await fetch("/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:Me})}),await kt(),r.activeWorkspacePath===Me&&(r.activeWorkspacePath=null)}}),Me=>m(v,Me,!0),()=>a(v));var Ht=k(Ze,2);Xw(Ht,{});var Vi=k(Ht,2);et($w(Vi,{}),Me=>m(h,Me,!0),()=>a(h)),I(te,ue)},$$slots:{default:!0}})};ae(pe,L=>{s.checking?L(We):s.authenticated?L(Ue,!1):L(He,1)})}I(e,Be),dt()}at(["click"]);Qv(V0,{target:document.getElementById("app")});