claude-remote-cli 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/claude-remote-cli.js +0 -3
- package/dist/frontend/assets/index-Bw4iKQrv.css +32 -0
- package/dist/frontend/assets/index-C9kPfx3H.js +47 -0
- package/dist/frontend/index.html +2 -2
- package/dist/server/config.js +22 -0
- package/dist/server/git.js +193 -1
- package/dist/server/index.js +51 -292
- package/dist/server/push.js +3 -54
- package/dist/server/sessions.js +265 -180
- package/dist/server/types.js +7 -13
- package/dist/server/workspaces.js +448 -0
- package/dist/server/ws.js +31 -92
- package/dist/test/pr-state.test.js +164 -0
- package/dist/test/pull-requests.test.js +3 -3
- package/dist/test/sessions.test.js +7 -23
- package/package.json +1 -2
- package/dist/frontend/assets/index-Bz_R9N9S.css +0 -32
- package/dist/frontend/assets/index-Yv6LVq28.js +0 -47
- package/dist/server/pty-handler.js +0 -214
- package/dist/server/sdk-handler.js +0 -536
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
var T_=Object.defineProperty;var ac=e=>{throw TypeError(e)};var M_=(e,t,i)=>t in e?T_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ti=(e,t,i)=>M_(e,typeof t!="symbol"?t+"":t,i),La=(e,t,i)=>t.has(e)||ac("Cannot "+i);var _=(e,t,i)=>(La(e,t,"read from private field"),i?i.call(e):t.get(e)),X=(e,t,i)=>t.has(e)?ac("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),W=(e,t,i,s)=>(La(e,t,"write to private field"),s?s.call(e,i):t.set(e,i),i),_e=(e,t,i)=>(La(e,t,"access private method"),i);var Mo=(e,t,i,s)=>({set _(r){W(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 il=!1;var Dh=Array.isArray,P_=Array.prototype.indexOf,_n=Array.prototype.includes,ga=Array.from,B_=Object.defineProperty,Kr=Object.getOwnPropertyDescriptor,L_=Object.getOwnPropertyDescriptors,A_=Object.prototype,O_=Array.prototype,td=Object.getPrototypeOf,lc=Object.isExtensible;const I_=()=>{};function N_(e){for(var t=0;t<e.length;t++)e[t]()}function id(){var e,t,i=new Promise((s,r)=>{e=s,t=r});return{promise:i,resolve:e,reject:t}}const Ot=2,So=4,bo=8,sd=1<<24,ys=16,zi=32,Nr=64,sl=128,xi=512,Dt=1024,It=2048,Wi=4096,ui=8192,gs=16384,Pr=32768,Br=65536,hc=1<<17,rd=1<<18,Cn=1<<19,nd=1<<20,vs=1<<25,Lr=65536,rl=1<<21,Th=1<<22,Ys=1<<23,Rr=Symbol("$state"),F_=Symbol("legacy props"),H_=Symbol(""),ar=new class extends Error{constructor(){super(...arguments);Ti(this,"name","StaleReactionError");Ti(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}};var Hu;const W_=!!((Hu=globalThis.document)!=null&&Hu.contentType)&&globalThis.document.contentType.includes("xml");function Mh(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function z_(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function U_(e,t,i){throw new Error("https://svelte.dev/e/each_key_duplicate")}function K_(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function q_(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function j_(e){throw new Error("https://svelte.dev/e/effect_orphan")}function V_(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Y_(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function G_(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function X_(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Q_(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function J_(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Z_=1,$_=2,od=4,ev=8,tv=16,iv=1,sv=4,rv=8,nv=16,ov=1,av=2,Mt=Symbol(),ad="http://www.w3.org/1999/xhtml",lv="http://www.w3.org/2000/svg",hv="http://www.w3.org/1998/Math/MathML";function cv(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function uv(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function ld(e){return e===this.v}function dv(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function hd(e){return!dv(e,this.v)}let fv=!1,gt=null;function vn(e){gt=e}function cd(e){return dd().get(e)}function _v(e,t){return dd().set(e,t),t}function Ve(e,t=!1,i){gt={p:gt,i:!1,c:null,e:null,s:e,x:null,l:null}}function Ye(e){var t=gt,i=t.e;if(i!==null){t.e=null;for(var s of i)Ad(s)}return e!==void 0&&(t.x=e),t.i=!0,gt=t.p,e??{}}function ud(){return!0}function dd(e){return gt===null&&Mh(),gt.c??(gt.c=new Map(vv(gt)||void 0))}function vv(e){let t=e.p;for(;t!==null;){const i=t.c;if(i!==null)return i;t=t.p}return null}let lr=[];function fd(){var e=lr;lr=[],N_(e)}function $i(e){if(lr.length===0&&!Yn){var t=lr;queueMicrotask(()=>{t===lr&&fd()})}lr.push(e)}function pv(){for(;lr.length>0;)fd()}function _d(e){var t=Fe;if(t===null)return Pe.f|=Ys,e;if((t.f&Pr)===0&&(t.f&So)===0)throw e;qs(e,t)}function qs(e,t){for(;t!==null;){if((t.f&sl)!==0){if((t.f&Pr)===0)throw e;try{t.b.error(e);return}catch(i){e=i}}t=t.parent}throw e}const gv=-7169;function ut(e,t){e.f=e.f&gv|t}function Ph(e){(e.f&xi)!==0||e.deps===null?ut(e,Dt):ut(e,Wi)}function vd(e){if(e!==null)for(const t of e)(t.f&Ot)===0||(t.f&Lr)===0||(t.f^=Lr,vd(t.deps))}function pd(e,t,i){(e.f&It)!==0?t.add(e):(e.f&Wi)!==0&&i.add(e),vd(e.deps),ut(e,Dt)}const Po=new Set;let xe=null,$o=null,Lt=null,ei=[],ma=null,nl=!1,Yn=!1;var Yr,Gr,fr,Xr,ho,co,_r,cs,Qr,di,ol,al,ll,gd;const oc=class oc{constructor(){X(this,di);Ti(this,"current",new Map);Ti(this,"previous",new Map);X(this,Yr,new Set);X(this,Gr,new Set);X(this,fr,0);X(this,Xr,0);X(this,ho,null);X(this,co,new Set);X(this,_r,new Set);X(this,cs,new Map);Ti(this,"is_fork",!1);X(this,Qr,!1)}skip_effect(t){_(this,cs).has(t)||_(this,cs).set(t,{d:[],m:[]})}unskip_effect(t){var i=_(this,cs).get(t);if(i){_(this,cs).delete(t);for(var s of i.d)ut(s,It),Fi(s);for(s of i.m)ut(s,Wi),Fi(s)}}process(t){var r;ei=[],this.apply();var i=[],s=[];for(const n of t)_e(this,di,al).call(this,n,i,s);if(_e(this,di,ol).call(this)){_e(this,di,ll).call(this,s),_e(this,di,ll).call(this,i);for(const[n,o]of _(this,cs))yd(n,o)}else{for(const n of _(this,Yr))n();_(this,Yr).clear(),_(this,fr)===0&&_e(this,di,gd).call(this),$o=this,xe=null,cc(s),cc(i),$o=null,(r=_(this,ho))==null||r.resolve()}Lt=null}capture(t,i){i!==Mt&&!this.previous.has(t)&&this.previous.set(t,i),(t.f&Ys)===0&&(this.current.set(t,t.v),Lt==null||Lt.set(t,t.v))}activate(){xe=this,this.apply()}deactivate(){xe===this&&(xe=null,Lt=null)}flush(){if(this.activate(),ei.length>0){if(md(),xe!==null&&xe!==this)return}else _(this,fr)===0&&this.process([]);this.deactivate()}discard(){for(const t of _(this,Gr))t(this);_(this,Gr).clear()}increment(t){W(this,fr,_(this,fr)+1),t&&W(this,Xr,_(this,Xr)+1)}decrement(t){W(this,fr,_(this,fr)-1),t&&W(this,Xr,_(this,Xr)-1),!_(this,Qr)&&(W(this,Qr,!0),$i(()=>{W(this,Qr,!1),_e(this,di,ol).call(this)?ei.length>0&&this.flush():this.revive()}))}revive(){for(const t of _(this,co))_(this,_r).delete(t),ut(t,It),Fi(t);for(const t of _(this,_r))ut(t,Wi),Fi(t);this.flush()}oncommit(t){_(this,Yr).add(t)}ondiscard(t){_(this,Gr).add(t)}settled(){return(_(this,ho)??W(this,ho,id())).promise}static ensure(){if(xe===null){const t=xe=new oc;Po.add(xe),Yn||$i(()=>{xe===t&&t.flush()})}return xe}apply(){}};Yr=new WeakMap,Gr=new WeakMap,fr=new WeakMap,Xr=new WeakMap,ho=new WeakMap,co=new WeakMap,_r=new WeakMap,cs=new WeakMap,Qr=new WeakMap,di=new WeakSet,ol=function(){return this.is_fork||_(this,Xr)>0},al=function(t,i,s){t.f^=Dt;for(var r=t.first;r!==null;){var n=r.f,o=(n&(zi|Nr))!==0,a=o&&(n&Dt)!==0,h=a||(n&ui)!==0||_(this,cs).has(r);if(!h&&r.fn!==null){o?r.f^=Dt:(n&So)!==0?i.push(r):wo(r)&&((n&ys)!==0&&_(this,_r).add(r),gn(r));var l=r.first;if(l!==null){r=l;continue}}for(;r!==null;){var u=r.next;if(u!==null){r=u;break}r=r.parent}}},ll=function(t){for(var i=0;i<t.length;i+=1)pd(t[i],_(this,co),_(this,_r))},gd=function(){var r;if(Po.size>1){this.previous.clear();var t=Lt,i=!0;for(const n of Po){if(n===this){i=!1;continue}const o=[];for(const[h,l]of this.current){if(n.current.has(h))if(i&&l!==n.current.get(h))n.current.set(h,l);else continue;o.push(h)}if(o.length===0)continue;const a=[...n.current.keys()].filter(h=>!this.current.has(h));if(a.length>0){var s=ei;ei=[];const h=new Set,l=new Map;for(const u of o)Sd(u,a,h,l);if(ei.length>0){xe=n,n.apply();for(const u of ei)_e(r=n,di,al).call(r,u,[],[]);n.deactivate()}ei=s}}xe=null,Lt=t}Po.delete(this)};let Gs=oc;function mv(e){var t=Yn;Yn=!0;try{for(var i;;){if(pv(),ei.length===0&&(xe==null||xe.flush(),ei.length===0))return ma=null,i;md()}}finally{Yn=t}}function md(){nl=!0;var e=null;try{for(var t=0;ei.length>0;){var i=Gs.ensure();if(t++>1e3){var s,r;Sv()}i.process(ei),Xs.clear()}}finally{ei=[],nl=!1,ma=null}}function Sv(){try{V_()}catch(e){qs(e,ma)}}let Bi=null;function cc(e){var t=e.length;if(t!==0){for(var i=0;i<t;){var s=e[i++];if((s.f&(gs|ui))===0&&wo(s)&&(Bi=new Set,gn(s),s.deps===null&&s.first===null&&s.nodes===null&&s.teardown===null&&s.ac===null&&Nd(s),(Bi==null?void 0:Bi.size)>0)){Xs.clear();for(const r of Bi){if((r.f&(gs|ui))!==0)continue;const n=[r];let o=r.parent;for(;o!==null;)Bi.has(o)&&(Bi.delete(o),n.push(o)),o=o.parent;for(let a=n.length-1;a>=0;a--){const h=n[a];(h.f&(gs|ui))===0&&gn(h)}}Bi.clear()}}Bi=null}}function Sd(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&Ot)!==0?Sd(r,t,i,s):(n&(Th|ys))!==0&&(n&It)===0&&bd(r,t,s)&&(ut(r,It),Fi(r))}}function bd(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(_n.call(t,r))return!0;if((r.f&Ot)!==0&&bd(r,t,i))return i.set(r,!0),!0}return i.set(e,!1),!1}function Fi(e){var t=ma=e,i=t.b;if(i!=null&&i.is_pending&&(e.f&(So|bo|sd))!==0&&(e.f&Pr)===0){i.defer_effect(e);return}for(;t.parent!==null;){t=t.parent;var s=t.f;if(nl&&t===Fe&&(s&ys)!==0&&(s&rd)===0&&(s&Pr)!==0)return;if((s&(Nr|zi))!==0){if((s&Dt)===0)return;t.f^=Dt}}ei.push(t)}function yd(e,t){if(!((e.f&zi)!==0&&(e.f&Dt)!==0)){(e.f&It)!==0?t.d.push(e):(e.f&Wi)!==0&&t.m.push(e),ut(e,Dt);for(var i=e.first;i!==null;)yd(i,t),i=i.next}}function bv(e){let t=0,i=$s(0),s;return()=>{Ah()&&(c(i),ya(()=>(t===0&&(s=ws(()=>e(()=>Qs(i)))),t+=1,()=>{$i(()=>{t-=1,t===0&&(s==null||s(),s=void 0,Qs(i))})})))}}var yv=Br|Cn;function wv(e,t,i,s){new Cv(e,t,i,s)}var Si,Eh,Vi,vr,Zt,Yi,li,Li,us,pr,As,Jr,Zr,$r,ds,fa,St,kv,xv,Ev,hl,zo,Uo,cl;class Cv{constructor(t,i,s,r){X(this,St);Ti(this,"parent");Ti(this,"is_pending",!1);Ti(this,"transform_error");X(this,Si);X(this,Eh,null);X(this,Vi);X(this,vr);X(this,Zt);X(this,Yi,null);X(this,li,null);X(this,Li,null);X(this,us,null);X(this,pr,0);X(this,As,0);X(this,Jr,!1);X(this,Zr,new Set);X(this,$r,new Set);X(this,ds,null);X(this,fa,bv(()=>(W(this,ds,$s(_(this,pr))),()=>{W(this,ds,null)})));var n;W(this,Si,t),W(this,Vi,i),W(this,vr,o=>{var a=Fe;a.b=this,a.f|=sl,s(o)}),this.parent=Fe.b,this.transform_error=r??((n=this.parent)==null?void 0:n.transform_error)??(o=>o),W(this,Zt,wa(()=>{_e(this,St,hl).call(this)},yv))}defer_effect(t){pd(t,_(this,Zr),_(this,$r))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!_(this,Vi).pending}update_pending_count(t){_e(this,St,cl).call(this,t),W(this,pr,_(this,pr)+t),!(!_(this,ds)||_(this,Jr))&&(W(this,Jr,!0),$i(()=>{W(this,Jr,!1),_(this,ds)&&pn(_(this,ds),_(this,pr))}))}get_effect_pending(){return _(this,fa).call(this),c(_(this,ds))}error(t){var i=_(this,Vi).onerror;let s=_(this,Vi).failed;if(!i&&!s)throw t;_(this,Yi)&&(ii(_(this,Yi)),W(this,Yi,null)),_(this,li)&&(ii(_(this,li)),W(this,li,null)),_(this,Li)&&(ii(_(this,Li)),W(this,Li,null));var r=!1,n=!1;const o=()=>{if(r){uv();return}r=!0,n&&J_(),_(this,Li)!==null&&Dr(_(this,Li),()=>{W(this,Li,null)}),_e(this,St,Uo).call(this,()=>{Gs.ensure(),_e(this,St,hl).call(this)})},a=h=>{try{n=!0,i==null||i(h,o),n=!1}catch(l){qs(l,_(this,Zt)&&_(this,Zt).parent)}s&&W(this,Li,_e(this,St,Uo).call(this,()=>{Gs.ensure();try{return wi(()=>{var l=Fe;l.b=this,l.f|=sl,s(_(this,Si),()=>h,()=>o)})}catch(l){return qs(l,_(this,Zt).parent),null}}))};$i(()=>{var h;try{h=this.transform_error(t)}catch(l){qs(l,_(this,Zt)&&_(this,Zt).parent);return}h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(a,l=>qs(l,_(this,Zt)&&_(this,Zt).parent)):a(h)})}}Si=new WeakMap,Eh=new WeakMap,Vi=new WeakMap,vr=new WeakMap,Zt=new WeakMap,Yi=new WeakMap,li=new WeakMap,Li=new WeakMap,us=new WeakMap,pr=new WeakMap,As=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,$r=new WeakMap,ds=new WeakMap,fa=new WeakMap,St=new WeakSet,kv=function(){try{W(this,Yi,wi(()=>_(this,vr).call(this,_(this,Si))))}catch(t){this.error(t)}},xv=function(t){const i=_(this,Vi).failed;i&&W(this,Li,wi(()=>{i(_(this,Si),()=>t,()=>()=>{})}))},Ev=function(){const t=_(this,Vi).pending;t&&(this.is_pending=!0,W(this,li,wi(()=>t(_(this,Si)))),$i(()=>{var i=W(this,us,document.createDocumentFragment()),s=ms();i.append(s),W(this,Yi,_e(this,St,Uo).call(this,()=>(Gs.ensure(),wi(()=>_(this,vr).call(this,s))))),_(this,As)===0&&(_(this,Si).before(i),W(this,us,null),Dr(_(this,li),()=>{W(this,li,null)}),_e(this,St,zo).call(this))}))},hl=function(){try{if(this.is_pending=this.has_pending_snippet(),W(this,As,0),W(this,pr,0),W(this,Yi,wi(()=>{_(this,vr).call(this,_(this,Si))})),_(this,As)>0){var t=W(this,us,document.createDocumentFragment());Wd(_(this,Yi),t);const i=_(this,Vi).pending;W(this,li,wi(()=>i(_(this,Si))))}else _e(this,St,zo).call(this)}catch(i){this.error(i)}},zo=function(){this.is_pending=!1;for(const t of _(this,Zr))ut(t,It),Fi(t);for(const t of _(this,$r))ut(t,Wi),Fi(t);_(this,Zr).clear(),_(this,$r).clear()},Uo=function(t){var i=Fe,s=Pe,r=gt;ts(_(this,Zt)),Di(_(this,Zt)),vn(_(this,Zt).ctx);try{return t()}catch(n){return _d(n),null}finally{ts(i),Di(s),vn(r)}},cl=function(t){var i;if(!this.has_pending_snippet()){this.parent&&_e(i=this.parent,St,cl).call(i,t);return}W(this,As,_(this,As)+t),_(this,As)===0&&(_e(this,St,zo).call(this),_(this,li)&&Dr(_(this,li),()=>{W(this,li,null)}),_(this,us)&&(_(this,Si).before(_(this,us)),W(this,us,null)))};function Rv(e,t,i,s){const r=Sa;var n=e.filter(d=>!d.settled);if(i.length===0&&n.length===0){s(t.map(r));return}var o=Fe,a=Dv(),h=n.length===1?n[0].promise:n.length>1?Promise.all(n.map(d=>d.promise)):null;function l(d){a();try{s(d)}catch(v){(o.f&gs)===0&&qs(v,o)}ul()}if(i.length===0){h.then(()=>l(t.map(r)));return}function u(){a(),Promise.all(i.map(d=>Mv(d))).then(d=>l([...t.map(r),...d])).catch(d=>qs(d,o))}h?h.then(u):u()}function Dv(){var e=Fe,t=Pe,i=gt,s=xe;return function(n=!0){ts(e),Di(t),vn(i),n&&(s==null||s.activate())}}function ul(e=!0){ts(null),Di(null),vn(null),e&&(xe==null||xe.deactivate())}function Tv(){var e=Fe.b,t=xe,i=e.is_rendered();return e.update_pending_count(1),t.increment(i),()=>{e.update_pending_count(-1),t.decrement(i)}}function Sa(e){var t=Ot|It,i=Pe!==null&&(Pe.f&Ot)!==0?Pe:null;return Fe!==null&&(Fe.f|=Cn),{ctx:gt,deps:null,effects:null,equals:ld,f:t,fn:e,reactions:null,rv:0,v:Mt,wv:0,parent:i??Fe,ac:null}}function Mv(e,t,i){Fe===null&&z_();var r=void 0,n=$s(Mt),o=!Pe,a=new Map;return qv(()=>{var v;var h=id();r=h.promise;try{Promise.resolve(e()).then(h.resolve,h.reject).finally(ul)}catch(p){h.reject(p),ul()}var l=xe;if(o){var u=Tv();(v=a.get(l))==null||v.reject(ar),a.delete(l),a.set(l,h)}const d=(p,f=void 0)=>{if(l.activate(),f)f!==ar&&(n.f|=Ys,pn(n,f));else{(n.f&Ys)!==0&&(n.f^=Ys),pn(n,p);for(const[g,m]of a){if(a.delete(g),g===l)break;m.reject(ar)}}u&&u()};h.promise.then(d,p=>d(null,p||"unknown"))}),Oh(()=>{for(const h of a.values())h.reject(ar)}),new Promise(h=>{function l(u){function d(){u===r?h(n):l(r)}u.then(d,d)}l(r)})}function G(e){const t=Sa(e);return zd(t),t}function wd(e){const t=Sa(e);return t.equals=hd,t}function Pv(e){var t=e.effects;if(t!==null){e.effects=null;for(var i=0;i<t.length;i+=1)ii(t[i])}}function Bv(e){for(var t=e.parent;t!==null;){if((t.f&Ot)===0)return(t.f&gs)===0?t:null;t=t.parent}return null}function Bh(e){var t,i=Fe;ts(Bv(e));try{e.f&=~Lr,Pv(e),t=jd(e)}finally{ts(i)}return t}function Cd(e){var t=Bh(e);if(!e.equals(t)&&(e.wv=Kd(),(!(xe!=null&&xe.is_fork)||e.deps===null)&&(e.v=t,e.deps===null))){ut(e,Dt);return}tr||(Lt!==null?(Ah()||xe!=null&&xe.is_fork)&&Lt.set(e,t):Ph(e))}function Lv(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(ar),s.teardown=I_,s.ac=null,eo(s,0),Nh(s))}function kd(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&gn(t)}let dl=new Set;const Xs=new Map;let xd=!1;function $s(e,t){var i={f:0,v:e,reactions:null,equals:ld,rv:0,wv:0};return i}function j(e,t){const i=$s(e);return zd(i),i}function Av(e,t=!1,i=!0){const s=$s(e);return t||(s.equals=hd),s}function S(e,t,i=!1){Pe!==null&&(!Hi||(Pe.f&hc)!==0)&&ud()&&(Pe.f&(Ot|ys|Th|hc))!==0&&(Ei===null||!_n.call(Ei,e))&&Q_();let s=i?Ge(t):t;return pn(e,s)}function pn(e,t){if(!e.equals(t)){var i=e.v;tr?Xs.set(e,t):Xs.set(e,i),e.v=t;var s=Gs.ensure();if(s.capture(e,i),(e.f&Ot)!==0){const r=e;(e.f&It)!==0&&Bh(r),Ph(r)}e.wv=Kd(),Ed(e,It),Fe!==null&&(Fe.f&Dt)!==0&&(Fe.f&(zi|Nr))===0&&(mi===null?Vv([e]):mi.push(e)),!s.is_fork&&dl.size>0&&!xd&&Ov()}return t}function Ov(){xd=!1;for(const e of dl)(e.f&Dt)!==0&&ut(e,Wi),wo(e)&&gn(e);dl.clear()}function Qs(e){S(e,e.v+1)}function Ed(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,a=(o&It)===0;if(a&&ut(n,t),(o&Ot)!==0){var h=n;Lt==null||Lt.delete(h),(o&Lr)===0&&(o&xi&&(n.f|=Lr),Ed(h,Wi))}else a&&((o&ys)!==0&&Bi!==null&&Bi.add(n),Fi(n))}}function Ge(e){if(typeof e!="object"||e===null||Rr in e)return e;const t=td(e);if(t!==A_&&t!==O_)return e;var i=new Map,s=Dh(e),r=j(0),n=bs,o=a=>{if(bs===n)return a();var h=Pe,l=bs;Di(null),_c(n);var u=a();return Di(h),_c(l),u};return s&&i.set("length",j(e.length)),new Proxy(e,{defineProperty(a,h,l){(!("value"in l)||l.configurable===!1||l.enumerable===!1||l.writable===!1)&&G_();var u=i.get(h);return u===void 0?o(()=>{var d=j(l.value);return i.set(h,d),d}):S(u,l.value,!0),!0},deleteProperty(a,h){var l=i.get(h);if(l===void 0){if(h in a){const u=o(()=>j(Mt));i.set(h,u),Qs(r)}}else S(l,Mt),Qs(r);return!0},get(a,h,l){var p;if(h===Rr)return e;var u=i.get(h),d=h in a;if(u===void 0&&(!d||(p=Kr(a,h))!=null&&p.writable)&&(u=o(()=>{var f=Ge(d?a[h]:Mt),g=j(f);return g}),i.set(h,u)),u!==void 0){var v=c(u);return v===Mt?void 0:v}return Reflect.get(a,h,l)},getOwnPropertyDescriptor(a,h){var l=Reflect.getOwnPropertyDescriptor(a,h);if(l&&"value"in l){var u=i.get(h);u&&(l.value=c(u))}else if(l===void 0){var d=i.get(h),v=d==null?void 0:d.v;if(d!==void 0&&v!==Mt)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return l},has(a,h){var v;if(h===Rr)return!0;var l=i.get(h),u=l!==void 0&&l.v!==Mt||Reflect.has(a,h);if(l!==void 0||Fe!==null&&(!u||(v=Kr(a,h))!=null&&v.writable)){l===void 0&&(l=o(()=>{var p=u?Ge(a[h]):Mt,f=j(p);return f}),i.set(h,l));var d=c(l);if(d===Mt)return!1}return u},set(a,h,l,u){var k;var d=i.get(h),v=h in a;if(s&&h==="length")for(var p=l;p<d.v;p+=1){var f=i.get(p+"");f!==void 0?S(f,Mt):p in a&&(f=o(()=>j(Mt)),i.set(p+"",f))}if(d===void 0)(!v||(k=Kr(a,h))!=null&&k.writable)&&(d=o(()=>j(void 0)),S(d,Ge(l)),i.set(h,d));else{v=d.v!==Mt;var g=o(()=>Ge(l));S(d,g)}var m=Reflect.getOwnPropertyDescriptor(a,h);if(m!=null&&m.set&&m.set.call(u,l),!v){if(s&&typeof h=="string"){var b=i.get("length"),R=Number(h);Number.isInteger(R)&&R>=b.v&&S(b,R+1)}Qs(r)}return!0},ownKeys(a){c(r);var h=Reflect.ownKeys(a).filter(d=>{var v=i.get(d);return v===void 0||v.v!==Mt});for(var[l,u]of i)u.v!==Mt&&!(l in a)&&h.push(l);return h},setPrototypeOf(){X_()}})}function uc(e){try{if(e!==null&&typeof e=="object"&&Rr in e)return e[Rr]}catch{}return e}function Iv(e,t){return Object.is(uc(e),uc(t))}var fl,Rd,Dd,Td,Md;function Nv(){if(fl===void 0){fl=window,Rd=document,Dd=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,i=Text.prototype;Td=Kr(t,"firstChild").get,Md=Kr(t,"nextSibling").get,lc(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),lc(i)&&(i.__t=void 0)}}function ms(e=""){return document.createTextNode(e)}function Ss(e){return Td.call(e)}function yo(e){return Md.call(e)}function w(e,t){return Ss(e)}function He(e,t=!1){{var i=Ss(e);return i instanceof Comment&&i.data===""?yo(i):i}}function E(e,t=1,i=!1){let s=e;for(;t--;)s=yo(s);return s}function Fv(e){e.textContent=""}function Pd(){return!1}function Bd(e,t,i){return document.createElementNS(t??ad,e,void 0)}function Hv(e,t){{const i=document.body;e.autofocus=!0,$i(()=>{document.activeElement===i&&e.focus()})}}let dc=!1;function Wv(){dc||(dc=!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 ba(e){var t=Pe,i=Fe;Di(null),ts(null);try{return e()}finally{Di(t),ts(i)}}function Lh(e,t,i,s=i){e.addEventListener(t,()=>ba(i));const r=e.__on_r;r?e.__on_r=()=>{r(),s(!0)}:e.__on_r=()=>s(!0),Wv()}function Ld(e){Fe===null&&(Pe===null&&j_(),q_()),tr&&K_()}function zv(e,t){var i=t.last;i===null?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}function rs(e,t,i){var s=Fe;s!==null&&(s.f&ui)!==0&&(e|=ui);var r={ctx:gt,deps:null,nodes:null,f:e|It|xi,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{gn(r)}catch(a){throw ii(r),a}else t!==null&&Fi(r);var n=r;if(i&&n.deps===null&&n.teardown===null&&n.nodes===null&&n.first===n.last&&(n.f&Cn)===0&&(n=n.first,(e&ys)!==0&&(e&Br)!==0&&n!==null&&(n.f|=Br)),n!==null&&(n.parent=s,s!==null&&zv(n,s),Pe!==null&&(Pe.f&Ot)!==0&&(e&Nr)===0)){var o=Pe;(o.effects??(o.effects=[])).push(n)}return r}function Ah(){return Pe!==null&&!Hi}function Oh(e){const t=rs(bo,null,!1);return ut(t,Dt),t.teardown=e,t}function er(e){Ld();var t=Fe.f,i=!Pe&&(t&zi)!==0&&(t&Pr)===0;if(i){var s=gt;(s.e??(s.e=[])).push(e)}else return Ad(e)}function Ad(e){return rs(So|nd,e,!1)}function Uv(e){return Ld(),rs(bo|nd,e,!0)}function Kv(e){Gs.ensure();const t=rs(Nr|Cn,e,!0);return(i={})=>new Promise(s=>{i.outro?Dr(t,()=>{ii(t),s(void 0)}):(ii(t),s(void 0))})}function Ih(e){return rs(So,e,!1)}function qv(e){return rs(Th|Cn,e,!0)}function ya(e,t=0){return rs(bo|t,e,!0)}function le(e,t=[],i=[],s=[]){Rv(s,t,i,r=>{rs(bo,()=>e(...r.map(c)),!0)})}function wa(e,t=0){var i=rs(ys|t,e,!0);return i}function wi(e){return rs(zi|Cn,e,!0)}function Od(e){var t=e.teardown;if(t!==null){const i=tr,s=Pe;fc(!0),Di(null);try{t.call(null)}finally{fc(i),Di(s)}}}function Nh(e,t=!1){var i=e.first;for(e.first=e.last=null;i!==null;){const r=i.ac;r!==null&&ba(()=>{r.abort(ar)});var s=i.next;(i.f&Nr)!==0?i.parent=null:ii(i,t),i=s}}function jv(e){for(var t=e.first;t!==null;){var i=t.next;(t.f&zi)===0&&ii(t),t=i}}function ii(e,t=!0){var i=!1;(t||(e.f&rd)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Id(e.nodes.start,e.nodes.end),i=!0),Nh(e,t&&!i),eo(e,0),ut(e,gs);var s=e.nodes&&e.nodes.t;if(s!==null)for(const n of s)n.stop();Od(e);var r=e.parent;r!==null&&r.first!==null&&Nd(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=null}function Id(e,t){for(;e!==null;){var i=e===t?null:yo(e);e.remove(),e=i}}function Nd(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 Dr(e,t,i=!0){var s=[];Fd(e,s,!0);var r=()=>{i&&ii(e),t&&t()},n=s.length;if(n>0){var o=()=>--n||r();for(var a of s)a.out(o)}else r()}function Fd(e,t,i){if((e.f&ui)===0){e.f^=ui;var s=e.nodes&&e.nodes.t;if(s!==null)for(const a of s)(a.is_global||i)&&t.push(a);for(var r=e.first;r!==null;){var n=r.next,o=(r.f&Br)!==0||(r.f&zi)!==0&&(e.f&ys)!==0;Fd(r,t,o?i:!1),r=n}}}function Fh(e){Hd(e,!0)}function Hd(e,t){if((e.f&ui)!==0){e.f^=ui,(e.f&Dt)===0&&(ut(e,It),Fi(e));for(var i=e.first;i!==null;){var s=i.next,r=(i.f&Br)!==0||(i.f&zi)!==0;Hd(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 Wd(e,t){if(e.nodes)for(var i=e.nodes.start,s=e.nodes.end;i!==null;){var r=i===s?null:yo(i);t.append(i),i=r}}let Ko=!1,tr=!1;function fc(e){tr=e}let Pe=null,Hi=!1;function Di(e){Pe=e}let Fe=null;function ts(e){Fe=e}let Ei=null;function zd(e){Pe!==null&&(Ei===null?Ei=[e]:Ei.push(e))}let ti=null,ai=0,mi=null;function Vv(e){mi=e}let Ud=1,hr=0,bs=hr;function _c(e){bs=e}function Kd(){return++Ud}function wo(e){var t=e.f;if((t&It)!==0)return!0;if(t&Ot&&(e.f&=~Lr),(t&Wi)!==0){for(var i=e.deps,s=i.length,r=0;r<s;r++){var n=i[r];if(wo(n)&&Cd(n),n.wv>e.wv)return!0}(t&xi)!==0&&Lt===null&&ut(e,Dt)}return!1}function qd(e,t,i=!0){var s=e.reactions;if(s!==null&&!(Ei!==null&&_n.call(Ei,e)))for(var r=0;r<s.length;r++){var n=s[r];(n.f&Ot)!==0?qd(n,t,!1):t===n&&(i?ut(n,It):(n.f&Dt)!==0&&ut(n,Wi),Fi(n))}}function jd(e){var g;var t=ti,i=ai,s=mi,r=Pe,n=Ei,o=gt,a=Hi,h=bs,l=e.f;ti=null,ai=0,mi=null,Pe=(l&(zi|Nr))===0?e:null,Ei=null,vn(e.ctx),Hi=!1,bs=++hr,e.ac!==null&&(ba(()=>{e.ac.abort(ar)}),e.ac=null);try{e.f|=rl;var u=e.fn,d=u();e.f|=Pr;var v=e.deps,p=xe==null?void 0:xe.is_fork;if(ti!==null){var f;if(p||eo(e,ai),v!==null&&ai>0)for(v.length=ai+ti.length,f=0;f<ti.length;f++)v[ai+f]=ti[f];else e.deps=v=ti;if(Ah()&&(e.f&xi)!==0)for(f=ai;f<v.length;f++)((g=v[f]).reactions??(g.reactions=[])).push(e)}else!p&&v!==null&&ai<v.length&&(eo(e,ai),v.length=ai);if(ud()&&mi!==null&&!Hi&&v!==null&&(e.f&(Ot|Wi|It))===0)for(f=0;f<mi.length;f++)qd(mi[f],e);if(r!==null&&r!==e){if(hr++,r.deps!==null)for(let m=0;m<i;m+=1)r.deps[m].rv=hr;if(t!==null)for(const m of t)m.rv=hr;mi!==null&&(s===null?s=mi:s.push(...mi))}return(e.f&Ys)!==0&&(e.f^=Ys),d}catch(m){return _d(m)}finally{e.f^=rl,ti=t,ai=i,mi=s,Pe=r,Ei=n,vn(o),Hi=a,bs=h}}function Yv(e,t){let i=t.reactions;if(i!==null){var s=P_.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&Ot)!==0&&(ti===null||!_n.call(ti,t))){var n=t;(n.f&xi)!==0&&(n.f^=xi,n.f&=~Lr),Ph(n),Lv(n),eo(n,0)}}function eo(e,t){var i=e.deps;if(i!==null)for(var s=t;s<i.length;s++)Yv(e,i[s])}function gn(e){var t=e.f;if((t&gs)===0){ut(e,Dt);var i=Fe,s=Ko;Fe=e,Ko=!0;try{(t&(ys|sd))!==0?jv(e):Nh(e),Od(e);var r=jd(e);e.teardown=typeof r=="function"?r:null,e.wv=Ud;var n;il&&fv&&(e.f&It)!==0&&e.deps}finally{Ko=s,Fe=i}}}async function Gv(){await Promise.resolve(),mv()}function c(e){var t=e.f,i=(t&Ot)!==0;if(Pe!==null&&!Hi){var s=Fe!==null&&(Fe.f&gs)!==0;if(!s&&(Ei===null||!_n.call(Ei,e))){var r=Pe.deps;if((Pe.f&rl)!==0)e.rv<hr&&(e.rv=hr,ti===null&&r!==null&&r[ai]===e?ai++:ti===null?ti=[e]:ti.push(e));else{(Pe.deps??(Pe.deps=[])).push(e);var n=e.reactions;n===null?e.reactions=[Pe]:_n.call(n,Pe)||n.push(Pe)}}}if(tr&&Xs.has(e))return Xs.get(e);if(i){var o=e;if(tr){var a=o.v;return((o.f&Dt)===0&&o.reactions!==null||Yd(o))&&(a=Bh(o)),Xs.set(o,a),a}var h=(o.f&xi)===0&&!Hi&&Pe!==null&&(Ko||(Pe.f&xi)!==0),l=(o.f&Pr)===0;wo(o)&&(h&&(o.f|=xi),Cd(o)),h&&!l&&(kd(o),Vd(o))}if(Lt!=null&&Lt.has(e))return Lt.get(e);if((e.f&Ys)!==0)throw e.v;return e.v}function Vd(e){if(e.f|=xi,e.deps!==null)for(const t of e.deps)(t.reactions??(t.reactions=[])).push(e),(t.f&Ot)!==0&&(t.f&xi)===0&&(kd(t),Vd(t))}function Yd(e){if(e.v===Mt)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(Xs.has(t)||(t.f&Ot)!==0&&Yd(t))return!0;return!1}function ws(e){var t=Hi;try{return Hi=!0,e()}finally{Hi=t}}const Xv=["touchstart","touchmove"];function Qv(e){return Xv.includes(e)}const cr=Symbol("events"),Gd=new Set,_l=new Set;function Jv(e,t,i,s={}){function r(n){if(s.capture||vl.call(t,n),!n.cancelBubble)return ba(()=>i==null?void 0:i.call(this,n))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?$i(()=>{t.addEventListener(e,r,s)}):t.addEventListener(e,r,s),r}function js(e,t,i,s,r){var n={capture:s,passive:r},o=Jv(e,t,i,n);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&Oh(()=>{t.removeEventListener(e,o,n)})}function Q(e,t,i){(t[cr]??(t[cr]={}))[e]=i}function Qe(e){for(var t=0;t<e.length;t++)Gd.add(e[t]);for(var i of _l)i(e)}let vc=null;function vl(e){var m,b;var t=this,i=t.ownerDocument,s=e.type,r=((m=e.composedPath)==null?void 0:m.call(e))||[],n=r[0]||e.target;vc=e;var o=0,a=vc===e&&e[cr];if(a){var h=r.indexOf(a);if(h!==-1&&(t===document||t===window)){e[cr]=t;return}var l=r.indexOf(t);if(l===-1)return;h<=l&&(o=h)}if(n=r[o]||e.target,n!==t){B_(e,"currentTarget",{configurable:!0,get(){return n||i}});var u=Pe,d=Fe;Di(null),ts(null);try{for(var v,p=[];n!==null;){var f=n.assignedSlot||n.parentNode||n.host||null;try{var g=(b=n[cr])==null?void 0:b[s];g!=null&&(!n.disabled||e.target===n)&&g.call(n,e)}catch(R){v?p.push(R):v=R}if(e.cancelBubble||f===t||f===null)break;n=f}if(v){for(let R of p)queueMicrotask(()=>{throw R});throw v}}finally{e[cr]=t,delete e.currentTarget,Di(u),ts(d)}}}var Wu;const Aa=((Wu=globalThis==null?void 0:globalThis.window)==null?void 0:Wu.trustedTypes)&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function Zv(e){return(Aa==null?void 0:Aa.createHTML(e))??e}function Xd(e){var t=Bd("template");return t.innerHTML=Zv(e.replaceAll("<!>","<!---->")),t.content}function mn(e,t){var i=Fe;i.nodes===null&&(i.nodes={start:e,end:t,a:null,t:null})}function B(e,t){var i=(t&ov)!==0,s=(t&av)!==0,r,n=!e.startsWith("<!>");return()=>{r===void 0&&(r=Xd(n?e:"<!>"+e),i||(r=Ss(r)));var o=s||Dd?document.importNode(r,!0):r.cloneNode(!0);if(i){var a=Ss(o),h=o.lastChild;mn(a,h)}else mn(o,o);return o}}function $v(e,t,i="svg"){var s=!e.startsWith("<!>"),r=`<${i}>${s?e:"<!>"+e}</${i}>`,n;return()=>{if(!n){var o=Xd(r),a=Ss(o);n=Ss(a)}var h=n.cloneNode(!0);return mn(h,h),h}}function Hh(e,t){return $v(e,t,"svg")}function pl(e=""){{var t=ms(e+"");return mn(t,t),t}}function Kt(){var e=document.createDocumentFragment(),t=document.createComment(""),i=ms();return e.append(t,i),mn(t,i),e}function T(e,t){e!==null&&e.before(t)}function oe(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 ep(e,t){return tp(e,t)}const Bo=new Map;function tp(e,{target:t,anchor:i,props:s={},events:r,context:n,intro:o=!0,transformError:a}){Nv();var h=void 0,l=Kv(()=>{var u=i??t.appendChild(ms());wv(u,{pending:()=>{}},p=>{Ve({});var f=gt;n&&(f.c=n),r&&(s.$$events=r),h=e(p,s)||{},Ye()},a);var d=new Set,v=p=>{for(var f=0;f<p.length;f++){var g=p[f];if(!d.has(g)){d.add(g);var m=Qv(g);for(const k of[t,document]){var b=Bo.get(k);b===void 0&&(b=new Map,Bo.set(k,b));var R=b.get(g);R===void 0?(k.addEventListener(g,vl,{passive:m}),b.set(g,1)):b.set(g,R+1)}}}};return v(ga(Gd)),_l.add(v),()=>{var m;for(var p of d)for(const b of[t,document]){var f=Bo.get(b),g=f.get(p);--g==0?(b.removeEventListener(p,vl),f.delete(p),f.size===0&&Bo.delete(b)):f.set(p,g)}_l.delete(v),u!==i&&((m=u.parentNode)==null||m.removeChild(u))}});return ip.set(h,l),h}let ip=new WeakMap;var Ai,Gi,hi,gr,uo,fo,_a;class Qd{constructor(t,i=!0){Ti(this,"anchor");X(this,Ai,new Map);X(this,Gi,new Map);X(this,hi,new Map);X(this,gr,new Set);X(this,uo,!0);X(this,fo,()=>{var t=xe;if(_(this,Ai).has(t)){var i=_(this,Ai).get(t),s=_(this,Gi).get(i);if(s)Fh(s),_(this,gr).delete(i);else{var r=_(this,hi).get(i);r&&(_(this,Gi).set(i,r.effect),_(this,hi).delete(i),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),s=r.effect)}for(const[n,o]of _(this,Ai)){if(_(this,Ai).delete(n),n===t)break;const a=_(this,hi).get(o);a&&(ii(a.effect),_(this,hi).delete(o))}for(const[n,o]of _(this,Gi)){if(n===i||_(this,gr).has(n))continue;const a=()=>{if(Array.from(_(this,Ai).values()).includes(n)){var l=document.createDocumentFragment();Wd(o,l),l.append(ms()),_(this,hi).set(n,{effect:o,fragment:l})}else ii(o);_(this,gr).delete(n),_(this,Gi).delete(n)};_(this,uo)||!s?(_(this,gr).add(n),Dr(o,a,!1)):a()}}});X(this,_a,t=>{_(this,Ai).delete(t);const i=Array.from(_(this,Ai).values());for(const[s,r]of _(this,hi))i.includes(s)||(ii(r.effect),_(this,hi).delete(s))});this.anchor=t,W(this,uo,i)}ensure(t,i){var s=xe,r=Pd();if(i&&!_(this,Gi).has(t)&&!_(this,hi).has(t))if(r){var n=document.createDocumentFragment(),o=ms();n.append(o),_(this,hi).set(t,{effect:wi(()=>i(o)),fragment:n})}else _(this,Gi).set(t,wi(()=>i(this.anchor)));if(_(this,Ai).set(s,t),r){for(const[a,h]of _(this,Gi))a===t?s.unskip_effect(h):s.skip_effect(h);for(const[a,h]of _(this,hi))a===t?s.unskip_effect(h.effect):s.skip_effect(h.effect);s.oncommit(_(this,fo)),s.ondiscard(_(this,_a))}else _(this,fo).call(this)}}Ai=new WeakMap,Gi=new WeakMap,hi=new WeakMap,gr=new WeakMap,uo=new WeakMap,fo=new WeakMap,_a=new WeakMap;function te(e,t,i=!1){var s=new Qd(e),r=i?Br:0;function n(o,a){s.ensure(o,a)}wa(()=>{var o=!1;t((a,h=0)=>{o=!0,n(h,a)}),o||n(!1,null)},r)}function Jd(e,t){return t}function sp(e,t,i){for(var s=[],r=t.length,n,o=t.length,a=0;a<r;a++){let d=t[a];Dr(d,()=>{if(n){if(n.pending.delete(d),n.done.add(d),n.pending.size===0){var v=e.outrogroups;gl(ga(n.done)),v.delete(n),v.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var h=s.length===0&&i!==null;if(h){var l=i,u=l.parentNode;Fv(u),u.append(l),e.items.clear()}gl(t,!h)}else n={pending:new Set(t),done:new Set},(e.outrogroups??(e.outrogroups=new Set)).add(n)}function gl(e,t=!0){for(var i=0;i<e.length;i++)ii(e[i],t)}var pc;function Rt(e,t,i,s,r,n=null){var o=e,a=new Map,h=(t&od)!==0;if(h){var l=e;o=l.appendChild(ms())}var u=null,d=wd(()=>{var b=i();return Dh(b)?b:b==null?[]:ga(b)}),v,p=!0;function f(){m.fallback=u,rp(m,v,o,t,s),u!==null&&(v.length===0?(u.f&vs)===0?Fh(u):(u.f^=vs,Fn(u,null,o)):Dr(u,()=>{u=null}))}var g=wa(()=>{v=c(d);for(var b=v.length,R=new Set,k=xe,y=Pd(),D=0;D<b;D+=1){var I=v[D],F=s(I,D),V=p?null:a.get(F);V?(V.v&&pn(V.v,I),V.i&&pn(V.i,D),y&&k.unskip_effect(V.e)):(V=np(a,p?o:pc??(pc=ms()),I,F,D,r,t,i),p||(V.e.f|=vs),a.set(F,V)),R.add(F)}if(b===0&&n&&!u&&(p?u=wi(()=>n(o)):(u=wi(()=>n(pc??(pc=ms()))),u.f|=vs)),b>R.size&&U_(),!p)if(y){for(const[Z,U]of a)R.has(Z)||k.skip_effect(U.e);k.oncommit(f),k.ondiscard(()=>{})}else f();c(d)}),m={effect:g,items:a,outrogroups:null,fallback:u};p=!1}function Mn(e){for(;e!==null&&(e.f&zi)===0;)e=e.next;return e}function rp(e,t,i,s,r){var U,ie,K,x,M,P,Y,ne,N;var n=(s&ev)!==0,o=t.length,a=e.items,h=Mn(e.effect.first),l,u=null,d,v=[],p=[],f,g,m,b;if(n)for(b=0;b<o;b+=1)f=t[b],g=r(f,b),m=a.get(g).e,(m.f&vs)===0&&((ie=(U=m.nodes)==null?void 0:U.a)==null||ie.measure(),(d??(d=new Set)).add(m));for(b=0;b<o;b+=1){if(f=t[b],g=r(f,b),m=a.get(g).e,e.outrogroups!==null)for(const he of e.outrogroups)he.pending.delete(m),he.done.delete(m);if((m.f&vs)!==0)if(m.f^=vs,m===h)Fn(m,null,i);else{var R=u?u.next:h;m===e.effect.last&&(e.effect.last=m.prev),m.prev&&(m.prev.next=m.next),m.next&&(m.next.prev=m.prev),Es(e,u,m),Es(e,m,R),Fn(m,R,i),u=m,v=[],p=[],h=Mn(u.next);continue}if((m.f&ui)!==0&&(Fh(m),n&&((x=(K=m.nodes)==null?void 0:K.a)==null||x.unfix(),(d??(d=new Set)).delete(m))),m!==h){if(l!==void 0&&l.has(m)){if(v.length<p.length){var k=p[0],y;u=k.prev;var D=v[0],I=v[v.length-1];for(y=0;y<v.length;y+=1)Fn(v[y],k,i);for(y=0;y<p.length;y+=1)l.delete(p[y]);Es(e,D.prev,I.next),Es(e,u,D),Es(e,I,k),h=k,u=I,b-=1,v=[],p=[]}else l.delete(m),Fn(m,h,i),Es(e,m.prev,m.next),Es(e,m,u===null?e.effect.first:u.next),Es(e,u,m),u=m;continue}for(v=[],p=[];h!==null&&h!==m;)(l??(l=new Set)).add(h),p.push(h),h=Mn(h.next);if(h===null)continue}(m.f&vs)===0&&v.push(m),u=m,h=Mn(m.next)}if(e.outrogroups!==null){for(const he of e.outrogroups)he.pending.size===0&&(gl(ga(he.done)),(M=e.outrogroups)==null||M.delete(he));e.outrogroups.size===0&&(e.outrogroups=null)}if(h!==null||l!==void 0){var F=[];if(l!==void 0)for(m of l)(m.f&ui)===0&&F.push(m);for(;h!==null;)(h.f&ui)===0&&h!==e.fallback&&F.push(h),h=Mn(h.next);var V=F.length;if(V>0){var Z=(s&od)!==0&&o===0?i:null;if(n){for(b=0;b<V;b+=1)(Y=(P=F[b].nodes)==null?void 0:P.a)==null||Y.measure();for(b=0;b<V;b+=1)(N=(ne=F[b].nodes)==null?void 0:ne.a)==null||N.fix()}sp(e,F,Z)}}n&&$i(()=>{var he,Ce;if(d!==void 0)for(m of d)(Ce=(he=m.nodes)==null?void 0:he.a)==null||Ce.apply()})}function np(e,t,i,s,r,n,o,a){var h=(o&Z_)!==0?(o&tv)===0?Av(i,!1,!1):$s(i):null,l=(o&$_)!==0?$s(r):null;return{v:h,i:l,e:wi(()=>(n(t,h??i,l??r,a),()=>{e.delete(s)}))}}function Fn(e,t,i){if(e.nodes)for(var s=e.nodes.start,r=e.nodes.end,n=t&&(t.f&vs)===0?t.nodes.start:i;s!==null;){var o=yo(s);if(n.before(s),s===r)return;s=o}}function Es(e,t,i){t===null?e.effect.first=i:t.next=i,i===null?e.effect.last=t:i.prev=t}function ml(e,t,i=!1,s=!1,r=!1){var n=e,o="";le(()=>{var a=Fe;if(o!==(o=t()??"")&&(a.nodes!==null&&(Id(a.nodes.start,a.nodes.end),a.nodes=null),o!=="")){var h=i?lv:s?hv:void 0,l=Bd(i?"svg":s?"math":"template",h);l.innerHTML=o;var u=i||s?l:l.content;if(mn(Ss(u),u.lastChild),i||s)for(;Ss(u);)n.before(Ss(u));else n.before(u)}})}function op(e,t,...i){var s=new Qd(e);wa(()=>{const r=t()??null;s.ensure(r,r&&(n=>r(n,...i)))},Br)}function Zd(e,t,i){Ih(()=>{var s=ws(()=>t(e,i==null?void 0:i())||{});if(s!=null&&s.destroy)return()=>s.destroy()})}function $d(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=$d(e[t]))&&(s&&(s+=" "),s+=i)}else for(i in e)e[i]&&(s&&(s+=" "),s+=i);return s}function ap(){for(var e,t,i=0,s="",r=arguments.length;i<r;i++)(e=arguments[i])&&(t=$d(e))&&(s&&(s+=" "),s+=t);return s}function Sl(e){return typeof e=="object"?ap(e):e??""}const gc=[...`
|
|
2
|
-
\r\f \v\uFEFF`];function lp(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 a=o+n;(o===0||gc.includes(s[o-1]))&&(a===s.length||gc.includes(s[a]))?s=(o===0?"":s.substring(0,o))+s.substring(a+1):o=a}}return s===""?null:s}function mc(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 hp(e,t){if(t){var i="",s,r;return Array.isArray(t)?(s=t[0],r=t[1]):s=t,s&&(i+=mc(s)),r&&(i+=mc(r,!0)),i=i.trim(),i===""?null:i}return String(e)}function Le(e,t,i,s,r,n){var o=e.__className;if(o!==i||o===void 0){var a=lp(i,s,n);a==null?e.removeAttribute("class"):t?e.className=a:e.setAttribute("class",a),e.__className=i}else if(n&&r!==n)for(var h in n){var l=!!n[h];(r==null||l!==!!r[h])&&e.classList.toggle(h,l)}return n}function Oa(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 ea(e,t,i,s){var r=e.__style;if(r!==t){var n=hp(t,s);n==null?e.removeAttribute("style"):e.style.cssText=n,e.__style=t}else s&&(Array.isArray(s)?(Oa(e,i==null?void 0:i[0],s[0]),Oa(e,i==null?void 0:i[1],s[1],"important")):Oa(e,i,s));return s}function ef(e,t,i=!1){if(e.multiple){if(t==null)return;if(!Dh(t))return cv();for(var s of e.options)s.selected=t.includes(Gn(s));return}for(s of e.options){var r=Gn(s);if(Iv(r,t)){s.selected=!0;return}}(!i||t!==void 0)&&(e.selectedIndex=-1)}function cp(e){var t=new MutationObserver(()=>{ef(e,e.__value)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Oh(()=>{t.disconnect()})}function qo(e,t,i=t){var s=new WeakSet,r=!0;Lh(e,"change",n=>{var o=n?"[selected]":":checked",a;if(e.multiple)a=[].map.call(e.querySelectorAll(o),Gn);else{var h=e.querySelector(o)??e.querySelector("option:not([disabled])");a=h&&Gn(h)}i(a),xe!==null&&s.add(xe)}),Ih(()=>{var n=t();if(e===document.activeElement){var o=$o??xe;if(s.has(o))return}if(ef(e,n,r),r&&n===void 0){var a=e.querySelector(":checked");a!==null&&(n=Gn(a),i(n))}e.__value=n,r=!1}),cp(e)}function Gn(e){return"__value"in e?e.__value:e.value}const up=Symbol("is custom element"),dp=Symbol("is html"),fp=W_?"progress":"PROGRESS";function _p(e,t){var i=tf(e);i.value===(i.value=t??void 0)||e.value===t&&(t!==0||e.nodeName!==fp)||(e.value=t??"")}function ct(e,t,i,s){var r=tf(e);r[t]!==(r[t]=i)&&(t==="loading"&&(e[H_]=i),i==null?e.removeAttribute(t):typeof i!="string"&&vp(e).includes(t)?e[t]=i:e.setAttribute(t,i))}function tf(e){return e.__attributes??(e.__attributes={[up]:e.nodeName.includes("-"),[dp]:e.namespaceURI===ad})}var Sc=new Map;function vp(e){var t=e.getAttribute("is")||e.nodeName,i=Sc.get(t);if(i)return i;Sc.set(t,i=[]);for(var s,r=e,n=Element.prototype;n!==r;){s=L_(r);for(var o in s)s[o].set&&i.push(o);r=td(r)}return i}function Sn(e,t,i=t){var s=new WeakSet;Lh(e,"input",async r=>{var n=r?e.defaultValue:e.value;if(n=Ia(e)?Na(n):n,i(n),xe!==null&&s.add(xe),await Gv(),n!==(n=t())){var o=e.selectionStart,a=e.selectionEnd,h=e.value.length;if(e.value=n??"",a!==null){var l=e.value.length;o===a&&a===h&&l>h?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(a,l))}}}),ws(t)==null&&e.value&&(i(Ia(e)?Na(e.value):e.value),xe!==null&&s.add(xe)),ya(()=>{var r=t();if(e===document.activeElement){var n=$o??xe;if(s.has(n))return}Ia(e)&&r===Na(e.value)||e.type==="date"&&!r&&!e.value||r!==e.value&&(e.value=r??"")})}function Ls(e,t,i=t){Lh(e,"change",s=>{var r=s?e.defaultChecked:e.checked;i(r)}),ws(t)==null&&i(e.checked),ya(()=>{var s=t();e.checked=!!s})}function Ia(e){var t=e.type;return t==="number"||t==="range"}function Na(e){return e===""?null:+e}function bc(e,t){return e===t||(e==null?void 0:e[Rr])===t}function ht(e={},t,i,s){return Ih(()=>{var r,n;return ya(()=>{r=n,n=[],ws(()=>{e!==i(...n)&&(t(e,...n),r&&bc(i(...r),e)&&t(null,...r))})}),()=>{$i(()=>{n&&bc(i(...n),e)&&t(null,...n)})}}),e}let Lo=!1;function pp(e){var t=Lo;try{return Lo=!1,[e(),Lo]}finally{Lo=t}}function mt(e,t,i,s){var R;var r=(i&rv)!==0,n=(i&nv)!==0,o=s,a=!0,h=()=>(a&&(a=!1,o=n?ws(s):s),o),l;if(r){var u=Rr in e||F_ in e;l=((R=Kr(e,t))==null?void 0:R.set)??(u&&t in e?k=>e[t]=k:void 0)}var d,v=!1;r?[d,v]=pp(()=>e[t]):d=e[t],d===void 0&&s!==void 0&&(d=h(),l&&(Y_(),l(d)));var p;if(p=()=>{var k=e[t];return k===void 0?h():(a=!0,k)},(i&sv)===0)return p;if(l){var f=e.$$legacy;return(function(k,y){return arguments.length>0?((!y||f||v)&&l(y?p():k),k):p()})}var g=!1,m=((i&iv)!==0?Sa:wd)(()=>(g=!1,p()));r&&c(m);var b=Fe;return(function(k,y){if(arguments.length>0){const D=y?c(m):r?Ge(k):k;return S(m,D),g=!0,o!==void 0&&(o=D),k}return tr&&g||(b.f&gs)!==0?m.v:c(m)})}function kn(e){gt===null&&Mh(),er(()=>{const t=ws(e);if(typeof t=="function")return t})}function gp(e){gt===null&&Mh(),kn(()=>()=>ws(e))}const mp="5";var zu;typeof window<"u"&&((zu=window.__svelte??(window.__svelte={})).v??(zu.v=new Set)).add(mp);class Wh extends Error{constructor(i){super("conflict");Ti(this,"sessionId");this.name="ConflictError",this.sessionId=i}}async function Nt(e){if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}async function Sp(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 bp(){return(await fetch("/sessions")).ok}async function yp(){return Nt(await fetch("/sessions"))}async function wp(){return Nt(await fetch("/worktrees"))}async function sf(){return Nt(await fetch("/repos"))}async function Cp(){return Nt(await fetch("/roots"))}async function kp(e,t={}){const i=new URLSearchParams({repo:e});return t.refresh&&i.set("refresh","1"),Nt(await fetch("/branches?"+i.toString()))}async function xp(e,t){return Nt(await fetch("/git-status?repo="+encodeURIComponent(e)+"&branch="+encodeURIComponent(t)))}async function Ep(e){return Nt(await fetch("/pull-requests?repo="+encodeURIComponent(e)))}async function jo(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 Wh(i.sessionId??"")}return Nt(t)}async function rf(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 Wh(i.sessionId??"")}return Nt(t)}async function Rp(){const e=await fetch("/sessions/terminal",{method:"POST"});return Nt(e)}async function Dp(e){await fetch("/sessions/"+e,{method:"DELETE"})}async function Tp(e,t){await fetch("/sessions/"+e,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:t})})}async function Mp(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 Pp(e){return Nt(await fetch("/roots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}))}async function Bp(e){return Nt(await fetch("/roots",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}))}async function Lp(e,t,i){return Nt(await fetch("/sessions/"+e+"/image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:t,mimeType:i})}))}async function nf(){return Nt(await fetch("/version"))}async function of(){return Nt(await fetch("/update",{method:"POST"}))}async function Ap(){return(await Nt(await fetch("/config/defaultAgent"))).defaultAgent}async function Op(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 Ca(e){return(await Nt(await fetch(`/config/${e}`)))[e]}async function ka(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 Ip=()=>Ca("defaultContinue"),Np=e=>ka("defaultContinue",e),Fp=()=>Ca("defaultYolo"),Hp=e=>ka("defaultYolo",e),Wp=()=>Ca("launchInTmux"),zp=e=>ka("launchInTmux",e),Up=()=>Ca("defaultNotifications"),Kp=e=>ka("defaultNotifications",e);async function qp(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")}let ta=j(!1),bl=j(null),yl=j(!0);function af(){return{get authenticated(){return c(ta)},get pinError(){return c(bl)},get checking(){return c(yl)}}}async function jp(){S(yl,!0);try{S(ta,await bp(),!0)}catch{S(ta,!1)}finally{S(yl,!1)}}async function Vp(e){S(bl,null);try{await Sp(e),S(ta,!0)}catch(t){S(bl,t instanceof Error?t.message:"Authentication failed",!0)}}const lf="claude-remote-sidebar-width",hf="claude-remote-sidebar-collapsed",cf=240,uf=180,df=500,Yp=44;function Gp(){try{const e=localStorage.getItem(lf);if(e){const t=parseInt(e,10);if(t>=uf&&t<=df)return t}}catch{}return cf}function Xp(){try{return localStorage.getItem(hf)==="true"}catch{return!1}}let ia=j(!1),wl=j(Ge(Gp())),Xn=j(Ge(Xp())),yc=j("repos"),wc=j(""),Cc=j(""),kc=j(""),xc=j("all");function xn(){return{get sidebarOpen(){return c(ia)},set sidebarOpen(e){S(ia,e,!0)},get sidebarWidth(){return c(wl)},set sidebarWidth(e){S(wl,e,!0)},get sidebarCollapsed(){return c(Xn)},set sidebarCollapsed(e){S(Xn,e,!0)},get activeTab(){return c(yc)},set activeTab(e){S(yc,e,!0)},get rootFilter(){return c(wc)},set rootFilter(e){S(wc,e,!0)},get repoFilter(){return c(Cc)},set repoFilter(e){S(Cc,e,!0)},get searchFilter(){return c(kc)},set searchFilter(e){S(kc,e,!0)},get prRoleFilter(){return c(xc)},set prRoleFilter(e){S(xc,e,!0)}}}function Ec(){S(ia,!0)}function hs(){S(ia,!1)}function Rc(){try{localStorage.setItem(lf,String(c(wl)))}catch{}}function Fa(){S(Xn,!c(Xn));try{localStorage.setItem(hf,String(c(Xn)))}catch{}}let Qn=null,Qp=null;function Jp(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 Dc(){return typeof Notification>"u"?"unsupported":Notification.permission}async function Zp(){return typeof Notification>"u"?"unsupported":Notification.requestPermission()}function $p(){return document.hidden||!document.hasFocus()}function eg(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 ff(){return"serviceWorker"in navigator&&"PushManager"in window}async function tg(){if(ff())try{Qp=await navigator.serviceWorker.register("/sw.js")}catch{return}}async function ig(e){if(ff())try{const i=await(await navigator.serviceWorker.ready).pushManager.getSubscription();i&&await qp(i.toJSON(),e)}catch{}}let sa=j(Ge([])),zh=j(Ge([])),_f=j(Ge([])),Cl=j(null),Ar=Ge({}),to=Ge({}),kl=Ge({}),xa=Ge({}),is=j(Ge({}));const vf="claude-remote-notifications";try{const e=localStorage.getItem(vf);e&&S(is,JSON.parse(e),!0)}catch{}function Uh(){try{localStorage.setItem(vf,JSON.stringify(c(is)))}catch{}}function Kh(){return{get sessions(){return c(sa)},get worktrees(){return c(zh)},get repos(){return c(_f)},get activeSessionId(){return c(Cl)},set activeSessionId(e){S(Cl,e,!0)},get attentionSessions(){return Ar},get gitStatuses(){return kl},get loadingItems(){return xa},get notificationSessions(){return c(is)}}}async function zt(){try{const[e,t,i]=await Promise.all([yp(),wp(),sf()]);S(sa,e,!0),S(zh,t,!0),S(_f,i,!0);const s=new Set(c(sa).map(n=>n.id));let r=!1;for(const n of Object.keys(Ar))s.has(n)||delete Ar[n];for(const n of Object.keys(to))s.has(n)||delete to[n];for(const n of Object.keys(c(is)))s.has(n)||(delete c(is)[n],r=!0);r&&Uh(),sg()}catch{}}let Ha=null;async function sg(){Ha&&clearTimeout(Ha),Ha=setTimeout(async()=>{for(const e of c(zh)){const t=e.name,i=e.repoPath+":"+t;if(!kl[i])try{const s=await xp(e.repoPath,t);kl[i]=s}catch{}}},500)}const rg=3e4;function ng(e,t){const i=c(sa).find(s=>s.id===e);if(i&&(i.idle=t),t&&e!==c(Cl)&&(i==null?void 0:i.type)!=="terminal"){const s=to[e];if(s&&Date.now()-s<rg)return;delete to[e],Ar[e]=!0,i&&c(is)[e]&&$p()&&eg(i)}else delete Ar[e]}function ra(e){delete Ar[e],to[e]=Date.now()}function og(e,t){c(is)[e]=t,Uh()}function Tc(e,t){e in c(is)||(c(is)[e]=t,Uh())}function ag(){return Object.entries(c(is)).filter(([,e])=>e).map(([e])=>e)}function Wa(e){return Ar[e.id]?"attention":e.idle?"idle":"running"}function Hn(e){xa[e]=!0}function Wn(e){delete xa[e]}function Rs(e){return!!xa[e]}const qh=location.protocol==="https:"?"wss:":"ws:";let sr=null,ci=null,Yt=null;const xl=30;let Jn=null,qr=0,Vo=0;function pf(e){sr&&(sr.close(),sr=null);const t=qh+"//"+location.host+"/ws/events";sr=new WebSocket(t),sr.onmessage=i=>{try{e(JSON.parse(i.data))}catch{}},sr.onclose=()=>{setTimeout(()=>pf(e),3e3)},sr.onerror=()=>{}}function gf(e,t,i,s){Jn&&(clearTimeout(Jn),Jn=null),qr=0,ci&&(ci.onclose=null,ci.close(),ci=null);const r=qh+"//"+location.host+"/ws/"+e,n=new WebSocket(r);n.onopen=()=>{ci=n,qr=0,i()},n.onmessage=o=>{t.write(o.data)},n.onclose=o=>{if(o.code===1e3){t.write(`\r
|
|
3
|
-
[Session ended]\r
|
|
4
|
-
`),ci=null,s();return}ci=null,qr===0&&t.write(`\r
|
|
5
|
-
[Reconnecting...]\r
|
|
6
|
-
`),mf(e,t,i,s)},n.onerror=()=>{}}function mf(e,t,i,s){if(qr>=xl){t.write(`\r
|
|
7
|
-
[Gave up reconnecting after `+xl+` attempts]\r
|
|
8
|
-
`);return}const r=Math.min(1e3*2**qr,1e4);qr++,Jn=setTimeout(async()=>{Jn=null;try{if(!(await(await fetch("/sessions")).json()).some(a=>a.id===e)){t.write(`\r
|
|
9
|
-
[Session ended]\r
|
|
10
|
-
`),s();return}t.clear(),gf(e,t,i,s)}catch{mf(e,t,i,s)}},r)}function Zn(e){ci&&ci.readyState===WebSocket.OPEN&&ci.send(e)}function za(e,t){ci&&ci.readyState===WebSocket.OPEN&&ci.send(JSON.stringify({type:"resize",cols:e,rows:t}))}let Qt=null;function Sf(e,t){Yt&&(Yt.onclose=null,Yt.close(),Yt=null),Vo=0,Qt=t;const i=qh+"//"+location.host+"/ws/"+e,s=new WebSocket(i);s.onopen=()=>{Yt=s},s.onmessage=r=>{var n,o;try{const a=JSON.parse(r.data);if(a.type==="session_info")return;if(a.type==="terminal_data"){(n=Qt==null?void 0:Qt.onTerminalData)==null||n.call(Qt,a.data);return}if(a.type==="terminal_exit"){(o=Qt==null?void 0:Qt.onTerminalExit)==null||o.call(Qt);return}Qt==null||Qt.onEvent(a)}catch{}},s.onclose=r=>{if(Yt=null,r.code===1e3){t.onSessionEnd();return}lg(e,t)},s.onerror=()=>{}}function lg(e,t){if(Vo>=xl)return;const i=Math.min(1e3*2**Vo,1e4);Vo++,setTimeout(()=>{Sf(e,t)},i)}function hg(e){Yt&&Yt.readyState===WebSocket.OPEN&&Yt.send(JSON.stringify({type:"message",text:e}))}function Mc(e,t){Yt&&Yt.readyState===WebSocket.OPEN&&Yt.send(JSON.stringify({type:"permission",requestId:e,approved:t}))}function cg(){Yt&&Yt.readyState===WebSocket.OPEN&&Yt.send(JSON.stringify({type:"open_companion"}))}const Mi=Ge({defaultContinue:!0,defaultYolo:!1,launchInTmux:!1,defaultAgent:"claude",defaultNotifications:!0});function Ea(){return Mi}async function jh(){const[e,t,i,s,r]=await Promise.all([Ip().catch(()=>Mi.defaultContinue),Fp().catch(()=>Mi.defaultYolo),Wp().catch(()=>Mi.launchInTmux),Ap().catch(()=>Mi.defaultAgent),Up().catch(()=>Mi.defaultNotifications)]);Mi.defaultContinue=e,Mi.defaultYolo=t,Mi.launchInTmux=i,Mi.defaultAgent=s,Mi.defaultNotifications=r}function Tr(e){return e.split("/").filter(Boolean).pop()||e}function El(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 a=new Date(e);return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a.getMonth()]+" "+a.getDate()}const Pt=typeof window<"u"&&"ontouchstart"in window&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent);var ug=B('<p class="error svelte-1qp96yb"> </p>'),dg=B('<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 fg(e,t){Ve(t,!0);const i=af();let s=j("");async function r(){const v=c(s).trim();v&&(await Vp(v),i.pinError&&S(s,""))}function n(v){v.key==="Enter"&&r()}var o=dg(),a=w(o),h=E(w(a),4);Hv(h);var l=E(h,2),u=E(l,2);{var d=v=>{var p=ug(),f=w(p);le(()=>oe(f,i.pinError)),T(v,p)};te(u,v=>{i.pinError&&v(d)})}Q("keydown",h,n),Sn(h,()=>c(s),v=>S(s,v)),Q("click",l,r),T(e,o),Ye()}Qe(["keydown","click"]);function jr(e){const t=e.firstElementChild,i=e.closest("li");if(!t||!i)return;let s=0;const r=()=>{s=e.scrollWidth-e.clientWidth,s>0?e.classList.add("has-overflow"):(e.classList.remove("has-overflow"),t.style.transform="",t.style.transition="")},n=()=>{if(s<=0)return;const h=Math.max(.6,s/80);t.style.transition=`transform ${h}s linear 0.3s`,t.style.transform=`translateX(-${s}px)`},o=()=>{if(s<=0)return;const h=Math.max(.4,s/100);t.style.transition=`transform ${h}s linear`,t.style.transform="translateX(0)"};r();const a=new ResizeObserver(r);return a.observe(e),i.addEventListener("mouseenter",n),i.addEventListener("mouseleave",o),{destroy(){a.disconnect(),i.removeEventListener("mouseenter",n),i.removeEventListener("mouseleave",o)}}}var _g=Hh('<svg class="agent-badge svelte-1ydsu2f" viewBox="0 0 512 509.64" xmlns="http://www.w3.org/2000/svg" aria-label="Claude"><path fill="currentColor" fill-rule="nonzero" d="M142.27 316.619l73.655-41.326 1.238-3.589-1.238-1.996-3.589-.001-12.31-.759-42.084-1.138-36.498-1.516-35.361-1.896-8.897-1.895-8.34-10.995.859-5.484 7.482-5.03 10.717.935 23.683 1.617 35.537 2.452 25.782 1.517 38.193 3.968h6.064l.86-2.451-2.073-1.517-1.618-1.517-36.776-24.922-39.81-26.338-20.852-15.166-11.273-7.683-5.687-7.204-2.451-15.721 10.237-11.273 13.75.935 3.513.936 13.928 10.716 29.749 23.027 38.848 28.612 5.687 4.727 2.275-1.617.278-1.138-2.553-4.271-21.13-38.193-22.546-38.848-10.035-16.101-2.654-9.655c-.935-3.968-1.617-7.304-1.617-11.374l11.652-15.823 6.445-2.073 15.545 2.073 6.547 5.687 9.655 22.092 15.646 34.78 24.265 47.291 7.103 14.028 3.791 12.992 1.416 3.968 2.449-.001v-2.275l1.997-26.641 3.69-32.707 3.589-42.084 1.239-11.854 5.863-14.206 11.652-7.683 9.099 4.348 7.482 10.716-1.036 6.926-4.449 28.915-8.72 45.294-5.687 30.331h3.313l3.792-3.791 15.342-20.372 25.782-32.227 11.374-12.789 13.27-14.129 8.517-6.724 16.1-.001 11.854 17.617-5.307 18.199-16.581 21.029-13.75 17.819-19.716 26.54-12.309 21.231 1.138 1.694 2.932-.278 44.536-9.479 24.062-4.347 28.714-4.928 12.992 6.066 1.416 6.167-5.106 12.613-30.71 7.583-36.018 7.204-53.636 12.689-.657.48.758.935 24.164 2.275 10.337.556h25.301l47.114 3.514 12.309 8.139 7.381 9.959-1.238 7.583-18.957 9.655-25.579-6.066-59.702-14.205-20.474-5.106-2.83-.001v1.694l17.061 16.682 31.266 28.233 39.152 36.397 1.997 8.999-5.03 7.102-5.307-.758-34.401-25.883-13.27-11.651-30.053-25.302-1.996-.001v2.654l6.926 10.136 36.574 54.975 1.895 16.859-2.653 5.485-9.479 3.311-10.414-1.895-21.408-30.054-22.092-33.844-17.819-30.331-2.173 1.238-10.515 113.261-4.929 5.788-11.374 4.348-9.478-7.204-5.03-11.652 5.03-23.027 6.066-30.052 4.928-23.886 4.449-29.674 2.654-9.858-.177-.657-2.173.278-22.37 30.71-34.021 45.977-26.919 28.815-6.445 2.553-11.173-5.789 1.037-10.337 6.243-9.2 37.257-47.392 22.47-29.371 14.508-16.961-.101-2.451h-.859l-98.954 64.251-17.618 2.275-7.583-7.103.936-11.652 3.589-3.791 29.749-20.474-.101.102.024.101z"></path></svg>'),vg=Hh('<svg class="agent-badge svelte-1ydsu2f" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-label="Codex"><path fill="currentColor" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"></path></svg>');function pg(e,t){var i=Kt(),s=He(i);{var r=o=>{var a=_g();T(o,a)},n=o=>{var a=vg();T(o,a)};te(s,o=>{t.agent==="claude"?o(r):o(n,!1)})}T(e,i)}var gg=B('<li role="menuitem"> </li>'),mg=B('<div class="context-menu-backdrop svelte-1nmhce7"></div> <ul class="context-menu svelte-1nmhce7" role="menu"></ul>',1),Sg=B('<button class="context-menu-trigger svelte-1nmhce7" aria-label="Actions" aria-haspopup="true">···</button> <!>',1);function bf(e,t){let i=j(!1),s=j(null),r=j(null);function n(g){g.stopPropagation(),c(i)?o():(S(i,!0),requestAnimationFrame(a))}function o(){S(i,!1)}function a(){if(!c(s)||!c(r))return;const g=c(s).getBoundingClientRect(),m=c(r).getBoundingClientRect();let b=g.bottom+4,R=g.right-m.width;b+m.height>window.innerHeight-8&&(b=g.top-m.height-4),R<8&&(R=8),c(r).style.top=b+"px",c(r).style.left=R+"px"}function h(g,m){m.stopPropagation(),!g.disabled&&(o(),g.action())}function l(g){!c(i)||g.key!=="Escape"||(g.stopPropagation(),o())}function u(g){g.stopPropagation(),o()}var d=Sg();js("keydown",Rd,l);var v=He(d);ht(v,g=>S(s,g),()=>c(s));var p=E(v,2);{var f=g=>{var m=mg(),b=He(m),R=E(b,2);Rt(R,21,()=>t.items,Jd,(k,y)=>{var D=gg();let I;var F=w(D);le(()=>{I=Le(D,1,"context-menu-item svelte-1nmhce7",null,I,{"context-menu-item--danger":c(y).danger,"context-menu-item--disabled":c(y).disabled}),ct(D,"tabindex",c(y).disabled?-1:0),oe(F,c(y).label)}),Q("click",D,V=>h(c(y),V)),Q("keydown",D,V=>V.key==="Enter"&&h(c(y),V)),T(k,D)}),ht(R,k=>S(r,k),()=>c(r)),Q("click",b,u),Q("click",R,k=>k.stopPropagation()),T(g,m)};te(p,g=>{c(i)&&g(f)})}le(()=>ct(v,"aria-expanded",c(i))),Q("click",v,n),T(e,d)}Qe(["click","keydown"]);var bg=B('<span class="shell-badge svelte-ix4pl2">>_</span>'),yg=B("<span> </span>"),wg=B('<span class="session-sub svelte-ix4pl2"> </span>'),Cg=B('<span class="session-sub svelte-ix4pl2">Shell</span>'),kg=B('<span class="diff-add svelte-ix4pl2"> </span>'),xg=B('<span class="diff-del svelte-ix4pl2"> </span>'),Eg=B('<span class="git-diff svelte-ix4pl2"><!> <!></span>'),Rg=B('<div class="session-row-3 svelte-ix4pl2"><span class="session-time svelte-ix4pl2"> </span> <!></div>'),Dg=B('<li><div class="session-info svelte-ix4pl2"><div class="session-row-1 svelte-ix4pl2"><span></span> <span class="session-name svelte-ix4pl2"><span class="session-name-text svelte-ix4pl2"> </span></span></div> <div><!> <!> <!></div> <!></div> <!></li>');function Pn(e,t){Ve(t,!0);let i=mt(t,"isLoading",3,!1),s=mt(t,"menuItems",19,()=>[]),r=G(()=>{switch(t.variant.kind){case"active":return t.variant.session.displayName||t.variant.session.repoName||t.variant.session.id;case"inactive-worktree":return t.variant.worktree.displayName||t.variant.worktree.name;case"idle-repo":return t.variant.repo.name}}),n=G(()=>{switch(t.variant.kind){case"active":return t.variant.session.root?Tr(t.variant.session.root):"";case"inactive-worktree":return t.variant.worktree.root?Tr(t.variant.worktree.root):"";case"idle-repo":return t.variant.repo.root?Tr(t.variant.repo.root):t.variant.repo.path}}),o=G(()=>{switch(t.variant.kind){case"active":return t.variant.session.repoName||"";case"inactive-worktree":return t.variant.worktree.repoName||"";case"idle-repo":return""}}),a=G(()=>{switch(t.variant.kind){case"active":return El(t.variant.session.lastActivity);case"inactive-worktree":return El(t.variant.worktree.lastActivity);case"idle-repo":return""}}),h=G(()=>t.variant.kind==="active"?"status-dot status-dot--"+t.variant.status:"status-dot status-dot--inactive"),l=G(()=>t.variant.kind==="active"&&t.variant.session.type==="terminal"),u=G(()=>t.variant.kind==="active"&&!c(l)?t.variant.session.agent:void 0),d=G(()=>t.variant.kind==="active"&&t.variant.isSelected),v=G(()=>t.variant.kind==="active"),p=G(()=>{if(!t.gitStatus)return"";switch(t.gitStatus.prState){case"open":return"○";case"merged":return"⬤";case"closed":return"⊗";default:return""}}),f=G(()=>{if(!t.gitStatus)return"";switch(t.gitStatus.prState){case"open":return"pr-icon pr-open";case"merged":return"pr-icon pr-merged";case"closed":return"pr-icon pr-closed";default:return""}});var g=Dg();let m;var b=w(g),R=w(b),k=w(R),y=E(k,2),D=w(y),I=w(D);Zd(y,de=>jr==null?void 0:jr(de));var F=E(R,2);let V;var Z=w(F);{var U=de=>{var L=bg();T(de,L)},ie=de=>{pg(de,{get agent(){return c(u)}})};te(Z,de=>{c(l)?de(U):c(u)&&de(ie,1)})}var K=E(Z,2);{var x=de=>{var L=yg(),ee=w(L);le(()=>{Le(L,1,Sl(c(f)),"svelte-ix4pl2"),oe(ee,c(p))}),T(de,L)};te(K,de=>{c(p)&&de(x)})}var M=E(K,2);{var P=de=>{var L=wg(),ee=w(L);le(()=>oe(ee,`${c(n)??""}${c(o)?" · "+c(o):""}`)),T(de,L)},Y=de=>{var L=Cg();T(de,L)};te(M,de=>{c(l)?de(Y,!1):de(P)})}var ne=E(F,2);{var N=de=>{var L=Rg(),ee=w(L),fe=w(ee),be=E(ee,2);{var ve=me=>{var Ee=Eg(),Ne=w(Ee);{var Je=ce=>{var Ue=kg(),rt=w(Ue);le(()=>oe(rt,`+${t.gitStatus.additions??""}`)),T(ce,Ue)};te(Ne,ce=>{t.gitStatus.additions&&ce(Je)})}var ze=E(Ne,2);{var Ae=ce=>{var Ue=xg(),rt=w(Ue);le(()=>oe(rt,`-${t.gitStatus.deletions??""}`)),T(ce,Ue)};te(ze,ce=>{t.gitStatus.deletions&&ce(Ae)})}T(me,Ee)};te(be,me=>{t.gitStatus&&(t.gitStatus.additions||t.gitStatus.deletions)&&me(ve)})}le(()=>oe(fe,c(a))),T(de,L)};te(ne,de=>{(c(a)||t.gitStatus&&(t.gitStatus.additions||t.gitStatus.deletions))&&de(N)})}var he=E(b,2);{var Ce=de=>{bf(de,{get items(){return s()}})};te(he,de=>{s().length>0&&de(Ce)})}le(()=>{m=Le(g,1,"svelte-ix4pl2",null,m,{"active-session":c(v),"inactive-worktree":!c(v),selected:c(d),loading:i()}),Le(k,1,Sl(c(h)),"svelte-ix4pl2"),oe(I,c(r)),V=Le(F,1,"session-row-2 svelte-ix4pl2",null,V,{"has-badge":!!c(u)||c(l)})}),Q("click",g,function(...de){var L;(L=t.onclick)==null||L.apply(this,de)}),T(e,g),Ye()}Qe(["click"]);var Tg=B('<li role="option"> </li>'),Mg=B('<li class="ss-option ss-no-results svelte-u1ddyn">No matches</li>'),Pg=B('<input type="text" class="ss-input svelte-u1ddyn"/> <ul class="ss-dropdown svelte-u1ddyn" role="listbox"><li role="option"> </li> <!> <!></ul>',1),Bg=B('<button type="button" class="ss-trigger svelte-u1ddyn"><span> </span> <svg class="ss-arrow svelte-u1ddyn" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1l5 5 5-5" stroke="currentColor" fill="none" stroke-width="1.5"></path></svg></button>'),Lg=B('<div class="searchable-select svelte-u1ddyn"><!></div>');function Pc(e,t){Ve(t,!0);let i=mt(t,"value",3,""),s=mt(t,"placeholder",3,"Select..."),r=j(!1),n=j(""),o=j(null),a=j(null),h=G(()=>{var k;return((k=t.options.find(y=>y.value===i()))==null?void 0:k.label)??""}),l=G(()=>{if(!c(n).trim())return t.options;const k=c(n).toLowerCase();return t.options.filter(y=>y.label.toLowerCase().includes(k))});function u(){S(r,!0),S(n,""),requestAnimationFrame(()=>{var k;return(k=c(a))==null?void 0:k.focus()})}function d(){S(r,!1),S(n,"")}function v(k){var y;d(),(y=t.onchange)==null||y.call(t,k)}function p(k){c(r)&&c(o)&&document.contains(k.target)&&!c(o).contains(k.target)&&d()}function f(k){k.key==="Escape"&&c(r)&&(d(),k.stopPropagation())}var g=Lg();js("click",fl,p);var m=w(g);{var b=k=>{var y=Pg(),D=He(y);ht(D,x=>S(a,x),()=>c(a));var I=E(D,2),F=w(I);let V;var Z=w(F),U=E(F,2);Rt(U,17,()=>c(l),x=>x.value,(x,M)=>{var P=Tg();let Y;var ne=w(P);le(()=>{Y=Le(P,1,"ss-option svelte-u1ddyn",null,Y,{"ss-selected":c(M).value===i()}),ct(P,"aria-selected",c(M).value===i()),oe(ne,c(M).label)}),Q("mousedown",P,()=>v(c(M).value)),T(x,P)});var ie=E(U,2);{var K=x=>{var M=Mg();T(x,M)};te(ie,x=>{c(l).length===0&&x(K)})}le(()=>{ct(D,"placeholder",c(h)||s()),V=Le(F,1,"ss-option ss-option--reset svelte-u1ddyn",null,V,{"ss-selected":!i()}),ct(F,"aria-selected",!i()),oe(Z,s())}),Q("keydown",D,f),Sn(D,()=>c(n),x=>S(n,x)),Q("mousedown",F,()=>v("")),T(k,y)},R=k=>{var y=Bg(),D=w(y);let I;var F=w(D);le(()=>{I=Le(D,1,"ss-trigger-text svelte-u1ddyn",null,I,{"ss-placeholder":!i()}),oe(F,c(h)||s())}),Q("click",y,u),T(k,y)};te(m,k=>{c(r)?k(b):k(R,!1)})}ht(g,k=>S(o,k),()=>c(o)),T(e,g),Ye()}Qe(["keydown","mousedown","click"]);var Ag=B("<!> <!>",1),Og=B('<div class="role-filter svelte-1o5d4l8"><button>All</button> <button>Author</button> <button>Reviewer</button></div>'),Ig=B('<div class="sidebar-filters svelte-1o5d4l8"><!> <input type="text" placeholder="Search..." class="svelte-1o5d4l8"/> <!></div>');function Ng(e,t){Ve(t,!0);const i=xn(),s=Kh();let r=G(()=>(()=>{const f=new Set;for(const g of s.sessions)g.root&&f.add(g.root);for(const g of s.worktrees)g.root&&f.add(g.root);for(const g of s.repos)g.root&&f.add(g.root);return[...f].sort()})()),n=G(()=>(()=>{const f=new Set;for(const g of s.sessions)(!i.rootFilter||g.root===i.rootFilter)&&g.repoName&&f.add(g.repoName);for(const g of s.worktrees)(!i.rootFilter||g.root===i.rootFilter)&&g.repoName&&f.add(g.repoName);for(const g of s.repos)(!i.rootFilter||g.root===i.rootFilter)&&g.name&&f.add(g.name);return[...f].sort()})()),o=G(()=>c(r).map(f=>({value:f,label:Tr(f)}))),a=G(()=>c(n).map(f=>({value:f,label:f})));var h=Ig(),l=w(h);{var u=f=>{var g=Ag(),m=He(g);Pc(m,{get options(){return c(o)},get value(){return i.rootFilter},placeholder:"All roots",onchange:R=>{i.rootFilter=R,i.repoFilter=""}});var b=E(m,2);Pc(b,{get options(){return c(a)},get value(){return i.repoFilter},placeholder:"All repos",onchange:R=>{i.repoFilter=R}}),T(f,g)};te(l,f=>{i.activeTab!=="terminals"&&f(u)})}var d=E(l,2),v=E(d,2);{var p=f=>{var g=Og(),m=w(g);let b;var R=E(m,2);let k;var y=E(R,2);let D;le(()=>{b=Le(m,1,"role-btn svelte-1o5d4l8",null,b,{active:i.prRoleFilter==="all"}),k=Le(R,1,"role-btn svelte-1o5d4l8",null,k,{active:i.prRoleFilter==="author"}),D=Le(y,1,"role-btn svelte-1o5d4l8",null,D,{active:i.prRoleFilter==="reviewer"})}),Q("click",m,()=>{i.prRoleFilter="all"}),Q("click",R,()=>{i.prRoleFilter="author"}),Q("click",y,()=>{i.prRoleFilter="reviewer"}),T(f,g)};te(v,f=>{i.activeTab==="prs"&&f(p)})}le(()=>_p(d,i.searchFilter)),Q("input",d,f=>{i.searchFilter=f.target.value}),T(e,h),Ye()}Qe(["input","click"]);var Co=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(){}},Fg={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Os,Rh,Uu,Hg=(Uu=class{constructor(){X(this,Os,Fg);X(this,Rh,!1)}setTimeoutProvider(e){W(this,Os,e)}setTimeout(e,t){return _(this,Os).setTimeout(e,t)}clearTimeout(e){_(this,Os).clearTimeout(e)}setInterval(e,t){return _(this,Os).setInterval(e,t)}clearInterval(e){_(this,Os).clearInterval(e)}},Os=new WeakMap,Rh=new WeakMap,Uu),ur=new Hg;function Wg(e){setTimeout(e,0)}var bn=typeof window>"u"||"Deno"in globalThis;function yi(){}function zg(e,t){return typeof e=="function"?e(t):e}function Rl(e){return typeof e=="number"&&e>=0&&e!==1/0}function yf(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Js(e,t){return typeof e=="function"?e(t):e}function Ci(e,t){return typeof e=="function"?e(t):e}function Bc(e,t){const{type:i="all",exact:s,fetchStatus:r,predicate:n,queryKey:o,stale:a}=e;if(o){if(s){if(t.queryHash!==Vh(o,t.options))return!1}else if(!so(t.queryKey,o))return!1}if(i!=="all"){const h=t.isActive();if(i==="active"&&!h||i==="inactive"&&h)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||r&&r!==t.state.fetchStatus||n&&!n(t))}function Lc(e,t){const{exact:i,status:s,predicate:r,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(i){if(io(t.options.mutationKey)!==io(n))return!1}else if(!so(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)||io)(e)}function io(e){return JSON.stringify(e,(t,i)=>Tl(i)?Object.keys(i).sort().reduce((s,r)=>(s[r]=i[r],s),{}):i)}function so(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(i=>so(e[i],t[i])):!1}var Ug=Object.prototype.hasOwnProperty;function wf(e,t,i=0){if(e===t)return e;if(i>500)return t;const s=Ac(e)&&Ac(t);if(!s&&!(Tl(e)&&Tl(t)))return t;const n=(s?e:Object.keys(e)).length,o=s?t:Object.keys(t),a=o.length,h=s?new Array(a):{};let l=0;for(let u=0;u<a;u++){const d=s?u:o[u],v=e[d],p=t[d];if(v===p){h[d]=v,(s?u<n:Ug.call(e,d))&&l++;continue}if(v===null||p===null||typeof v!="object"||typeof p!="object"){h[d]=p;continue}const f=wf(v,p,i+1);h[d]=f,f===v&&l++}return n===a&&l===n?e:h}function Dl(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 Ac(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Tl(e){if(!Oc(e))return!1;const t=e.constructor;if(t===void 0)return!0;const i=t.prototype;return!(!Oc(i)||!i.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Oc(e){return Object.prototype.toString.call(e)==="[object Object]"}function Kg(e){return new Promise(t=>{ur.setTimeout(t,e)})}function Ml(e,t,i){return typeof i.structuralSharing=="function"?i.structuralSharing(e,t):i.structuralSharing!==!1?wf(e,t):t}function qg(e,t,i=0){const s=[...e,t];return i&&s.length>i?s.slice(1):s}function jg(e,t,i=0){const s=[t,...e];return i&&s.length>i?s.slice(0,-1):s}var Yh=Symbol();function Cf(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 Vg(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 mr,Is,en,Ku,Yg=(Ku=class extends Co{constructor(){super();X(this,mr);X(this,Is);X(this,en);W(this,en,t=>{if(!bn&&window.addEventListener){const i=()=>t();return window.addEventListener("visibilitychange",i,!1),()=>{window.removeEventListener("visibilitychange",i)}}})}onSubscribe(){_(this,Is)||this.setEventListener(_(this,en))}onUnsubscribe(){var t;this.hasListeners()||((t=_(this,Is))==null||t.call(this),W(this,Is,void 0))}setEventListener(t){var i;W(this,en,t),(i=_(this,Is))==null||i.call(this),W(this,Is,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){_(this,mr)!==t&&(W(this,mr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(i=>{i(t)})}isFocused(){var t;return typeof _(this,mr)=="boolean"?_(this,mr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},mr=new WeakMap,Is=new WeakMap,en=new WeakMap,Ku),Gh=new Yg;function Pl(){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 Gg=Wg;function Xg(){let e=[],t=0,i=a=>{a()},s=a=>{a()},r=Gg;const n=a=>{t?e.push(a):r(()=>{i(a)})},o=()=>{const a=e;e=[],a.length&&r(()=>{s(()=>{a.forEach(h=>{i(h)})})})};return{batch:a=>{let h;t++;try{h=a()}finally{t--,t||o()}return h},batchCalls:a=>(...h)=>{n(()=>{a(...h)})},schedule:n,setNotifyFunction:a=>{i=a},setBatchNotifyFunction:a=>{s=a},setScheduler:a=>{r=a}}}var Ut=Xg(),tn,Ns,sn,qu,Qg=(qu=class extends Co{constructor(){super();X(this,tn,!0);X(this,Ns);X(this,sn);W(this,sn,t=>{if(!bn&&window.addEventListener){const i=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",i,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",s)}}})}onSubscribe(){_(this,Ns)||this.setEventListener(_(this,sn))}onUnsubscribe(){var t;this.hasListeners()||((t=_(this,Ns))==null||t.call(this),W(this,Ns,void 0))}setEventListener(t){var i;W(this,sn,t),(i=_(this,Ns))==null||i.call(this),W(this,Ns,t(this.setOnline.bind(this)))}setOnline(t){_(this,tn)!==t&&(W(this,tn,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return _(this,tn)}},tn=new WeakMap,Ns=new WeakMap,sn=new WeakMap,qu),na=new Qg;function Jg(e){return Math.min(1e3*2**e,3e4)}function kf(e){return(e??"online")==="online"?na.isOnline():!0}var Bl=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function xf(e){let t=!1,i=0,s;const r=Pl(),n=()=>r.status!=="pending",o=g=>{var m;if(!n()){const b=new Bl(g);v(b),(m=e.onCancel)==null||m.call(e,b)}},a=()=>{t=!0},h=()=>{t=!1},l=()=>Gh.isFocused()&&(e.networkMode==="always"||na.isOnline())&&e.canRun(),u=()=>kf(e.networkMode)&&e.canRun(),d=g=>{n()||(s==null||s(),r.resolve(g))},v=g=>{n()||(s==null||s(),r.reject(g))},p=()=>new Promise(g=>{var m;s=b=>{(n()||l())&&g(b)},(m=e.onPause)==null||m.call(e)}).then(()=>{var g;s=void 0,n()||(g=e.onContinue)==null||g.call(e)}),f=()=>{if(n())return;let g;const m=i===0?e.initialPromise:void 0;try{g=m??e.fn()}catch(b){g=Promise.reject(b)}Promise.resolve(g).then(d).catch(b=>{var I;if(n())return;const R=e.retry??(bn?0:3),k=e.retryDelay??Jg,y=typeof k=="function"?k(i,b):k,D=R===!0||typeof R=="number"&&i<R||typeof R=="function"&&R(i,b);if(t||!D){v(b);return}i++,(I=e.onFail)==null||I.call(e,i,b),Kg(y).then(()=>l()?void 0:p()).then(()=>{t?v(b):f()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(s==null||s(),r),cancelRetry:a,continueRetry:h,canStart:u,start:()=>(u()?f():p().then(f),r)}}var Sr,ju,Ef=(ju=class{constructor(){X(this,Sr)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Rl(this.gcTime)&&W(this,Sr,ur.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(bn?1/0:300*1e3))}clearGcTimeout(){_(this,Sr)&&(ur.clearTimeout(_(this,Sr)),W(this,Sr,void 0))}},Sr=new WeakMap,ju),br,rn,bi,yr,wt,_o,wr,Oi,ls,Vu,Zg=(Vu=class extends Ef{constructor(t){super();X(this,Oi);X(this,br);X(this,rn);X(this,bi);X(this,yr);X(this,wt);X(this,_o);X(this,wr);W(this,wr,!1),W(this,_o,t.defaultOptions),this.setOptions(t.options),this.observers=[],W(this,yr,t.client),W(this,bi,_(this,yr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,W(this,br,Nc(this.options)),this.state=t.state??_(this,br),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,_o),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const i=Nc(this.options);i.data!==void 0&&(this.setState(Ic(i.data,i.dataUpdatedAt)),W(this,br,i))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&_(this,bi).remove(this)}setData(t,i){const s=Ml(this.state.data,t,this.options);return _e(this,Oi,ls).call(this,{data:s,type:"success",dataUpdatedAt:i==null?void 0:i.updatedAt,manual:i==null?void 0:i.manual}),s}setState(t,i){_e(this,Oi,ls).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,br))}isActive(){return this.observers.some(t=>Ci(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=>Js(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:!yf(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,bi).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,wr)?_(this,wt).cancel({revert:!0}):_(this,wt).cancelRetry()),this.scheduleGc()),_(this,bi).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||_e(this,Oi,ls).call(this,{type:"invalidate"})}async fetch(t,i){var h,l,u,d,v,p,f,g,m,b,R,k;if(this.state.fetchStatus!=="idle"&&((h=_(this,wt))==null?void 0:h.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 y=this.observers.find(D=>D.options.queryFn);y&&this.setOptions(y.options)}const s=new AbortController,r=y=>{Object.defineProperty(y,"signal",{enumerable:!0,get:()=>(W(this,wr,!0),s.signal)})},n=()=>{const y=Cf(this.options,i),I=(()=>{const F={client:_(this,yr),queryKey:this.queryKey,meta:this.meta};return r(F),F})();return W(this,wr,!1),this.options.persister?this.options.persister(y,I,this):y(I)},a=(()=>{const y={fetchOptions:i,options:this.options,queryKey:this.queryKey,client:_(this,yr),state:this.state,fetchFn:n};return r(y),y})();(l=this.options.behavior)==null||l.onFetch(a,this),W(this,rn,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=a.fetchOptions)==null?void 0:u.meta))&&_e(this,Oi,ls).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),W(this,wt,xf({initialPromise:i==null?void 0:i.initialPromise,fn:a.fetchFn,onCancel:y=>{y instanceof Bl&&y.revert&&this.setState({..._(this,rn),fetchStatus:"idle"}),s.abort()},onFail:(y,D)=>{_e(this,Oi,ls).call(this,{type:"failed",failureCount:y,error:D})},onPause:()=>{_e(this,Oi,ls).call(this,{type:"pause"})},onContinue:()=>{_e(this,Oi,ls).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const y=await _(this,wt).start();if(y===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(y),(p=(v=_(this,bi).config).onSuccess)==null||p.call(v,y,this),(g=(f=_(this,bi).config).onSettled)==null||g.call(f,y,this.state.error,this),y}catch(y){if(y instanceof Bl){if(y.silent)return _(this,wt).promise;if(y.revert){if(this.state.data===void 0)throw y;return this.state.data}}throw _e(this,Oi,ls).call(this,{type:"error",error:y}),(b=(m=_(this,bi).config).onError)==null||b.call(m,y,this),(k=(R=_(this,bi).config).onSettled)==null||k.call(R,this.state.data,y,this),y}finally{this.scheduleGc()}}},br=new WeakMap,rn=new WeakMap,bi=new WeakMap,yr=new WeakMap,wt=new WeakMap,_o=new WeakMap,wr=new WeakMap,Oi=new WeakSet,ls=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,...Rf(s.data,this.options),fetchMeta:t.meta??null};case"success":const r={...s,...Ic(t.data,t.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return W(this,rn,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),Ut.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),_(this,bi).notify({query:this,type:"updated",action:t})})},Vu);function Rf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:kf(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Ic(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Nc(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 $t,Be,vo,Vt,Cr,nn,fs,Fs,po,on,an,kr,xr,Hs,ln,We,zn,Ll,Al,Ol,Il,Nl,Fl,Hl,Df,Yu,$g=(Yu=class extends Co{constructor(t,i){super();X(this,We);X(this,$t);X(this,Be);X(this,vo);X(this,Vt);X(this,Cr);X(this,nn);X(this,fs);X(this,Fs);X(this,po);X(this,on);X(this,an);X(this,kr);X(this,xr);X(this,Hs);X(this,ln,new Set);this.options=i,W(this,$t,t),W(this,Fs,null),W(this,fs,Pl()),this.bindMethods(),this.setOptions(i)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(_(this,Be).addObserver(this),Fc(_(this,Be),this.options)?_e(this,We,zn).call(this):this.updateResult(),_e(this,We,Il).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Wl(_(this,Be),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Wl(_(this,Be),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,_e(this,We,Nl).call(this),_e(this,We,Fl).call(this),_(this,Be).removeObserver(this)}setOptions(t){const i=this.options,s=_(this,Be);if(this.options=_(this,$t).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Ci(this.options.enabled,_(this,Be))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");_e(this,We,Hl).call(this),_(this,Be).setOptions(this.options),i._defaulted&&!Dl(this.options,i)&&_(this,$t).getQueryCache().notify({type:"observerOptionsUpdated",query:_(this,Be),observer:this});const r=this.hasListeners();r&&Hc(_(this,Be),s,this.options,i)&&_e(this,We,zn).call(this),this.updateResult(),r&&(_(this,Be)!==s||Ci(this.options.enabled,_(this,Be))!==Ci(i.enabled,_(this,Be))||Js(this.options.staleTime,_(this,Be))!==Js(i.staleTime,_(this,Be)))&&_e(this,We,Ll).call(this);const n=_e(this,We,Al).call(this);r&&(_(this,Be)!==s||Ci(this.options.enabled,_(this,Be))!==Ci(i.enabled,_(this,Be))||n!==_(this,Hs))&&_e(this,We,Ol).call(this,n)}getOptimisticResult(t){const i=_(this,$t).getQueryCache().build(_(this,$t),t),s=this.createResult(i,t);return tm(this,s)&&(W(this,Vt,s),W(this,nn,this.options),W(this,Cr,_(this,Be).state)),s}getCurrentResult(){return _(this,Vt)}trackResult(t,i){return new Proxy(t,{get:(s,r)=>(this.trackProp(r),i==null||i(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&_(this,fs).status==="pending"&&_(this,fs).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(t){_(this,ln).add(t)}getCurrentQuery(){return _(this,Be)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const i=_(this,$t).defaultQueryOptions(t),s=_(this,$t).getQueryCache().build(_(this,$t),i);return s.fetch().then(()=>this.createResult(s,i))}fetch(t){return _e(this,We,zn).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),_(this,Vt)))}createResult(t,i){var Z;const s=_(this,Be),r=this.options,n=_(this,Vt),o=_(this,Cr),a=_(this,nn),l=t!==s?t.state:_(this,vo),{state:u}=t;let d={...u},v=!1,p;if(i._optimisticResults){const U=this.hasListeners(),ie=!U&&Fc(t,i),K=U&&Hc(t,s,i,r);(ie||K)&&(d={...d,...Rf(u.data,t.options)}),i._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:f,errorUpdatedAt:g,status:m}=d;p=d.data;let b=!1;if(i.placeholderData!==void 0&&p===void 0&&m==="pending"){let U;n!=null&&n.isPlaceholderData&&i.placeholderData===(a==null?void 0:a.placeholderData)?(U=n.data,b=!0):U=typeof i.placeholderData=="function"?i.placeholderData((Z=_(this,an))==null?void 0:Z.state.data,_(this,an)):i.placeholderData,U!==void 0&&(m="success",p=Ml(n==null?void 0:n.data,U,i),v=!0)}if(i.select&&p!==void 0&&!b)if(n&&p===(o==null?void 0:o.data)&&i.select===_(this,po))p=_(this,on);else try{W(this,po,i.select),p=i.select(p),p=Ml(n==null?void 0:n.data,p,i),W(this,on,p),W(this,Fs,null)}catch(U){W(this,Fs,U)}_(this,Fs)&&(f=_(this,Fs),p=_(this,on),g=Date.now(),m="error");const R=d.fetchStatus==="fetching",k=m==="pending",y=m==="error",D=k&&R,I=p!==void 0,V={status:m,fetchStatus:d.fetchStatus,isPending:k,isSuccess:m==="success",isError:y,isInitialLoading:D,isLoading:D,data:p,dataUpdatedAt:d.dataUpdatedAt,error:f,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:R,isRefetching:R&&!k,isLoadingError:y&&!I,isPaused:d.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:y&&I,isStale:Xh(t,i),refetch:this.refetch,promise:_(this,fs),isEnabled:Ci(i.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const U=V.data!==void 0,ie=V.status==="error"&&!U,K=P=>{ie?P.reject(V.error):U&&P.resolve(V.data)},x=()=>{const P=W(this,fs,V.promise=Pl());K(P)},M=_(this,fs);switch(M.status){case"pending":t.queryHash===s.queryHash&&K(M);break;case"fulfilled":(ie||V.data!==M.value)&&x();break;case"rejected":(!ie||V.error!==M.reason)&&x();break}}return V}updateResult(){const t=_(this,Vt),i=this.createResult(_(this,Be),this.options);if(W(this,Cr,_(this,Be).state),W(this,nn,this.options),_(this,Cr).data!==void 0&&W(this,an,_(this,Be)),Dl(i,t))return;W(this,Vt,i);const s=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,n=typeof r=="function"?r():r;if(n==="all"||!n&&!_(this,ln).size)return!0;const o=new Set(n??_(this,ln));return this.options.throwOnError&&o.add("error"),Object.keys(_(this,Vt)).some(a=>{const h=a;return _(this,Vt)[h]!==t[h]&&o.has(h)})};_e(this,We,Df).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&_e(this,We,Il).call(this)}},$t=new WeakMap,Be=new WeakMap,vo=new WeakMap,Vt=new WeakMap,Cr=new WeakMap,nn=new WeakMap,fs=new WeakMap,Fs=new WeakMap,po=new WeakMap,on=new WeakMap,an=new WeakMap,kr=new WeakMap,xr=new WeakMap,Hs=new WeakMap,ln=new WeakMap,We=new WeakSet,zn=function(t){_e(this,We,Hl).call(this);let i=_(this,Be).fetch(this.options,t);return t!=null&&t.throwOnError||(i=i.catch(yi)),i},Ll=function(){_e(this,We,Nl).call(this);const t=Js(this.options.staleTime,_(this,Be));if(bn||_(this,Vt).isStale||!Rl(t))return;const s=yf(_(this,Vt).dataUpdatedAt,t)+1;W(this,kr,ur.setTimeout(()=>{_(this,Vt).isStale||this.updateResult()},s))},Al=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(_(this,Be)):this.options.refetchInterval)??!1},Ol=function(t){_e(this,We,Fl).call(this),W(this,Hs,t),!(bn||Ci(this.options.enabled,_(this,Be))===!1||!Rl(_(this,Hs))||_(this,Hs)===0)&&W(this,xr,ur.setInterval(()=>{(this.options.refetchIntervalInBackground||Gh.isFocused())&&_e(this,We,zn).call(this)},_(this,Hs)))},Il=function(){_e(this,We,Ll).call(this),_e(this,We,Ol).call(this,_e(this,We,Al).call(this))},Nl=function(){_(this,kr)&&(ur.clearTimeout(_(this,kr)),W(this,kr,void 0))},Fl=function(){_(this,xr)&&(ur.clearInterval(_(this,xr)),W(this,xr,void 0))},Hl=function(){const t=_(this,$t).getQueryCache().build(_(this,$t),this.options);if(t===_(this,Be))return;const i=_(this,Be);W(this,Be,t),W(this,vo,t.state),this.hasListeners()&&(i==null||i.removeObserver(this),t.addObserver(this))},Df=function(t){Ut.batch(()=>{t.listeners&&this.listeners.forEach(i=>{i(_(this,Vt))}),_(this,$t).getQueryCache().notify({query:_(this,Be),type:"observerResultsUpdated"})})},Yu);function em(e,t){return Ci(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Fc(e,t){return em(e,t)||e.state.data!==void 0&&Wl(e,t,t.refetchOnMount)}function Wl(e,t,i){if(Ci(t.enabled,e)!==!1&&Js(t.staleTime,e)!=="static"){const s=typeof i=="function"?i(e):i;return s==="always"||s!==!1&&Xh(e,t)}return!1}function Hc(e,t,i,s){return(e!==t||Ci(s.enabled,e)===!1)&&(!i.suspense||e.state.status!=="error")&&Xh(e,i)}function Xh(e,t){return Ci(t.enabled,e)!==!1&&e.isStaleByTime(Js(t.staleTime,e))}function tm(e,t){return!Dl(e.getCurrentResult(),t)}function Wc(e){return{onFetch:(t,i)=>{var u,d,v,p,f;const s=t.options,r=(v=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:v.direction,n=((p=t.state.data)==null?void 0:p.pages)||[],o=((f=t.state.data)==null?void 0:f.pageParams)||[];let a={pages:[],pageParams:[]},h=0;const l=async()=>{let g=!1;const m=k=>{Vg(k,()=>t.signal,()=>g=!0)},b=Cf(t.options,t.fetchOptions),R=async(k,y,D)=>{if(g)return Promise.reject();if(y==null&&k.pages.length)return Promise.resolve(k);const F=(()=>{const ie={client:t.client,queryKey:t.queryKey,pageParam:y,direction:D?"backward":"forward",meta:t.options.meta};return m(ie),ie})(),V=await b(F),{maxPages:Z}=t.options,U=D?jg:qg;return{pages:U(k.pages,V,Z),pageParams:U(k.pageParams,y,Z)}};if(r&&n.length){const k=r==="backward",y=k?im:zc,D={pages:n,pageParams:o},I=y(s,D);a=await R(D,I,k)}else{const k=e??n.length;do{const y=h===0?o[0]??s.initialPageParam:zc(s,a);if(h>0&&y==null)break;a=await R(a,y),h++}while(h<k)}return a};t.options.persister?t.fetchFn=()=>{var g,m;return(m=(g=t.options).persister)==null?void 0:m.call(g,l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},i)}:t.fetchFn=l}}}function zc(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 im(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 go,Xi,Wt,Er,Qi,Ps,Gu,sm=(Gu=class extends Ef{constructor(t){super();X(this,Qi);X(this,go);X(this,Xi);X(this,Wt);X(this,Er);W(this,go,t.client),this.mutationId=t.mutationId,W(this,Wt,t.mutationCache),W(this,Xi,[]),this.state=t.state||rm(),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,Xi).includes(t)||(_(this,Xi).push(t),this.clearGcTimeout(),_(this,Wt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){W(this,Xi,_(this,Xi).filter(i=>i!==t)),this.scheduleGc(),_(this,Wt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){_(this,Xi).length||(this.state.status==="pending"?this.scheduleGc():_(this,Wt).remove(this))}continue(){var t;return((t=_(this,Er))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,h,l,u,d,v,p,f,g,m,b,R,k,y,D,I,F;const i=()=>{_e(this,Qi,Ps).call(this,{type:"continue"})},s={client:_(this,go),meta:this.options.meta,mutationKey:this.options.mutationKey};W(this,Er,xf({fn:()=>this.options.mutationFn?this.options.mutationFn(t,s):Promise.reject(new Error("No mutationFn found")),onFail:(V,Z)=>{_e(this,Qi,Ps).call(this,{type:"failed",failureCount:V,error:Z})},onPause:()=>{_e(this,Qi,Ps).call(this,{type:"pause"})},onContinue:i,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>_(this,Wt).canRun(this)}));const r=this.state.status==="pending",n=!_(this,Er).canStart();try{if(r)i();else{_e(this,Qi,Ps).call(this,{type:"pending",variables:t,isPaused:n}),_(this,Wt).config.onMutate&&await _(this,Wt).config.onMutate(t,this,s);const Z=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,s));Z!==this.state.context&&_e(this,Qi,Ps).call(this,{type:"pending",context:Z,variables:t,isPaused:n})}const V=await _(this,Er).start();return await((l=(h=_(this,Wt).config).onSuccess)==null?void 0:l.call(h,V,t,this.state.context,this,s)),await((d=(u=this.options).onSuccess)==null?void 0:d.call(u,V,t,this.state.context,s)),await((p=(v=_(this,Wt).config).onSettled)==null?void 0:p.call(v,V,null,this.state.variables,this.state.context,this,s)),await((g=(f=this.options).onSettled)==null?void 0:g.call(f,V,null,t,this.state.context,s)),_e(this,Qi,Ps).call(this,{type:"success",data:V}),V}catch(V){try{await((b=(m=_(this,Wt).config).onError)==null?void 0:b.call(m,V,t,this.state.context,this,s))}catch(Z){Promise.reject(Z)}try{await((k=(R=this.options).onError)==null?void 0:k.call(R,V,t,this.state.context,s))}catch(Z){Promise.reject(Z)}try{await((D=(y=_(this,Wt).config).onSettled)==null?void 0:D.call(y,void 0,V,this.state.variables,this.state.context,this,s))}catch(Z){Promise.reject(Z)}try{await((F=(I=this.options).onSettled)==null?void 0:F.call(I,void 0,V,t,this.state.context,s))}catch(Z){Promise.reject(Z)}throw _e(this,Qi,Ps).call(this,{type:"error",error:V}),V}finally{_(this,Wt).runNext(this)}}},go=new WeakMap,Xi=new WeakMap,Wt=new WeakMap,Er=new WeakMap,Qi=new WeakSet,Ps=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),Ut.batch(()=>{_(this,Xi).forEach(s=>{s.onMutationUpdate(t)}),_(this,Wt).notify({mutation:this,type:"updated",action:t})})},Gu);function rm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var _s,Ii,mo,Xu,nm=(Xu=class extends Co{constructor(t={}){super();X(this,_s);X(this,Ii);X(this,mo);this.config=t,W(this,_s,new Set),W(this,Ii,new Map),W(this,mo,0)}build(t,i,s){const r=new sm({client:t,mutationCache:this,mutationId:++Mo(this,mo)._,options:t.defaultMutationOptions(i),state:s});return this.add(r),r}add(t){_(this,_s).add(t);const i=Ao(t);if(typeof i=="string"){const s=_(this,Ii).get(i);s?s.push(t):_(this,Ii).set(i,[t])}this.notify({type:"added",mutation:t})}remove(t){if(_(this,_s).delete(t)){const i=Ao(t);if(typeof i=="string"){const s=_(this,Ii).get(i);if(s)if(s.length>1){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}else s[0]===t&&_(this,Ii).delete(i)}}this.notify({type:"removed",mutation:t})}canRun(t){const i=Ao(t);if(typeof i=="string"){const s=_(this,Ii).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=Ao(t);if(typeof i=="string"){const r=(s=_(this,Ii).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(){Ut.batch(()=>{_(this,_s).forEach(t=>{this.notify({type:"removed",mutation:t})}),_(this,_s).clear(),_(this,Ii).clear()})}getAll(){return Array.from(_(this,_s))}find(t){const i={exact:!0,...t};return this.getAll().find(s=>Lc(i,s))}findAll(t={}){return this.getAll().filter(i=>Lc(t,i))}notify(t){Ut.batch(()=>{this.listeners.forEach(i=>{i(t)})})}resumePausedMutations(){const t=this.getAll().filter(i=>i.state.isPaused);return Ut.batch(()=>Promise.all(t.map(i=>i.continue().catch(yi))))}},_s=new WeakMap,Ii=new WeakMap,mo=new WeakMap,Xu);function Ao(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ji,Qu,om=(Qu=class extends Co{constructor(t={}){super();X(this,Ji);this.config=t,W(this,Ji,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 Zg({client:t,queryKey:r,queryHash:n,options:t.defaultQueryOptions(i),state:s,defaultOptions:t.getQueryDefaults(r)}),this.add(o)),o}add(t){_(this,Ji).has(t.queryHash)||(_(this,Ji).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const i=_(this,Ji).get(t.queryHash);i&&(t.destroy(),i===t&&_(this,Ji).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ut.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return _(this,Ji).get(t)}getAll(){return[..._(this,Ji).values()]}find(t){const i={exact:!0,...t};return this.getAll().find(s=>Bc(i,s))}findAll(t={}){const i=this.getAll();return Object.keys(t).length>0?i.filter(s=>Bc(t,s)):i}notify(t){Ut.batch(()=>{this.listeners.forEach(i=>{i(t)})})}onFocus(){Ut.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ut.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ji=new WeakMap,Qu),nt,Ws,zs,hn,cn,Us,un,dn,Ju,Tf=(Ju=class{constructor(e={}){X(this,nt);X(this,Ws);X(this,zs);X(this,hn);X(this,cn);X(this,Us);X(this,un);X(this,dn);W(this,nt,e.queryCache||new om),W(this,Ws,e.mutationCache||new nm),W(this,zs,e.defaultOptions||{}),W(this,hn,new Map),W(this,cn,new Map),W(this,Us,0)}mount(){Mo(this,Us)._++,_(this,Us)===1&&(W(this,un,Gh.subscribe(async e=>{e&&(await this.resumePausedMutations(),_(this,nt).onFocus())})),W(this,dn,na.subscribe(async e=>{e&&(await this.resumePausedMutations(),_(this,nt).onOnline())})))}unmount(){var e,t;Mo(this,Us)._--,_(this,Us)===0&&((e=_(this,un))==null||e.call(this),W(this,un,void 0),(t=_(this,dn))==null||t.call(this),W(this,dn,void 0))}isFetching(e){return _(this,nt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return _(this,Ws).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(Js(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=zg(t,n);if(o!==void 0)return _(this,nt).build(this,s).setData(o,{...i,manual:!0})}setQueriesData(e,t,i){return Ut.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);Ut.batch(()=>{t.findAll(e).forEach(i=>{t.remove(i)})})}resetQueries(e,t){const i=_(this,nt);return Ut.batch(()=>(i.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const i={revert:!0,...t},s=Ut.batch(()=>_(this,nt).findAll(e).map(r=>r.cancel(i)));return Promise.all(s).then(yi).catch(yi)}invalidateQueries(e,t={}){return Ut.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=Ut.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(Js(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=Wc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(yi).catch(yi)}ensureInfiniteQueryData(e){return e.behavior=Wc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return na.isOnline()?_(this,Ws).resumePausedMutations():Promise.resolve()}getQueryCache(){return _(this,nt)}getMutationCache(){return _(this,Ws)}getDefaultOptions(){return _(this,zs)}setDefaultOptions(e){W(this,zs,e)}setQueryDefaults(e,t){_(this,hn).set(io(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[..._(this,hn).values()],i={};return t.forEach(s=>{so(e,s.queryKey)&&Object.assign(i,s.defaultOptions)}),i}setMutationDefaults(e,t){_(this,cn).set(io(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[..._(this,cn).values()],i={};return t.forEach(s=>{so(e,s.mutationKey)&&Object.assign(i,s.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;const t={..._(this,zs).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=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,zs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){_(this,nt).clear(),_(this,Ws).clear()}},nt=new WeakMap,Ws=new WeakMap,zs=new WeakMap,hn=new WeakMap,cn=new WeakMap,Us=new WeakMap,un=new WeakMap,dn=new WeakMap,Ju);const Mf=Symbol("QueryClient"),am=()=>{const e=cd(Mf);if(!e)throw new Error("No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?");return e},lm=e=>{_v(Mf,e)},hm=Symbol("isRestoring"),cm=()=>{try{return cd(hm)??{current:!1}}catch{return{current:!1}}};function um(){return cm()}function dm(e){return am()}var fm=["forEach","isDisjointFrom","isSubsetOf","isSupersetOf"],_m=["difference","intersection","symmetricDifference","union"],Uc=!1,fn,Ni,Ks,va,wn,Pf,Bf;const pa=class pa extends Set{constructor(i){super();X(this,wn);X(this,fn,new Map);X(this,Ni,j(0));X(this,Ks,j(0));X(this,va,bs||-1);if(i){for(var s of i)super.add(s);_(this,Ks).v=super.size}Uc||_e(this,wn,Bf).call(this)}has(i){var s=super.has(i),r=_(this,fn),n=r.get(i);if(n===void 0){if(!s)return c(_(this,Ni)),!1;n=_e(this,wn,Pf).call(this,!0),r.set(i,n)}return c(n),s}add(i){return super.has(i)||(super.add(i),S(_(this,Ks),super.size),Qs(_(this,Ni))),this}delete(i){var s=super.delete(i),r=_(this,fn),n=r.get(i);return n!==void 0&&(r.delete(i),S(n,!1)),s&&(S(_(this,Ks),super.size),Qs(_(this,Ni))),s}clear(){if(super.size!==0){super.clear();var i=_(this,fn);for(var s of i.values())S(s,!1);i.clear(),S(_(this,Ks),0),Qs(_(this,Ni))}}keys(){return this.values()}values(){return c(_(this,Ni)),super.values()}entries(){return c(_(this,Ni)),super.entries()}[Symbol.iterator](){return this.keys()}get size(){return c(_(this,Ks))}};fn=new WeakMap,Ni=new WeakMap,Ks=new WeakMap,va=new WeakMap,wn=new WeakSet,Pf=function(i){return bs===_(this,va)?j(i):$s(i)},Bf=function(){Uc=!0;var i=pa.prototype,s=Set.prototype;for(const r of fm)i[r]=function(...n){return c(_(this,Ni)),s[r].apply(this,n)};for(const r of _m)i[r]=function(...n){c(_(this,Ni));var o=s[r].apply(this,n);return new pa(o)}};let zl=pa;function vm(e){const t=Array.isArray(e)?[]:{},i=new zl,s=new Proxy(t,{set(n,o,a,h){if(i.delete(o),o in n)return Reflect.set(n,o,a,h);let l=j(a);return Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:()=>c(l)&&gm(c(l))?c(l)():c(l),set:u=>{S(l,u)}}),!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),a=Object.keys(n),h=o.filter(l=>!a.includes(l));for(const l of h)delete s[l];for(const l of a)s[l]=pm(()=>n[l])}return r(e),[s,r]}const Lf=Symbol("LazyValue");function pm(e){return e[Lf]=!0,e}function gm(e){return!!e[Lf]}function mm(e,t){switch(e){case"post":er(t);break;case"pre":Uv(t);break}}const Ua=(e,t,i)=>{let s=!1,r=Array.isArray(e)?[]:void 0;mm(t,()=>{const n=Array.isArray(e)?e.map(a=>a()):e();if(!s){s=!0,r=n;return}const o=ws(()=>i(n,r));return r=n,o})};function Sm(e,t,i){const s=G(()=>dm()),r=um(),n=G(()=>{const u=c(s).defaultQueryOptions(e());return u._optimisticResults=r.current?"isRestoring":"optimistic",u});let o=j(Ge(new t(c(s),c(n))));Ua(()=>c(s),"pre",()=>{S(o,new t(c(s),c(n)),!0)});function a(){const u=c(o).getOptimisticResult(c(n));return c(n).notifyOnChangeProps?u:c(o).trackResult(u)}const[h,l]=vm(a());return er(()=>{const u=r.current?()=>{}:c(o).subscribe(()=>l(a()));return c(o).updateResult(),u}),Ua(()=>c(n),"pre",()=>{c(o).setOptions(c(n))}),Ua(()=>[c(n),c(o)],"pre",()=>{l(a())}),h}function bm(e,t){return Sm(e,$g)}function ym(e,t){Ve(t,!0);const i=mt(t,"client",19,()=>new Tf);kn(()=>{i().mount()}),lm(i()),gp(()=>{i().unmount()});var s=Kt(),r=He(s);op(r,()=>t.children),T(e,s),Ye()}var wm=B("<span> </span>"),Cm=B('<span class="diff-add svelte-jhsg4e"> </span>'),km=B('<span class="diff-del svelte-jhsg4e"> </span>'),xm=B('<span class="git-diff svelte-jhsg4e"><!> <!></span>'),Em=B('<div class="pr-row-3 svelte-jhsg4e"><span class="pr-time svelte-jhsg4e"> </span> <!></div>'),Rm=B('<li><div class="pr-info svelte-jhsg4e"><div class="pr-row-1 svelte-jhsg4e"><span> </span> <span class="pr-title svelte-jhsg4e"><span class="pr-title-text svelte-jhsg4e"> </span></span></div> <div class="pr-row-2 svelte-jhsg4e"><span class="pr-meta svelte-jhsg4e"> </span> <span> </span> <!></div> <!></div> <!></li>');function Dm(e,t){Ve(t,!0);let i=mt(t,"isSelected",3,!1),s=mt(t,"menuItems",19,()=>[]),r=G(()=>{switch(t.pr.state){case"OPEN":return"○";case"MERGED":return"⬤";default:return"⊗"}}),n=G(()=>{switch(t.pr.state){case"OPEN":return"pr-state pr-open";case"MERGED":return"pr-state pr-merged";default:return"pr-state pr-closed"}}),o=G(()=>t.pr.role==="author"?"Author":"Reviewer"),a=G(()=>{switch(t.pr.reviewDecision){case"APPROVED":return"✓";case"CHANGES_REQUESTED":return"✗";case"REVIEW_REQUIRED":return"⏳";default:return""}}),h=G(()=>{switch(t.pr.reviewDecision){case"APPROVED":return"review-approved";case"CHANGES_REQUESTED":return"review-changes";default:return"review-pending"}}),l=G(()=>El(t.pr.updatedAt));var u=Rm();let d;var v=w(u),p=w(v),f=w(p),g=w(f),m=E(f,2),b=w(m),R=w(b);Zd(m,M=>jr==null?void 0:jr(M));var k=E(p,2),y=w(k),D=w(y),I=E(y,2),F=w(I),V=E(I,2);{var Z=M=>{var P=wm(),Y=w(P);le(()=>{Le(P,1,`review-badge ${c(h)??""}`,"svelte-jhsg4e"),ct(P,"title",t.pr.reviewDecision??""),oe(Y,c(a))}),T(M,P)};te(V,M=>{c(a)&&M(Z)})}var U=E(k,2);{var ie=M=>{var P=Em(),Y=w(P),ne=w(Y),N=E(Y,2);{var he=Ce=>{var de=xm(),L=w(de);{var ee=ve=>{var me=Cm(),Ee=w(me);le(()=>oe(Ee,`+${t.pr.additions??""}`)),T(ve,me)};te(L,ve=>{t.pr.additions&&ve(ee)})}var fe=E(L,2);{var be=ve=>{var me=km(),Ee=w(me);le(()=>oe(Ee,`-${t.pr.deletions??""}`)),T(ve,me)};te(fe,ve=>{t.pr.deletions&&ve(be)})}T(Ce,de)};te(N,Ce=>{(t.pr.additions||t.pr.deletions)&&Ce(he)})}le(()=>oe(ne,c(l))),T(M,P)};te(U,M=>{(c(l)||t.pr.additions||t.pr.deletions)&&M(ie)})}var K=E(v,2);{var x=M=>{bf(M,{get items(){return s()}})};te(K,M=>{s().length>0&&M(x)})}le(()=>{d=Le(u,1,"pr-item svelte-jhsg4e",null,d,{"active-session":t.isActiveSession,selected:i()}),Le(f,1,Sl(c(n)),"svelte-jhsg4e"),oe(g,c(r)),oe(R,t.pr.title),oe(D,`#${t.pr.number??""} · ${t.pr.author??""}`),Le(I,1,`role-badge role-${t.pr.role??""}`,"svelte-jhsg4e"),oe(F,c(o))}),Q("click",u,function(...M){var P;(P=t.onclick)==null||P.apply(this,M)}),T(e,u),Ye()}Qe(["click"]);var Tm=B('<button class="repo-group-refresh svelte-1ekl114" aria-label="Refresh pull requests"><span>↻</span></button>'),Mm=B('<li class="pr-hint">Loading...</li>'),Pm=B('<li class="pr-hint">GitHub CLI not authenticated<br/><span class="pr-hint-sub">Run <code>gh auth login</code> on the host</span></li>'),Bm=B('<li class="pr-hint">Could not fetch pull requests</li>'),Lm=B('<li class="pr-hint">No open pull requests</li>'),Am=B('<li class="repo-group-header"><span>▶</span> <span class="repo-group-name"> </span> <span class="repo-group-root"> </span> <span class="repo-group-count"> </span> <!></li> <!>',1);function Om(e,t){Ve(t,!0);const i=xn();let s=j(!1);const r=bm(()=>({queryKey:["pull-requests",t.repo.path],queryFn:()=>Ep(t.repo.path),enabled:c(s)}));let n=G(()=>r.data),o=G(()=>{var U;return((U=c(n))==null?void 0:U.error)??null}),a=G(()=>{var U;return((U=c(n))==null?void 0:U.prs)??[]}),h=G(()=>{var ie;const U=(ie=i.searchFilter)==null?void 0:ie.toLowerCase();return c(a).filter(K=>!(i.prRoleFilter!=="all"&&K.role!==i.prRoleFilter||U&&!K.title.toLowerCase().includes(U)))});function l(){S(s,!c(s))}function u(U){U.stopPropagation(),r.refetch()}function d(U){return[{label:"Open in GitHub",action:()=>window.open(U.url,"_blank","noopener")},{label:"Start (YOLO)",action:()=>t.onPRClick(U,t.repo,!0)}]}var v=Am(),p=He(v),f=w(p);let g;var m=E(f,2),b=w(m),R=E(m,2),k=w(R),y=E(R,2),D=w(y),I=E(y,2);{var F=U=>{var ie=Tm(),K=w(ie);let x;le(()=>{ie.disabled=r.isFetching,x=Le(K,1,"svelte-1ekl114",null,x,{spinning:r.isFetching})}),Q("click",ie,u),T(U,ie)};te(I,U=>{c(s)&&U(F)})}var V=E(p,2);{var Z=U=>{var ie=Kt(),K=He(ie);{var x=N=>{var he=Mm();T(N,he)},M=N=>{var he=Pm();T(N,he)},P=N=>{var he=Bm();T(N,he)},Y=N=>{var he=Lm();T(N,he)},ne=N=>{var he=Kt(),Ce=He(he);Rt(Ce,17,()=>c(h),de=>de.number,(de,L)=>{{let ee=G(()=>!!t.findSessionForBranch(c(L).headRefName)),fe=G(()=>{var ve,me,Ee;return((ve=t.activeSession)==null?void 0:ve.type)==="worktree"&&((me=t.activeSession)==null?void 0:me.branchName)===c(L).headRefName&&((Ee=t.activeSession)==null?void 0:Ee.repoName)===t.repo.name}),be=G(()=>d(c(L)));Dm(de,{get pr(){return c(L)},get isActiveSession(){return c(ee)},get isSelected(){return c(fe)},onclick:()=>t.onPRClick(c(L),t.repo),get menuItems(){return c(be)}})}}),T(N,he)};te(K,N=>{r.isLoading?N(x):c(o)==="gh_not_authenticated"?N(M,1):c(o)?N(P,2):c(h).length===0?N(Y,3):N(ne,!1)})}T(U,ie)};te(V,U=>{c(s)&&U(Z)})}le(U=>{g=Le(f,1,"chevron",null,g,{expanded:c(s)}),oe(b,t.repo.name),oe(k,U),oe(D,c(n)?c(a).length:"-")},[()=>Tr(t.repo.root)]),Q("click",p,l),T(e,v),Ye()}Qe(["click"]);var Im=B('<li class="session-divider">Active</li>'),Nm=B('<li class="session-divider">Available</li>'),Fm=B("<!> <!> <!> <!>",1),Hm=B('<li class="session-divider">Active</li> <!>',1),Wm=B('<li class="session-divider">Available</li>'),zm=B('<li class="repo-group-header"><span>▶</span> <span class="repo-group-name"> </span> <span class="repo-group-root"> </span> <span class="repo-group-count"> </span> <button class="repo-group-add">+</button></li> <!>',1),Um=B("<!> <!> <!>",1),Km=B('<li class="pr-hint">No active terminals</li>'),qm=B('<li class="terminal-header"><button class="terminal-add-btn" aria-label="New terminal">+ New Terminal</button></li> <!> <!>',1),jm=B('<li class="pr-hint">No repos found</li>'),Vm=B('<div class="session-list-tabs svelte-ynafm7"><button>Repos<span class="tab-count svelte-ynafm7"> </span></button> <button>Worktrees<span class="tab-count svelte-ynafm7"> </span></button> <button>Terminals<span class="tab-count svelte-ynafm7"> </span></button> <button>PRs<span class="tab-count svelte-ynafm7"> </span></button></div> <!> <ul class="session-list svelte-ynafm7"><!></ul>',1);function Ym(e,t){Ve(t,!0);const i=xn(),s=Kh(),r=Ea();kn(()=>{jh().catch(()=>{})});let n=G(()=>s.sessions.filter(C=>C.type==="repo")),o=G(()=>s.sessions.filter(C=>C.type==="worktree")),a=G(()=>s.sessions.filter(C=>C.type==="terminal")),h=G(()=>new Set(c(n).map(C=>C.repoPath))),l=G(()=>new Set(c(o).map(C=>C.repoPath).filter(Boolean)));function u(C,q){return(C||"").localeCompare(q||"")}let d=G(()=>{var C;return(C=i.searchFilter)==null?void 0:C.toLowerCase()});function v(C,q,ue){return!(i.rootFilter&&C!==i.rootFilter||i.repoFilter&&q!==i.repoFilter||c(d)&&!ue.toLowerCase().includes(c(d)))}function p(C,q){return new Date(q||0).getTime()-new Date(C||0).getTime()}let f=G(()=>c(n).filter(C=>v(C.root,C.repoName,C.displayName||C.repoName||C.id)).sort((C,q)=>u(C.root,q.root)||u(C.repoName,q.repoName)||p(C.lastActivity,q.lastActivity))),g=G(()=>s.repos.filter(C=>!c(h).has(C.path)&&v(C.root,C.name,C.name)).sort((C,q)=>u(C.root,q.root)||u(C.name,q.name))),m=G(()=>c(o).filter(C=>v(C.root,C.repoName,C.displayName||C.repoName||C.worktreeName||C.id)).sort((C,q)=>u(C.root,q.root)||u(C.repoName,q.repoName)||p(C.lastActivity,q.lastActivity))),b=G(()=>s.worktrees.filter(C=>!c(l).has(C.path)&&v(C.root,C.repoName,C.name)).sort((C,q)=>u(C.root,q.root)||u(C.repoName,q.repoName)||p(C.lastActivity,q.lastActivity))),R=G(()=>(()=>{const C=new Map;for(const q of c(b)){const ue=q.repoName||q.name,Se=(q.root||"")+":"+ue;C.has(Se)||C.set(Se,{key:Se,repoName:ue,root:q.root,worktrees:[]}),C.get(Se).worktrees.push(q)}return[...C.values()].sort((q,ue)=>u(q.root,ue.root)||u(q.repoName,ue.repoName))})());function k(C){var ue;const q=((ue=C.worktrees[0])==null?void 0:ue.repoPath)||"";return{name:C.repoName,path:q,root:C.root}}let y=j(Ge(new Set));function D(C){const q=new Set(c(y));q.has(C)?q.delete(C):q.add(C),S(y,q,!0)}let I=G(()=>s.repos.filter(C=>!(i.rootFilter&&C.root!==i.rootFilter||i.repoFilter&&C.name!==i.repoFilter)).sort((C,q)=>u(C.root,q.root)||u(C.name,q.name))),F=G(()=>s.activeSessionId?s.sessions.find(C=>C.id===s.activeSessionId):void 0),V=G(()=>c(a).filter(C=>!i.searchFilter||(C.displayName||C.id).toLowerCase().includes(i.searchFilter.toLowerCase())).sort((C,q)=>p(C.lastActivity,q.lastActivity))),Z=G(()=>c(f).length+c(g).length),U=G(()=>c(m).length+c(b).length),ie=G(()=>c(V).length),K=G(()=>c(I).length);function x(C){return s.sessions.find(q=>q.type==="worktree"&&q.branchName===C)}function M(C){return s.worktrees.find(q=>q.branchName===C)}async function P(C,q,ue=!1){const Se=x(C.headRefName);if(Se){ra(Se.id),t.onSelectSession(Se.id);return}const $e=M(C.headRefName);if($e){const Ke=$e.path;Hn(Ke);try{const et=await jo({repoPath:$e.repoPath,repoName:$e.repoName,worktreePath:$e.path,yolo:ue||r.defaultYolo,useTmux:r.launchInTmux});await zt(),et!=null&&et.id&&t.onSelectSession(et.id)}catch{}finally{Wn(Ke)}return}try{const Ke=await jo({repoPath:q.path,repoName:q.name,branchName:C.headRefName,yolo:ue||r.defaultYolo,useTmux:r.launchInTmux});await zt(),Ke!=null&&Ke.id&&t.onSelectSession(Ke.id)}catch{}}async function Y(C){const q=C.id;if(!Rs(q)){Hn(q);try{await Dp(C.id),await zt(),s.activeSessionId===C.id&&(s.activeSessionId=null)}catch{}finally{Wn(q)}}}async function ne(C){const q=prompt("Rename session:",C.displayName||C.repoName||C.id);q&&q.trim()&&q.trim()!==(C.displayName||C.repoName||C.id)&&(await Tp(C.id,q.trim()),await zt())}function N(C){ra(C.id),t.onSelectSession(C.id)}async function he(C,q=!1){const ue=C.path;if(!Rs(ue)){Hn(ue);try{const Se=await jo({repoPath:C.repoPath,repoName:C.repoName,worktreePath:C.path,yolo:q||r.defaultYolo,useTmux:r.launchInTmux});await zt(),Se!=null&&Se.id&&t.onSelectSession(Se.id)}catch{}finally{Wn(ue)}}}async function Ce(C,q=!1){const ue=C.path;if(!Rs(ue)){Hn(ue);try{const Se=await rf({repoPath:C.path,repoName:C.name,continue:r.defaultContinue,yolo:q||r.defaultYolo,useTmux:r.launchInTmux});await zt(),Se!=null&&Se.id&&t.onSelectSession(Se.id)}catch(Se){Se instanceof Wh&&Se.sessionId&&(await zt(),t.onSelectSession(Se.sessionId))}finally{Wn(ue)}}}async function de(C){const q=s.notificationSessions[C.id]??!1;!q&&Dc()!=="granted"&&await Zp()!=="granted"||og(C.id,!q)}function L(C){const q=s.notificationSessions[C.id]??!1,ue=Dc()==="denied";return[{label:"Rename",action:()=>ne(C)},{label:q?"Notifications ✓":ue?"Notifications (blocked)":"Notifications",action:()=>de(C),disabled:ue},{label:"Kill",action:()=>Y(C),danger:!0}]}function ee(C){const q={name:C.repoName,path:C.repoPath,root:C.root};return[{label:"Customize",action:()=>t.onOpenNewSession(q,{tab:"worktrees",branchName:C.branchName})},{label:"Resume",action:()=>he(C)},{label:"Resume (YOLO)",action:()=>he(C,!0)},{label:"Delete",action:()=>t.onDeleteWorktree(C),danger:!0}]}function fe(C){return[{label:"Customize",action:()=>t.onOpenNewSession(C)},{label:"New Worktree",action:()=>t.onNewWorktree(C)}]}async function be(){try{const C=await Rp();await zt(),C!=null&&C.id&&t.onSelectSession(C.id)}catch{}}var ve=Vm(),me=He(ve),Ee=w(me);let Ne;var Je=E(w(Ee)),ze=w(Je),Ae=E(Ee,2);let ce;var Ue=E(w(Ae)),rt=w(Ue),qt=E(Ae,2);let yt;var De=E(w(qt)),Re=w(De),Ze=E(qt,2);let Ft;var si=E(w(Ze)),fi=w(si),Oe=E(me,2);Ng(Oe,{});var z=E(Oe,2),se=w(z);{var ke=C=>{var q=Fm(),ue=He(q);{var Se=H=>{var $=Im();T(H,$)};te(ue,H=>{c(f).length>0&&H(Se)})}var $e=E(ue,2);Rt($e,17,()=>c(f),H=>H.id,(H,$)=>{{let A=G(()=>({kind:"active",session:c($),status:Wa(c($)),isSelected:s.activeSessionId===c($).id})),ae=G(()=>Rs(c($).id)),we=G(()=>L(c($)));Pn(H,{get variant(){return c(A)},get gitStatus(){return s.gitStatuses[c($).repoPath+":"+c($).worktreeName]},get isLoading(){return c(ae)},onclick:()=>N(c($)),get menuItems(){return c(we)}})}});var Ke=E($e,2);{var et=H=>{var $=Nm();T(H,$)};te(Ke,H=>{c(g).length>0&&H(et)})}var je=E(Ke,2);Rt(je,17,()=>c(g),H=>H.path,(H,$)=>{{let A=G(()=>({kind:"idle-repo",repo:c($)})),ae=G(()=>Rs(c($).path)),we=G(()=>fe(c($)));Pn(H,{get variant(){return c(A)},get isLoading(){return c(ae)},onclick:()=>Ce(c($)),get menuItems(){return c(we)}})}}),T(C,q)},pe=C=>{var q=Um(),ue=He(q);{var Se=je=>{var H=Hm(),$=E(He(H),2);Rt($,17,()=>c(m),A=>A.id,(A,ae)=>{{let we=G(()=>({kind:"active",session:c(ae),status:Wa(c(ae)),isSelected:s.activeSessionId===c(ae).id})),_t=G(()=>Rs(c(ae).id)),_i=G(()=>L(c(ae)));Pn(A,{get variant(){return c(we)},get gitStatus(){return s.gitStatuses[c(ae).repoPath+":"+c(ae).worktreeName]},get isLoading(){return c(_t)},onclick:()=>N(c(ae)),get menuItems(){return c(_i)}})}}),T(je,H)};te(ue,je=>{c(m).length>0&&je(Se)})}var $e=E(ue,2);{var Ke=je=>{var H=Wm();T(je,H)};te($e,je=>{c(R).length>0&&je(Ke)})}var et=E($e,2);Rt(et,17,()=>c(R),je=>je.key,(je,H)=>{var $=zm(),A=He($),ae=w(A);let we;var _t=E(ae,2),_i=w(_t),ri=E(_t,2),Dn=w(ri),ir=E(ri,2),Pa=w(ir),xs=E(ir,2),Do=E(A,2);{var To=ns=>{var Hr=Kt(),os=He(Hr);Rt(os,17,()=>c(H).worktrees,Ui=>Ui.path,(Ui,vi)=>{{let Tn=G(()=>({kind:"inactive-worktree",worktree:c(vi)})),R_=G(()=>Rs(c(vi).path)),D_=G(()=>ee(c(vi)));Pn(Ui,{get variant(){return c(Tn)},get gitStatus(){return s.gitStatuses[c(vi).repoPath+":"+c(vi).name]},get isLoading(){return c(R_)},onclick:()=>he(c(vi)),get menuItems(){return c(D_)}})}}),T(ns,Hr)},Ba=G(()=>!c(y).has(c(H).key));te(Do,ns=>{c(Ba)&&ns(To)})}le((ns,Hr)=>{we=Le(ae,1,"chevron",null,we,ns),oe(_i,c(H).repoName),oe(Dn,Hr),oe(Pa,c(H).worktrees.length),ct(xs,"aria-label",`New worktree for ${c(H).repoName??""}`)},[()=>({expanded:!c(y).has(c(H).key)}),()=>Tr(c(H).root)]),Q("click",A,()=>D(c(H).key)),Q("click",xs,ns=>{ns.stopPropagation(),t.onNewWorktree(k(c(H)))}),T(je,$)}),T(C,q)},ge=C=>{var q=qm(),ue=He(q),Se=w(ue),$e=E(ue,2);Rt($e,17,()=>c(V),je=>je.id,(je,H)=>{{let $=G(()=>({kind:"active",session:c(H),status:Wa(c(H)),isSelected:s.activeSessionId===c(H).id})),A=G(()=>Rs(c(H).id)),ae=G(()=>L(c(H)));Pn(je,{get variant(){return c($)},get isLoading(){return c(A)},onclick:()=>N(c(H)),get menuItems(){return c(ae)}})}});var Ke=E($e,2);{var et=je=>{var H=Km();T(je,H)};te(Ke,je=>{c(V).length===0&&je(et)})}Q("click",Se,be),T(C,q)},Ie=C=>{var q=Kt(),ue=He(q);{var Se=Ke=>{var et=jm();T(Ke,et)},$e=Ke=>{var et=Kt(),je=He(et);Rt(je,17,()=>c(I),H=>H.path,(H,$)=>{Om(H,{get repo(){return c($)},findSessionForBranch:x,get activeSession(){return c(F)},onPRClick:P})}),T(Ke,et)};te(ue,Ke=>{c(I).length===0?Ke(Se):Ke($e,!1)})}T(C,q)};te(se,C=>{i.activeTab==="repos"?C(ke):i.activeTab==="worktrees"?C(pe,1):i.activeTab==="terminals"?C(ge,2):C(Ie,!1)})}le(()=>{Ne=Le(Ee,1,"sidebar-tab svelte-ynafm7",null,Ne,{active:i.activeTab==="repos"}),oe(ze,c(Z)),ce=Le(Ae,1,"sidebar-tab svelte-ynafm7",null,ce,{active:i.activeTab==="worktrees"}),oe(rt,c(U)),yt=Le(qt,1,"sidebar-tab svelte-ynafm7",null,yt,{active:i.activeTab==="terminals"}),oe(Re,c(ie)),Ft=Le(Ze,1,"sidebar-tab svelte-ynafm7",null,Ft,{active:i.activeTab==="prs"}),oe(fi,c(K))}),Q("click",Ee,()=>{i.activeTab="repos"}),Q("click",Ae,()=>{i.activeTab="worktrees"}),Q("click",qt,()=>{i.activeTab="terminals"}),Q("click",Ze,()=>{i.activeTab="prs"}),T(e,ve),Ye()}Qe(["click"]);var Gm=B('<span class="sidebar-label svelte-owj5vn">Sessions</span>'),Xm=B('<!> <button class="new-session-btn svelte-owj5vn"> </button> <button class="settings-btn svelte-owj5vn">⚙ Settings</button> <div class="resize-handle svelte-owj5vn"></div>',1),Qm=B('<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 Jm(e,t){Ve(t,!0);const i=xn();let s=G(()=>i.activeTab==="worktrees"?"+ New Worktree":"+ New Session"),r=G(()=>i.sidebarCollapsed?Yp:i.sidebarWidth);function n(R){R.preventDefault();const k=R.clientX,y=i.sidebarWidth,D=F=>{const V=Math.min(df,Math.max(uf,y+(F.clientX-k)));i.sidebarWidth=V},I=()=>{document.removeEventListener("mousemove",D),document.removeEventListener("mouseup",I),document.body.style.cursor="",document.body.style.userSelect="",Rc()};document.addEventListener("mousemove",D),document.addEventListener("mouseup",I),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function o(R){R.preventDefault(),i.sidebarWidth=cf,Rc()}var a=Qm();let h,l;var u=w(a),d=w(u),v=w(d),p=E(d,2);{var f=R=>{var k=Gm();T(R,k)};te(p,R=>{i.sidebarCollapsed||R(f)})}var g=E(p,2),m=E(u,2);{var b=R=>{var k=Xm(),y=He(k);Ym(y,{get onSelectSession(){return t.onSelectSession},get onOpenNewSession(){return t.onOpenNewSession},get onNewWorktree(){return t.onNewWorktree},get onDeleteWorktree(){return t.onDeleteWorktree}});var D=E(y,2),I=w(D),F=E(D,2),V=E(F,2);le(()=>oe(I,c(s))),Q("click",D,()=>t.onOpenNewSession()),Q("click",F,function(...Z){var U;(U=t.onOpenSettings)==null||U.apply(this,Z)}),Q("mousedown",V,n),Q("dblclick",V,o),T(R,k)};te(m,R=>{i.sidebarCollapsed||R(b)})}le(()=>{h=Le(a,1,"sidebar svelte-owj5vn",null,h,{open:i.sidebarOpen,collapsed:i.sidebarCollapsed}),l=ea(a,"",l,{width:`${c(r)??""}px`,"min-width":`${c(r)??""}px`}),ct(d,"aria-label",i.sidebarCollapsed?"Expand sidebar":"Collapse sidebar"),oe(v,i.sidebarCollapsed?"»":"«")}),Q("click",d,function(...R){Fa==null||Fa.apply(this,R)}),Q("click",g,function(...R){hs==null||hs.apply(this,R)}),T(e,a),Ye()}Qe(["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 Af=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,$m=(e,t)=>{for(var i in t)Af(e,i,{get:t[i],enumerable:!0})},at=(e,t,i,s)=>{for(var r=s>1?void 0:s?Zm(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&&Af(t,i,r),r},re=(e,t)=>(i,s)=>t(i,s,e),Kc="Terminal input",Ul={get:()=>Kc,set:e=>Kc=e},qc="Too much output to announce, navigate to rows manually to read",Kl={get:()=>qc,set:e=>qc=e};function eS(e){return e.replace(/\r?\n/g,"\r")}function tS(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function iS(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function sS(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Of(r,t,i,s)}}function Of(e,t,i,s){e=eS(e),e=tS(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function If(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 jc(e,t,i,s,r){If(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Bs(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Ra(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 rS=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 a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},nS=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,a,h=0,l=0;if(this.interim[0]){let v=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let f=0,g;for(;(g=this.interim[++f]&63)&&f<4;)p<<=6,p|=g;let m=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,b=m-f;for(;l<b;){if(l>=i)return 0;if(g=e[l++],(g&192)!==128){l--,v=!0;break}else this.interim[f++]=g,p<<=6,p|=g&63}v||(m===2?p<128?l--:t[s++]=p:m===3?p<2048||p>=55296&&p<=57343||p===65279||(t[s++]=p):p<65536||p>1114111||(t[s++]=p)),this.interim.fill(0)}let u=i-4,d=l;for(;d<i;){for(;d<u&&!((r=e[d])&128)&&!((n=e[d+1])&128)&&!((o=e[d+2])&128)&&!((a=e[d+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,d+=4;if(r=e[d++],r<128)t[s++]=r;else if((r&224)===192){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(h=(r&31)<<6|n&63,h<128){d--;continue}t[s++]=h}else if((r&240)===224){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(d>=i)return this.interim[0]=r,s;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[d++],(a&192)!==128){d--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Nf="",Vs=" ",ko=class Ff{constructor(){this.fg=0,this.bg=0,this.extended=new oa}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 Ff;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}},oa=class Hf{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 Hf(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ri=class Wf extends ko{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new oa,this.combinedData=""}static fromCharData(t){let i=new Wf;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?Bs(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()]}},Vc="di$target",ql="di$dependencies",Ka=new Map;function oS(e){return e[ql]||[]}function Tt(e){if(Ka.has(e))return Ka.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");aS(t,i,r)};return t._id=e,Ka.set(e,t),t}function aS(e,t,i){t[Vc]===t?t[ql].push({id:e,index:i}):(t[ql]=[{id:e,index:i}],t[Vc]=t)}var Gt=Tt("BufferService"),zf=Tt("CoreMouseService"),Fr=Tt("CoreService"),lS=Tt("CharsetService"),Qh=Tt("InstantiationService"),Uf=Tt("LogService"),Xt=Tt("OptionsService"),Kf=Tt("OscLinkService"),hS=Tt("UnicodeService"),xo=Tt("DecorationService"),jl=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var u;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(),a=-1,h=-1,l=!1;for(let d=0;d<o;d++)if(!(h===-1&&!i.hasContent(d))){if(i.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=d,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&d===o-1){let v=(u=this._oscLinkService.getLinkData(a))==null?void 0:u.uri;if(v){let p={start:{x:h+1,y:e},end:{x:d+(!l&&d===o-1?1:0),y:e}},f=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let g=new URL(v);["http:","https:"].includes(g.protocol)||(f=!0)}catch{f=!0}f||s.push({text:v,range:p,activate:(g,m)=>r?r.activate(g,m,p):cS(g,m),hover:(g,m)=>{var b;return(b=r==null?void 0:r.hover)==null?void 0:b.call(r,g,m,p)},leave:(g,m)=>{var b;return(b=r==null?void 0:r.leave)==null?void 0:b.call(r,g,m,p)}})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};jl=at([re(0,Gt),re(1,Xt),re(2,Kf)],jl);function cS(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 Da=Tt("CharSizeService"),Cs=Tt("CoreBrowserService"),Jh=Tt("MouseService"),ks=Tt("RenderService"),uS=Tt("SelectionService"),qf=Tt("CharacterJoinerService"),En=Tt("ThemeService"),jf=Tt("LinkProviderService"),dS=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Yc.isErrorNoTelemetry(e)?new Yc(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)}},fS=new dS;function Yo(e){_S(e)||fS.onUnexpectedError(e)}var Vl="Canceled";function _S(e){return e instanceof vS?!0:e instanceof Error&&e.name===Vl&&e.message===Vl}var vS=class extends Error{constructor(){super(Vl),this.name=this.message}};function pS(e){return new Error(`Illegal argument: ${e}`)}var Yc=class Yl extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Yl)return t;let i=new Yl;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Gl=class Vf extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Vf.prototype)}};function ni(e,t=0){return e[e.length-(1+t)]}var gS;(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})(gS||(gS={}));function mS(e,t){let i=this,s=!1,r;return function(){return s||(s=!0,t||(r=e.apply(i,arguments))),r}}var Yf;(e=>{function t(y){return y&&typeof y=="object"&&typeof y[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*r(y){yield y}e.single=r;function n(y){return t(y)?y:r(y)}e.wrap=n;function o(y){return y||i}e.from=o;function*a(y){for(let D=y.length-1;D>=0;D--)yield y[D]}e.reverse=a;function h(y){return!y||y[Symbol.iterator]().next().done===!0}e.isEmpty=h;function l(y){return y[Symbol.iterator]().next().value}e.first=l;function u(y,D){let I=0;for(let F of y)if(D(F,I++))return!0;return!1}e.some=u;function d(y,D){for(let I of y)if(D(I))return I}e.find=d;function*v(y,D){for(let I of y)D(I)&&(yield I)}e.filter=v;function*p(y,D){let I=0;for(let F of y)yield D(F,I++)}e.map=p;function*f(y,D){let I=0;for(let F of y)yield*D(F,I++)}e.flatMap=f;function*g(...y){for(let D of y)yield*D}e.concat=g;function m(y,D,I){let F=I;for(let V of y)F=D(F,V);return F}e.reduce=m;function*b(y,D,I=y.length){for(D<0&&(D+=y.length),I<0?I+=y.length:I>y.length&&(I=y.length);D<I;D++)yield y[D]}e.slice=b;function R(y,D=Number.POSITIVE_INFINITY){let I=[];if(D===0)return[I,y];let F=y[Symbol.iterator]();for(let V=0;V<D;V++){let Z=F.next();if(Z.done)return[I,e.empty()];I.push(Z.value)}return[I,{[Symbol.iterator](){return F}}]}e.consume=R;async function k(y){let D=[];for await(let I of y)D.push(I);return Promise.resolve(D)}e.asyncToArray=k})(Yf||(Yf={}));function Or(e){if(Yf.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 SS(...e){return tt(()=>Or(e))}function tt(e){return{dispose:mS(()=>{e()})}}var Gf=class Xf{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{Or(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?Xf.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)}};Gf.DISABLE_DISPOSED_WARNING=!1;var Zs=Gf,Me=class{constructor(){this._store=new Zs,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)}};Me.None=Object.freeze({dispose(){}});var yn=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},ps=typeof window=="object"?window:globalThis,Xl=class Ql{constructor(t){this.element=t,this.next=Ql.Undefined,this.prev=Ql.Undefined}};Xl.Undefined=new Xl(void 0);var it=Xl,Gc=class{constructor(){this._first=it.Undefined,this._last=it.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===it.Undefined}clear(){let e=this._first;for(;e!==it.Undefined;){let t=e.next;e.prev=it.Undefined,e.next=it.Undefined,e=t}this._first=it.Undefined,this._last=it.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new it(e);if(this._first===it.Undefined)this._first=i,this._last=i;else if(t){let r=this._last;this._last=i,i.prev=r,r.next=i}else{let r=this._first;this._first=i,i.next=r,r.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==it.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==it.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==it.Undefined&&e.next!==it.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===it.Undefined&&e.next===it.Undefined?(this._first=it.Undefined,this._last=it.Undefined):e.next===it.Undefined?(this._last=this._last.prev,this._last.next=it.Undefined):e.prev===it.Undefined&&(this._first=this._first.next,this._first.prev=it.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==it.Undefined;)yield e.element,e=e.next}},bS=globalThis.performance&&typeof globalThis.performance.now=="function",yS=class Qf{static create(t){return new Qf(t)}constructor(t){this._now=bS&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},At;(e=>{e.None=()=>Me.None;function t(K,x){return d(K,()=>{},0,void 0,!0,void 0,x)}e.defer=t;function i(K){return(x,M=null,P)=>{let Y=!1,ne;return ne=K(N=>{if(!Y)return ne?ne.dispose():Y=!0,x.call(M,N)},null,P),Y&&ne.dispose(),ne}}e.once=i;function s(K,x,M){return l((P,Y=null,ne)=>K(N=>P.call(Y,x(N)),null,ne),M)}e.map=s;function r(K,x,M){return l((P,Y=null,ne)=>K(N=>{x(N),P.call(Y,N)},null,ne),M)}e.forEach=r;function n(K,x,M){return l((P,Y=null,ne)=>K(N=>x(N)&&P.call(Y,N),null,ne),M)}e.filter=n;function o(K){return K}e.signal=o;function a(...K){return(x,M=null,P)=>{let Y=SS(...K.map(ne=>ne(N=>x.call(M,N))));return u(Y,P)}}e.any=a;function h(K,x,M,P){let Y=M;return s(K,ne=>(Y=x(Y,ne),Y),P)}e.reduce=h;function l(K,x){let M,P={onWillAddFirstListener(){M=K(Y.fire,Y)},onDidRemoveLastListener(){M==null||M.dispose()}},Y=new J(P);return x==null||x.add(Y),Y.event}function u(K,x){return x instanceof Array?x.push(K):x&&x.add(K),K}function d(K,x,M=100,P=!1,Y=!1,ne,N){let he,Ce,de,L=0,ee,fe={leakWarningThreshold:ne,onWillAddFirstListener(){he=K(ve=>{L++,Ce=x(Ce,ve),P&&!de&&(be.fire(Ce),Ce=void 0),ee=()=>{let me=Ce;Ce=void 0,de=void 0,(!P||L>1)&&be.fire(me),L=0},typeof M=="number"?(clearTimeout(de),de=setTimeout(ee,M)):de===void 0&&(de=0,queueMicrotask(ee))})},onWillRemoveListener(){Y&&L>0&&(ee==null||ee())},onDidRemoveLastListener(){ee=void 0,he.dispose()}},be=new J(fe);return N==null||N.add(be),be.event}e.debounce=d;function v(K,x=0,M){return e.debounce(K,(P,Y)=>P?(P.push(Y),P):[Y],x,void 0,!0,void 0,M)}e.accumulate=v;function p(K,x=(P,Y)=>P===Y,M){let P=!0,Y;return n(K,ne=>{let N=P||!x(ne,Y);return P=!1,Y=ne,N},M)}e.latch=p;function f(K,x,M){return[e.filter(K,x,M),e.filter(K,P=>!x(P),M)]}e.split=f;function g(K,x=!1,M=[],P){let Y=M.slice(),ne=K(Ce=>{Y?Y.push(Ce):he.fire(Ce)});P&&P.add(ne);let N=()=>{Y==null||Y.forEach(Ce=>he.fire(Ce)),Y=null},he=new J({onWillAddFirstListener(){ne||(ne=K(Ce=>he.fire(Ce)),P&&P.add(ne))},onDidAddFirstListener(){Y&&(x?setTimeout(N):N())},onDidRemoveLastListener(){ne&&ne.dispose(),ne=null}});return P&&P.add(he),he.event}e.buffer=g;function m(K,x){return(M,P,Y)=>{let ne=x(new R);return K(function(N){let he=ne.evaluate(N);he!==b&&M.call(P,he)},void 0,Y)}}e.chain=m;let b=Symbol("HaltChainable");class R{constructor(){this.steps=[]}map(x){return this.steps.push(x),this}forEach(x){return this.steps.push(M=>(x(M),M)),this}filter(x){return this.steps.push(M=>x(M)?M:b),this}reduce(x,M){let P=M;return this.steps.push(Y=>(P=x(P,Y),P)),this}latch(x=(M,P)=>M===P){let M=!0,P;return this.steps.push(Y=>{let ne=M||!x(Y,P);return M=!1,P=Y,ne?Y:b}),this}evaluate(x){for(let M of this.steps)if(x=M(x),x===b)break;return x}}function k(K,x,M=P=>P){let P=(...he)=>N.fire(M(...he)),Y=()=>K.on(x,P),ne=()=>K.removeListener(x,P),N=new J({onWillAddFirstListener:Y,onDidRemoveLastListener:ne});return N.event}e.fromNodeEventEmitter=k;function y(K,x,M=P=>P){let P=(...he)=>N.fire(M(...he)),Y=()=>K.addEventListener(x,P),ne=()=>K.removeEventListener(x,P),N=new J({onWillAddFirstListener:Y,onDidRemoveLastListener:ne});return N.event}e.fromDOMEventEmitter=y;function D(K){return new Promise(x=>i(K)(x))}e.toPromise=D;function I(K){let x=new J;return K.then(M=>{x.fire(M)},()=>{x.fire(void 0)}).finally(()=>{x.dispose()}),x.event}e.fromPromise=I;function F(K,x){return K(M=>x.fire(M))}e.forward=F;function V(K,x,M){return x(M),K(P=>x(P))}e.runAndSubscribe=V;class Z{constructor(x,M){this._observable=x,this._counter=0,this._hasChanged=!1;let P={onWillAddFirstListener:()=>{x.addObserver(this)},onDidRemoveLastListener:()=>{x.removeObserver(this)}};this.emitter=new J(P),M&&M.add(this.emitter)}beginUpdate(x){this._counter++}handlePossibleChange(x){}handleChange(x,M){this._hasChanged=!0}endUpdate(x){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function U(K,x){return new Z(K,x).emitter.event}e.fromObservable=U;function ie(K){return(x,M,P)=>{let Y=0,ne=!1,N={beginUpdate(){Y++},endUpdate(){Y--,Y===0&&(K.reportChanges(),ne&&(ne=!1,x.call(M)))},handlePossibleChange(){},handleChange(){ne=!0}};K.addObserver(N),K.reportChanges();let he={dispose(){K.removeObserver(N)}};return P instanceof Zs?P.add(he):Array.isArray(P)&&P.push(he),he}}e.fromObservableLight=ie})(At||(At={}));var Jl=class Zl{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Zl._idPool++}`,Zl.all.add(this)}start(t){this._stopWatch=new yS,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}}};Jl.all=new Set,Jl._idPool=0;var wS=Jl,CS=-1,Jf=class Zf{constructor(t,i,s=(Zf._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(),a=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${o}):`;console.warn(a),console.warn(n);let h=new ES(a,n);this._errorHandler(h)}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}};Jf._idPool=1;var kS=Jf,xS=class $f{constructor(t){this.value=t}static create(){let t=new Error;return new $f(t.stack??"")}print(){console.warn(this.value.split(`
|
|
28
|
-
`).slice(2).join(`
|
|
29
|
-
`))}},ES=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},RS=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},DS=0,qa=class{constructor(e){this.value=e,this.id=DS++}},TS=2,MS,J=class{constructor(e){var t,i,s,r;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new kS((e==null?void 0:e.onListenerError)??Yo,((i=this._options)==null?void 0:i.leakWarningThreshold)??CS):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new wS(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,a,h,l,u;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let d=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(d);let v=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new RS(`${d}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((o=this._options)==null?void 0:o.onListenerError)||Yo)(p),Me.None}if(this._disposed)return Me.None;t&&(e=e.bind(t));let s=new qa(e),r;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=xS.create(),r=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof qa?(this._deliveryQueue??(this._deliveryQueue=new PS),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(a=this._options)==null?void 0:a.onWillAddFirstListener)==null||h.call(a,this),this._listeners=s,(u=(l=this._options)==null?void 0:l.onDidAddFirstListener)==null||u.call(l,this)),this._size++;let n=tt(()=>{r==null||r(),this._removeListener(s)});return i instanceof Zs?i.add(n):Array.isArray(i)&&i.push(n),n}),this._event}_removeListener(e){var r,n,o,a;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,(a=(o=this._options)==null?void 0:o.onDidRemoveLastListener)==null||a.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*TS<=t.length){let h=0;for(let l=0;l<t.length;l++)t[l]?t[h++]=t[l]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=h}}_deliver(e,t){var s;if(!e)return;let i=((s=this._options)==null?void 0:s.onListenerError)||Yo;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 qa)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}},PS=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}},$l=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new J,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new J,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}};$l.INSTANCE=new $l;var Zh=$l;function BS(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Zh.INSTANCE.onDidChangeZoomLevel;function LS(e){return Zh.INSTANCE.getZoomFactor(e)}Zh.INSTANCE.onDidChangeFullscreen;var Rn=typeof navigator=="object"?navigator.userAgent:"",eh=Rn.indexOf("Firefox")>=0,AS=Rn.indexOf("AppleWebKit")>=0,$h=Rn.indexOf("Chrome")>=0,OS=!$h&&Rn.indexOf("Safari")>=0;Rn.indexOf("Electron/")>=0;Rn.indexOf("Android")>=0;var ja=!1;if(typeof ps.matchMedia=="function"){let e=ps.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=ps.matchMedia("(display-mode: fullscreen)");ja=e.matches,BS(ps,e,({matches:i})=>{ja&&t.matches||(ja=i)})}var Ur="en",th=!1,ih=!1,Go=!1,e_=!1,Oo,Xo=Ur,Xc=Ur,IS,Pi,Mr=globalThis,Bt,Zu;typeof Mr.vscode<"u"&&typeof Mr.vscode.process<"u"?Bt=Mr.vscode.process:typeof process<"u"&&typeof((Zu=process==null?void 0:process.versions)==null?void 0:Zu.node)=="string"&&(Bt=process);var $u,NS=typeof(($u=Bt==null?void 0:Bt.versions)==null?void 0:$u.electron)=="string",FS=NS&&(Bt==null?void 0:Bt.type)==="renderer",ed;if(typeof Bt=="object"){th=Bt.platform==="win32",ih=Bt.platform==="darwin",Go=Bt.platform==="linux",Go&&Bt.env.SNAP&&Bt.env.SNAP_REVISION,Bt.env.CI||Bt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Oo=Ur,Xo=Ur;let e=Bt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Oo=t.userLocale,Xc=t.osLocale,Xo=t.resolvedLanguage||Ur,IS=(ed=t.languagePack)==null?void 0:ed.translationsConfigFile}catch{}e_=!0}else typeof navigator=="object"&&!FS?(Pi=navigator.userAgent,th=Pi.indexOf("Windows")>=0,ih=Pi.indexOf("Macintosh")>=0,(Pi.indexOf("Macintosh")>=0||Pi.indexOf("iPad")>=0||Pi.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Go=Pi.indexOf("Linux")>=0,(Pi==null?void 0:Pi.indexOf("Mobi"))>=0,Xo=globalThis._VSCODE_NLS_LANGUAGE||Ur,Oo=navigator.language.toLowerCase(),Xc=Oo):console.error("Unable to resolve platform.");var t_=th,es=ih,HS=Go,Qc=e_,ss=Pi,Ds=Xo,WS;(e=>{function t(){return Ds}e.value=t;function i(){return Ds.length===2?Ds==="en":Ds.length>=3?Ds[0]==="e"&&Ds[1]==="n"&&Ds[2]==="-":!1}e.isDefaultVariant=i;function s(){return Ds==="en"}e.isDefault=s})(WS||(WS={}));var zS=typeof Mr.postMessage=="function"&&!Mr.importScripts;(()=>{if(zS){let e=[];Mr.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}),Mr.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var US=!!(ss&&ss.indexOf("Chrome")>=0);ss&&ss.indexOf("Firefox")>=0;!US&&ss&&ss.indexOf("Safari")>=0;ss&&ss.indexOf("Edg/")>=0;ss&&ss.indexOf("Android")>=0;var Wr=typeof navigator=="object"?navigator:{};Qc||document.queryCommandSupported&&document.queryCommandSupported("copy")||Wr&&Wr.clipboard&&Wr.clipboard.writeText,Qc||Wr&&Wr.clipboard&&Wr.clipboard.readText;var ec=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}},Va=new ec,Jc=new ec,Zc=new ec,KS=new Array(230),i_;(e=>{function t(a){return Va.keyCodeToStr(a)}e.toString=t;function i(a){return Va.strToKeyCode(a)}e.fromString=i;function s(a){return Jc.keyCodeToStr(a)}e.toUserSettingsUS=s;function r(a){return Zc.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function n(a){return Jc.strToKeyCode(a)||Zc.strToKeyCode(a)}e.fromUserSettings=n;function o(a){if(a>=98&&a<=113)return null;switch(a){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Va.keyCodeToStr(a)}e.toElectronAccelerator=o})(i_||(i_={}));var qS=class s_{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 s_&&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 jS([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},jS=class{constructor(e){if(e.length===0)throw pS("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 VS(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return i_.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(eh)switch(t){case 59:return 85;case 60:if(HS)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(es)return 57;break}else if(AS&&(es&&t===93||!es&&t===92))return 57;return KS[t]||0}var YS=es?256:2048,GS=512,XS=1024,QS=es?2048:256,$c=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=VS(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|=YS),this.altKey&&(t|=GS),this.shiftKey&&(t|=XS),this.metaKey&&(t|=QS),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new qS(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},eu=new WeakMap;function JS(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 ZS=class{static getSameOriginWindowChain(e){let t=eu.get(e);if(!t){t=[],eu.set(e,t);let i=e,s;do s=JS(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 a=n.iframeElement.getBoundingClientRect();i+=a.top,s+=a.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=ZS.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},tu=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($h){let n=navigator.userAgent.match(/Chrome\/(\d+)/);s=(n?parseInt(n[1]):123)<=122}if(e){let n=e,o=e,a=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")s?this.deltaY=n.wheelDeltaY/(120*a):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 h=e;h.deltaMode===h.DOM_DELTA_LINE?eh&&!es?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")OS&&t_?this.deltaX=-(n.wheelDeltaX/120):s?this.deltaX=n.wheelDeltaX/(120*a):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 h=e;h.deltaMode===h.DOM_DELTA_LINE?eh&&!es?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*a):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},r_=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),$S;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof eb?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:At.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:r_})})($S||($S={}));var eb=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?r_:(this._emitter||(this._emitter=new J),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},tc=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 Gl("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Gl("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},tb=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 Gl("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}},ib;(e=>{async function t(s){let r,n=await Promise.all(s.map(o=>o.then(a=>a,a=>{r||(r=a)})));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})(ib||(ib={}));var iu=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 J,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await At.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new 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())}};iu.EMPTY=iu.fromArray([]);var{getWindow:Zi,getWindowId:sb,onDidRegisterWindow:rb}=(function(){let e=new Map,t={window:ps,disposables:new Zs};e.set(ps.vscodeWindowId,t);let i=new J,s=new J,r=new J;function n(o,a){return(typeof o=="number"?e.get(o):void 0)??(a?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(e.has(o.vscodeWindowId))return Me.None;let a=new Zs,h={window:o,disposables:a.add(new Zs)};return e.set(o.vscodeWindowId,h),a.add(tt(()=>{e.delete(o.vscodeWindowId),s.fire(o)})),a.add(ye(o,Ct.BEFORE_UNLOAD,()=>{r.fire(o)})),i.fire(h),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return e.has(o)},getWindowById:n,getWindow(o){var l;let a=o;if((l=a==null?void 0:a.ownerDocument)!=null&&l.defaultView)return a.ownerDocument.defaultView.window;let h=o;return h!=null&&h.view?h.view.window:ps},getDocument(o){return Zi(o).document}}})(),nb=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 ye(e,t,i,s){return new nb(e,t,i,s)}var su=function(e,t,i,s){return ye(e,t,i,s)},ic,ob=class extends tb{constructor(e){super(),this.defaultTarget=e&&Zi(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},ru=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){Yo(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(ru.sort),o.shift().execute();s.set(n,!1)};ic=(n,o,a=0)=>{let h=sb(n),l=new ru(o,a),u=e.get(h);return u||(u=[],e.set(h,u)),u.push(l),i.get(h)||(i.set(h,!0),n.requestAnimationFrame(()=>r(h))),l}})();function ab(e){let t=e.getBoundingClientRect(),i=Zi(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"},lb=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 $n(e){return new lb(e)}var n_=class{constructor(){this._hooks=new Zs,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=Zi(e)}this._hooks.add(ye(n,Ct.POINTER_MOVE,o=>{if(o.buttons!==i){this.stopMonitoring(!0);return}o.preventDefault(),this._pointerMoveCallback(o)})),this._hooks.add(ye(n,Ct.POINTER_UP,o=>this.stopMonitoring(!0)))}};function hb(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 ji;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ji||(ji={}));var Un=class Ht extends Me{constructor(){super(),this.dispatched=!1,this.targets=new Gc,this.ignoreTargets=new Gc,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(At.runAndSubscribe(rb,({window:t,disposables:i})=>{i.add(ye(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(ye(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(ye(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:ps,disposables:this._store}))}static addTarget(t){if(!Ht.isTouchDevice())return Me.None;Ht.INSTANCE||(Ht.INSTANCE=new Ht);let i=Ht.INSTANCE.targets.push(t);return tt(i)}static ignoreTarget(t){if(!Ht.isTouchDevice())return Me.None;Ht.INSTANCE||(Ht.INSTANCE=new Ht);let i=Ht.INSTANCE.ignoreTargets.push(t);return tt(i)}static isTouchDevice(){return"ontouchstart"in ps||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(ji.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 a=i.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let h=this.activeTouches[a.identifier],l=Date.now()-h.initialTimeStamp;if(l<Ht.HOLD_DELAY&&Math.abs(h.initialPageX-ni(h.rollingPageX))<30&&Math.abs(h.initialPageY-ni(h.rollingPageY))<30){let u=this.newGestureEvent(ji.Tap,h.initialTarget);u.pageX=ni(h.rollingPageX),u.pageY=ni(h.rollingPageY),this.dispatchEvent(u)}else if(l>=Ht.HOLD_DELAY&&Math.abs(h.initialPageX-ni(h.rollingPageX))<30&&Math.abs(h.initialPageY-ni(h.rollingPageY))<30){let u=this.newGestureEvent(ji.Contextmenu,h.initialTarget);u.pageX=ni(h.rollingPageX),u.pageY=ni(h.rollingPageY),this.dispatchEvent(u)}else if(r===1){let u=ni(h.rollingPageX),d=ni(h.rollingPageY),v=ni(h.rollingTimestamps)-h.rollingTimestamps[0],p=u-h.rollingPageX[0],f=d-h.rollingPageY[0],g=[...this.targets].filter(m=>h.initialTarget instanceof Node&&m.contains(h.initialTarget));this.inertia(t,g,s,Math.abs(p)/v,p>0?1:-1,u,Math.abs(f)/v,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(ji.End,h.initialTarget)),delete this.activeTouches[a.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===ji.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>Ht.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===ji.Change||t.type===ji.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,a,h,l){this.handle=ic(t,()=>{let u=Date.now(),d=u-s,v=0,p=0,f=!0;r+=Ht.SCROLL_FRICTION*d,a+=Ht.SCROLL_FRICTION*d,r>0&&(f=!1,v=n*r*d),a>0&&(f=!1,p=h*a*d);let g=this.newGestureEvent(ji.Change);g.translationX=v,g.translationY=p,i.forEach(m=>m.dispatchEvent(g)),f||this.inertia(t,i,u,r,n,o+v,a,h,l+p)})}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],a=this.newGestureEvent(ji.Change,o.initialTarget);a.translationX=n.pageX-ni(o.rollingPageX),a.translationY=n.pageY-ni(o.rollingPageY),a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a),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)}};Un.SCROLL_FRICTION=-.005,Un.HOLD_DELAY=700,Un.CLEAR_TAP_COUNT_TIME=400,at([hb],Un,"isTouchDevice",1);var cb=Un,sc=class extends Me{onclick(e,t){this._register(ye(e,Ct.CLICK,i=>t(new Io(Zi(e),i))))}onmousedown(e,t){this._register(ye(e,Ct.MOUSE_DOWN,i=>t(new Io(Zi(e),i))))}onmouseover(e,t){this._register(ye(e,Ct.MOUSE_OVER,i=>t(new Io(Zi(e),i))))}onmouseleave(e,t){this._register(ye(e,Ct.MOUSE_LEAVE,i=>t(new Io(Zi(e),i))))}onkeydown(e,t){this._register(ye(e,Ct.KEY_DOWN,i=>t(new $c(i))))}onkeyup(e,t){this._register(ye(e,Ct.KEY_UP,i=>t(new $c(i))))}oninput(e,t){this._register(ye(e,Ct.INPUT,t))}onblur(e,t){this._register(ye(e,Ct.BLUR,t))}onfocus(e,t){this._register(ye(e,Ct.FOCUS,t))}onchange(e,t){this._register(ye(e,Ct.CHANGE,t))}ignoreGesture(e){return cb.ignoreTarget(e)}},nu=11,ub=class extends sc{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=nu+"px",this.domNode.style.height=nu+"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 n_),this._register(su(this.bgDomNode,Ct.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(su(this.domNode,Ct.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new ob),this._pointerdownScheduleRepeatTimer=this._register(new tc)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Zi(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()}},db=class sh{constructor(t,i,s,r,n,o,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,r=r|0,n=n|0,o=o|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}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 sh(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 sh(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,a=this.scrollHeight!==t.scrollHeight,h=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:a,scrollTopChanged:h}}},fb=class extends Me{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new db(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 au(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=au.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)))}},ou=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function Ya(e,t){let i=t-e;return function(s){return e+i*pb(s)}}function _b(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var au=class rh{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),_b(Ya(t,r),Ya(n,i),.33)}return Ya(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 ou(s,r,!1)}return new ou(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return rh.start(t,i,s)}static start(t,i,s){s=s+10;let r=Date.now()-10;return new rh(t,i,r,s)}};function vb(e){return Math.pow(e,3)}function pb(e){return 1-vb(1-e)}var gb=class extends Me{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 tc)}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":"")))}},mb=140,o_=class extends sc{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 gb(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new n_),this._shouldRender=!0,this.domNode=$n(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(ye(this.domNode.domNode,Ct.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new ub(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=$n(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(ye(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=ab(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(t_&&o>mb){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(a))},()=>{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()}},a_=class nh{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 nh(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),a=Math.max(0,o-2*i),h=r>0&&r>s;if(!h)return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(s*a/r))),u=(a-l)/(r-s),d=n*u;return{computedAvailableSize:Math.round(o),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:u,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=nh._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)}},Sb=class extends o_{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new a_(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}},bb=class extends o_{constructor(e,t,i){let s=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new a_(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}},yb=500,lu=50,wb=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},oh=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($h){let i=Zi(t.browserEvent),s=LS(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 wb(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),a=Math.abs(i.deltaY),h=Math.max(Math.min(r,o),1),l=Math.max(Math.min(n,a),1),u=Math.max(r,o),d=Math.max(n,a);u%h===0&&d%l===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};oh.INSTANCE=new oh;var Cb=oh,kb=class extends sc{constructor(e,t,i){super(),this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new J),this.onWillScroll=this._onWillScroll.event,this._options=Eb(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 bb(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Sb(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=$n(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=$n(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=$n(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 tc),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Or(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,es&&(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 tu(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Or(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new tu(i))};this._mouseWheelToDispose.push(ye(this._listenOnDomNode,Ct.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Cb.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 a=!es&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!o&&(o=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),l={};if(n){let u=lu*n,d=h.scrollTop-(u<0?Math.floor(u):Math.ceil(u));this._verticalScrollbar.writeScrollPosition(l,d)}if(o){let u=lu*o,d=h.scrollLeft-(u<0?Math.floor(u):Math.ceil(u));this._horizontalScrollbar.writeScrollPosition(l,d)}l=this._scrollable.validateScrollPosition(l),(h.scrollLeft!==l.scrollLeft||h.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),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(),yb)}},xb=class extends kb{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 Eb(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,es&&(t.className+=" mac"),t}var ah=class extends Me{constructor(e,t,i,s,r,n,o,a){super(),this._bufferService=i,this._optionsService=o,this._renderService=a,this._onRequestScrollLines=this._register(new J),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new fb({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>ic(s.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new xb(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(At.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(tt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(tt(()=>this._styleElement.remove())),this._register(At.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
30
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(l=>this._handleScroll(l)))}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}};ah=at([re(2,Gt),re(3,Cs),re(4,zf),re(5,En),re(6,Xt),re(7,ks)],ah);var lh=class extends Me{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()}};lh=at([re(1,Gt),re(2,Cs),re(3,xo),re(4,ks)],lh);var Rb=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)}},Ki={full:0,left:0,center:0,right:0},Ts={full:0,left:0,center:0,right:0},Bn={full:0,left:0,center:0,right:0},aa=class extends Me{constructor(e,t,i,s,r,n,o,a){var l;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=r,this._optionsService=n,this._themeService=o,this._coreBrowserService=a,this._colorZoneStore=new Rb,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(),(l=this._viewportElement.parentElement)==null||l.insertBefore(this._canvas,this._viewportElement),this._register(tt(()=>{var u;return(u=this._canvas)==null?void 0:u.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ts.full=this._canvas.width,Ts.left=e,Ts.center=t,Ts.right=e,this._refreshDrawHeightConstants(),Bn.full=1,Bn.left=1,Bn.center=1+Ts.left,Bn.right=1+Ts.left+Ts.center}_refreshDrawHeightConstants(){Ki.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);Ki.left=t,Ki.center=t,Ki.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Ki.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(Bn[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Ki[e.position||"full"]/2),Ts[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Ki[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}))}};aa=at([re(2,Gt),re(3,xo),re(4,ks),re(5,Xt),re(6,En),re(7,Cs)],aa);var O;(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=""))(O||(O={}));var Qo;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(Qo||(Qo={}));var l_;(e=>e.ST=`${O.ESC}\\`)(l_||(l_={}));var hh=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(`${O.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)}}};hh=at([re(2,Gt),re(3,Xt),re(4,Fr),re(5,ks)],hh);var kt=0,xt=0,Et=0,ot=0,hu={css:"#00000000",rgba:0},ft;(e=>{function t(r,n,o,a){return a!==void 0?`#${rr(r)}${rr(n)}${rr(o)}${rr(a)}`:`#${rr(r)}${rr(n)}${rr(o)}`}e.toCss=t;function i(r,n,o,a=255){return(r<<24|n<<16|o<<8|a)>>>0}e.toRgba=i;function s(r,n,o,a){return{css:e.toCss(r,n,o,a),rgba:e.toRgba(r,n,o,a)}}e.toColor=s})(ft||(ft={}));var Xe;(e=>{function t(h,l){if(ot=(l.rgba&255)/255,ot===1)return{css:l.css,rgba:l.rgba};let u=l.rgba>>24&255,d=l.rgba>>16&255,v=l.rgba>>8&255,p=h.rgba>>24&255,f=h.rgba>>16&255,g=h.rgba>>8&255;kt=p+Math.round((u-p)*ot),xt=f+Math.round((d-f)*ot),Et=g+Math.round((v-g)*ot);let m=ft.toCss(kt,xt,Et),b=ft.toRgba(kt,xt,Et);return{css:m,rgba:b}}e.blend=t;function i(h){return(h.rgba&255)===255}e.isOpaque=i;function s(h,l,u){let d=Jo.ensureContrastRatio(h.rgba,l.rgba,u);if(d)return ft.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=s;function r(h){let l=(h.rgba|255)>>>0;return[kt,xt,Et]=Jo.toChannels(l),{css:ft.toCss(kt,xt,Et),rgba:l}}e.opaque=r;function n(h,l){return ot=Math.round(l*255),[kt,xt,Et]=Jo.toChannels(h.rgba),{css:ft.toCss(kt,xt,Et,ot),rgba:ft.toRgba(kt,xt,Et,ot)}}e.opacity=n;function o(h,l){return ot=h.rgba&255,n(h,ot*l/255)}e.multiplyOpacity=o;function a(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=a})(Xe||(Xe={}));var st;(e=>{let t,i;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return kt=parseInt(r.slice(1,2).repeat(2),16),xt=parseInt(r.slice(2,3).repeat(2),16),Et=parseInt(r.slice(3,4).repeat(2),16),ft.toColor(kt,xt,Et);case 5:return kt=parseInt(r.slice(1,2).repeat(2),16),xt=parseInt(r.slice(2,3).repeat(2),16),Et=parseInt(r.slice(3,4).repeat(2),16),ot=parseInt(r.slice(4,5).repeat(2),16),ft.toColor(kt,xt,Et,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 kt=parseInt(n[1]),xt=parseInt(n[2]),Et=parseInt(n[3]),ot=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),ft.toColor(kt,xt,Et,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),[kt,xt,Et,ot]=t.getImageData(0,0,1,1).data,ot!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ft.toRgba(kt,xt,Et,ot),css:r}}e.toColor=s})(st||(st={}));var jt;(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,a=r/255,h=n/255,l=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),u=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return l*.2126+u*.7152+d*.0722}e.relativeLuminance2=i})(jt||(jt={}));var Jo;(e=>{function t(o,a){if(ot=(a&255)/255,ot===1)return a;let h=a>>24&255,l=a>>16&255,u=a>>8&255,d=o>>24&255,v=o>>16&255,p=o>>8&255;return kt=d+Math.round((h-d)*ot),xt=v+Math.round((l-v)*ot),Et=p+Math.round((u-p)*ot),ft.toRgba(kt,xt,Et)}e.blend=t;function i(o,a,h){let l=jt.relativeLuminance(o>>8),u=jt.relativeLuminance(a>>8);if(as(l,u)<h){if(u<l){let p=s(o,a,h),f=as(l,jt.relativeLuminance(p>>8));if(f<h){let g=r(o,a,h),m=as(l,jt.relativeLuminance(g>>8));return f>m?p:g}return p}let d=r(o,a,h),v=as(l,jt.relativeLuminance(d>>8));if(v<h){let p=s(o,a,h),f=as(l,jt.relativeLuminance(p>>8));return v>f?d:p}return d}}e.ensureContrastRatio=i;function s(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,v=a>>24&255,p=a>>16&255,f=a>>8&255,g=as(jt.relativeLuminance2(v,p,f),jt.relativeLuminance2(l,u,d));for(;g<h&&(v>0||p>0||f>0);)v-=Math.max(0,Math.ceil(v*.1)),p-=Math.max(0,Math.ceil(p*.1)),f-=Math.max(0,Math.ceil(f*.1)),g=as(jt.relativeLuminance2(v,p,f),jt.relativeLuminance2(l,u,d));return(v<<24|p<<16|f<<8|255)>>>0}e.reduceLuminance=s;function r(o,a,h){let l=o>>24&255,u=o>>16&255,d=o>>8&255,v=a>>24&255,p=a>>16&255,f=a>>8&255,g=as(jt.relativeLuminance2(v,p,f),jt.relativeLuminance2(l,u,d));for(;g<h&&(v<255||p<255||f<255);)v=Math.min(255,v+Math.ceil((255-v)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),g=as(jt.relativeLuminance2(v,p,f),jt.relativeLuminance2(l,u,d));return(v<<24|p<<16|f<<8|255)>>>0}e.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}e.toChannels=n})(Jo||(Jo={}));function rr(e){let t=e.toString(16);return t.length<2?"0"+t:t}function as(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Db=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()]}},la=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,a=t.getFg(0),h=t.getBg(0);for(let l=0;l<t.getTrimmedLength();l++)if(t.loadCell(l,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==a||this._workCell.bg!==h){if(l-r>1){let u=this._getJoinedRanges(s,o,n,t,r);for(let d=0;d<u.length;d++)i.push(u[d])}r=l,o=n,a=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||Vs.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(s,o,n,t,r);for(let u=0;u<l.length;u++)i.push(l[u])}return i}_getJoinedRanges(e,t,i,s,r){let n=e.substring(t,i),o=[];try{o=this._characterJoiners[0].handler(n)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let h=this._characterJoiners[a].handler(n);for(let l=0;l<h.length;l++)la._mergeRanges(o,h[l])}catch(h){console.error(h)}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 a=i;a<this._bufferService.cols;a++){let h=t.getWidth(a),l=t.getString(a).length||Vs.length;if(h!==0){if(!r&&o[0]<=n&&(o[0]=a,r=!0),o[1]<=n){if(o[1]=a,o=e[++s],!o)break;o[0]<=n?(o[0]=a,r=!0):r=!1}n+=l}}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}};la=at([re(0,Gt)],la);function Tb(e){return 57508<=e&&e<=57558}function Mb(e){return 9472<=e&&e<=9631}function Pb(e){return Tb(e)||Mb(e)}function Bb(){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 ch=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,a,h,l,u){let d=[],v=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,f=e.getNoBgTrimmedLength();i&&f<n+1&&(f=n+1);let g,m=0,b="",R=0,k=0,y=0,D=0,I=!1,F=0,V=!1,Z=0,U=0,ie=[],K=l!==-1&&u!==-1;for(let x=0;x<f;x++){e.loadCell(x,this._workCell);let M=this._workCell.getWidth();if(M===0)continue;let P=!1,Y=x>=U,ne=x,N=this._workCell;if(v.length>0&&x===v[0][0]&&Y){let ce=v.shift(),Ue=this._isCellInSelection(ce[0],t);for(R=ce[0]+1;R<ce[1];R++)Y&&(Y=Ue===this._isCellInSelection(R,t));Y&&(Y=!i||n<ce[0]||n>=ce[1]),Y?(P=!0,N=new Db(this._workCell,e.translateToString(!0,ce[0],ce[1]),ce[1]-ce[0]),ne=ce[1]-1,M=N.getWidth()):U=ce[1]}let he=this._isCellInSelection(x,t),Ce=i&&x===n,de=K&&x>=l&&x<=u,L=!1;this._decorationService.forEachDecorationAtCell(x,t,void 0,ce=>{L=!0});let ee=N.getChars()||Vs;if(ee===" "&&(N.isUnderline()||N.isOverline())&&(ee=" "),Z=M*a-h.get(ee,N.isBold(),N.isItalic()),!g)g=this._document.createElement("span");else if(m&&(he&&V||!he&&!V&&N.bg===k)&&(he&&V&&p.selectionForeground||N.fg===y)&&N.extended.ext===D&&de===I&&Z===F&&!Ce&&!P&&!L&&Y){N.isInvisible()?b+=Vs:b+=ee,m++;continue}else m&&(g.textContent=b),g=this._document.createElement("span"),m=0,b="";if(k=N.bg,y=N.fg,D=N.extended.ext,I=de,F=Z,V=he,P&&n>=x&&n<=ne&&(n=x),!this._coreService.isCursorHidden&&Ce&&this._coreService.isCursorInitialized){if(ie.push("xterm-cursor"),this._coreBrowserService.isFocused)o&&ie.push("xterm-cursor-blink"),ie.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":ie.push("xterm-cursor-outline");break;case"block":ie.push("xterm-cursor-block");break;case"bar":ie.push("xterm-cursor-bar");break;case"underline":ie.push("xterm-cursor-underline");break}}if(N.isBold()&&ie.push("xterm-bold"),N.isItalic()&&ie.push("xterm-italic"),N.isDim()&&ie.push("xterm-dim"),N.isInvisible()?b=Vs:b=N.getChars()||Vs,N.isUnderline()&&(ie.push(`xterm-underline-${N.extended.underlineStyle}`),b===" "&&(b=" "),!N.isUnderlineColorDefault()))if(N.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${ko.toColorRGB(N.getUnderlineColor()).join(",")})`;else{let ce=N.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&N.isBold()&&ce<8&&(ce+=8),g.style.textDecorationColor=p.ansi[ce].css}N.isOverline()&&(ie.push("xterm-overline"),b===" "&&(b=" ")),N.isStrikethrough()&&ie.push("xterm-strikethrough"),de&&(g.style.textDecoration="underline");let fe=N.getFgColor(),be=N.getFgColorMode(),ve=N.getBgColor(),me=N.getBgColorMode(),Ee=!!N.isInverse();if(Ee){let ce=fe;fe=ve,ve=ce;let Ue=be;be=me,me=Ue}let Ne,Je,ze=!1;this._decorationService.forEachDecorationAtCell(x,t,void 0,ce=>{ce.options.layer!=="top"&&ze||(ce.backgroundColorRGB&&(me=50331648,ve=ce.backgroundColorRGB.rgba>>8&16777215,Ne=ce.backgroundColorRGB),ce.foregroundColorRGB&&(be=50331648,fe=ce.foregroundColorRGB.rgba>>8&16777215,Je=ce.foregroundColorRGB),ze=ce.options.layer==="top")}),!ze&&he&&(Ne=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ve=Ne.rgba>>8&16777215,me=50331648,ze=!0,p.selectionForeground&&(be=50331648,fe=p.selectionForeground.rgba>>8&16777215,Je=p.selectionForeground)),ze&&ie.push("xterm-decoration-top");let Ae;switch(me){case 16777216:case 33554432:Ae=p.ansi[ve],ie.push(`xterm-bg-${ve}`);break;case 50331648:Ae=ft.toColor(ve>>16,ve>>8&255,ve&255),this._addStyle(g,`background-color:#${cu((ve>>>0).toString(16),"0",6)}`);break;case 0:default:Ee?(Ae=p.foreground,ie.push("xterm-bg-257")):Ae=p.background}switch(Ne||N.isDim()&&(Ne=Xe.multiplyOpacity(Ae,.5)),be){case 16777216:case 33554432:N.isBold()&&fe<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(fe+=8),this._applyMinimumContrast(g,Ae,p.ansi[fe],N,Ne,void 0)||ie.push(`xterm-fg-${fe}`);break;case 50331648:let ce=ft.toColor(fe>>16&255,fe>>8&255,fe&255);this._applyMinimumContrast(g,Ae,ce,N,Ne,Je)||this._addStyle(g,`color:#${cu(fe.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(g,Ae,p.foreground,N,Ne,Je)||Ee&&ie.push("xterm-fg-257")}ie.length&&(g.className=ie.join(" "),ie.length=0),!Ce&&!P&&!L&&Y?m++:g.textContent=b,Z!==this.defaultSpacing&&(g.style.letterSpacing=`${Z}px`),d.push(g),x=ne}return g&&m&&(g.textContent=b),d}_applyMinimumContrast(e,t,i,s,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Pb(s.getCode()))return!1;let o=this._getContrastCache(s),a;if(!r&&!n&&(a=o.getColor(t.rgba,i.rgba)),a===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);a=Xe.ensureContrastRatio(r||t,n||i,h),o.setColor((r||t).rgba,(n||i).rgba,a??null)}return a?(this._addStyle(e,`color:${a.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]}};ch=at([re(1,qf),re(2,Xt),re(3,Cs),re(4,Fr),re(5,xo),re(6,En)],ch);function cu(e,t,i){for(;e.length<i;)e=t+e;return e}var Lb=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}},Ab=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,a=Math.max(n,0),h=Math.min(o,e.rows-1);if(a>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=a,this.viewportCappedEndRow=h,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 Ob(){return new Ab}var Ga="xterm-dom-renderer-owner-",pi="xterm-rows",Fo="xterm-fg-",uu="xterm-bg-",Ln="xterm-focus",Ho="xterm-selection",Ib=1,uh=class extends Me{constructor(e,t,i,s,r,n,o,a,h,l,u,d,v,p){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=r,this._helperContainer=n,this._linkifier2=o,this._charSizeService=h,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=v,this._themeService=p,this._terminalClass=Ib++,this._rowElements=[],this._selectionRenderModel=Ob(),this.onRequestRedraw=this._register(new J).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(Ho),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Bb(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(f=>this._injectCss(f))),this._injectCss(this._themeService.colors),this._rowFactory=a.createInstance(ch,document),this._element.classList.add(Ga+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(f=>this._handleLinkHover(f))),this._register(this._linkifier2.onHideLinkUnderline(f=>this._handleLinkLeave(f))),this._register(tt(()=>{this._element.classList.remove(Ga+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Lb(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: ${Xe.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}.${Ln} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${pi}.${Ln} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${pi}.${Ln} .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} .${Ho} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ho} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ho} 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: ${Xe.multiplyOpacity(o,.5).css}; }${this._terminalSelector} .${uu}${n} { background-color: ${o.css}; }`;t+=`${this._terminalSelector} .${Fo}257 { color: ${Xe.opaque(e.background).css}; }${this._terminalSelector} .${Fo}257.xterm-dim { color: ${Xe.multiplyOpacity(Xe.opaque(e.background),.5).css}; }${this._terminalSelector} .${uu}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(Ln),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Ln),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,a=this._document.createDocumentFragment();if(i){let h=e[0]>t[0];a.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],o-n+1))}else{let h=s===n?e[0]:0,l=n===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,h,l));let u=o-n-1;if(a.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,u)),n!==o){let d=r===o?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,0,d))}}this._selectionContainer.appendChild(a)}_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,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let l=h+i.ydisp,u=this._rowElements[h],d=i.lines.get(l);if(!u||!d)break;u.replaceChildren(...this._rowFactory.createRow(d,l,l===s,o,a,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ga}${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 a=this._bufferService.buffer,h=a.ybase+a.y,l=Math.min(a.x,r-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,v=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=i;p<=s;++p){let f=p+a.ydisp,g=this._rowElements[p],m=a.lines.get(f);if(!g||!m)break;g.replaceChildren(...this._rowFactory.createRow(m,f,f===h,d,v,l,u,this.dimensions.css.cell.width,this._widthCache,n?p===i?e:0:-1,n?(p===s?t:r)-1:-1))}}};uh=at([re(7,Qh),re(8,Da),re(9,Xt),re(10,Gt),re(11,Fr),re(12,Cs),re(13,En)],uh);var dh=class extends Me{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new J),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Fb(this._optionsService))}catch{this._measureStrategy=this._register(new Nb(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())}};dh=at([re(2,Xt)],dh);var h_=class extends Me{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)}},Nb=class extends h_{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}},Fb=class extends h_{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}},Hb=class extends Me{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 Wb(this._window)),this._onDprChange=this._register(new J),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new J),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(At.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(ye(this._textarea,"focus",()=>this._isFocused=!0)),this._register(ye(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}},Wb=class extends Me{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new yn),this._onDprChange=this._register(new J),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=ye(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)}},zb=class extends Me{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 rc(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 Ub(e,t,i,s,r,n,o,a,h){if(!n)return;let l=rc(e,t,i);if(l)return l[0]=Math.ceil((l[0]+(h?o/2:0))/o),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),s+(h?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}var fh=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,r){return Ub(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=rc(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])}}};fh=at([re(0,ks),re(1,Da)],fh);var Kb=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=[]}},c_={};$m(c_,{getSafariVersion:()=>jb,isChromeOS:()=>__,isFirefox:()=>u_,isIpad:()=>Vb,isIphone:()=>Yb,isLegacyEdge:()=>qb,isLinux:()=>nc,isMac:()=>ha,isNode:()=>Ta,isSafari:()=>d_,isWindows:()=>f_});var Ta=typeof process<"u"&&"title"in process,Eo=Ta?"node":navigator.userAgent,Ro=Ta?"node":navigator.platform,u_=Eo.includes("Firefox"),qb=Eo.includes("Edge"),d_=/^((?!chrome|android).)*safari/i.test(Eo);function jb(){if(!d_)return 0;let e=Eo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var ha=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Ro),Vb=Ro==="iPad",Yb=Ro==="iPhone",f_=["Windows","Win16","Win32","WinCE"].includes(Ro),nc=Ro.indexOf("Linux")>=0,__=/\bCrOS\b/.test(Eo),v_=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()}},Gb=class extends v_{_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())}}},Xb=class extends v_{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ca=!Ta&&"requestIdleCallback"in window?Xb:Gb,Qb=class{constructor(){this._queue=new ca}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},_h=class extends Me{constructor(e,t,i,s,r,n,o,a,h){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new yn),this._pausedResizeTask=new Qb,this._observerDisposable=this._register(new yn),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new J),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new J),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new J),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new J),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Kb((l,u)=>this._renderRows(l,u),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Jb(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 l;return(l=this._renderer.value)==null?void 0:l.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(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(l=>this._registerIntersectionObserver(l,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()}};_h=at([re(2,Xt),re(3,Da),re(4,Fr),re(5,xo),re(6,Gt),re(7,Cs),re(8,En)],_h);var Jb=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Zb(e,t,i,s){let r=i.buffer.x,n=i.buffer.y;if(!i.buffer.hasScrollback)return t0(r,n,e,t,i,s)+Ma(n,t,i,s)+i0(r,n,e,t,i,s);let o;if(n===t)return o=r>e?"D":"C",no(Math.abs(r-e),ro(o,s));o=n>t?"D":"C";let a=Math.abs(n-t),h=e0(n>t?e:r,i)+(a-1)*i.cols+1+$b(n>t?r:e);return no(h,ro(o,s))}function $b(e,t){return e-1}function e0(e,t){return t.cols-e}function t0(e,t,i,s,r,n){return Ma(t,s,r,n).length===0?"":no(g_(e,t,e,t-Ir(t,r),!1,r).length,ro("D",n))}function Ma(e,t,i,s){let r=e-Ir(e,i),n=t-Ir(t,i),o=Math.abs(r-n)-s0(e,t,i);return no(o,ro(p_(e,t),s))}function i0(e,t,i,s,r,n){let o;Ma(t,s,r,n).length>0?o=s-Ir(s,r):o=t;let a=s,h=r0(e,t,i,s,r,n);return no(g_(e,o,i,a,h==="C",r).length,ro(h,n))}function s0(e,t,i){var o;let s=0,r=e-Ir(e,i),n=t-Ir(t,i);for(let a=0;a<Math.abs(r-n);a++){let h=p_(e,t)==="A"?-1:1;(o=i.buffer.lines.get(r+h*a))!=null&&o.isWrapped&&s++}return s}function Ir(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 r0(e,t,i,s,r,n){let o;return Ma(i,s,r,n).length>0?o=s-Ir(s,r):o=t,e<i&&o<=s||e>=i&&o<s?"C":"D"}function p_(e,t){return e>t?"A":"B"}function g_(e,t,i,s,r,n){let o=e,a=t,h="";for(;(o!==i||a!==s)&&a>=0&&a<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(h+=n.buffer.translateBufferLineToString(a,!1,e,o),o=0,e=0,a++):!r&&o<0&&(h+=n.buffer.translateBufferLineToString(a,!1,0,e+1),o=n.cols-1,e=o,a--);return h+n.buffer.translateBufferLineToString(a,!1,e,o)}function ro(e,t){let i=t?"O":"[";return O.ESC+i+e}function no(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var n0=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 du(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 Xa=50,o0=15,a0=50,l0=500,h0=" ",c0=new RegExp(h0,"g"),vh=class extends Me{constructor(e,t,i,s,r,n,o,a,h){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=r,this._mouseService=n,this._optionsService=o,this._renderService=a,this._coreBrowserService=h,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 J),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new J),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new J),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new J),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=l=>this._handleMouseMove(l),this._mouseUpListener=l=>this._handleMouseUp(l),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(l=>this._handleTrim(l)),this._register(this._bufferService.buffers.onBufferActivate(l=>this._handleBufferActivate(l))),this.enable(),this._model=new n0(this._bufferService),this._activeSelectionMode=0,this._register(tt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(l=>{l.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 a=i.translateBufferLineToString(o,!0,r,n);s.push(a)}}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),a=i.translateBufferLineToString(n,!0);o!=null&&o.isWrapped?s[s.length-1]+=a:s.push(a)}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(c0," ")).join(f_?`\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())),nc&&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=du(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=rc(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,-Xa),Xa),t/=Xa,t/Math.abs(t)+Math.round(t*(o0-1)))}shouldForceSelection(e){return ha?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(),a0)}_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&&!(ha&&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<l0&&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=Zb(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),a=this._convertViewportColToCharacterIndex(n,e[0]),h=a,l=e[0]-a,u=0,d=0,v=0,p=0;if(o.charAt(a)===" "){for(;a>0&&o.charAt(a-1)===" ";)a--;for(;h<o.length&&o.charAt(h+1)===" ";)h++}else{let m=e[0],b=e[0];n.getWidth(m)===0&&(u++,m--),n.getWidth(b)===2&&(d++,b++);let R=n.getString(b).length;for(R>1&&(p+=R-1,h+=R-1);m>0&&a>0&&!this._isCharWordSeparator(n.loadCell(m-1,this._workCell));){n.loadCell(m-1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,m--):k>1&&(v+=k-1,a-=k-1),a--,m--}for(;b<n.length&&h+1<o.length&&!this._isCharWordSeparator(n.loadCell(b+1,this._workCell));){n.loadCell(b+1,this._workCell);let k=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,b++):k>1&&(p+=k-1,h+=k-1),h++,b++}}h++;let f=a+l-u+v,g=Math.min(this._bufferService.cols,h-a+u+d-v-p);if(!(!t&&o.slice(a,h).trim()==="")){if(i&&f===0&&n.getCodePoint(0)!==32){let m=r.lines.get(e[1]-1);if(m&&n.isWrapped&&m.getCodePoint(this._bufferService.cols-1)!==32){let b=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(b){let R=this._bufferService.cols-b.start;f-=R,g+=R}}}if(s&&f+g===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let m=r.lines.get(e[1]+1);if(m!=null&&m.isWrapped&&m.getCodePoint(0)!==32){let b=this._getWordAt([0,e[1]+1],!1,!1,!0);b&&(g+=b.length)}}return{start:f,length:g}}}_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=du(i,this._bufferService.cols)}};vh=at([re(3,Gt),re(4,Fr),re(5,Jh),re(6,Xt),re(7,ks),re(8,Cs)],vh);var fu=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={}}},_u=class{constructor(){this._color=new fu,this._css=new fu}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},vt=Object.freeze((()=>{let e=[st.toColor("#2e3436"),st.toColor("#cc0000"),st.toColor("#4e9a06"),st.toColor("#c4a000"),st.toColor("#3465a4"),st.toColor("#75507b"),st.toColor("#06989a"),st.toColor("#d3d7cf"),st.toColor("#555753"),st.toColor("#ef2929"),st.toColor("#8ae234"),st.toColor("#fce94f"),st.toColor("#729fcf"),st.toColor("#ad7fa8"),st.toColor("#34e2e2"),st.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],r=t[i/6%6|0],n=t[i%6];e.push({css:ft.toCss(s,r,n),rgba:ft.toRgba(s,r,n)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ft.toCss(s,s,s),rgba:ft.toRgba(s,s,s)})}return e})()),nr=st.toColor("#ffffff"),Kn=st.toColor("#000000"),vu=st.toColor("#ffffff"),pu=Kn,An={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},u0=nr,ph=class extends Me{constructor(e){super(),this._optionsService=e,this._contrastCache=new _u,this._halfContrastCache=new _u,this._onChangeColors=this._register(new J),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:nr,background:Kn,cursor:vu,cursorAccent:pu,selectionForeground:void 0,selectionBackgroundTransparent:An,selectionBackgroundOpaque:Xe.blend(Kn,An),selectionInactiveBackgroundTransparent:An,selectionInactiveBackgroundOpaque:Xe.blend(Kn,An),scrollbarSliderBackground:Xe.opacity(nr,.2),scrollbarSliderHoverBackground:Xe.opacity(nr,.4),scrollbarSliderActiveBackground:Xe.opacity(nr,.5),overviewRulerBorder:nr,ansi:vt.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=qe(e.foreground,nr),t.background=qe(e.background,Kn),t.cursor=Xe.blend(t.background,qe(e.cursor,vu)),t.cursorAccent=Xe.blend(t.background,qe(e.cursorAccent,pu)),t.selectionBackgroundTransparent=qe(e.selectionBackground,An),t.selectionBackgroundOpaque=Xe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=qe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Xe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?qe(e.selectionForeground,hu):void 0,t.selectionForeground===hu&&(t.selectionForeground=void 0),Xe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Xe.opacity(t.selectionBackgroundTransparent,.3)),Xe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Xe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=qe(e.scrollbarSliderBackground,Xe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=qe(e.scrollbarSliderHoverBackground,Xe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=qe(e.scrollbarSliderActiveBackground,Xe.opacity(t.foreground,.5)),t.overviewRulerBorder=qe(e.overviewRulerBorder,u0),t.ansi=vt.slice(),t.ansi[0]=qe(e.black,vt[0]),t.ansi[1]=qe(e.red,vt[1]),t.ansi[2]=qe(e.green,vt[2]),t.ansi[3]=qe(e.yellow,vt[3]),t.ansi[4]=qe(e.blue,vt[4]),t.ansi[5]=qe(e.magenta,vt[5]),t.ansi[6]=qe(e.cyan,vt[6]),t.ansi[7]=qe(e.white,vt[7]),t.ansi[8]=qe(e.brightBlack,vt[8]),t.ansi[9]=qe(e.brightRed,vt[9]),t.ansi[10]=qe(e.brightGreen,vt[10]),t.ansi[11]=qe(e.brightYellow,vt[11]),t.ansi[12]=qe(e.brightBlue,vt[12]),t.ansi[13]=qe(e.brightMagenta,vt[13]),t.ansi[14]=qe(e.brightCyan,vt[14]),t.ansi[15]=qe(e.brightWhite,vt[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=qe(e.extendedAnsi[s],vt[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};ph=at([re(0,Xt)],ph);function qe(e,t){if(e!==void 0)try{return st.toColor(e)}catch{}return t}var d0=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)}},f0=class{constructor(){this._services=new d0,this._services.set(Qh,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=oS(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)}},_0={trace:0,debug:1,info:2,warn:3,error:4,off:5},v0="xterm.js: ",gh=class extends Me{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=_0[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?"":v0)+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)}};gh=at([re(0,Xt)],gh);var gu=class extends Me{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new J),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new J),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new J),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}},Te=3,dt=Object.freeze(new ko),Wo=0,Qa=2,qn=class m_{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Te);let r=i||Ri.fromCharData([0,Nf,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let i=this._data[t*Te+0],s=i&2097151;return[this._data[t*Te+1],i&2097152?this._combined[t]:s?Bs(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*Te+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*Te+0]=t|2097152|i[2]<<22):this._data[t*Te+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*Te+0]>>22}hasWidth(t){return this._data[t*Te+0]&12582912}getFg(t){return this._data[t*Te+1]}getBg(t){return this._data[t*Te+2]}hasContent(t){return this._data[t*Te+0]&4194303}getCodePoint(t){let i=this._data[t*Te+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*Te+0]&2097152}getString(t){let i=this._data[t*Te+0];return i&2097152?this._combined[t]:i&2097151?Bs(i&2097151):""}isProtected(t){return this._data[t*Te+2]&536870912}loadCell(t,i){return Wo=t*Te,i.content=this._data[Wo+0],i.fg=this._data[Wo+1],i.bg=this._data[Wo+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*Te+0]=i.content,this._data[t*Te+1]=i.fg,this._data[t*Te+2]=i.bg}setCellFromCodepoint(t,i,s,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*Te+0]=i|s<<22,this._data[t*Te+1]=r.fg,this._data[t*Te+2]=r.bg}addCodepointToCell(t,i,s){let r=this._data[t*Te+0];r&2097152?this._combined[t]+=Bs(i):r&2097151?(this._combined[t]=Bs(r&2097151)+Bs(i),r&=-2097152,r|=2097152):r=i|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[t*Te+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*Qa<this._data.buffer.byteLength;let s=t*Te;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 a=parseInt(r[o],10);a>=t&&delete this._combined[a]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let a=parseInt(n[o],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,s*4*Qa<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Qa<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 m_(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*Te+0]&4194303)return t+(this._data[t*Te+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Te+0]&4194303||this._data[t*Te+2]&50331648)return t+(this._data[t*Te+0]>>22);return 0}copyCellsFrom(t,i,s,r,n){let o=t._data;if(n)for(let h=r-1;h>=0;h--){for(let l=0;l<Te;l++)this._data[(s+h)*Te+l]=o[(i+h)*Te+l];o[(i+h)*Te+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}else for(let h=0;h<r;h++){for(let l=0;l<Te;l++)this._data[(s+h)*Te+l]=o[(i+h)*Te+l];o[(i+h)*Te+2]&268435456&&(this._extendedAttrs[s+h]=t._extendedAttrs[i+h])}let a=Object.keys(t._combined);for(let h=0;h<a.length;h++){let l=parseInt(a[h],10);l>=i&&(this._combined[l-i+s]=t._combined[l])}}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*Te+0],a=o&2097151,h=o&2097152?this._combined[i]:a?Bs(a):Vs;if(n+=h,r)for(let l=0;l<h.length;++l)r.push(i);i+=o>>22||1}return r&&r.push(i),n}};function p0(e,t,i,s,r,n){let o=[];for(let a=0;a<e.length-1;a++){let h=a,l=e.get(++h);if(!l.isWrapped)continue;let u=[e.get(a)];for(;h<e.length&&l.isWrapped;)u.push(l),l=e.get(++h);if(!n&&s>=a&&s<h){a+=u.length-1;continue}let d=0,v=oo(u,d,t),p=1,f=0;for(;p<u.length;){let m=oo(u,p,t),b=m-f,R=i-v,k=Math.min(b,R);u[d].copyCellsFrom(u[p],f,v,k,!1),v+=k,v===i&&(d++,v=0),f+=k,f===m&&(p++,f=0),v===0&&d!==0&&u[d-1].getWidth(i-1)===2&&(u[d].copyCellsFrom(u[d-1],i-1,v++,1,!1),u[d-1].setCell(i-1,r))}u[d].replaceCells(v,i,r);let g=0;for(let m=u.length-1;m>0&&(m>d||u[m].getTrimmedLength()===0);m--)g++;g>0&&(o.push(a+u.length-g),o.push(g)),a+=u.length-1}return o}function g0(e,t){let i=[],s=0,r=t[s],n=0;for(let o=0;o<e.length;o++)if(r===o){let a=t[++s];e.onDeleteEmitter.fire({index:o-n,amount:a}),o+=a-1,n+=a,r=t[++s]}else i.push(o);return{layout:i,countRemoved:n}}function m0(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 S0(e,t,i){let s=[],r=e.map((h,l)=>oo(e,l,t)).reduce((h,l)=>h+l),n=0,o=0,a=0;for(;a<r;){if(r-a<i){s.push(r-a);break}n+=i;let h=oo(e,o,t);n>h&&(n-=h,o++);let l=e[o].getWidth(n-1)===2;l&&n--;let u=l?i-1:i;s.push(u),a+=u}return s}function oo(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 b_{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=b_._nextId++,this._onDispose=this.register(new J),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Or(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};S_._nextId=1;var b0=S_,bt={},or=bt.B;bt[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};bt.A={"#":"£"};bt.B=void 0;bt[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};bt.C=bt[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};bt.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};bt.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};bt.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};bt.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};bt.E=bt[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};bt.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};bt.H=bt[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};bt["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var mu=4294967295,Su=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=dt.clone(),this.savedCharset=or,this.markers=[],this._nullCell=Ri.fromCharData([0,Nf,1,0]),this._whitespaceCell=Ri.fromCharData([0,Vs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ca,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new gu(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 oa),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 oa),this._whitespaceCell}getBlankLine(e,t){return new qn(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>mu?mu:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=dt);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new gu(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(dt),s=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);let n=0;if(this._rows<t)for(let o=this._rows;o<t;o++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new qn(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 qn(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=p0(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(dt),i);if(s.length>0){let r=g0(this.lines,s);m0(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(dt),r=i;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new qn(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(dt),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let a=this.lines.get(o);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let h=[a];for(;a.isWrapped&&o>0;)a=this.lines.get(--o),h.unshift(a);if(!i){let k=this.ybase+this.y;if(k>=o&&k<o+h.length)continue}let l=h[h.length-1].getTrimmedLength(),u=S0(h,this._cols,e),d=u.length-h.length,v;this.ybase===0&&this.y!==this.lines.length-1?v=Math.max(0,this.y-this.lines.maxLength+d):v=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let k=0;k<d;k++){let y=this.getBlankLine(dt,!0);p.push(y)}p.length>0&&(r.push({start:o+h.length+n,newLines:p}),n+=p.length),h.push(...p);let f=u.length-1,g=u[f];g===0&&(f--,g=u[f]);let m=h.length-d-1,b=l;for(;m>=0;){let k=Math.min(b,g);if(h[f]===void 0)break;if(h[f].copyCellsFrom(h[m],b-k,g-k,k,!0),g-=k,g===0&&(f--,g=u[f]),b-=k,b===0){m--;let y=Math.max(m,0);b=oo(h,y,this._cols)}}for(let k=0;k<h.length;k++)u[k]<e&&h[k].setCell(u[k],s);let R=d-v;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+d,this.ybase+t-1)}if(r.length>0){let o=[],a=[];for(let g=0;g<this.lines.length;g++)a.push(this.lines.get(g));let h=this.lines.length,l=h-1,u=0,d=r[u];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let v=0;for(let g=Math.min(this.lines.maxLength-1,h+n-1);g>=0;g--)if(d&&d.start>l+v){for(let m=d.newLines.length-1;m>=0;m--)this.lines.set(g--,d.newLines[m]);g++,o.push({index:l+1,amount:d.newLines.length}),v+=d.newLines.length,d=r[++u]}else this.lines.set(g,a[l--]);let p=0;for(let g=o.length-1;g>=0;g--)o[g].index+=p,this.lines.onInsertEmitter.fire(o[g]),p+=o[g].amount;let f=Math.max(0,h+n-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}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 b0(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)}},y0=class extends Me{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new J),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 Su(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Su(!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)}},y_=2,w_=1,mh=class extends Me{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new J),this.onResize=this._onResize.event,this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,y_),this.rows=Math.max(e.rawOptions.rows||0,w_),this.buffers=this._register(new y0(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))}};mh=at([re(0,Xt)],mh);var zr={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:ha,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},w0=["normal","bold","100","200","300","400","500","600","700","800","900"],C0=class extends Me{constructor(e){super(),this._onOptionChange=this._register(new J),this.onOptionChange=this._onOptionChange.event;let t={...zr};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 zr))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in zr))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=zr[e]),!k0(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=zr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=w0.includes(t)?t:zr[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 k0(e){return e==="block"||e==="underline"||e==="bar"}function jn(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]&&jn(e[s],t-1);return i}var bu=Object.freeze({insertMode:!1}),yu=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Sh=class extends Me{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 J),this.onData=this._onData.event,this._onUserInput=this._register(new J),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new J),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new J),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=jn(bu),this.decPrivateModes=jn(yu)}reset(){this.modes=jn(bu),this.decPrivateModes=jn(yu)}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))}};Sh=at([re(0,Gt),re(1,Uf),re(2,Xt)],Sh);var wu={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 Ja(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 Za=String.fromCharCode,Cu={DEFAULT:e=>{let t=[Ja(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${Za(t[0])}${Za(t[1])}${Za(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ja(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Ja(e,!0)};${e.x};${e.y}${t}`}},bh=class extends Me{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 J),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(wu))this.addProtocol(s,wu[s]);for(let s of Object.keys(Cu))this.addEncoding(s,Cu[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)}};bh=at([re(0,Gt),re(1,Fr),re(2,Xt)],bh);var $a=[[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]],x0=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],pt;function E0(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 R0=class{constructor(){if(this.version="6",!pt){pt=new Uint8Array(65536),pt.fill(1),pt[0]=0,pt.fill(0,1,32),pt.fill(0,127,160),pt.fill(2,4352,4448),pt[9001]=2,pt[9002]=2,pt.fill(2,11904,42192),pt[12351]=1,pt.fill(2,44032,55204),pt.fill(2,63744,64256),pt.fill(2,65040,65050),pt.fill(2,65072,65136),pt.fill(2,65280,65377),pt.fill(2,65504,65511);for(let e=0;e<$a.length;++e)pt.fill(0,$a[e][0],$a[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?pt[e]:E0(e,x0)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let r=dr.extractWidth(t);r===0?s=!1:r>i&&(i=r)}return dr.createPropertyValue(0,i,s)}},dr=class Zo{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new J,this.onChange=this._onChange.event;let t=new R0;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 l=t.charCodeAt(n);56320<=l&&l<=57343?o=(o-55296)*1024+l-56320+65536:i+=this.wcwidth(l)}let a=this.charProperties(o,s),h=Zo.extractWidth(a);Zo.extractShouldJoin(a)&&(h-=Zo.extractWidth(s)),i+=h,s=a}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},D0=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 ku(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 On=2147483647,T0=256,C_=class yh{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>T0)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 yh;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 yh(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>On?On: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>On?On: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,On):t}},In=[],M0=class{constructor(){this._state=0,this._active=In,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=In}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=In,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||In,!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",Ra(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=In,this._id=-1,this._state=0}}},oi=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ra(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}},Nn=[],P0=class{constructor(){this._handlers=Object.create(null),this._active=Nn,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Nn}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=Nn,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Nn,!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",Ra(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=Nn,this._ident=0}},Vn=new C_;Vn.addParam(0);var xu=class{constructor(e){this._handler=e,this._data="",this._params=Vn,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Vn,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Ra(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=Vn,this._data="",this._hitLimit=!1,i));return this._params=Vn,this._data="",this._hitLimit=!1,t}},B0=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=i<<4|s}},ki=160,L0=(function(){let e=new B0(4095),t=Array.apply(null,Array(256)).map((a,h)=>h),i=(a,h)=>t.slice(a,h),s=i(32,127),r=i(0,24);r.push(25),r.push.apply(r,i(28,32));let n=i(0,14),o;e.setDefault(1,0),e.addMany(s,0,2,0);for(o in n)e.addMany([24,26,153,154],o,3,0),e.addMany(i(128,144),o,3,0),e.addMany(i(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ki,0,2,0),e.add(ki,8,5,8),e.add(ki,6,0,6),e.add(ki,11,0,11),e.add(ki,13,13,13),e})(),A0=class extends Me{constructor(e=L0){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 C_,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 M0),this._dcsParser=this._register(new P0),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 a=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](this._params),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,o}this._parseStack.handlers=[];break;case 4:if(i===!1&&h>-1){for(;h>=0&&(o=a[h](),o!==!0);h--)if(o instanceof Promise)return this._parseStack.handlerPos=h,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 a=n;a<t;++a){switch(s=e[a],r=this._transitions.table[this.currentState<<8|(s<160?s:ki)],r>>4){case 2:for(let v=a+1;;++v){if(v>=t||(s=e[v])<32||s>126&&s<ki){this._printHandler(e,a,v),a=v-1;break}if(++v>=t||(s=e[v])<32||s>126&&s<ki){this._printHandler(e,a,v),a=v-1;break}if(++v>=t||(s=e[v])<32||s>126&&s<ki){this._printHandler(e,a,v),a=v-1;break}if(++v>=t||(s=e[v])<32||s>126&&s<ki){this._printHandler(e,a,v),a=v-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:a,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|s],l=h?h.length-1:-1;for(;l>=0&&(o=h[l](this._params),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(3,h,l,r,a),o;l<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(++a<t&&(s=e[a])>47&&s<60);a--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let u=this._escHandlers[this._collect<<8|s],d=u?u.length-1:-1;for(;d>=0&&(o=u[d](),o!==!0);d--)if(o instanceof Promise)return this._preserveStack(4,u,d,r,a),o;d<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 v=a+1;;++v)if(v>=t||(s=e[v])===24||s===26||s===27||s>127&&s<ki){this._dcsParser.put(e,a,v),a=v-1;break}break;case 14:if(o=this._dcsParser.unhook(s!==24&&s!==26),o)return this._preserveStack(6,[],0,r,a),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 v=a+1;;v++)if(v>=t||(s=e[v])<32||s>127&&s<ki){this._oscParser.put(e,a,v),a=v-1;break}break;case 6:if(o=this._oscParser.end(s!==24&&s!==26),o)return this._preserveStack(5,[],0,r,a),o;s===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},O0=/^([\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})$/,I0=/^[\da-f]+$/;function Eu(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=O0.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),I0.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 el(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 N0(e,t=16){let[i,s,r]=e;return`rgb:${el(i,t)}/${el(s,t)}/${el(r,t)}`}var F0={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ms=131072,Ru=10;function Du(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 Tu=5e3,Mu=0,H0=class extends Me{constructor(e,t,i,s,r,n,o,a,h=new A0){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=a,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rS,this._utf8Decoder=new nS,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=dt.clone(),this._eraseAttrDataInternal=dt.clone(),this._onRequestBell=this._register(new J),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new J),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new J),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new J),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new J),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new J),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new J),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new J),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new J),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new J),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new J),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new J),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new J),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 wh(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,u)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:u.toArray()})}),this._parser.setEscHandlerFallback(l=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(l)})}),this._parser.setExecuteHandlerFallback(l=>{this._logService.debug("Unknown EXECUTE code: ",{code:l})}),this._parser.setOscHandlerFallback((l,u,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:u,data:d})}),this._parser.setDcsHandlerFallback((l,u,d)=>{u==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:u,payload:d})}),this._parser.setPrintHandler((l,u,d)=>this.print(l,u,d)),this._parser.registerCsiHandler({final:"@"},l=>this.insertChars(l)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},l=>this.scrollLeft(l)),this._parser.registerCsiHandler({final:"A"},l=>this.cursorUp(l)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},l=>this.scrollRight(l)),this._parser.registerCsiHandler({final:"B"},l=>this.cursorDown(l)),this._parser.registerCsiHandler({final:"C"},l=>this.cursorForward(l)),this._parser.registerCsiHandler({final:"D"},l=>this.cursorBackward(l)),this._parser.registerCsiHandler({final:"E"},l=>this.cursorNextLine(l)),this._parser.registerCsiHandler({final:"F"},l=>this.cursorPrecedingLine(l)),this._parser.registerCsiHandler({final:"G"},l=>this.cursorCharAbsolute(l)),this._parser.registerCsiHandler({final:"H"},l=>this.cursorPosition(l)),this._parser.registerCsiHandler({final:"I"},l=>this.cursorForwardTab(l)),this._parser.registerCsiHandler({final:"J"},l=>this.eraseInDisplay(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},l=>this.eraseInDisplay(l,!0)),this._parser.registerCsiHandler({final:"K"},l=>this.eraseInLine(l,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},l=>this.eraseInLine(l,!0)),this._parser.registerCsiHandler({final:"L"},l=>this.insertLines(l)),this._parser.registerCsiHandler({final:"M"},l=>this.deleteLines(l)),this._parser.registerCsiHandler({final:"P"},l=>this.deleteChars(l)),this._parser.registerCsiHandler({final:"S"},l=>this.scrollUp(l)),this._parser.registerCsiHandler({final:"T"},l=>this.scrollDown(l)),this._parser.registerCsiHandler({final:"X"},l=>this.eraseChars(l)),this._parser.registerCsiHandler({final:"Z"},l=>this.cursorBackwardTab(l)),this._parser.registerCsiHandler({final:"`"},l=>this.charPosAbsolute(l)),this._parser.registerCsiHandler({final:"a"},l=>this.hPositionRelative(l)),this._parser.registerCsiHandler({final:"b"},l=>this.repeatPrecedingCharacter(l)),this._parser.registerCsiHandler({final:"c"},l=>this.sendDeviceAttributesPrimary(l)),this._parser.registerCsiHandler({prefix:">",final:"c"},l=>this.sendDeviceAttributesSecondary(l)),this._parser.registerCsiHandler({final:"d"},l=>this.linePosAbsolute(l)),this._parser.registerCsiHandler({final:"e"},l=>this.vPositionRelative(l)),this._parser.registerCsiHandler({final:"f"},l=>this.hVPosition(l)),this._parser.registerCsiHandler({final:"g"},l=>this.tabClear(l)),this._parser.registerCsiHandler({final:"h"},l=>this.setMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"h"},l=>this.setModePrivate(l)),this._parser.registerCsiHandler({final:"l"},l=>this.resetMode(l)),this._parser.registerCsiHandler({prefix:"?",final:"l"},l=>this.resetModePrivate(l)),this._parser.registerCsiHandler({final:"m"},l=>this.charAttributes(l)),this._parser.registerCsiHandler({final:"n"},l=>this.deviceStatus(l)),this._parser.registerCsiHandler({prefix:"?",final:"n"},l=>this.deviceStatusPrivate(l)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},l=>this.softReset(l)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},l=>this.setCursorStyle(l)),this._parser.registerCsiHandler({final:"r"},l=>this.setScrollRegion(l)),this._parser.registerCsiHandler({final:"s"},l=>this.saveCursor(l)),this._parser.registerCsiHandler({final:"t"},l=>this.windowOptions(l)),this._parser.registerCsiHandler({final:"u"},l=>this.restoreCursor(l)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},l=>this.insertColumns(l)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},l=>this.deleteColumns(l)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},l=>this.selectProtected(l)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},l=>this.requestMode(l,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},l=>this.requestMode(l,!1)),this._parser.setExecuteHandler(O.BEL,()=>this.bell()),this._parser.setExecuteHandler(O.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(O.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(O.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(O.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(O.BS,()=>this.backspace()),this._parser.setExecuteHandler(O.HT,()=>this.tab()),this._parser.setExecuteHandler(O.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(O.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Qo.IND,()=>this.index()),this._parser.setExecuteHandler(Qo.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Qo.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new oi(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new oi(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new oi(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new oi(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new oi(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new oi(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new oi(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new oi(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new oi(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new oi(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new oi(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new oi(l=>this.restoreCursorColor(l))),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 l in bt)this._parser.registerEscHandler({intermediates:"(",final:l},()=>this.selectCharset("("+l)),this._parser.registerEscHandler({intermediates:")",final:l},()=>this.selectCharset(")"+l)),this._parser.registerEscHandler({intermediates:"*",final:l},()=>this.selectCharset("*"+l)),this._parser.registerEscHandler({intermediates:"+",final:l},()=>this.selectCharset("+"+l)),this._parser.registerEscHandler({intermediates:"-",final:l},()=>this.selectCharset("-"+l)),this._parser.registerEscHandler({intermediates:".",final:l},()=>this.selectCharset("."+l)),this._parser.registerEscHandler({intermediates:"/",final:l},()=>this.selectCharset("/"+l));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(l=>(this._logService.error("Parsing error: ",l),l)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new xu((l,u)=>this.requestStatusString(l,u)))}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"),Tu))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Tu} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ms&&(n=this._parseStack.position+Ms)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,l=>String.fromCharCode(l)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(l=>l.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ms&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ms))),o||this._dirtyRowTracker.clearRange(),e.length>Ms)for(let l=n;l<e.length;l+=Ms){let u=l+Ms<e.length?l+Ms:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,u),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,u),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,d))return this._preserveStack(s,r,d,l),this._logSlowResolvingAsync(i),i}else if(!o){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,l))return this._preserveStack(s,r,l,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,i){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let v=this._parser.precedingJoinState;for(let p=t;p<i;++p){if(s=e[p],s<127&&n){let b=n[String.fromCharCode(s)];b&&(s=b.charCodeAt(0))}let f=this._unicodeService.charProperties(s,v);r=dr.extractWidth(f);let g=dr.extractShouldJoin(f),m=g?dr.extractWidth(v):0;if(v=f,o&&this._onA11yChar.fire(Bs(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-m>a){if(h){let b=d,R=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof qn&&d.copyCellsFrom(b,R,0,m,!1);R<a;)b.setCellFromCodepoint(R++,0,1,u)}else if(this._activeBuffer.x=a-1,r===2)continue}if(g&&this._activeBuffer.x){let b=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-b,s,r);for(let R=r-m;--R>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-m,this._activeBuffer.getNullCell(u)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,s,r,u),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=v,this._activeBuffer.x<a&&i-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Du(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new xu(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new oi(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(dt));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=dr.extractWidth(t),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*i),a=0;for(let l=0;l<n.length;){let u=n.codePointAt(l)||0;o[a++]=u,l+=u>65535?2:1}let h=a;for(let l=1;l<i;++l)o.copyWithin(h,0,a),h+=a;return this.print(o,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(O.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(O.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(O.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(O.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(O.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,or),this._charsetService.setgCharset(1,or),this._charsetService.setgCharset(2,or),this._charsetService.setgCharset(3,or);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(g=>(g[g.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",g[g.SET=1]="SET",g[g.RESET=2]="RESET",g[g.PERMANENTLY_SET=3]="PERMANENTLY_SET",g[g.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:a,cols:h}=this._bufferService,{active:l,alt:u}=a,d=this._optionsService.rawOptions,v=(g,m)=>(o.triggerDataEvent(`${O.ESC}[${t?"":"?"}${g};${m}$y`),!0),p=g=>g?1:2,f=e.params[0];return t?f===2?v(f,4):f===4?v(f,p(o.modes.insertMode)):f===12?v(f,3):f===20?v(f,p(d.convertEol)):v(f,0):f===1?v(f,p(s.applicationCursorKeys)):f===3?v(f,d.windowOptions.setWinLines?h===80?2:h===132?1:0:0):f===6?v(f,p(s.origin)):f===7?v(f,p(s.wraparound)):f===8?v(f,3):f===9?v(f,p(r==="X10")):f===12?v(f,p(d.cursorBlink)):f===25?v(f,p(!o.isCursorHidden)):f===45?v(f,p(s.reverseWraparound)):f===66?v(f,p(s.applicationKeypad)):f===67?v(f,4):f===1e3?v(f,p(r==="VT200")):f===1002?v(f,p(r==="DRAG")):f===1003?v(f,p(r==="ANY")):f===1004?v(f,p(s.sendFocus)):f===1005?v(f,4):f===1006?v(f,p(n==="SGR")):f===1015?v(f,4):f===1016?v(f,p(n==="SGR_PIXELS")):f===1048?v(f,1):f===47||f===1047||f===1049?v(f,p(l===u)):f===2004?v(f,p(s.bracketedPasteMode)):f===2026?v(f,p(s.synchronizedOutput)):v(f,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),a=0;do s[1]===5&&(r=1),s[n+a+1+r]=o[a];while(++a<o.length&&a+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+t<e.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=dt.fg,e.bg=dt.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let r=0;r<t;r++)i=e.params[r],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=dt.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=dt.bg&16777215):i===38||i===48||i===58?r+=this._extractColor(e,r,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=dt.fg&16777215,s.bg&=-67108864,s.bg|=dt.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${O.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${O.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(`${O.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=dt.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Du(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(`${O.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Ru&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Ru&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),r=i.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(Pu(n))if(r==="?")t.push({type:0,index:n});else{let o=Eu(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=Eu(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]);Pu(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,or),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(F0[e[0]],bt[e[1]]||or),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=dt.clone(),this._eraseAttrDataInternal=dt.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new 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(`${O.ESC}${o}${O.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)}},wh=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&&(Mu=e,e=t,t=Mu),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};wh=at([re(0,Gt)],wh);function Pu(e){return 0<=e&&e<256}var W0=5e7,Bu=12,z0=50,U0=class extends Me{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 J),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>W0)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=a=>performance.now()-i>=Bu?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(i,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(o);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Bu)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>z0&&(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()}},Ch=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 a=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(h,a)),this._dataByLinkId.set(h.id,h),h.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)))}};Ch=at([re(0,Gt)],Ch);var Lu=!1,K0=class extends Me{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new yn),this._onBinary=this._register(new J),this.onBinary=this._onBinary.event,this._onData=this._register(new J),this.onData=this._onData.event,this._onLineFeed=this._register(new J),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new J),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new J),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new J),this._instantiationService=new f0,this.optionsService=this._register(new C0(e)),this._instantiationService.setService(Xt,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(mh)),this._instantiationService.setService(Gt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(gh)),this._instantiationService.setService(Uf,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Sh)),this._instantiationService.setService(Fr,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(bh)),this._instantiationService.setService(zf,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(dr)),this._instantiationService.setService(hS,this.unicodeService),this._charsetService=this._instantiationService.createInstance(D0),this._instantiationService.setService(lS,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ch),this._instantiationService.setService(Kf,this._oscLinkService),this._inputHandler=this._register(new H0(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(At.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(At.forward(this._bufferService.onResize,this._onResize)),this._register(At.forward(this.coreService.onData,this._onData)),this._register(At.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new U0((t,i)=>this._inputHandler.parse(t,i))),this._register(At.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new J),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&&!Lu&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Lu=!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,y_),t=Math.max(t,w_),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(ku.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ku(this._bufferService),!1))),this._windowsWrappingHeuristics.value=tt(()=>{for(let t of e)t.dispose()})}}},q0={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 j0(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=O.ESC+"OA":r.key=O.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=O.ESC+"OD":r.key=O.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=O.ESC+"OC":r.key=O.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=O.ESC+"OB":r.key=O.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":O.DEL,e.altKey&&(r.key=O.ESC+r.key);break;case 9:if(e.shiftKey){r.key=O.ESC+"[Z";break}r.key=O.HT,r.cancel=!0;break;case 13:r.key=e.altKey?O.ESC+O.CR:O.CR,r.cancel=!0;break;case 27:r.key=O.ESC,e.altKey&&(r.key=O.ESC+O.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"D":t?r.key=O.ESC+"OD":r.key=O.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"C":t?r.key=O.ESC+"OC":r.key=O.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"A":t?r.key=O.ESC+"OA":r.key=O.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=O.ESC+"[1;"+(n+1)+"B":t?r.key=O.ESC+"OB":r.key=O.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=O.ESC+"[2~");break;case 46:n?r.key=O.ESC+"[3;"+(n+1)+"~":r.key=O.ESC+"[3~";break;case 36:n?r.key=O.ESC+"[1;"+(n+1)+"H":t?r.key=O.ESC+"OH":r.key=O.ESC+"[H";break;case 35:n?r.key=O.ESC+"[1;"+(n+1)+"F":t?r.key=O.ESC+"OF":r.key=O.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=O.ESC+"[5;"+(n+1)+"~":r.key=O.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=O.ESC+"[6;"+(n+1)+"~":r.key=O.ESC+"[6~";break;case 112:n?r.key=O.ESC+"[1;"+(n+1)+"P":r.key=O.ESC+"OP";break;case 113:n?r.key=O.ESC+"[1;"+(n+1)+"Q":r.key=O.ESC+"OQ";break;case 114:n?r.key=O.ESC+"[1;"+(n+1)+"R":r.key=O.ESC+"OR";break;case 115:n?r.key=O.ESC+"[1;"+(n+1)+"S":r.key=O.ESC+"OS";break;case 116:n?r.key=O.ESC+"[15;"+(n+1)+"~":r.key=O.ESC+"[15~";break;case 117:n?r.key=O.ESC+"[17;"+(n+1)+"~":r.key=O.ESC+"[17~";break;case 118:n?r.key=O.ESC+"[18;"+(n+1)+"~":r.key=O.ESC+"[18~";break;case 119:n?r.key=O.ESC+"[19;"+(n+1)+"~":r.key=O.ESC+"[19~";break;case 120:n?r.key=O.ESC+"[20;"+(n+1)+"~":r.key=O.ESC+"[20~";break;case 121:n?r.key=O.ESC+"[21;"+(n+1)+"~":r.key=O.ESC+"[21~";break;case 122:n?r.key=O.ESC+"[23;"+(n+1)+"~":r.key=O.ESC+"[23~";break;case 123:n?r.key=O.ESC+"[24;"+(n+1)+"~":r.key=O.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=O.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=O.DEL:e.keyCode===219?r.key=O.ESC:e.keyCode===220?r.key=O.FS:e.keyCode===221&&(r.key=O.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let a=(o=q0[e.keyCode])==null?void 0:o[e.shiftKey?1:0];if(a)r.key=O.ESC+a;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(h);e.shiftKey&&(l=l.toUpperCase()),r.key=O.ESC+l}else if(e.keyCode===32)r.key=O.ESC+(e.ctrlKey?O.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=O.ESC+h,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=O.US),e.key==="@"&&(r.key=O.NUL));break}return r}var lt=0,V0=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ca,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ca,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<s.length;r++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[r]=e[t],t++):s[r]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(lt=this._search(t),lt===-1)||this._getKey(this._array[lt])!==t)return!1;do if(this._array[lt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(lt),!0;while(++lt<this._array.length&&this._getKey(this._array[lt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,i=new Array(this._array.length-e.length),s=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:i[s++]=this._array[r];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(lt=this._search(e),!(lt<0||lt>=this._array.length)&&this._getKey(this._array[lt])===e))do yield this._array[lt];while(++lt<this._array.length&&this._getKey(this._array[lt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(lt=this._search(e),!(lt<0||lt>=this._array.length)&&this._getKey(this._array[lt])===e))do t(this._array[lt]);while(++lt<this._array.length&&this._getKey(this._array[lt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,r=this._getKey(this._array[s]);if(r>e)i=s-1;else if(r<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},tl=0,Au=0,Y0=class extends Me{constructor(){super(),this._decorations=new V0(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new J),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new J),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 G0(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=>{tl=r.options.x??0,Au=tl+(r.options.width??1),e>=tl&&e<Au&&(!i||(r.options.layer??"bottom")===i)&&s(r)})}},G0=class extends Zs{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new J),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new J),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=st.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=st.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},X0=1e3,Q0=class{constructor(e,t=X0){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)}},Ou=20,ua=class extends Me{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 Q0(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(ye(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<Ou+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
35
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Ou+1&&(this._liveRegion.textContent+=Kl.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=[],a=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",h=(i.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,o)),l.setAttribute("aria-posinset",h),l.setAttribute("aria-setsize",s),this._alignRowWidth(l))}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,a;if(t===0?(o=i,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(o=this._rowElements.shift(),a=i,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}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 a;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:((a=s.textContent)==null?void 0:a.length)??0}),!this._rowContainer.contains(i.node))return;let r=({node:h,offset:l})=>{let u=h instanceof Text?h.parentNode:h,d=parseInt(u==null?void 0:u.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let v=this._rowColumns.get(u);if(!v)return console.warn("columns is null. Race condition?"),null;let p=l<v.length?v[l]:v.slice(-1)[0]+1;return p>=this._terminal.cols&&(++d,p=0),{row:d,column:p}},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})`}};ua=at([re(1,Qh),re(2,Cs),re(3,ks)],ua);var kh=class extends Me{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 J),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new J),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(tt(()=>{var n;Or(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(ye(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ye(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ye(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ye(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,a=>{var l,u;if(this._isMouseOut)return;let h=a==null?void 0:a.map(d=>({link:d}));(l=this._activeProviderReplies)==null||l.set(n,h),i=this._checkLinkProviderResult(n,e,i),((u=this._activeProviderReplies)==null?void 0:u.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],a=o.link.range.start.y<e?0:o.link.range.start.x,h=o.link.range.end.y>e?this._bufferService.cols:o.link.range.end.x;for(let l=a;l<=h;l++){if(i.has(l)){r.splice(n--,1);break}i.add(l)}}}}_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(a=>this._linkAtPosition(a.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 a=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(a){i=!0,this._handleNewLink(a);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&&J0(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,Or(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}}};kh=at([re(1,Jh),re(2,ks),re(3,Gt),re(4,jf)],kh);function J0(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 Z0=class extends K0{constructor(e={}){super(e),this._linkifier=this._register(new yn),this.browser=c_,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new yn),this._onCursorMove=this._register(new J),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new J),this.onKey=this._onKey.event,this._onRender=this._register(new J),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new J),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new J),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new J),this.onBell=this._onBell.event,this._onFocus=this._register(new J),this._onBlur=this._register(new J),this._onA11yCharEmitter=this._register(new J),this._onA11yTabEmitter=this._register(new J),this._onWillOpen=this._register(new J),this._setup(),this._decorationService=this._instantiationService.createInstance(Y0),this._instantiationService.setService(xo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(zb),this._instantiationService.setService(jf,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(jl)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(At.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(At.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(At.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(At.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(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=Xe.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${O.ESC}]${s};${N0(r)}${l_.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=ft.toColor(...t.color));else{let n=i;this._themeService.modifyColors(o=>o[n]=ft.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ua,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(O.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(O.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,a=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"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(ye(this.element,"copy",t=>{this.hasSelection()&&iS(t,this._selectionService)}));let e=t=>sS(t,this.textarea,this.coreService,this.optionsService);this._register(ye(this.textarea,"paste",e)),this._register(ye(this.element,"paste",e)),u_?this._register(ye(this.element,"mousedown",t=>{t.button===2&&jc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ye(this.element,"contextmenu",t=>{jc(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nc&&this._register(ye(this.element,"auxclick",t=>{t.button===1&&If(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ye(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ye(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ye(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ye(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ye(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ye(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ye(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(ye(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",Ul.get()),__||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(Hb,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Cs,this._coreBrowserService),this._register(ye(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(ye(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(dh,this._document,this._helperContainer),this._instantiationService.setService(Da,this._charSizeService),this._themeService=this._instantiationService.createInstance(ph),this._instantiationService.setService(En,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(la),this._instantiationService.setService(qf,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(_h,this.rows,this.screenElement)),this._instantiationService.setService(ks,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(hh,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(fh),this._instantiationService.setService(Jh,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(kh,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(ah,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(vh,this.element,this.screenElement,s)),this._instantiationService.setService(uS,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(At.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(lh,this.screenElement)),this._register(ye(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(ua,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(aa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(aa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(uh,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(n){var l,u,d,v,p;let o=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!o)return!1;let a,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(a=3,n.button!==void 0&&(a=n.button<3?n.button:3)):a=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,a=n.button<3?n.button:3;break;case"mousedown":h=1,a=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let f=n.deltaY;if(f===0||e.coreMouseService.consumeWheelEvent(n,(v=(d=(u=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:u.device)==null?void 0:d.cell)==null?void 0:v.height,(p=e._coreBrowserService)==null?void 0:p.dpr)===0)return!1;h=f<0?0:1,a=4;break;default:return!1}return h===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:o.col,row:o.row,x:o.x,y:o.y,button:a,action:h,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(ye(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(ye(t,"wheel",n=>{var o,a,h,l,u;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,(l=(h=(a=(o=e._renderService)==null?void 0:o.dimensions)==null?void 0:a.device)==null?void 0:h.cell)==null?void 0:l.height,(u=e._coreBrowserService)==null?void 0:u.dpr)===0)return this.cancel(n,!0);let d=O.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(d,!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){Of(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=j0(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===O.ETX||i.key===O.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)&&($0(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(dt));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(O.ESC+"[I"):this.coreService.triggerDataEvent(O.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(`${O.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(`${O.ESC}[6;${r};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function $0(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var ey=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)}},ty=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)}},Iu=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 ty(t)}getNullCell(){return new Ri}},iy=class extends Me{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new J),this.onBufferChange=this._onBufferChange.event,this._normal=new Iu(this._core.buffers.normal,"normal"),this._alternate=new Iu(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)}},sy=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)}},ry=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}},ny=["cols","rows"],qi=0,oy=class extends Me{constructor(e){super(),this._core=this._register(new Z0(e)),this._addonManager=this._register(new ey),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(ny.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 sy(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new ry(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 iy(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 Ul.get()},set promptLabel(e){Ul.set(e)},get tooMuchOutput(){return Kl.get()},set tooMuchOutput(e){Kl.set(e)}}}_verifyIntegers(...e){for(qi of e)if(qi===1/0||isNaN(qi)||qi%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(qi of e)if(qi&&(qi===1/0||isNaN(qi)||qi%1!==0||qi<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 ay=2,ly=1,hy=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 d;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:((d=this._terminal.options.overviewRuler)==null?void 0:d.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"))},a=o.top+o.bottom,h=o.right+o.left,l=s-a,u=r-h-t;return{cols:Math.max(ay,Math.floor(u/e.css.cell.width)),rows:Math.max(ly,Math.floor(l/e.css.cell.height))}}},cy=B('<div class="scroll-fabs svelte-5qgfij"><button class="scroll-fab svelte-5qgfij" data-dir="up" aria-label="Page up">▲</button> <button class="scroll-fab svelte-5qgfij" data-dir="down" aria-label="Page down">▼</button> <button class="scroll-fab scroll-fab-bottom svelte-5qgfij" data-dir="bottom" aria-label="Skip to bottom">↧</button></div>'),uy=B('<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 xh(e,t){Ve(t,!0);let i=mt(t,"useTmux",3,!1),s=mt(t,"companionMode",3,!1),r,n=j(null),o,a=!1;function h(){return c(n)}function l(){var z;(z=c(n))==null||z.focus()}function u(){if(!c(n))return;const z=c(n).buffer.active,se=z.viewportY>=z.baseY,ke=z.viewportY;o==null||o.fit(),se?c(n).scrollToBottom():c(n).scrollToLine(ke),za(c(n).cols,c(n).rows),P()}kn(()=>{const z=new oy({cursorBlink:!0,fontSize:Pt?12:14,fontFamily:"Menlo, monospace",scrollback:1e4,theme:{background:"#000000",foreground:"#d4d4d4",cursor:"#d4d4d4"}});if(o=new hy,z.loadAddon(o),z.open(r),Pt){const pe=r.querySelector(".xterm-viewport");pe&&(pe.style.touchAction="none",pe.style.overflowY="hidden");const ge=r.querySelector(".xterm-screen");if(ge){ge.addEventListener("wheel",C=>{C.stopImmediatePropagation(),C.preventDefault()},{capture:!0,passive:!1});const Ie=C=>{z.modes.mouseTrackingMode!=="none"&&C.stopImmediatePropagation()};for(const C of["mousedown","mouseup","mousemove"])ge.addEventListener(C,Ie,{capture:!0})}}o.fit(),z.onData(pe=>Zn(pe));{const pe=/Mac|iPhone|iPad|iPod/.test(navigator.platform||"");z.attachCustomKeyEventHandler(ge=>!pe&&ge.type==="keydown"&&ge.ctrlKey&&!ge.shiftKey&&!ge.altKey&&!ge.metaKey&&(ge.key==="v"||ge.key==="V")&&navigator.clipboard&&navigator.clipboard.read?(navigator.clipboard.read().then(Ie=>{let C=null,q=null;for(const ue of Ie){for(const Se of ue.types)if(Se.startsWith("image/")){q=Se,C=ue;break}if(C)break}C&&q?C.getType(q).then(ue=>Ne(ue,q)):navigator.clipboard.readText().then(ue=>{ue&&z.paste(ue)})}).catch(()=>{navigator.clipboard.readText&&navigator.clipboard.readText().then(Ie=>{Ie&&z.paste(Ie)}).catch(()=>{})}),!1):!0)}z.parser.registerOscHandler(52,pe=>{var C;const ge=pe.indexOf(";");if(ge===-1)return!0;const Ie=pe.slice(ge+1);if(!Ie||Ie==="?")return!0;try{const q=Uint8Array.from(atob(Ie),Se=>Se.charCodeAt(0)),ue=new TextDecoder("utf-8").decode(q);(C=navigator.clipboard)==null||C.writeText(ue).catch(()=>{})}catch{}return!0}),z.onScroll(P),z.onWriteParsed(P);let se=null;const ke=new ResizeObserver(()=>{se&&clearTimeout(se),se=setTimeout(()=>{const pe=z.buffer.active,ge=pe.viewportY>=pe.baseY,Ie=pe.viewportY;o.fit(),ge?z.scrollToBottom():z.scrollToLine(Ie),za(z.cols,z.rows),P()},Pt?150:0)});return ke.observe(r),Pt&&(document.addEventListener("touchmove",ee,{passive:!1}),document.addEventListener("touchend",fe),document.addEventListener("touchcancel",fe)),S(n,z,!0),()=>{se&&clearTimeout(se),Z&&clearTimeout(Z),ke.disconnect(),z.dispose(),S(n,null),b=!1,d=!1,Pt&&(document.removeEventListener("touchmove",ee),document.removeEventListener("touchend",fe),document.removeEventListener("touchcancel",fe))}}),er(()=>{t.sessionId&&c(n)&&!s()&&(c(n).clear(),gf(t.sessionId,c(n),()=>{c(n)&&za(c(n).cols,c(n).rows)},()=>{}))});let d=!1,v=0,p=0,f=j(0),g=j(0),m=j(!1),b=!1,R=0,k=0,y=!1,D=0,I=0,F=j(!1),V=j(!1),Z=null,U=0,ie=0;const K=500,x=10;let M=!1;function P(){M||(M=!0,requestAnimationFrame(Y))}function Y(){if(M=!1,!c(n))return;const z=c(n).buffer.active,se=z.baseY+c(n).rows,ke=z.viewportY,pe=me;if(!pe)return;const ge=pe.clientHeight;if(se<=c(n).rows){S(m,!1);return}S(m,!0),S(f,Math.max(Pt?44:20,c(n).rows/se*ge),!0),S(g,ke/(se-c(n).rows)*(ge-c(f)))}function ne(z){if(!c(n)||!me)return;const se=me.getBoundingClientRect(),pe=c(n).buffer.active.baseY+c(n).rows;if(pe<=c(n).rows)return;const ge=me.clientHeight,Ie=Math.max(Pt?44:20,c(n).rows/pe*ge),C=ge-Ie,q=z-se.top-Ie/2,ue=Math.max(0,Math.min(1,q/C)),Se=Math.round(ue*(pe-c(n).rows));c(n).scrollToLine(Se)}function N(z){const se=z.touches[0];se&&(d=!0,v=se.clientY,p=c(g))}function he(){var z;c(V)&&(S(V,!1),(z=t.onCopyModeChange)==null||z.call(t,!1))}function Ce(){var ke;if(Z=null,b=!1,navigator.vibrate&&navigator.vibrate(50),i()){S(V,!0),(ke=t.onCopyModeChange)==null||ke.call(t,!0),Zn("[");return}S(F,!0);const z=r.querySelector(".xterm-screen");z&&(z.style.userSelect="text",z.style.webkitUserSelect="text"),r.querySelectorAll("canvas").forEach(pe=>{pe.style.pointerEvents="none"});const se=r.querySelector(".xterm-rows");if(se){const pe=document.createRange();pe.selectNodeContents(se);const ge=window.getSelection();ge==null||ge.removeAllRanges(),ge==null||ge.addRange(pe)}}function de(){var se;S(F,!1);const z=r.querySelector(".xterm-screen");z&&(z.style.userSelect="",z.style.webkitUserSelect=""),r.querySelectorAll("canvas").forEach(ke=>{ke.style.pointerEvents=""}),(se=window.getSelection())==null||se.removeAllRanges()}function L(z){var ke;if(c(F)){const pe=((ke=window.getSelection())==null?void 0:ke.toString())??"";pe.trim().length>0&&(navigator.clipboard.writeText(pe).catch(()=>{}),navigator.vibrate&&navigator.vibrate(30)),de();return}if(c(V)||z.target.closest(".terminal-scrollbar")||z.target.closest(".scroll-fabs")||!c(n))return;const se=z.touches[0];se&&(R=se.clientY,I=se.clientY,k=c(n).buffer.active.viewportY,y=!1,D=0,b=!0,U=se.clientX,ie=se.clientY,Z&&clearTimeout(Z),Z=setTimeout(()=>{Ce()},K))}function ee(z){const se=z.touches[0];if(se){if(d){if(!c(n)||!me)return;z.preventDefault();const ke=se.clientY-v,ge=c(n).buffer.active.baseY+c(n).rows;if(ge<=c(n).rows)return;const Ie=me.clientHeight,C=Math.max(44,c(n).rows/ge*Ie),q=Ie-C,Se=Math.max(0,Math.min(q,p+ke))/q,$e=Math.round(Se*(ge-c(n).rows));c(n).scrollToLine($e);return}if(b&&c(n)&&!c(F)){if(Z){const pe=Math.abs(se.clientX-U),ge=Math.abs(se.clientY-ie);(pe>x||ge>x)&&(clearTimeout(Z),Z=null)}if(c(n).rows===0||r.clientHeight===0)return;const ke=R-se.clientY;if(Math.abs(ke)>5){y=!0,z.preventDefault();const pe=r.clientHeight/c(n).rows;if(c(n).buffer.active.type==="alternate"){const ge=I-se.clientY;I=se.clientY;const Ie=ge/pe;D+=Ie;const C=Math.trunc(D);if(C!==0){D-=C;const q=C>0?65:64,ue=Math.max(1,Math.round(c(n).cols/2)),Se=Math.max(1,Math.round(c(n).rows/2)),$e=`\x1B[<${q};${ue};${Se}M`,Ke=Math.min(Math.abs(C),5);for(let et=0;et<Ke;et++)Zn($e)}}else{const ge=ke/pe,Ie=c(n).buffer.active.baseY,C=Math.max(0,Math.min(Ie,Math.round(k+ge)));c(n).scrollToLine(C)}}}}}function fe(){Z&&(clearTimeout(Z),Z=null),d=!1,b=!1,y=!1,D=0}function be(z){z.target!==Ee&&ne(z.clientY)}function ve(z){var pe,ge,Ie;z.preventDefault();const se=z.target.closest("button");if(!se)return;const ke=se.dataset.dir;ke==="up"?(pe=c(n))==null||pe.scrollPages(-1):ke==="down"?(ge=c(n))==null||ge.scrollPages(1):ke==="bottom"&&((Ie=c(n))==null||Ie.scrollToBottom())}let me,Ee;async function Ne(z,se){var pe;if(a||!t.sessionId)return;a=!0,(pe=t.onImageUpload)==null||pe.call(t,"Pasting image…",!1);const ke=new FileReader;ke.onload=async()=>{var Ie,C,q;const ge=ke.result.split(",")[1];try{const ue=await Lp(t.sessionId,ge,se);ue.clipboardSet?(Ie=t.onImageUpload)==null||Ie.call(t,"Image pasted",!1):(C=t.onImageUpload)==null||C.call(t,ue.path,!0,ue.path)}catch(ue){const Se=ue instanceof Error?ue.message:"Image upload failed";(q=t.onImageUpload)==null||q.call(t,Se,!1)}finally{a=!1}},ke.readAsDataURL(z)}function Je(z){var se;if((se=z.clipboardData)!=null&&se.items){for(const ke of z.clipboardData.items)if(ke.type.startsWith("image/")){z.preventDefault(),z.stopPropagation();const pe=ke.getAsFile();pe&&Ne(pe,ke.type);return}}}let ze=j(!1);function Ae(z){var se;(se=z.dataTransfer)!=null&&se.types.includes("Files")&&(z.preventDefault(),S(ze,!0))}function ce(){S(ze,!1)}function Ue(z){var ke;if(z.preventDefault(),S(ze,!1),!((ke=z.dataTransfer)!=null&&ke.files.length))return;const se=z.dataTransfer.files[0];se.type.startsWith("image/")&&Ne(se,se.type)}function rt(z){var se;d||y||z.target.closest(".terminal-scrollbar")||c(F)||((se=c(n))==null||se.focus(),z.preventDefault())}var qt={getTerm:h,focusTerm:l,fitTerm:u,exitCopyMode:he,handleImageUpload:Ne},yt=uy();let De;var Re=w(yt);ht(Re,z=>r=z,()=>r);var Ze=E(Re,2);ct(Ze,"aria-valuenow",0);var Ft=w(Ze);let si;ht(Ft,z=>Ee=z,()=>Ee),ht(Ze,z=>me=z,()=>me);var fi=E(Ze,2);{var Oe=z=>{var se=cy();Q("mousedown",se,ve),T(z,se)};te(fi,z=>{Pt&&c(m)&&z(Oe)})}return le(()=>{De=Le(yt,1,"terminal-wrapper svelte-5qgfij",null,De,{"drag-over":c(ze),"selection-mode":c(F)}),si=ea(Ft,"",si,{display:c(m)?"block":"none",height:c(f)+"px",top:c(g)+"px"})}),Q("touchstart",yt,function(...z){var se;(se=Pt?L:void 0)==null||se.apply(this,z)}),Q("touchend",yt,function(...z){var se;(se=Pt?rt:void 0)==null||se.apply(this,z)}),js("paste",Re,Je),js("dragover",Re,Ae),js("dragleave",Re,ce),js("drop",Re,Ue),Q("click",Ze,be),Q("touchstart",Ft,N),T(e,yt),Ye(qt)}Qe(["touchstart","touchend","click","mousedown"]);const dy=3/1e6,fy=15/1e6,_y=15/1e6,vy=75/1e6,py={sonnet:{input:dy,output:fy},opus:{input:_y,output:vy}};function k_(e,t,i="sonnet"){const s=py[i];return e*s.input+t*s.output}function x_(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"k":String(e)}function E_(e){return e<.005?"<$0.01":"$"+e.toFixed(2)}const Vr=Ge({}),ao=Ge({}),da=Ge({}),lo=Ge({});function gy(e){const t=Vr[e];if(!t||t.length===0)return[];switch(t[t.length-1].type){case"turn_completed":return["Continue","Show diff","Summarize changes"];case"error":return["Retry","Show logs","Skip"];case"agent_message":return["Continue","Thanks"];default:return[]}}function my(e){return{get events(){return Vr[e]??[]},get activePermission(){return ao[e]??null},get tokenUsage(){return da[e]??{input:0,output:0,estimatedCost:0}},get isStreaming(){return lo[e]??!1},get quickReplies(){return gy(e)}}}function Nu(e,t){Vr[e]||(Vr[e]=[]),Vr[e].push(t),t.type==="turn_started"?lo[e]=!0:(t.type==="turn_completed"||t.type==="error")&&(lo[e]=!1),t.usage&&by(e,t.usage.input_tokens,t.usage.output_tokens)}function Sy(e,t){ao[e]=t}function Fu(e,t){const i=ao[e];i&&(ao[e]={...i,status:t})}function by(e,t,i){const s=da[e]??{input:0,output:0};da[e]={input:s.input+t,output:s.output+i,estimatedCost:k_(s.input+t,s.output+i)}}function yy(e){Vr[e]=[],ao[e]=null,da[e]={input:0,output:0,estimatedCost:0},lo[e]=!1}function wy(e,t){lo[e]=t}var Cy=B('<div class="user-message svelte-1q16011"><div class="user-message-text svelte-1q16011"> </div></div>');function ky(e,t){var i=Cy(),s=w(i),r=w(s);le(()=>oe(r,t.text)),T(e,i)}var xy=B('<div class="agent-message svelte-1r3r7jb"><!></div>');function Ey(e,t){Ve(t,!0);function i(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/```(\w*)\n([\s\S]*?)```/g,(a,h,l)=>'<pre class="code-block"><code>'+l.trim()+"</code></pre>").replace(/`([^`]+)`/g,'<code class="inline-code">$1</code>').replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener">$1</a>').replace(/\n/g,"<br>")}var s=xy(),r=w(s);ml(r,()=>i(t.text)),T(e,s),Ye()}var Ry=B('<span class="file-dir svelte-649juz"> </span>'),Dy=B('<span class="diff-add svelte-649juz"> </span>'),Ty=B('<span class="diff-remove svelte-649juz"> </span>'),My=B('<div class="file-change-card svelte-649juz"><span class="file-icon svelte-649juz">📄</span> <span class="file-path svelte-649juz"><!><span class="file-name svelte-649juz"> </span></span> <span class="diff-stats svelte-649juz"><!> <!></span></div>');function Py(e,t){Ve(t,!0);let i=mt(t,"additions",3,0),s=mt(t,"deletions",3,0),r=G(()=>t.path.split("/").pop()??t.path),n=G(()=>t.path.includes("/")?t.path.slice(0,t.path.lastIndexOf("/")+1):"");var o=My(),a=E(w(o),2),h=w(a);{var l=b=>{var R=Ry(),k=w(R);le(()=>oe(k,c(n))),T(b,R)};te(h,b=>{c(n)&&b(l)})}var u=E(h),d=w(u),v=E(a,2),p=w(v);{var f=b=>{var R=Dy(),k=w(R);le(()=>oe(k,`+${i()??""}`)),T(b,R)};te(p,b=>{i()&&b(f)})}var g=E(p,2);{var m=b=>{var R=Ty(),k=w(R);le(()=>oe(k,`-${s()??""}`)),T(b,R)};te(g,b=>{s()&&b(m)})}le(()=>oe(d,c(r))),T(e,o),Ye()}var By=B("<span> </span>"),Ly=B('<pre class="tool-input svelte-9tdk1v"> </pre>'),Ay=B('<div class="tool-call-card svelte-9tdk1v"><button class="tool-header svelte-9tdk1v"><span class="tool-name svelte-9tdk1v"> </span> <!> <span class="toggle-icon svelte-9tdk1v"> </span></button> <!></div>');function Oy(e,t){let i=j(!1);function s(f){return f?f==="success"||f==="completed"?"status-success":f==="error"||f==="failed"?"status-error":f==="running"||f==="pending"?"status-pending":"":""}var r=Ay(),n=w(r),o=w(n),a=w(o),h=E(o,2);{var l=f=>{var g=By(),m=w(g);le(b=>{Le(g,1,`tool-status ${b??""}`,"svelte-9tdk1v"),oe(m,t.status)},[()=>s(t.status)]),T(f,g)};te(h,f=>{t.status&&f(l)})}var u=E(h,2),d=w(u),v=E(n,2);{var p=f=>{var g=Ly(),m=w(g);le(b=>oe(m,b),[()=>JSON.stringify(t.toolInput,null,2)]),T(f,g)};te(v,f=>{c(i)&&t.toolInput&&f(p)})}le(()=>{oe(a,t.toolName),oe(d,c(i)?"▲":"▼")}),Q("click",n,()=>S(i,!c(i))),T(e,r)}Qe(["click"]);var Iy=B('Thinking<span class="dots svelte-fizs81">...</span>',1),Ny=B('<div class="reasoning-content svelte-fizs81" id="reasoning-content"> </div>'),Fy=B('<div class="reasoning-panel svelte-fizs81"><button class="reasoning-header svelte-fizs81" aria-controls="reasoning-content"><span class="reasoning-label svelte-fizs81"><!></span> <span class="toggle-icon svelte-fizs81"> </span></button> <!></div>');function Hy(e,t){let i=j(!1);var s=Fy(),r=w(s),n=w(r),o=w(n);{var a=p=>{var f=pl("Thinking");T(p,f)},h=p=>{var f=Iy();T(p,f)};te(o,p=>{c(i)?p(a):p(h,!1)})}var l=E(n,2),u=w(l),d=E(r,2);{var v=p=>{var f=Ny(),g=w(f);le(()=>oe(g,t.text)),T(p,f)};te(d,p=>{c(i)&&p(v)})}le(()=>{ct(r,"aria-expanded",c(i)),oe(u,c(i)?"▲":"▼")}),Q("click",r,()=>S(i,!c(i))),T(e,s)}Qe(["click"]);var Wy=B('<button class="dismiss-btn svelte-au1iu7" aria-label="Dismiss error">×</button>'),zy=B('<button class="retry-btn svelte-au1iu7">Retry</button>'),Uy=B('<div class="error-card svelte-au1iu7"><div class="error-body svelte-au1iu7"><span class="error-text svelte-au1iu7"> </span> <!></div> <!></div>');function Ky(e,t){var i=Uy(),s=w(i),r=w(s),n=w(r),o=E(r,2);{var a=u=>{var d=Wy();Q("click",d,function(...v){var p;(p=t.onDismiss)==null||p.apply(this,v)}),T(u,d)};te(o,u=>{t.onDismiss&&u(a)})}var h=E(s,2);{var l=u=>{var d=zy();Q("click",d,function(...v){var p;(p=t.onRetry)==null||p.apply(this,v)}),T(u,d)};te(h,u=>{t.onRetry&&u(l)})}le(()=>oe(n,t.text)),T(e,i)}Qe(["click"]);var qy=B('<div class="usage-info svelte-1q2w5up"> </div>'),jy=B('<div class="turn-completed svelte-1q2w5up"><div class="separator-line svelte-1q2w5up"></div> <!></div>');function Vy(e,t){Ve(t,!0);var i=jy(),s=E(w(i),2);{var r=n=>{var o=qy(),a=w(o);le((h,l)=>oe(a,`${h??""} tokens · ${l??""}`),[()=>x_(t.usage.input_tokens+t.usage.output_tokens),()=>E_(k_(t.usage.input_tokens,t.usage.output_tokens))]),T(n,o)};te(s,n=>{t.usage&&n(r)})}T(e,i),Ye()}var Yy=B('<div class="empty-state svelte-o5aojg"><p class="svelte-o5aojg">Send a message to start a conversation</p> <span class="cursor-blink svelte-o5aojg">|</span></div>'),Gy=B('<div class="session-started svelte-o5aojg"><span class="session-started-text svelte-o5aojg"> </span></div>'),Xy=B('<div class="working-indicator svelte-o5aojg"><span class="working-dot svelte-o5aojg">●</span> <span class="working-text svelte-o5aojg">Claude is working...</span></div>'),Qy=B('<div class="message-list svelte-o5aojg"><!> <!></div>'),Jy=B('<div class="chat-view svelte-o5aojg"><!></div>');function Zy(e,t){Ve(t,!0);let i,s=j(!0);er(()=>{t.events.length,c(s)&&i&&queueMicrotask(()=>{i==null||i.scrollTo({top:i.scrollHeight})})});function r(){if(!i)return;const{scrollTop:l,scrollHeight:u,clientHeight:d}=i;S(s,u-l-d<40)}var n=Jy(),o=w(n);{var a=l=>{var u=Yy();T(l,u)},h=l=>{var u=Qy(),d=w(u);Rt(d,17,()=>t.events,f=>f.id??f.timestamp,(f,g)=>{var m=Kt(),b=He(m);{var R=U=>{ky(U,{get text(){return c(g).text}})},k=U=>{Ey(U,{get text(){return c(g).text}})},y=U=>{Py(U,{get path(){return c(g).path},get additions(){return c(g).additions},get deletions(){return c(g).deletions}})},D=U=>{Oy(U,{get toolName(){return c(g).toolName},get toolInput(){return c(g).toolInput},get status(){return c(g).status}})},I=U=>{Hy(U,{get text(){return c(g).text}})},F=U=>{Ky(U,{get text(){return c(g).text},get onRetry(){return t.onRetry}})},V=U=>{Vy(U,{get usage(){return c(g).usage}})},Z=U=>{var ie=Gy(),K=w(ie),x=w(K);le(()=>oe(x,c(g).text)),T(U,ie)};te(b,U=>{c(g).type==="user_message"&&c(g).text?U(R):c(g).type==="agent_message"&&c(g).text?U(k,1):c(g).type==="file_change"&&c(g).path?U(y,2):c(g).type==="tool_call"&&c(g).toolName?U(D,3):c(g).type==="reasoning"&&c(g).text?U(I,4):c(g).type==="error"&&c(g).text?U(F,5):c(g).type==="turn_completed"?U(V,6):c(g).type==="session_started"&&c(g).text&&U(Z,7)})}T(f,m)});var v=E(d,2);{var p=f=>{var g=Xy();T(f,g)};te(v,f=>{t.isStreaming&&f(p)})}T(l,u)};te(o,l=>{t.events.length===0?l(a):l(h,!1)})}ht(n,l=>i=l,()=>i),js("scroll",n,r),T(e,n),Ye()}var $y=B('<span class="send-dots svelte-mnrni5">...</span>'),ew=Hh('<svg class="send-icon svelte-mnrni5" viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>'),tw=B('<div class="chat-input-container svelte-mnrni5"><textarea placeholder="Send a message..." rows="1" class="chat-textarea svelte-mnrni5"></textarea> <button aria-label="Send message"><!></button></div>');function iw(e,t){Ve(t,!0);let i=mt(t,"disabled",3,!1),s=j(""),r;function n(){const m=c(s).trim();!m||i()||(t.onSend(m),S(s,""),r&&(r.style.height="auto"))}function o(m){m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),n())}function a(){r&&(r.style.height="auto",r.style.height=Math.min(r.scrollHeight,120)+"px")}let h=G(()=>!i()&&c(s).trim().length>0);var l=tw(),u=w(l);ht(u,m=>r=m,()=>r);var d=E(u,2);let v;var p=w(d);{var f=m=>{var b=$y();T(m,b)},g=m=>{var b=ew();T(m,b)};te(p,m=>{i()?m(f):m(g,!1)})}le(()=>{u.disabled=i(),v=Le(d,1,"send-btn svelte-mnrni5",null,v,{disabled:!c(h)}),d.disabled=!c(h)}),Q("input",u,a),Q("keydown",u,o),Sn(u,()=>c(s),m=>S(s,m)),Q("click",d,n),T(e,l),Ye()}Qe(["input","keydown","click"]);var sw=B('<button class="quick-reply-btn svelte-2y5bi6"> </button>'),rw=B('<div class="quick-replies svelte-2y5bi6" role="group" aria-label="Quick replies"></div>');function nw(e,t){Ve(t,!0);var i=Kt(),s=He(i);{var r=n=>{var o=rw();Rt(o,21,()=>t.suggestions,Jd,(a,h)=>{var l=sw(),u=w(l);le(()=>oe(u,c(h))),Q("click",l,()=>t.onSelect(c(h))),T(a,l)}),T(n,o)};te(s,n=>{t.suggestions.length>0&&n(r)})}T(e,i),Ye()}Qe(["click"]);var ow=B('<div class="permission-actions svelte-1amwf6m"><button class="approve-btn svelte-1amwf6m">Approve</button> <button class="deny-btn svelte-1amwf6m">Deny</button></div>'),aw=B('<div class="permission-badge badge-approved svelte-1amwf6m">Approved ✓</div>'),lw=B('<div class="permission-badge badge-denied svelte-1amwf6m">Denied ✗</div>'),hw=B('<div class="permission-badge badge-timeout svelte-1amwf6m">Timed out</div>'),cw=B('<div><div class="permission-header svelte-1amwf6m"><span class="permission-tool svelte-1amwf6m"> </span></div> <!></div>');function uw(e,t){Ve(t,!0);let i=G(()=>{const p=t.permission.input;if(t.permission.toolName==="Edit"||t.permission.toolName==="Write"){const f=p.file_path??p.path??"";return t.permission.toolName+": "+String(f)}if(t.permission.toolName==="Bash"||t.permission.toolName==="Run"){const f=p.command??p.cmd??"";return"Run: "+String(f)}return t.permission.toolName});var s=cw();let r;var n=w(s),o=w(n),a=w(o),h=E(n,2);{var l=p=>{var f=ow(),g=w(f),m=E(g,2);le(()=>{ct(g,"aria-label",`Approve: ${c(i)??""}`),ct(m,"aria-label",`Deny: ${c(i)??""}`)}),Q("click",g,()=>t.onApprove(t.permission.id)),Q("click",m,()=>t.onDeny(t.permission.id)),T(p,f)},u=p=>{var f=aw();T(p,f)},d=p=>{var f=lw();T(p,f)},v=p=>{var f=hw();T(p,f)};te(h,p=>{t.permission.status==="pending"?p(l):t.permission.status==="approved"?p(u,1):t.permission.status==="denied"?p(d,2):t.permission.status==="timed_out"&&p(v,3)})}le(()=>{r=Le(s,1,"permission-card svelte-1amwf6m",null,r,{resolved:t.permission.status!=="pending",timed_out:t.permission.status==="timed_out"}),oe(a,c(i))}),T(e,s),Ye()}Qe(["click"]);var dw=B('<div class="cost-display svelte-p9ddlc"> </div>');function fw(e,t){Ve(t,!0);let i=G(()=>t.usage.input>0||t.usage.output>0?x_(t.usage.input+t.usage.output)+" tokens · "+E_(t.usage.estimatedCost):"—");var s=dw(),r=w(s);le(()=>oe(r,c(i))),T(e,s),Ye()}var _w=B('<div class="fallback-banner svelte-oor1t0">SDK mode unavailable — fell back to terminal</div>'),vw=B('<div class="companion-status svelte-oor1t0"><span class="spinner svelte-oor1t0"></span> Starting shell...</div>'),pw=B('<div class="companion-status svelte-oor1t0"><span class="error-text svelte-oor1t0">Shell failed</span> <button class="retry-shell-btn svelte-oor1t0">Retry</button></div>'),gw=B('<div class="session-view svelte-oor1t0"><!> <div class="tab-bar svelte-oor1t0" role="tablist"><button role="tab">Chat</button> <button role="tab">Terminal</button></div> <div class="tab-content svelte-oor1t0"><div class="tab-panel chat-panel svelte-oor1t0"><div class="chat-scroll-area svelte-oor1t0"><!></div> <!> <!> <!> <!></div> <div class="tab-panel terminal-panel svelte-oor1t0"><!></div></div></div>');function mw(e,t){Ve(t,!0);let i=mt(t,"mode",3,"pty"),s=mt(t,"sdkFallback",3,!1),r=mt(t,"useTmux",3,!1),n=j("chat"),o=j(void 0),a=j(!1),h=j(!1),l=j(!1),u=j(""),d=G(()=>t.sessionId?my(t.sessionId):null),v=G(()=>()=>c(d)?c(d).events:[]);er(()=>{if(t.sessionId&&i()==="sdk"){yy(t.sessionId),S(u,""),S(a,!1),S(l,!1),S(n,"chat");const x={onEvent:M=>{t.sessionId&&(M.type==="tool_call"&&M.status==="pending"&&M.id&&M.toolName&&Sy(t.sessionId,{id:M.id,toolName:M.toolName,input:M.toolInput??{},status:"pending"}),Nu(t.sessionId,M))},onTerminalData:M=>{S(h,!1),S(a,!0)},onTerminalExit:()=>{S(a,!1)},onSessionEnd:()=>{t.sessionId&&wy(t.sessionId,!1)}};Sf(t.sessionId,x)}});function p(x){t.sessionId&&(S(u,x,!0),Nu(t.sessionId,{type:"user_message",text:x,timestamp:new Date().toISOString(),id:"user-"+Date.now()}),hg(x))}function f(x){p(x)}function g(x){t.sessionId&&Fu(t.sessionId,"approved"),Mc(x,!0)}function m(x){t.sessionId&&Fu(t.sessionId,"denied"),Mc(x,!1)}function b(){p(c(u)||"Retry")}function R(){S(h,!0),S(l,!1),cg(),setTimeout(()=>{c(h)&&(S(h,!1),S(l,!0))},1e4)}function k(){S(n,"terminal"),!c(a)&&!c(h)&&i()==="sdk"&&R()}function y(){var x;(x=c(o))==null||x.focusTerm()}function D(){var x;(x=c(o))==null||x.fitTerm()}function I(){var x;(x=c(o))==null||x.exitCopyMode()}function F(x,M){var P;(P=c(o))==null||P.handleImageUpload(x,M)}var V={focusTerm:y,fitTerm:D,exitCopyMode:I,handleImageUpload:F},Z=Kt(),U=He(Z);{var ie=x=>{var M=gw(),P=w(M);{var Y=De=>{var Re=_w();T(De,Re)};te(P,De=>{s()&&De(Y)})}var ne=E(P,2),N=w(ne);let he;var Ce=E(N,2);let de;var L=E(ne,2),ee=w(L);let fe;var be=w(ee),ve=w(be);{let De=G(()=>c(v)()),Re=G(()=>{var Ze;return((Ze=c(d))==null?void 0:Ze.isStreaming)??!1});Zy(ve,{get events(){return c(De)},get isStreaming(){return c(Re)},onRetry:b})}var me=E(be,2);{var Ee=De=>{uw(De,{get permission(){return c(d).activePermission},onApprove:g,onDeny:m})};te(me,De=>{var Re;(Re=c(d))!=null&&Re.activePermission&&c(d).activePermission.status==="pending"&&De(Ee)})}var Ne=E(me,2);{let De=G(()=>{var Re;return((Re=c(d))==null?void 0:Re.quickReplies)??[]});nw(Ne,{get suggestions(){return c(De)},onSelect:f})}var Je=E(Ne,2);{let De=G(()=>{var Re;return((Re=c(d))==null?void 0:Re.tokenUsage)??{input:0,output:0,estimatedCost:0}});fw(Je,{get usage(){return c(De)}})}var ze=E(Je,2);{let De=G(()=>{var Re;return((Re=c(d))==null?void 0:Re.isStreaming)??!1});iw(ze,{get disabled(){return c(De)},onSend:p})}var Ae=E(ee,2);let ce;var Ue=w(Ae);{var rt=De=>{var Re=vw();T(De,Re)},qt=De=>{var Re=pw(),Ze=E(w(Re),2);Q("click",Ze,R),T(De,Re)},yt=De=>{{let Re=G(()=>t.onImageUpload??void 0),Ze=G(()=>t.onCopyModeChange??void 0);ht(xh(De,{get sessionId(){return t.sessionId},get onImageUpload(){return c(Re)},get useTmux(){return r()},get onCopyModeChange(){return c(Ze)},companionMode:!0}),Ft=>S(o,Ft,!0),()=>c(o))}};te(Ue,De=>{c(h)?De(rt):c(l)?De(qt,1):De(yt,!1)})}le(()=>{he=Le(N,1,"tab svelte-oor1t0",null,he,{active:c(n)==="chat"}),ct(N,"aria-selected",c(n)==="chat"),de=Le(Ce,1,"tab svelte-oor1t0",null,de,{active:c(n)==="terminal"}),ct(Ce,"aria-selected",c(n)==="terminal"),fe=ea(ee,"",fe,{display:c(n)==="chat"?"flex":"none"}),ce=ea(Ae,"",ce,{display:c(n)==="terminal"?"flex":"none"})}),Q("click",N,()=>S(n,"chat")),Q("click",Ce,k),T(x,M)},K=x=>{{let M=G(()=>t.onImageUpload??void 0),P=G(()=>t.onCopyModeChange??void 0);ht(xh(x,{get sessionId(){return t.sessionId},get onImageUpload(){return c(M)},get useTmux(){return r()},get onCopyModeChange(){return c(P)}}),Y=>S(o,Y,!0),()=>c(o))}};te(U,x=>{i()==="sdk"?x(ie):x(K,!1)})}return T(e,Z),Ye(V)}Qe(["click"]);var Sw=B("<button><!></button>"),bw=B("<button><!></button>"),yw=B('<div class="toolbar svelte-k7we1m" role="toolbar"><div class="toolbar-grid svelte-k7we1m"><!></div></div>');function ww(e,t){Ve(t,!0),mt(t,"useTmux",3,!1);let i=mt(t,"inCopyMode",3,!1);const s=[{html:"Tab",key:" ",label:"Tab"},{html:"⇧Tab",key:"\x1B[Z",label:"Shift+Tab"},{html:"↑",key:"\x1B[A",label:"Up arrow",extraClass:"tb-arrow"},{html:"Esc",key:"\x1B",label:"Escape"},{html:"📷",id:"upload-image-btn",label:"Upload image"},{html:"^V",id:"paste-btn",label:"Paste from clipboard"},{html:"^C",key:"",label:"Ctrl+C"},{html:"←",key:"\x1B[D",label:"Left arrow",extraClass:"tb-arrow"},{html:"↓",key:"\x1B[B",label:"Down arrow",extraClass:"tb-arrow"},{html:"→",key:"\x1B[C",label:"Right arrow",extraClass:"tb-arrow"},{html:"⇧⏎",key:"\x1B[13;2u",label:"Shift+Enter (newline)",extraClass:"tb-newline"},{html:"⏎",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:"←",key:"h",label:"Left",extraClass:"tb-arrow"},{html:"↓",key:"j",label:"Down",extraClass:"tb-arrow"},{html:"↑",key:"k",label:"Up",extraClass:"tb-arrow"},{html:"→",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(d){var v;if(d.id==="upload-image-btn"){t.onUploadImage(),Pt&&t.onRefocusMobileInput();return}if(d.id==="paste-btn"){(v=navigator.clipboard)!=null&&v.readText?navigator.clipboard.readText().then(p=>{p&&t.onSendKey(p)}).catch(()=>{t.onUploadImage()}):t.onUploadImage(),Pt&&t.onRefocusMobileInput();return}d.key&&((d.key==="\r"||d.key==="\x1B[13;2u")&&t.onFlushComposedText(),t.onSendKey(d.key),(d.key==="\r"||d.key==="\x1B[13;2u")&&t.onClearInput(),Pt&&t.onRefocusMobileInput())}function o(d){var v;t.onSendKey(d.key),d.exitsCopyMode&&((v=t.onExitCopyMode)==null||v.call(t)),Pt&&t.onRefocusMobileInput()}function a(d){d.preventDefault();const v=d.target.closest("button");if(!v)return;if(i()){const f=r.find(g=>v.dataset.key===g.key);f&&o(f);return}const p=s.find(f=>f.id===v.id||f.key&&v.dataset.key===f.key);p&&n(p)}var h=Kt(),l=He(h);{var u=d=>{var v=yw(),p=w(v),f=w(p);{var g=b=>{var R=Kt(),k=He(R);Rt(k,17,()=>r,y=>y.label,(y,D)=>{var I=Sw(),F=w(I);ml(F,()=>c(D).html),le(()=>{Le(I,1,`tb-btn ${c(D).extraClass??""??""}`,"svelte-k7we1m"),ct(I,"data-key",c(D).key),ct(I,"aria-label",c(D).label)}),T(y,I)}),T(b,R)},m=b=>{var R=Kt(),k=He(R);Rt(k,17,()=>s,y=>y.label,(y,D)=>{var I=bw(),F=w(I);ml(F,()=>c(D).html),le(()=>{Le(I,1,`tb-btn ${c(D).extraClass??""??""}`,"svelte-k7we1m"),ct(I,"id",c(D).id),ct(I,"data-key",c(D).key),ct(I,"aria-label",c(D).label)}),T(y,I)}),T(b,R)};te(f,b=>{i()?b(g):b(m,!1)})}Q("mousedown",v,a),T(d,v)};te(l,d=>{Pt&&d(u)})}T(e,h),Ye()}Qe(["mousedown"]);var Cw=B('<div><button class="icon-btn svelte-wp0i5g" aria-label="Open sessions menu">☰</button> <span class="mobile-title svelte-wp0i5g"> </span></div>');function kw(e,t){let i=mt(t,"hidden",3,!1);var s=Cw();let r;var n=w(s),o=E(n,2),a=w(o);le(()=>{r=Le(s,1,"mobile-header svelte-wp0i5g",null,r,{hidden:i()}),oe(a,t.title)}),Q("click",n,function(...h){var l;(l=t.onMenuClick)==null||l.apply(this,h)}),T(e,s)}Qe(["click"]);var xw=B('<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">×</button></div>'),Ew=B('<div class="update-toast svelte-1trivgv"><div class="update-toast-content svelte-1trivgv"><span class="update-toast-text svelte-1trivgv"> </span> <!></div></div>');function Rw(e,t){Ve(t,!0);let i=j(!1),s=j(""),r=j("Update Now"),n=j(!1),o=j(!0);kn(async()=>{try{const v=await nf();v.updateAvailable&&(S(s,`Update available: v${v.current} → v${v.latest}`),S(r,"Update Now"),S(n,!1),S(o,!0),S(i,!0))}catch{}});async function a(){S(n,!0),S(r,"Updating…");try{(await of()).restarting?(S(s,"Updated! Restarting server…"),S(o,!1),setTimeout(()=>{location.reload()},5e3)):(S(s,"Updated! Please restart the server manually."),S(o,!1))}catch{S(s,"Update failed. Please try again."),S(n,!1),S(r,"Retry"),S(o,!0)}}function h(){S(i,!1)}var l=Kt(),u=He(l);{var d=v=>{var p=Ew(),f=w(p),g=w(f),m=w(g),b=E(g,2);{var R=k=>{var y=xw(),D=w(y),I=w(D),F=E(D,2);le(()=>{D.disabled=c(n),oe(I,c(r))}),Q("click",D,a),Q("click",F,h),T(k,y)};te(b,k=>{c(o)&&k(R)})}le(()=>oe(m,c(s))),T(v,p)};te(u,v=>{c(i)&&v(d)})}T(e,l),Ye()}Qe(["click"]);var Dw=B('<button class="image-toast-insert svelte-1y8sviv">Insert</button>'),Tw=B('<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">×</button></div></div></div>');function Mw(e,t){Ve(t,!0);let i=j(!1),s=j(""),r=j(!1),n=j(null),o=null;function a(m,b,R){o&&(clearTimeout(o),o=null),S(s,m,!0),S(r,b,!0),S(n,R??null,!0),S(i,!0)}function h(){S(i,!1),S(n,null),o&&(clearTimeout(o),o=null)}function l(m){o&&clearTimeout(o),o=setTimeout(()=>{c(n)||h()},m)}function u(){c(n)&&Zn(c(n)),h()}function d(){h()}var v={show:a,hide:h,autoDismiss:l},p=Kt(),f=He(p);{var g=m=>{var b=Tw(),R=w(b),k=w(R),y=w(k),D=E(k,2),I=w(D);{var F=Z=>{var U=Dw();Q("click",U,u),T(Z,U)};te(I,Z=>{c(r)&&Z(F)})}var V=E(I,2);le(()=>oe(y,c(s))),Q("click",V,d),T(m,b)};te(f,m=>{c(i)&&m(g)})}return T(e,p),Ye(v)}Qe(["click"]);var Pw=B("<option> </option>"),Bw=B("<option> </option>"),Lw=B('<li class="branch-create-new svelte-thtd9b" role="option" aria-selected="false"> </li>'),Aw=B('<li role="option" aria-selected="false" class="svelte-thtd9b"> </li>'),Ow=B('<ul class="branch-dropdown svelte-thtd9b"><!> <!></ul>'),Iw=B('<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>'),Nw=B('<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>'),Fw=B('<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>Repos</button> <button>Worktrees</button></div> <div class="dialog-body svelte-thtd9b"><div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-root">Root directory</label> <select id="ns-root" class="dialog-select svelte-thtd9b"><option>Select a root...</option><!></select></div> <div class="dialog-field svelte-thtd9b"><label class="dialog-label svelte-thtd9b" for="ns-repo">Repository</label> <select id="ns-repo" class="dialog-select svelte-thtd9b"><option>Select a repo...</option><!></select></div> <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 Hw(e,t){Ve(t,!0);let i=mt(t,"preselectedRepo",3,null);const s=xn(),r=Ea();let n,o=j("repos"),a=j(Ge([])),h=j(""),l=j(""),u=j(""),d=j(""),v=j("claude"),p=j(!1),f=j(!1),g=j(!1),m=j(Ge([])),b=j(!1),R=j(!1),k=j(!1),y=0,D=G(()=>{const H=new Set;return c(a).forEach($=>{$.root&&H.add($.root)}),Array.from(H).sort()}),I=G(()=>c(h)?c(a).filter(H=>H.root===c(h)).sort((H,$)=>H.name.localeCompare($.name)):[]),F=G(()=>{if(!c(u).trim())return[];const H=c(u).toLowerCase();return c(m).filter($=>$.toLowerCase().includes(H)).slice(0,10)}),V=G(()=>c(m).some(H=>H===c(u)));async function Z(H,$={}){const A=++y;if(H){$.preserveExisting||S(m,[],!0),$.refresh?S(k,!0):S(R,!0);try{const ae=await kp(H,$.refresh?{refresh:!0}:{});if(A!==y||H!==c(l))return;S(m,ae,!0),c(u).trim()&&S(b,!0)}catch{if(A!==y||H!==c(l))return;$.preserveExisting||S(m,[],!0)}finally{A===y&&(S(R,!1),S(k,!1))}}}async function U(){!c(l)||c(k)||await Z(c(l),{refresh:!0,preserveExisting:!0})}function ie(){y+=1,S(u,""),S(m,[],!0),S(b,!1),S(R,!1),S(k,!1)}function K(){S(l,""),ie()}function x(){ie(),c(l)&&Z(c(l))}function M(){S(b,c(u).trim().length>0)}function P(H){S(u,H,!0),S(b,!1)}function Y(){S(h,""),S(l,""),S(d,""),S(p,!1),S(f,!1),S(g,!1),ie()}async function ne(H,$){Y(),S(o,($==null?void 0:$.tab)??(s.activeTab==="repos"||s.activeTab==="worktrees"?s.activeTab:"repos"),!0);try{S(a,await sf(),!0)}catch{S(a,[],!0)}await jh(),S(v,r.defaultAgent,!0),$!=null&&$.agent&&S(v,$.agent,!0),S(p,r.defaultYolo,!0),S(f,r.defaultContinue,!0),S(g,r.launchInTmux,!0),($==null?void 0:$.yolo)!==void 0&&S(p,$.yolo,!0),($==null?void 0:$.useTmux)!==void 0&&S(g,$.useTmux,!0);const A=H??i();if(A!=null&&A.root)S(h,A.root,!0),await Promise.resolve(),S(l,A.path,!0),await Z(A.path);else if(s.repoFilter){const ae=c(a).find(we=>we.name===s.repoFilter&&(!s.rootFilter||we.root===s.rootFilter));ae!=null&&ae.root&&(S(h,ae.root,!0),await Promise.resolve(),S(l,ae.path,!0),c(o)==="worktrees"&&await Z(ae.path))}else s.rootFilter&&S(h,s.rootFilter,!0);$!=null&&$.branchName&&S(u,$.branchName,!0),$!=null&&$.claudeArgs&&S(d,$.claudeArgs,!0),n.showModal()}function N(){n.close()}async function he(){var A,ae;const H=c(l);if(!H)return;const $=c(d).trim().split(/\s+/).filter(Boolean);try{let we;c(o)==="repos"?we=await rf({repoPath:H,repoName:H.split("/").filter(Boolean).pop(),continue:c(f),yolo:c(p),claudeArgs:$.length>0?$:void 0,agent:c(v),useTmux:c(g)}):we=await jo({repoPath:H,repoName:H.split("/").filter(Boolean).pop(),branchName:c(u).trim()||void 0,yolo:c(p),claudeArgs:$.length>0?$:void 0,agent:c(v),useTmux:c(g)}),n.close(),await zt(),we!=null&&we.id&&(c(o)==="worktrees"&&we.type==="repo"&&(s.activeTab="repos"),(A=t.onSessionCreated)==null||A.call(t,we.id))}catch(we){if(we instanceof Error&&"sessionId"in we){const _t=we;n.close(),await zt(),_t.sessionId&&((ae=t.onSessionCreated)==null||ae.call(t,_t.sessionId))}}}function Ce(H){H.target===n&&n.close()}function de(H){c(b)&&H.key==="Escape"&&(S(b,!1),H.stopPropagation())}var L={open:ne,close:N},ee=Fw(),fe=w(ee),be=w(fe),ve=w(be),me=E(be,2),Ee=w(me);let Ne;var Je=E(Ee,2);let ze;var Ae=E(me,2),ce=w(Ae),Ue=E(w(ce),2),rt=w(Ue);rt.value=rt.__value="";var qt=E(rt);Rt(qt,16,()=>c(D),H=>H,(H,$)=>{var A=Pw(),ae=w(A),we={};le(_t=>{oe(ae,_t),we!==(we=$)&&(A.value=(A.__value=$)??"")},[()=>Tr($)]),T(H,A)});var yt=E(ce,2),De=E(w(yt),2),Re=w(De);Re.value=Re.__value="";var Ze=E(Re);Rt(Ze,17,()=>c(I),H=>H.path,(H,$)=>{var A=Bw(),ae=w(A),we={};le(()=>{oe(ae,c($).name),we!==(we=c($).path)&&(A.value=(A.__value=c($).path)??"")}),T(H,A)});var Ft=E(yt,2),si=E(w(Ft),2),fi=w(si);fi.value=fi.__value="claude";var Oe=E(fi);Oe.value=Oe.__value="codex";var z=E(Ft,2);{var se=H=>{var $=Iw(),A=w($),ae=E(w(A),2),we=w(ae);let _t;var _i=E(A,2),ri=w(_i),Dn=E(ri,2);{var ir=xs=>{var Do=Ow(),To=w(Do);{var Ba=os=>{var Ui=Lw(),vi=w(Ui);le(Tn=>oe(vi,`Create new: ${Tn??""}`),[()=>c(u).trim()]),Q("mousedown",Ui,()=>P(c(u).trim())),T(os,Ui)},ns=G(()=>!c(V)&&c(u).trim());te(To,os=>{c(ns)&&os(Ba)})}var Hr=E(To,2);Rt(Hr,16,()=>c(F),os=>os,(os,Ui)=>{var vi=Aw(),Tn=w(vi);le(()=>oe(Tn,Ui)),Q("mousedown",vi,()=>P(Ui)),T(os,vi)}),T(xs,Do)},Pa=G(()=>c(b)&&(c(F).length>0||c(u).trim()&&!c(V)));te(Dn,xs=>{c(Pa)&&xs(ir)})}le(()=>{ae.disabled=!c(l)||c(R)||c(k),_t=Le(we,0,"svelte-thtd9b",null,_t,{spinning:c(R)||c(k)})}),Q("click",ae,U),Q("input",ri,M),js("focus",ri,()=>{c(u).trim()&&S(b,!0)}),Sn(ri,()=>c(u),xs=>S(u,xs)),T(H,$)};te(z,H=>{c(o)==="worktrees"&&H(se)})}var ke=E(z,2);{var pe=H=>{var $=Nw(),A=w($);Ls(A,()=>c(f),ae=>S(f,ae)),T(H,$)};te(ke,H=>{c(o)==="repos"&&H(pe)})}var ge=E(ke,2),Ie=w(ge),C=E(ge,2),q=w(C),ue=E(C,2),Se=E(w(ue),2),$e=E(Ae,2),Ke=w($e),et=E(Ke,2),je=w(et);return ht(ee,H=>n=H,()=>n),le(()=>{oe(ve,c(o)==="repos"?"New Session":"New Worktree"),Ne=Le(Ee,1,"dialog-tab svelte-thtd9b",null,Ne,{active:c(o)==="repos"}),ze=Le(Je,1,"dialog-tab svelte-thtd9b",null,ze,{active:c(o)==="worktrees"}),De.disabled=!c(h),et.disabled=!c(l),oe(je,c(o)==="repos"?"Start Session":"Create Worktree")}),Q("click",ee,Ce),Q("keydown",ee,de),Q("click",Ee,()=>{S(o,"repos")}),Q("click",Je,()=>{S(o,"worktrees")}),Q("change",Ue,K),qo(Ue,()=>c(h),H=>S(h,H)),Q("change",De,x),qo(De,()=>c(l),H=>S(l,H)),qo(si,()=>c(v),H=>S(v,H)),Ls(Ie,()=>c(p),H=>S(p,H)),Ls(q,()=>c(g),H=>S(g,H)),Sn(Se,()=>c(d),H=>S(d,H)),Q("click",Ke,()=>n.close()),Q("click",et,he),T(e,ee),Ye(L)}Qe(["click","keydown","change","input","mousedown"]);var Ww=B('<p class="empty-msg svelte-fdtoa4">No root directories configured.</p>'),zw=B('<li class="root-item svelte-fdtoa4"><span class="root-path svelte-fdtoa4"> </span> <button class="remove-btn svelte-fdtoa4">✕</button></li>'),Uw=B('<ul class="roots-list svelte-fdtoa4"></ul>'),Kw=B('<p class="error-msg svelte-fdtoa4"> </p>'),qw=B('<span class="version-status svelte-fdtoa4">Up to date</span>'),jw=B('<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>'),Vw=B('<button class="btn btn-ghost btn-sm svelte-fdtoa4"> </button>'),Yw=B('<p class="version-status-msg svelte-fdtoa4"> </p>'),Gw=B('<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">✕</button></div> <div class="dialog-body svelte-fdtoa4"><section class="settings-section svelte-fdtoa4"><h3 class="section-title svelte-fdtoa4">Root Directories</h3> <p class="section-desc svelte-fdtoa4">Directories scanned for git repositories.</p> <!> <div class="add-root-row svelte-fdtoa4"><input type="text" class="add-root-input svelte-fdtoa4" placeholder="/path/to/projects" autocomplete="off"/> <button class="btn btn-primary svelte-fdtoa4">Add</button></div> <!></section> <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 Xw(e,t){Ve(t,!0);let i,s=j(Ge([])),r=j(""),n=j(!1);const o=Ea();let a=j(""),h=j(""),l=j(null),u=j(!1),d=j(!1),v=j(!1),p=j(!1),f=j("");async function g(){try{S(s,await Cp(),!0)}catch{S(s,[],!0)}}async function m(){S(a,""),S(r,""),S(f,""),S(d,!1),S(p,!1),S(n,localStorage.getItem("devtools-enabled")==="true"),await g(),await jh(),i.showModal(),Z()}function b(){i.close()}async function R(){const A=c(r).trim();if(A){S(a,"");try{S(s,await Pp(A),!0),S(r,""),await zt()}catch{S(a,"Failed to add root directory.")}}}async function k(A){S(a,"");try{S(s,await Bp(A),!0),await zt()}catch{S(a,"Failed to remove root directory.")}}async function y(){const A=o.defaultAgent;S(a,"");try{await Op(o.defaultAgent)}catch{o.defaultAgent=A,S(a,"Failed to update default agent.")}}async function D(){const A=o.defaultContinue;S(a,"");try{await Np(o.defaultContinue)}catch{o.defaultContinue=A,S(a,"Failed to update continue default.")}}async function I(){const A=o.defaultYolo;S(a,"");try{await Hp(o.defaultYolo)}catch{o.defaultYolo=A,S(a,"Failed to update yolo default.")}}async function F(){const A=o.launchInTmux;S(a,"");try{await zp(o.launchInTmux)}catch(ae){o.launchInTmux=A,S(a,ae instanceof Error?ae.message:"Failed to update tmux setting.",!0)}}async function V(){const A=o.defaultNotifications;S(a,"");try{await Kp(o.defaultNotifications)}catch{o.defaultNotifications=A,S(a,"Failed to update notifications default.")}}async function Z(){S(v,!0),S(f,"");try{const A=await nf();S(h,A.current,!0),S(l,A.latest,!0),S(u,A.updateAvailable,!0),S(d,!0)}catch{S(f,"Failed to check for updates.")}finally{S(v,!1)}}async function U(){S(p,!0),S(f,"");try{(await of()).restarting?(S(f,"Updated! Restarting server…"),setTimeout(()=>{location.reload()},5e3)):S(f,"Updated! Please restart the server manually."),S(u,!1)}catch{S(f,"Update failed. Please try again."),S(p,!1)}}function ie(){localStorage.setItem("devtools-enabled",c(n)?"true":"false"),window.dispatchEvent(new Event("devtools-changed"))}async function K(){i.close(),await zt()}function x(A){A.target===i&&K()}function M(A){A.key==="Enter"&&R()}var P={open:m,close:b},Y=Gw(),ne=w(Y),N=w(ne),he=E(w(N),2),Ce=E(N,2),de=w(Ce),L=E(w(de),4);{var ee=A=>{var ae=Ww();T(A,ae)},fe=A=>{var ae=Uw();Rt(ae,20,()=>c(s),we=>we,(we,_t)=>{var _i=zw(),ri=w(_i),Dn=w(ri),ir=E(ri,2);le(()=>{ct(ri,"title",_t),oe(Dn,_t),ct(ir,"aria-label",`Remove ${_t??""}`)}),Q("click",ir,()=>k(_t)),T(we,_i)}),T(A,ae)};te(L,A=>{c(s).length===0?A(ee):A(fe,!1)})}var be=E(L,2),ve=w(be),me=E(ve,2),Ee=E(be,2);{var Ne=A=>{var ae=Kw(),we=w(ae);le(()=>oe(we,c(a))),T(A,ae)};te(Ee,A=>{c(a)&&A(Ne)})}var Je=E(de,2),ze=E(w(Je),4),Ae=w(ze);Ae.value=Ae.__value="claude";var ce=E(Ae);ce.value=ce.__value="codex";var Ue=E(Je,2),rt=E(w(Ue),4),qt=w(rt),yt=E(rt,2),De=w(yt),Re=E(yt,2),Ze=w(Re),Ft=E(Re,2),si=w(Ft),fi=E(Ue,2),Oe=E(w(fi),2),z=w(Oe),se=E(fi,2),ke=E(w(se),2),pe=w(ke),ge=w(pe);{var Ie=A=>{var ae=pl();le(()=>oe(ae,`v${c(h)??""}`)),T(A,ae)},C=A=>{var ae=pl("...");T(A,ae)};te(ge,A=>{c(h)?A(Ie):A(C,!1)})}var q=E(pe,2);{var ue=A=>{var ae=qw();T(A,ae)};te(q,A=>{c(d)&&!c(u)&&!c(p)&&A(ue)})}var Se=E(ke,2);{var $e=A=>{var ae=jw(),we=w(ae),_t=w(we),_i=E(we,2),ri=w(_i);le(()=>{oe(_t,`v${c(h)??""} → v${c(l)??""}`),_i.disabled=c(p),oe(ri,c(p)?"Updating…":"Update Now")}),Q("click",_i,U),T(A,ae)},Ke=A=>{var ae=Vw(),we=w(ae);le(()=>{ae.disabled=c(v),oe(we,c(v)?"Checking…":"Check for updates")}),Q("click",ae,Z),T(A,ae)};te(Se,A=>{c(u)?A($e):c(d)||A(Ke,1)})}var et=E(Se,2);{var je=A=>{var ae=Yw(),we=w(ae);le(()=>oe(we,c(f))),T(A,ae)};te(et,A=>{c(f)&&A(je)})}var H=E(Ce,2),$=w(H);return ht(Y,A=>i=A,()=>i),Q("click",Y,x),Q("click",he,K),Q("keydown",ve,M),Sn(ve,()=>c(r),A=>S(r,A)),Q("click",me,R),Q("change",ze,y),qo(ze,()=>o.defaultAgent,A=>o.defaultAgent=A),Q("change",qt,D),Ls(qt,()=>o.defaultContinue,A=>o.defaultContinue=A),Q("change",De,I),Ls(De,()=>o.defaultYolo,A=>o.defaultYolo=A),Q("change",Ze,F),Ls(Ze,()=>o.launchInTmux,A=>o.launchInTmux=A),Q("change",si,V),Ls(si,()=>o.defaultNotifications,A=>o.defaultNotifications=A),Q("change",z,ie),Ls(z,()=>c(n),A=>S(n,A)),Q("click",$,K),T(e,Y),Ye(P)}Qe(["click","keydown","change"]);var Qw=B('<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),Jw=B('<p class="error-msg svelte-15sco2n"> </p>'),Zw=B('<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 $w(e,t){Ve(t,!0);let i,s=j(null),r=j(""),n=j(!1);function o(F){S(s,F,!0),S(r,""),S(n,!1),i.showModal()}function a(){i.close()}async function h(){if(!(!c(s)||c(n))){S(n,!0),S(r,""),Hn(c(s).path);try{await Mp(c(s).path,c(s).repoPath),i.close(),await zt()}catch(F){S(r,F instanceof Error?F.message:"Failed to delete worktree.",!0),S(n,!1)}finally{c(s)&&Wn(c(s).path)}}}function l(){i.close()}function u(F){F.target===i&&i.close()}var d={open:o,close:a},v=Zw(),p=w(v),f=E(w(p),2),g=w(f);{var m=F=>{var V=Qw(),Z=He(V),U=E(w(Z)),ie=w(U),K=E(Z,2),x=w(K);le(()=>{oe(ie,c(s).displayName||c(s).name),oe(x,c(s).path)}),T(F,V)};te(g,F=>{c(s)&&F(m)})}var b=E(g,2);{var R=F=>{var V=Jw(),Z=w(V);le(()=>oe(Z,c(r))),T(F,V)};te(b,F=>{c(r)&&F(R)})}var k=E(f,2),y=w(k),D=E(y,2),I=w(D);return ht(v,F=>i=F,()=>i),le(()=>{y.disabled=c(n),D.disabled=c(n),oe(I,c(n)?"Deleting...":"Delete")}),Q("click",v,u),Q("click",y,l),Q("click",D,h),T(e,v),Ye(d)}Qe(["click"]);var e1=B('<div class="sidebar-overlay svelte-13zv0lp"></div>'),t1=B("<p>Select or create a session</p>"),i1=B('<div class="main-app svelte-13zv0lp"><!> <!> <div class="terminal-area svelte-13zv0lp"><!> <!> <!> <div class="no-session-msg svelte-13zv0lp"><!></div></div></div> <!> <!> <!> <!> <!>',1);function s1(e,t){Ve(t,!0);const i=new Tf({defaultOptions:{queries:{staleTime:300*1e3,gcTime:600*1e3,refetchOnWindowFocus:!1}}}),s=af(),r=xn(),n=Kh(),o=Ea();function a(L,ee){const fe={repo:"repos",worktree:"worktrees"};r.activeTab=fe[ee]||"repos",n.activeSessionId=L,ra(L),hs()}Jp(a);let h=j(void 0),l=j(void 0),u=j(void 0),d=j(void 0),v=j(void 0),p=j(void 0),f=j(!1);kn(()=>{jp();let L,ee;if(Pt&&window.visualViewport){const fe=window.visualViewport;let be=null;const ve=()=>{const me=window.innerHeight-fe.height;S(f,me>50),c(p)&&(c(f)?c(p).style.height=fe.height+"px":c(p).style.height=""),window.scrollTo(0,0),be&&clearTimeout(be),be=setTimeout(()=>{var Ee;return(Ee=c(h))==null?void 0:Ee.fitTerm()},100)};fe.addEventListener("resize",ve),fe.addEventListener("scroll",ve),L=()=>{fe.removeEventListener("resize",ve),fe.removeEventListener("scroll",ve),be&&clearTimeout(be)}}if(Pt){let ve=0,me=0,Ee=!1;const Ne=Ae=>{const ce=Ae.touches[0];ce&&ce.clientX<=30&&!r.sidebarOpen&&(ve=ce.clientX,me=ce.clientY,Ee=!0)},Je=Ae=>{if(!Ee)return;const ce=Ae.touches[0];if(!ce)return;const Ue=ce.clientX-ve,rt=Math.abs(ce.clientY-me);if(rt>Ue&&(rt>8||Ue>8)){Ee=!1;return}Ue>=50&&(Ee=!1,Ec())},ze=()=>{Ee=!1};document.addEventListener("touchstart",Ne,{passive:!0}),document.addEventListener("touchmove",Je,{passive:!0}),document.addEventListener("touchend",ze),ee=()=>{document.removeEventListener("touchstart",Ne),document.removeEventListener("touchmove",Je),document.removeEventListener("touchend",ze)}}return()=>{L==null||L(),ee==null||ee()}}),er(()=>{s.authenticated&&zt().then(()=>{const L=new URLSearchParams(window.location.search),ee=L.get("session"),fe=L.get("tab");ee&&(window.history.replaceState({},"","/"),a(ee,fe||"repo"));for(const be of n.sessions)Tc(be.id,o.defaultNotifications);tg().then(()=>{ig(ag())})})}),er(()=>{s.authenticated&&pf(L=>{L.type==="worktrees-changed"?zt():L.type==="session-idle-changed"&&L.sessionId&&ng(L.sessionId,L.idle??!1)})});function g(L){var ee;n.activeSessionId=L,ra(L),hs(),(ee=c(h))==null||ee.focusTerm()}function m(L,ee){var fe;(fe=c(u))==null||fe.open(L,ee)}function b(){var L;(L=c(d))==null||L.open()}function R(L){var ee;(ee=c(u))==null||ee.open(L,{tab:"worktrees"})}function k(L){var ee;(ee=c(v))==null||ee.open(L)}function y(L){var ee;n.activeSessionId=L,Tc(L,o.defaultNotifications),hs(),(ee=c(h))==null||ee.focusTerm()}function D(L,ee,fe){var be,ve;(be=c(l))==null||be.show(L,ee,fe),ee||(ve=c(l))==null||ve.autoDismiss(3e3)}function I(L){Zn(L)}function F(){}function V(){}function Z(){const L=document.createElement("input");L.type="file",L.accept="image/*",L.onchange=()=>{var fe,be;const ee=(fe=L.files)==null?void 0:fe[0];ee&&((be=c(h))==null||be.handleImageUpload(ee,ee.type))},L.click()}function U(){var L;(L=c(h))==null||L.focusTerm()}let ie=G(()=>{var L;return n.activeSessionId?((L=n.sessions.find(ee=>ee.id===n.activeSessionId))==null?void 0:L.displayName)||"Session":"Claude Remote CLI"}),K=G(()=>{var L;return((L=n.sessions.find(ee=>ee.id===n.activeSessionId))==null?void 0:L.useTmux)??!1}),x=G(()=>{var L;return((L=n.sessions.find(ee=>ee.id===n.activeSessionId))==null?void 0:L.mode)??"pty"}),M=j(!1);function P(L){S(M,L,!0)}function Y(){var L;(L=c(h))==null||L.exitCopyMode()}var ne=Kt(),N=He(ne);{var he=L=>{},Ce=L=>{fg(L,{})},de=L=>{ym(L,{get client(){return i},children:(ee,fe)=>{var be=i1(),ve=He(be),me=w(ve);{var Ee=Oe=>{var z=e1();Q("click",z,function(...se){hs==null||hs.apply(this,se)}),T(Oe,z)};te(me,Oe=>{r.sidebarOpen&&Oe(Ee)})}var Ne=E(me,2);Jm(Ne,{onSelectSession:g,onOpenNewSession:m,onOpenSettings:b,onNewWorktree:R,onDeleteWorktree:k});var Je=E(Ne,2),ze=w(Je);kw(ze,{get title(){return c(ie)},get onMenuClick(){return Ec},get hidden(){return c(f)}});var Ae=E(ze,2);{var ce=Oe=>{ht(mw(Oe,{get sessionId(){return n.activeSessionId},mode:"sdk",onImageUpload:D,get useTmux(){return c(K)},onCopyModeChange:P}),z=>S(h,z,!0),()=>c(h))},Ue=Oe=>{ht(xh(Oe,{get sessionId(){return n.activeSessionId},onImageUpload:D,get useTmux(){return c(K)},onCopyModeChange:P}),z=>S(h,z,!0),()=>c(h))};te(Ae,Oe=>{c(x)==="sdk"?Oe(ce):Oe(Ue,!1)})}var rt=E(Ae,2);ww(rt,{onSendKey:I,onFlushComposedText:F,onClearInput:V,onUploadImage:Z,onRefocusMobileInput:U,get useTmux(){return c(K)},get inCopyMode(){return c(M)},onExitCopyMode:Y});var qt=E(rt,2),yt=w(qt);{var De=Oe=>{var z=t1();T(Oe,z)};te(yt,Oe=>{n.activeSessionId||Oe(De)})}ht(ve,Oe=>S(p,Oe),()=>c(p));var Re=E(ve,2);ht(Hw(Re,{onSessionCreated:y}),Oe=>S(u,Oe,!0),()=>c(u));var Ze=E(Re,2);ht(Xw(Ze,{}),Oe=>S(d,Oe,!0),()=>c(d));var Ft=E(Ze,2);ht($w(Ft,{}),Oe=>S(v,Oe,!0),()=>c(v));var si=E(Ft,2);Rw(si,{});var fi=E(si,2);ht(Mw(fi,{}),Oe=>S(l,Oe,!0),()=>c(l)),T(ee,be)},$$slots:{default:!0}})};te(N,L=>{s.checking?L(he):s.authenticated?L(de,!1):L(Ce,1)})}T(e,ne),Ye()}Qe(["click"]);ep(s1,{target:document.getElementById("app")});
|