@worca/ui 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- var Z_=Object.defineProperty;var Sl=(e,t)=>()=>(e&&(t=e(e=0)),t);var Cl=(e,t)=>{for(var s in t)Z_(e,s,{get:t[s],enumerable:!0})};var ah={};Cl(ah,{Terminal:()=>yw});function Fv(e){return e.replace(/\r?\n/g,"\r")}function Hv(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Wv(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function jv(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");bp(r,t,s,i)}}function bp(e,t,s,i){e=Fv(e),e=Hv(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function yp(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function _u(e,t,s,i,r){yp(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function ai(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wa(e,t=0,s=e.length){let i="";for(let r=t;r<s;++r){let o=e[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}function qv(e){return e[mc]||[]}function Ke(e){if(Jl.has(e))return Jl.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Kv(t,s,r)};return t._id=e,Jl.set(e,t),t}function Kv(e,t,s){t[vu]===t?t[mc].push({id:e,index:s}):(t[mc]=[{id:e,index:s}],t[vu]=t)}function Xv(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ var Q_=Object.defineProperty;var Sl=(e,t)=>()=>(e&&(t=e(e=0)),t);var Cl=(e,t)=>{for(var s in t)Q_(e,s,{get:t[s],enumerable:!0})};var ah={};Cl(ah,{Terminal:()=>ww});function Hv(e){return e.replace(/\r?\n/g,"\r")}function Wv(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function jv(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function Vv(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");bp(r,t,s,i)}}function bp(e,t,s,i){e=Hv(e),e=Wv(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function yp(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function _u(e,t,s,i,r){yp(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function ai(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function wa(e,t=0,s=e.length){let i="";for(let r=t;r<s;++r){let o=e[r];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}function Kv(e){return e[mc]||[]}function Ke(e){if(Jl.has(e))return Jl.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Gv(t,s,r)};return t._id=e,Jl.set(e,t),t}function Gv(e,t,s){t[vu]===t?t[mc].push({id:e,index:s}):(t[mc]=[{id:e,index:s}],t[vu]=t)}function Jv(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
- WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}function sa(e){eb(e)||Qv.onUnexpectedError(e)}function eb(e){return e instanceof tb?!0:e instanceof Error&&e.name===_c&&e.message===_c}function sb(e){return e?new Error(`Illegal argument: ${e}`):new Error("Illegal argument")}function ib(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function Lt(e,t=0){return e[e.length-(1+t)]}function ob(e,t){return(s,i)=>t(e(s),e(i))}function ab(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function cb(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function ub(e){Ui=e}function Ca(e){return Ui?.trackDisposable(e),e}function xa(e){Ui?.markAsDisposed(e)}function Oo(e,t){Ui?.setParent(e,t)}function pb(e,t){if(Ui)for(let s of e)Ui.setParent(s,t)}function Cu(e){return Ui?.markAsSingleton(e),e}function qi(e){if(Pp.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}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 fb(...e){let t=we(()=>qi(e));return pb(e,t),t}function we(e){let t=Ca({dispose:cb(()=>{xa(t),e()})});return t}function Eb(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}function Tb(e){return Qc.INSTANCE.getZoomFactor(e)}function Ab(){return na}function qb(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return qp.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Ec)switch(t){case 59:return 85;case 60:if(Ob)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_s)return 57;break}else if(oa&&(_s&&t===93||!_s&&t===92))return 57;return jb[t]||0}function Jb(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}function r0(e){return 55296<=e&&e<=56319}function Pu(e){return 56320<=e&&e<=57343}function o0(e,t){return(e-55296<<10)+(t-56320)+65536}function n0(e){return ih(e,0)}function ih(e,t){switch(typeof e){case"object":return e===null?zs(349,t):Array.isArray(e)?l0(e,t):c0(e,t);case"string":return Yp(e,t);case"boolean":return a0(e,t);case"number":return zs(e,t);case"undefined":return zs(937,t);default:return zs(617,t)}}function zs(e,t){return(t<<5)-t+e|0}function a0(e,t){return zs(e?433:863,t)}function Yp(e,t){t=zs(149417,t);for(let s=0,i=e.length;s<i;s++)t=zs(e.charCodeAt(s),t);return t}function l0(e,t){return t=zs(104579,t),e.reduce((s,i)=>ih(i,s),t)}function c0(e,t){return t=zs(181387,t),Object.keys(e).sort().reduce((s,i)=>(s=Yp(i,s),ih(e[i],s)),t)}function sc(e,t,s=32){let i=s-t,r=~((1<<i)-1);return(e<<t|(r&e)>>>i)>>>0}function Bu(e,t=0,s=e.byteLength,i=0){for(let r=0;r<s;r++)e[t+r]=i}function h0(e,t,s="0"){for(;e.length<t;)e=s+e;return e}function So(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join(""):h0((e>>>0).toString(16),t/4)}function te(e,t,s,i){return new p0(e,t,s,i)}function f0(e,t){return function(s){return t(new Ao(e,s))}}function m0(e){return function(t){return e(new Tc(t))}}function v0(e){let t=e.getBoundingClientRect(),s=rs(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}function Jp(e,t,s,...i){let r=b0.exec(t);if(!r)throw new Error("Bad use of emmet");let o=r[1]||"div",n;return e!=="http://www.w3.org/1999/xhtml"?n=document.createElementNS(e,o):n=document.createElement(o),r[3]&&(n.id=r[3]),r[4]&&(n.className=r[4].replace(/\./g," ").trim()),s&&Object.entries(s).forEach(([a,c])=>{typeof c>"u"||(/^on\w+$/.test(a)?n[a]=c:a==="selected"?c&&n.setAttribute(a,"true"):n.setAttribute(a,c))}),n.append(...i),n}function y0(e,t,...s){return Jp("http://www.w3.org/1999/xhtml",e,t,...s)}function xt(e){return typeof e=="number"?`${e}px`:e}function Io(e){return new w0(e)}function S0(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...n){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,n)}),this[o]}}function rc(e,t){let s=t-e;return function(i){return e+s*A0(i)}}function E0(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}function T0(e){return Math.pow(e,3)}function A0(e){return 1-T0(1-e)}function N0(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,_s&&(t.className+=" mac"),t}function Hi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Is(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function W0(e){return 57508<=e&&e<=57558}function j0(e){return 9472<=e&&e<=9631}function V0(e){return W0(e)||j0(e)}function U0(){return{css:{canvas:Zn(),cell:Zn()},device:{canvas:Zn(),cell:Zn(),char:{width:0,height:0,left:0,top:0}}}}function Zn(){return{width:0,height:0}}function Vu(e,t,s){for(;e.length<s;)e=t+e;return e}function G0(){return new K0}function oh(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),n=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-n]}function ty(e,t,s,i,r,o,n,a,c){if(!o)return;let l=oh(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(c?n/2:0))/n),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}function ry(){if(!nf)return 0;let e=jo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}function dy(e,t,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return fy(r,o,e,t,s,i)+$a(o,t,s,i)+my(r,o,e,t,s,i);let n;if(o===t)return n=r>e?"D":"C",No(Math.abs(r-e),zo(n,i));n=o>t?"D":"C";let a=Math.abs(o-t),c=py(o>t?e:r,s)+(a-1)*s.cols+1+uy(o>t?r:e,s);return No(c,zo(n,i))}function uy(e,t){return e-1}function py(e,t){return t.cols-e}function fy(e,t,s,i,r,o){return $a(t,i,r,o).length===0?"":No(df(e,t,e,t-Ki(t,r),!1,r).length,zo("D",o))}function $a(e,t,s,i){let r=e-Ki(e,s),o=t-Ki(t,s),n=Math.abs(r-o)-gy(e,t,s);return No(n,zo(hf(e,t),i))}function my(e,t,s,i,r,o){let n;$a(t,i,r,o).length>0?n=i-Ki(i,r):n=t;let a=i,c=_y(e,t,s,i,r,o);return No(df(e,n,s,a,c==="C",r).length,zo(c,o))}function gy(e,t,s){let i=0,r=e-Ki(e,s),o=t-Ki(t,s);for(let n=0;n<Math.abs(r-o);n++){let a=hf(e,t)==="A"?-1:1;s.buffer.lines.get(r+a*n)?.isWrapped&&i++}return i}function Ki(e,t){let s=0,i=t.buffer.lines.get(e),r=i?.isWrapped;for(;r&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),r=i?.isWrapped;return s}function _y(e,t,s,i,r,o){let n;return $a(s,i,r,o).length>0?n=i-Ki(i,r):n=t,e<s&&n<=i||e>=s&&n<i?"C":"D"}function hf(e,t){return e>t?"A":"B"}function df(e,t,s,i,r,o){let n=e,a=t,c="";for(;(n!==s||a!==i)&&a>=0&&a<o.buffer.lines.length;)n+=r?1:-1,r&&n>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,n),n=0,e=0,a++):!r&&n<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),n=o.cols-1,e=n,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,n)}function zo(e,t){let s=t?"O":"[";return M.ESC+s+e}function No(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}function qu(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)}function ge(e,t){if(e!==void 0)try{return ke.toColor(e)}catch{}return t}function Ry(e,t,s,i,r,o){let n=[];for(let a=0;a<e.length-1;a++){let c=a,l=e.get(++c);if(!l.isWrapped)continue;let h=[e.get(a)];for(;c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(!o&&i>=a&&i<c){a+=h.length-1;continue}let d=0,m=Fo(h,d,t),p=1,f=0;for(;p<h.length;){let w=Fo(h,p,t),k=w-f,$=s-m,y=Math.min(k,$);h[d].copyCellsFrom(h[p],f,m,y,!1),m+=y,m===s&&(d++,m=0),f+=y,f===w&&(p++,f=0),m===0&&d!==0&&h[d-1].getWidth(s-1)===2&&(h[d].copyCellsFrom(h[d-1],s-1,m++,1,!1),h[d-1].setCell(s-1,r))}h[d].replaceCells(m,s,r);let _=0;for(let w=h.length-1;w>0&&(w>d||h[w].getTrimmedLength()===0);w--)_++;_>0&&(n.push(a+h.length-_),n.push(_)),a+=h.length-1}return n}function Dy(e,t){let s=[],i=0,r=t[i],o=0;for(let n=0;n<e.length;n++)if(r===n){let a=t[++i];e.onDeleteEmitter.fire({index:n-o,amount:a}),n+=a-1,o+=a,r=t[++i]}else s.push(n);return{layout:s,countRemoved:o}}function Ly(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function Py(e,t,s){let i=[],r=e.map((c,l)=>Fo(e,l,t)).reduce((c,l)=>c+l),o=0,n=0,a=0;for(;a<r;){if(r-a<s){i.push(r-a);break}o+=s;let c=Fo(e,n,t);o>c&&(o-=c,n++);let l=e[n].getWidth(o-1)===2;l&&o--;let h=l?s-1:s;i.push(h),a+=h}return i}function Fo(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}function zy(e){return e==="block"||e==="underline"||e==="bar"}function Po(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&Po(e[i],t-1);return s}function lc(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}function Fy(e,t){let s=0,i=t.length-1,r;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e<t[r][0])i=r-1;else return!0;return!1}function rp(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}function np(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=Yy.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Xy.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(t.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function dc(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function Jy(e,t=16){let[s,i,r]=e;return`rgb:${dc(s,t)}/${dc(i,t)}/${dc(r,t)}`}function lp(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}function dp(e){return 0<=e&&e<256}function ow(e,t,s,i){let r={type:0,cancel:!1,key:void 0},o=(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=M.ESC+"OA":r.key=M.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=M.ESC+"OD":r.key=M.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=M.ESC+"OC":r.key=M.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=M.ESC+"OB":r.key=M.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":M.DEL,e.altKey&&(r.key=M.ESC+r.key);break;case 9:if(e.shiftKey){r.key=M.ESC+"[Z";break}r.key=M.HT,r.cancel=!0;break;case 13:r.key=e.altKey?M.ESC+M.CR:M.CR,r.cancel=!0;break;case 27:r.key=M.ESC,e.altKey&&(r.key=M.ESC+M.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"D":t?r.key=M.ESC+"OD":r.key=M.ESC+"[D";break;case 39:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"C":t?r.key=M.ESC+"OC":r.key=M.ESC+"[C";break;case 38:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"A":t?r.key=M.ESC+"OA":r.key=M.ESC+"[A";break;case 40:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"B":t?r.key=M.ESC+"OB":r.key=M.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=M.ESC+"[2~");break;case 46:o?r.key=M.ESC+"[3;"+(o+1)+"~":r.key=M.ESC+"[3~";break;case 36:o?r.key=M.ESC+"[1;"+(o+1)+"H":t?r.key=M.ESC+"OH":r.key=M.ESC+"[H";break;case 35:o?r.key=M.ESC+"[1;"+(o+1)+"F":t?r.key=M.ESC+"OF":r.key=M.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=M.ESC+"[5;"+(o+1)+"~":r.key=M.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=M.ESC+"[6;"+(o+1)+"~":r.key=M.ESC+"[6~";break;case 112:o?r.key=M.ESC+"[1;"+(o+1)+"P":r.key=M.ESC+"OP";break;case 113:o?r.key=M.ESC+"[1;"+(o+1)+"Q":r.key=M.ESC+"OQ";break;case 114:o?r.key=M.ESC+"[1;"+(o+1)+"R":r.key=M.ESC+"OR";break;case 115:o?r.key=M.ESC+"[1;"+(o+1)+"S":r.key=M.ESC+"OS";break;case 116:o?r.key=M.ESC+"[15;"+(o+1)+"~":r.key=M.ESC+"[15~";break;case 117:o?r.key=M.ESC+"[17;"+(o+1)+"~":r.key=M.ESC+"[17~";break;case 118:o?r.key=M.ESC+"[18;"+(o+1)+"~":r.key=M.ESC+"[18~";break;case 119:o?r.key=M.ESC+"[19;"+(o+1)+"~":r.key=M.ESC+"[19~";break;case 120:o?r.key=M.ESC+"[20;"+(o+1)+"~":r.key=M.ESC+"[20~";break;case 121:o?r.key=M.ESC+"[21;"+(o+1)+"~":r.key=M.ESC+"[21~";break;case 122:o?r.key=M.ESC+"[23;"+(o+1)+"~":r.key=M.ESC+"[23~";break;case 123:o?r.key=M.ESC+"[24;"+(o+1)+"~":r.key=M.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=M.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=M.DEL:e.keyCode===219?r.key=M.ESC:e.keyCode===220?r.key=M.FS:e.keyCode===221&&(r.key=M.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let n=rw[e.keyCode]?.[e.shiftKey?1:0];if(n)r.key=M.ESC+n;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(a);e.shiftKey&&(c=c.toUpperCase()),r.key=M.ESC+c}else if(e.keyCode===32)r.key=M.ESC+(e.ctrlKey?M.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),r.key=M.ESC+a,r.cancel=!0}}else s&&!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=M.US),e.key==="@"&&(r.key=M.NUL));break}return r}function dw(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}function pw(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var vp,zv,Nv,Ee,U,mu,pc,gu,fc,Vv,Uv,wp,li,Ho,ua,qt,vu,mc,Jl,gt,kp,Gi,Gv,Jc,$p,_t,Ep,Yv,Wo,gc,Sa,Fs,Zc,Hs,Jv,Tp,Tr,Ap,Zv,Qv,_c,tb,bu,bc,rb,Lp,nb,yu,wu,Su,Y$,lb,Pp,hb,Ui,db,Mp,ci,re,Er,Mt,wc,xe,xu,mb,gb,_b,ku,vb,ot,Cc,bb,$u,zp,yb,kc,wb,Sb,Cb,ia,xb,kb,ra,N,$b,$c,Qc,J$,Z$,Ar,Ec,oa,eh,Hp,Q$,eE,na,$r,pa,fa,Mo,Rb,Wp,jp,Db,Lb,Pb,Bb,Jn,aa,Eu,Mb,Os,Ns,Bt,Vp,Ib,Zl,Up,_s,Ob,Ql,zb,tE,vs,ii,Nb,Fb,Hb,Wb,sE,iE,rE,oE,ri,nE,th,ec,Tu,Au,jb,qp,Vb,Ub,Kb,Gb,Yb,Xb,Tc,Ru,Zb,Ao,Du,Gp,Qb,e0,sh,t0,s0,tc,i0,Lu,d0,aE,rs,lE,cE,hE,Mu,dE,uE,u0,pE,fE,p0,Iu,g0,ma,_0,ic,Ou,mE,je,b0,w0,Zp,gs,Ro,C0,rh,zu,x0,k0,$0,Nu,Fu,R0,D0,Qp,ef,L0,P0,B0,Hu,Wu,M0,Lc,I0,O0,z0,Pc,Bc,F0,fs,oi,Co,ga,M,ca,tf,Mc,Ve,Ue,qe,$e,ju,Le,ye,ke,mt,ha,H0,_a,Ic,q0,K0,oc,jt,Qn,Uu,xo,ea,Y0,Oc,zc,sf,X0,J0,Z0,Q0,ey,Nc,sy,rf,ka,jo,Vo,of,iy,nf,va,oy,ny,af,nh,lf,cf,ay,ly,ba,cy,Fc,hy,vy,nc,by,yy,wy,Sy,Cy,Hc,Ku,Gu,Me,Wi,Do,Yu,Xu,ko,xy,Wc,ky,$y,Ey,Ty,jc,Ay,Ju,ae,De,ta,ac,Lo,pf,By,Oe,ji,Zu,Qu,My,mf,gf,Vc,kr,Iy,Oy,ep,tp,Uc,sp,cc,ip,qc,hc,Ny,Ie,Hy,Vi,Wy,$o,jy,_f,Eo,Vy,Pt,To,Uy,Bo,op,qy,Ut,Ky,Gy,Yy,Xy,Zy,ni,ap,cp,hp,Qy,Gc,ew,up,tw,sw,Yc,pp,iw,rw,Ae,nw,uc,fp,aw,lw,cw,hw,mp,gp,ya,Xc,uw,fw,mw,_p,gw,_w,vw,bw,ms,yw,lh=Sl(()=>{vp=Object.defineProperty,zv=Object.getOwnPropertyDescriptor,Nv=(e,t)=>{for(var s in t)vp(e,s,{get:t[s],enumerable:!0})},Ee=(e,t,s,i)=>{for(var r=i>1?void 0:i?zv(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&vp(t,s,r),r},U=(e,t)=>(s,i)=>t(s,i,e),mu="Terminal input",pc={get:()=>mu,set:e=>mu=e},gu="Too much output to announce, navigate to rows manually to read",fc={get:()=>gu,set:e=>gu=e};Vv=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=r;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,i;let a=e.charCodeAt(o);56320<=a&&a<=57343?t[i++]=(n-55296)*1024+a-56320+65536:(t[i++]=n,t[i++]=a);continue}n!==65279&&(t[i++]=n)}return i}},Uv=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,o,n,a,c=0,l=0;if(this.interim[0]){let m=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let f=0,_;for(;(_=this.interim[++f]&63)&&f<4;)p<<=6,p|=_;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=w-f;for(;l<k;){if(l>=s)return 0;if(_=e[l++],(_&192)!==128){l--,m=!0;break}else this.interim[f++]=_,p<<=6,p|=_&63}m||(w===2?p<128?l--:t[i++]=p:w===3?p<2048||p>=55296&&p<=57343||p===65279||(t[i++]=p):p<65536||p>1114111||(t[i++]=p)),this.interim.fill(0)}let h=s-4,d=l;for(;d<s;){for(;d<h&&!((r=e[d])&128)&&!((o=e[d+1])&128)&&!((n=e[d+2])&128)&&!((a=e[d+3])&128);)t[i++]=r,t[i++]=o,t[i++]=n,t[i++]=a,d+=4;if(r=e[d++],r<128)t[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(c=(r&31)<<6|o&63,c<128){d--;continue}t[i++]=c}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(c=(r&15)<<12|(o&63)<<6|n&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[i++]=c}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,i;if(a=e[d++],(a&192)!==128){d--;continue}if(c=(r&7)<<18|(o&63)<<12|(n&63)<<6|a&63,c<65536||c>1114111)continue;t[i++]=c}}return i}},wp="",li=" ",Ho=class Sp{constructor(){this.fg=0,this.bg=0,this.extended=new ua}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 Sp;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}},ua=class Cp{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 Cp(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},qt=class xp extends Ho{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ua,this.combinedData=""}static fromCharData(t){let s=new xp;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ai(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},vu="di$target",mc="di$dependencies",Jl=new Map;gt=Ke("BufferService"),kp=Ke("CoreMouseService"),Gi=Ke("CoreService"),Gv=Ke("CharsetService"),Jc=Ke("InstantiationService"),$p=Ke("LogService"),_t=Ke("OptionsService"),Ep=Ke("OscLinkService"),Yv=Ke("UnicodeService"),Wo=Ke("DecorationService"),gc=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new qt,n=s.getTrimmedLength(),a=-1,c=-1,l=!1;for(let h=0;h<n;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,a=o.extended.urlId;continue}else l=o.extended.urlId!==a;else c!==-1&&(l=!0);if(l||c!==-1&&h===n-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let m={start:{x:c+1,y:e},end:{x:h+(!l&&h===n-1?1:0),y:e}},p=!1;if(!r?.allowNonHttpProtocols)try{let f=new URL(d);["http:","https:"].includes(f.protocol)||(p=!0)}catch{p=!0}p||i.push({text:d,range:m,activate:(f,_)=>r?r.activate(f,_,m):Xv(f,_),hover:(f,_)=>r?.hover?.(f,_,m),leave:(f,_)=>r?.leave?.(f,_,m)})}l=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,a=o.extended.urlId):(c=-1,a=-1)}}t(i)}};gc=Ee([U(0,gt),U(1,_t),U(2,Ep)],gc);Sa=Ke("CharSizeService"),Fs=Ke("CoreBrowserService"),Zc=Ke("MouseService"),Hs=Ke("RenderService"),Jv=Ke("SelectionService"),Tp=Ke("CharacterJoinerService"),Tr=Ke("ThemeService"),Ap=Ke("LinkProviderService"),Zv=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?bu.isErrorNoTelemetry(e)?new bu(e.message+`
3
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}function sa(e){tb(e)||eb.onUnexpectedError(e)}function tb(e){return e instanceof sb?!0:e instanceof Error&&e.name===_c&&e.message===_c}function ib(e){return e?new Error(`Illegal argument: ${e}`):new Error("Illegal argument")}function rb(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function Lt(e,t=0){return e[e.length-(1+t)]}function nb(e,t){return(s,i)=>t(e(s),e(i))}function lb(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function hb(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function pb(e){Ui=e}function Ca(e){return Ui?.trackDisposable(e),e}function xa(e){Ui?.markAsDisposed(e)}function Oo(e,t){Ui?.setParent(e,t)}function fb(e,t){if(Ui)for(let s of e)Ui.setParent(s,t)}function Cu(e){return Ui?.markAsSingleton(e),e}function qi(e){if(Pp.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}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 mb(...e){let t=we(()=>qi(e));return fb(e,t),t}function we(e){let t=Ca({dispose:hb(()=>{xa(t),e()})});return t}function Tb(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}function Ab(e){return Qc.INSTANCE.getZoomFactor(e)}function Rb(){return na}function Kb(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return qp.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Ec)switch(t){case 59:return 85;case 60:if(zb)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(_s)return 57;break}else if(oa&&(_s&&t===93||!_s&&t===92))return 57;return Vb[t]||0}function Zb(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}function o0(e){return 55296<=e&&e<=56319}function Pu(e){return 56320<=e&&e<=57343}function n0(e,t){return(e-55296<<10)+(t-56320)+65536}function a0(e){return ih(e,0)}function ih(e,t){switch(typeof e){case"object":return e===null?zs(349,t):Array.isArray(e)?c0(e,t):h0(e,t);case"string":return Yp(e,t);case"boolean":return l0(e,t);case"number":return zs(e,t);case"undefined":return zs(937,t);default:return zs(617,t)}}function zs(e,t){return(t<<5)-t+e|0}function l0(e,t){return zs(e?433:863,t)}function Yp(e,t){t=zs(149417,t);for(let s=0,i=e.length;s<i;s++)t=zs(e.charCodeAt(s),t);return t}function c0(e,t){return t=zs(104579,t),e.reduce((s,i)=>ih(i,s),t)}function h0(e,t){return t=zs(181387,t),Object.keys(e).sort().reduce((s,i)=>(s=Yp(i,s),ih(e[i],s)),t)}function sc(e,t,s=32){let i=s-t,r=~((1<<i)-1);return(e<<t|(r&e)>>>i)>>>0}function Bu(e,t=0,s=e.byteLength,i=0){for(let r=0;r<s;r++)e[t+r]=i}function d0(e,t,s="0"){for(;e.length<t;)e=s+e;return e}function So(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(s=>s.toString(16).padStart(2,"0")).join(""):d0((e>>>0).toString(16),t/4)}function te(e,t,s,i){return new f0(e,t,s,i)}function m0(e,t){return function(s){return t(new Ao(e,s))}}function g0(e){return function(t){return e(new Tc(t))}}function b0(e){let t=e.getBoundingClientRect(),s=rs(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}function Jp(e,t,s,...i){let r=y0.exec(t);if(!r)throw new Error("Bad use of emmet");let o=r[1]||"div",n;return e!=="http://www.w3.org/1999/xhtml"?n=document.createElementNS(e,o):n=document.createElement(o),r[3]&&(n.id=r[3]),r[4]&&(n.className=r[4].replace(/\./g," ").trim()),s&&Object.entries(s).forEach(([a,c])=>{typeof c>"u"||(/^on\w+$/.test(a)?n[a]=c:a==="selected"?c&&n.setAttribute(a,"true"):n.setAttribute(a,c))}),n.append(...i),n}function w0(e,t,...s){return Jp("http://www.w3.org/1999/xhtml",e,t,...s)}function xt(e){return typeof e=="number"?`${e}px`:e}function Io(e){return new S0(e)}function C0(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...n){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,n)}),this[o]}}function rc(e,t){let s=t-e;return function(i){return e+s*R0(i)}}function T0(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}function A0(e){return Math.pow(e,3)}function R0(e){return 1-A0(1-e)}function F0(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,_s&&(t.className+=" mac"),t}function Hi(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Is(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function j0(e){return 57508<=e&&e<=57558}function V0(e){return 9472<=e&&e<=9631}function U0(e){return j0(e)||V0(e)}function q0(){return{css:{canvas:Zn(),cell:Zn()},device:{canvas:Zn(),cell:Zn(),char:{width:0,height:0,left:0,top:0}}}}function Zn(){return{width:0,height:0}}function Vu(e,t,s){for(;e.length<s;)e=t+e;return e}function Y0(){return new G0}function oh(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),o=parseInt(r.getPropertyValue("padding-left")),n=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-n]}function sy(e,t,s,i,r,o,n,a,c){if(!o)return;let l=oh(e,t,s);if(l)return l[0]=Math.ceil((l[0]+(c?n/2:0))/n),l[1]=Math.ceil(l[1]/a),l[0]=Math.min(Math.max(l[0],1),i+(c?1:0)),l[1]=Math.min(Math.max(l[1],1),r),l}function oy(){if(!nf)return 0;let e=jo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}function uy(e,t,s,i){let r=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return my(r,o,e,t,s,i)+$a(o,t,s,i)+gy(r,o,e,t,s,i);let n;if(o===t)return n=r>e?"D":"C",No(Math.abs(r-e),zo(n,i));n=o>t?"D":"C";let a=Math.abs(o-t),c=fy(o>t?e:r,s)+(a-1)*s.cols+1+py(o>t?r:e,s);return No(c,zo(n,i))}function py(e,t){return e-1}function fy(e,t){return t.cols-e}function my(e,t,s,i,r,o){return $a(t,i,r,o).length===0?"":No(df(e,t,e,t-Ki(t,r),!1,r).length,zo("D",o))}function $a(e,t,s,i){let r=e-Ki(e,s),o=t-Ki(t,s),n=Math.abs(r-o)-_y(e,t,s);return No(n,zo(hf(e,t),i))}function gy(e,t,s,i,r,o){let n;$a(t,i,r,o).length>0?n=i-Ki(i,r):n=t;let a=i,c=vy(e,t,s,i,r,o);return No(df(e,n,s,a,c==="C",r).length,zo(c,o))}function _y(e,t,s){let i=0,r=e-Ki(e,s),o=t-Ki(t,s);for(let n=0;n<Math.abs(r-o);n++){let a=hf(e,t)==="A"?-1:1;s.buffer.lines.get(r+a*n)?.isWrapped&&i++}return i}function Ki(e,t){let s=0,i=t.buffer.lines.get(e),r=i?.isWrapped;for(;r&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),r=i?.isWrapped;return s}function vy(e,t,s,i,r,o){let n;return $a(s,i,r,o).length>0?n=i-Ki(i,r):n=t,e<s&&n<=i||e>=s&&n<i?"C":"D"}function hf(e,t){return e>t?"A":"B"}function df(e,t,s,i,r,o){let n=e,a=t,c="";for(;(n!==s||a!==i)&&a>=0&&a<o.buffer.lines.length;)n+=r?1:-1,r&&n>o.cols-1?(c+=o.buffer.translateBufferLineToString(a,!1,e,n),n=0,e=0,a++):!r&&n<0&&(c+=o.buffer.translateBufferLineToString(a,!1,0,e+1),n=o.cols-1,e=n,a--);return c+o.buffer.translateBufferLineToString(a,!1,e,n)}function zo(e,t){let s=t?"O":"[";return M.ESC+s+e}function No(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}function qu(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)}function ge(e,t){if(e!==void 0)try{return ke.toColor(e)}catch{}return t}function Dy(e,t,s,i,r,o){let n=[];for(let a=0;a<e.length-1;a++){let c=a,l=e.get(++c);if(!l.isWrapped)continue;let h=[e.get(a)];for(;c<e.length&&l.isWrapped;)h.push(l),l=e.get(++c);if(!o&&i>=a&&i<c){a+=h.length-1;continue}let d=0,m=Fo(h,d,t),p=1,f=0;for(;p<h.length;){let w=Fo(h,p,t),k=w-f,$=s-m,y=Math.min(k,$);h[d].copyCellsFrom(h[p],f,m,y,!1),m+=y,m===s&&(d++,m=0),f+=y,f===w&&(p++,f=0),m===0&&d!==0&&h[d-1].getWidth(s-1)===2&&(h[d].copyCellsFrom(h[d-1],s-1,m++,1,!1),h[d-1].setCell(s-1,r))}h[d].replaceCells(m,s,r);let _=0;for(let w=h.length-1;w>0&&(w>d||h[w].getTrimmedLength()===0);w--)_++;_>0&&(n.push(a+h.length-_),n.push(_)),a+=h.length-1}return n}function Ly(e,t){let s=[],i=0,r=t[i],o=0;for(let n=0;n<e.length;n++)if(r===n){let a=t[++i];e.onDeleteEmitter.fire({index:n-o,amount:a}),n+=a-1,o+=a,r=t[++i]}else s.push(n);return{layout:s,countRemoved:o}}function Py(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function By(e,t,s){let i=[],r=e.map((c,l)=>Fo(e,l,t)).reduce((c,l)=>c+l),o=0,n=0,a=0;for(;a<r;){if(r-a<s){i.push(r-a);break}o+=s;let c=Fo(e,n,t);o>c&&(o-=c,n++);let l=e[n].getWidth(o-1)===2;l&&o--;let h=l?s-1:s;i.push(h),a+=h}return i}function Fo(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}function Ny(e){return e==="block"||e==="underline"||e==="bar"}function Po(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&Po(e[i],t-1);return s}function lc(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}function Hy(e,t){let s=0,i=t.length-1,r;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e<t[r][0])i=r-1;else return!0;return!1}function rp(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}function np(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=Xy.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Jy.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let r=0;r<3;++r){let o=parseInt(t.slice(s*r,s*r+s),16);i[r]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function dc(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function Zy(e,t=16){let[s,i,r]=e;return`rgb:${dc(s,t)}/${dc(i,t)}/${dc(r,t)}`}function lp(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}function dp(e){return 0<=e&&e<256}function nw(e,t,s,i){let r={type:0,cancel:!1,key:void 0},o=(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=M.ESC+"OA":r.key=M.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=M.ESC+"OD":r.key=M.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=M.ESC+"OC":r.key=M.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=M.ESC+"OB":r.key=M.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":M.DEL,e.altKey&&(r.key=M.ESC+r.key);break;case 9:if(e.shiftKey){r.key=M.ESC+"[Z";break}r.key=M.HT,r.cancel=!0;break;case 13:r.key=e.altKey?M.ESC+M.CR:M.CR,r.cancel=!0;break;case 27:r.key=M.ESC,e.altKey&&(r.key=M.ESC+M.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"D":t?r.key=M.ESC+"OD":r.key=M.ESC+"[D";break;case 39:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"C":t?r.key=M.ESC+"OC":r.key=M.ESC+"[C";break;case 38:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"A":t?r.key=M.ESC+"OA":r.key=M.ESC+"[A";break;case 40:if(e.metaKey)break;o?r.key=M.ESC+"[1;"+(o+1)+"B":t?r.key=M.ESC+"OB":r.key=M.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=M.ESC+"[2~");break;case 46:o?r.key=M.ESC+"[3;"+(o+1)+"~":r.key=M.ESC+"[3~";break;case 36:o?r.key=M.ESC+"[1;"+(o+1)+"H":t?r.key=M.ESC+"OH":r.key=M.ESC+"[H";break;case 35:o?r.key=M.ESC+"[1;"+(o+1)+"F":t?r.key=M.ESC+"OF":r.key=M.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=M.ESC+"[5;"+(o+1)+"~":r.key=M.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=M.ESC+"[6;"+(o+1)+"~":r.key=M.ESC+"[6~";break;case 112:o?r.key=M.ESC+"[1;"+(o+1)+"P":r.key=M.ESC+"OP";break;case 113:o?r.key=M.ESC+"[1;"+(o+1)+"Q":r.key=M.ESC+"OQ";break;case 114:o?r.key=M.ESC+"[1;"+(o+1)+"R":r.key=M.ESC+"OR";break;case 115:o?r.key=M.ESC+"[1;"+(o+1)+"S":r.key=M.ESC+"OS";break;case 116:o?r.key=M.ESC+"[15;"+(o+1)+"~":r.key=M.ESC+"[15~";break;case 117:o?r.key=M.ESC+"[17;"+(o+1)+"~":r.key=M.ESC+"[17~";break;case 118:o?r.key=M.ESC+"[18;"+(o+1)+"~":r.key=M.ESC+"[18~";break;case 119:o?r.key=M.ESC+"[19;"+(o+1)+"~":r.key=M.ESC+"[19~";break;case 120:o?r.key=M.ESC+"[20;"+(o+1)+"~":r.key=M.ESC+"[20~";break;case 121:o?r.key=M.ESC+"[21;"+(o+1)+"~":r.key=M.ESC+"[21~";break;case 122:o?r.key=M.ESC+"[23;"+(o+1)+"~":r.key=M.ESC+"[23~";break;case 123:o?r.key=M.ESC+"[24;"+(o+1)+"~":r.key=M.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=M.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=M.DEL:e.keyCode===219?r.key=M.ESC:e.keyCode===220?r.key=M.FS:e.keyCode===221&&(r.key=M.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let n=ow[e.keyCode]?.[e.shiftKey?1:0];if(n)r.key=M.ESC+n;else if(e.keyCode>=65&&e.keyCode<=90){let a=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(a);e.shiftKey&&(c=c.toUpperCase()),r.key=M.ESC+c}else if(e.keyCode===32)r.key=M.ESC+(e.ctrlKey?M.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let a=e.code.slice(3,4);e.shiftKey||(a=a.toLowerCase()),r.key=M.ESC+a,r.cancel=!0}}else s&&!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=M.US),e.key==="@"&&(r.key=M.NUL));break}return r}function uw(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}function fw(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var vp,Nv,Fv,Ee,U,mu,pc,gu,fc,Uv,qv,wp,li,Ho,ua,qt,vu,mc,Jl,gt,kp,Gi,Yv,Jc,$p,_t,Ep,Xv,Wo,gc,Sa,Fs,Zc,Hs,Zv,Tp,Tr,Ap,Qv,eb,_c,sb,bu,bc,ob,Lp,ab,yu,wu,Su,J$,cb,Pp,db,Ui,ub,Mp,ci,re,Er,Mt,wc,xe,xu,gb,_b,vb,ku,bb,ot,Cc,yb,$u,zp,wb,kc,Sb,Cb,xb,ia,kb,$b,ra,N,Eb,$c,Qc,Q$,eE,Ar,Ec,oa,eh,Hp,tE,sE,na,$r,pa,fa,Mo,Db,Wp,jp,Lb,Pb,Bb,Mb,Jn,aa,Eu,Ib,Os,Ns,Bt,Vp,Ob,Zl,Up,_s,zb,Ql,Nb,iE,vs,ii,Fb,Hb,Wb,jb,rE,oE,nE,aE,ri,lE,th,ec,Tu,Au,Vb,qp,Ub,qb,Gb,Yb,Xb,Jb,Tc,Ru,Qb,Ao,Du,Gp,e0,t0,sh,s0,i0,tc,r0,Lu,u0,cE,rs,hE,dE,uE,Mu,pE,fE,p0,mE,gE,f0,Iu,_0,ma,v0,ic,Ou,_E,je,y0,S0,Zp,gs,Ro,x0,rh,zu,k0,$0,E0,Nu,Fu,D0,L0,Qp,ef,P0,B0,M0,Hu,Wu,I0,Lc,O0,z0,N0,Pc,Bc,H0,fs,oi,Co,ga,M,ca,tf,Mc,Ve,Ue,qe,$e,ju,Le,ye,ke,mt,ha,W0,_a,Ic,K0,G0,oc,jt,Qn,Uu,xo,ea,X0,Oc,zc,sf,J0,Z0,Q0,ey,ty,Nc,iy,rf,ka,jo,Vo,of,ry,nf,va,ny,ay,af,nh,lf,cf,ly,cy,ba,hy,Fc,dy,by,nc,yy,wy,Sy,Cy,xy,Hc,Ku,Gu,Me,Wi,Do,Yu,Xu,ko,ky,Wc,$y,Ey,Ty,Ay,jc,Ry,Ju,ae,De,ta,ac,Lo,pf,My,Oe,ji,Zu,Qu,Iy,mf,gf,Vc,kr,Oy,zy,ep,tp,Uc,sp,cc,ip,qc,hc,Fy,Ie,Wy,Vi,jy,$o,Vy,_f,Eo,Uy,Pt,To,qy,Bo,op,Ky,Ut,Gy,Yy,Xy,Jy,Qy,ni,ap,cp,hp,ew,Gc,tw,up,sw,iw,Yc,pp,rw,ow,Ae,aw,uc,fp,lw,cw,hw,dw,mp,gp,ya,Xc,pw,mw,gw,_p,_w,vw,bw,yw,ms,ww,lh=Sl(()=>{vp=Object.defineProperty,Nv=Object.getOwnPropertyDescriptor,Fv=(e,t)=>{for(var s in t)vp(e,s,{get:t[s],enumerable:!0})},Ee=(e,t,s,i)=>{for(var r=i>1?void 0:i?Nv(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&vp(t,s,r),r},U=(e,t)=>(s,i)=>t(s,i,e),mu="Terminal input",pc={get:()=>mu,set:e=>mu=e},gu="Too much output to announce, navigate to rows manually to read",fc={get:()=>gu,set:e=>gu=e};Uv=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let o=e.charCodeAt(r++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=r;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,i;let a=e.charCodeAt(o);56320<=a&&a<=57343?t[i++]=(n-55296)*1024+a-56320+65536:(t[i++]=n,t[i++]=a);continue}n!==65279&&(t[i++]=n)}return i}},qv=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,o,n,a,c=0,l=0;if(this.interim[0]){let m=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let f=0,_;for(;(_=this.interim[++f]&63)&&f<4;)p<<=6,p|=_;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=w-f;for(;l<k;){if(l>=s)return 0;if(_=e[l++],(_&192)!==128){l--,m=!0;break}else this.interim[f++]=_,p<<=6,p|=_&63}m||(w===2?p<128?l--:t[i++]=p:w===3?p<2048||p>=55296&&p<=57343||p===65279||(t[i++]=p):p<65536||p>1114111||(t[i++]=p)),this.interim.fill(0)}let h=s-4,d=l;for(;d<s;){for(;d<h&&!((r=e[d])&128)&&!((o=e[d+1])&128)&&!((n=e[d+2])&128)&&!((a=e[d+3])&128);)t[i++]=r,t[i++]=o,t[i++]=n,t[i++]=a,d+=4;if(r=e[d++],r<128)t[i++]=r;else if((r&224)===192){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(c=(r&31)<<6|o&63,c<128){d--;continue}t[i++]=c}else if((r&240)===224){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(c=(r&15)<<12|(o&63)<<6|n&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[i++]=c}else if((r&248)===240){if(d>=s)return this.interim[0]=r,i;if(o=e[d++],(o&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,i;if(n=e[d++],(n&192)!==128){d--;continue}if(d>=s)return this.interim[0]=r,this.interim[1]=o,this.interim[2]=n,i;if(a=e[d++],(a&192)!==128){d--;continue}if(c=(r&7)<<18|(o&63)<<12|(n&63)<<6|a&63,c<65536||c>1114111)continue;t[i++]=c}}return i}},wp="",li=" ",Ho=class Sp{constructor(){this.fg=0,this.bg=0,this.extended=new ua}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 Sp;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}},ua=class Cp{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}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 Cp(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},qt=class xp extends Ho{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new ua,this.combinedData=""}static fromCharData(t){let s=new xp;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ai(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 s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},vu="di$target",mc="di$dependencies",Jl=new Map;gt=Ke("BufferService"),kp=Ke("CoreMouseService"),Gi=Ke("CoreService"),Yv=Ke("CharsetService"),Jc=Ke("InstantiationService"),$p=Ke("LogService"),_t=Ke("OptionsService"),Ep=Ke("OscLinkService"),Xv=Ke("UnicodeService"),Wo=Ke("DecorationService"),gc=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,o=new qt,n=s.getTrimmedLength(),a=-1,c=-1,l=!1;for(let h=0;h<n;h++)if(!(c===-1&&!s.hasContent(h))){if(s.loadCell(h,o),o.hasExtendedAttrs()&&o.extended.urlId)if(c===-1){c=h,a=o.extended.urlId;continue}else l=o.extended.urlId!==a;else c!==-1&&(l=!0);if(l||c!==-1&&h===n-1){let d=this._oscLinkService.getLinkData(a)?.uri;if(d){let m={start:{x:c+1,y:e},end:{x:h+(!l&&h===n-1?1:0),y:e}},p=!1;if(!r?.allowNonHttpProtocols)try{let f=new URL(d);["http:","https:"].includes(f.protocol)||(p=!0)}catch{p=!0}p||i.push({text:d,range:m,activate:(f,_)=>r?r.activate(f,_,m):Jv(f,_),hover:(f,_)=>r?.hover?.(f,_,m),leave:(f,_)=>r?.leave?.(f,_,m)})}l=!1,o.hasExtendedAttrs()&&o.extended.urlId?(c=h,a=o.extended.urlId):(c=-1,a=-1)}}t(i)}};gc=Ee([U(0,gt),U(1,_t),U(2,Ep)],gc);Sa=Ke("CharSizeService"),Fs=Ke("CoreBrowserService"),Zc=Ke("MouseService"),Hs=Ke("RenderService"),Zv=Ke("SelectionService"),Tp=Ke("CharacterJoinerService"),Tr=Ke("ThemeService"),Ap=Ke("LinkProviderService"),Qv=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?bu.isErrorNoTelemetry(e)?new bu(e.message+`
4
4
 
5
5
  `+e.stack):new Error(e.message+`
6
6
 
7
- `+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)}},Qv=new Zv;_c="Canceled";tb=class extends Error{constructor(){super(_c),this.name=this.message}};bu=class vc extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vc)return t;let s=new vc;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},bc=class Rp extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Rp.prototype)}};rb=class Dp{constructor(t){this._array=t,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(Dp.assertInvariants){if(this._prevFindLastPredicate){for(let i of this._array)if(this._prevFindLastPredicate(i)&&!t(i))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}let s=ib(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=s+1,s===-1?void 0:this._array[s]}};rb.assertInvariants=!1;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function r(o){return o===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Lp||(Lp={}));nb=(e,t)=>e-t,yu=class yc{constructor(t){this.iterate=t}forEach(t){this.iterate(s=>(t(s),!0))}toArray(){let t=[];return this.iterate(s=>(t.push(s),!0)),t}filter(t){return new yc(s=>this.iterate(i=>t(i)?s(i):!0))}map(t){return new yc(s=>this.iterate(i=>s(t(i))))}some(t){let s=!1;return this.iterate(i=>(s=t(i),!s)),s}findFirst(t){let s;return this.iterate(i=>t(i)?(s=i,!1):!0),s}findLast(t){let s;return this.iterate(i=>(t(i)&&(s=i),!0)),s}findLastMaxBy(t){let s,i=!0;return this.iterate(r=>((i||Lp.isGreaterThan(t(r,s)))&&(i=!1,s=r),!0)),s}};yu.empty=new yu(e=>{});Y$=class{constructor(e,t){this.toKey=t,this._map=new Map,this[wu]="SetWithKey";for(let s of e)this.add(s)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(s=>e.call(t,s,s,this))}[(Su=Symbol.iterator,wu=Symbol.toStringTag,Su)](){return this.values()}},lb=class{constructor(){this.map=new Map}add(e,t){let s=this.map.get(e);s||(s=new Set,this.map.set(e,s)),s.add(t)}delete(e,t){let s=this.map.get(e);s&&(s.delete(t),s.size===0&&this.map.delete(e))}forEach(e,t){let s=this.map.get(e);s&&s.forEach(t)}get(e){return this.map.get(e)||new Set}};(e=>{function t(C){return C&&typeof C=="object"&&typeof C[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(C){yield C}e.single=r;function o(C){return t(C)?C:r(C)}e.wrap=o;function n(C){return C||s}e.from=n;function*a(C){for(let S=C.length-1;S>=0;S--)yield C[S]}e.reverse=a;function c(C){return!C||C[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(C){return C[Symbol.iterator]().next().value}e.first=l;function h(C,S){let L=0;for(let H of C)if(S(H,L++))return!0;return!1}e.some=h;function d(C,S){for(let L of C)if(S(L))return L}e.find=d;function*m(C,S){for(let L of C)S(L)&&(yield L)}e.filter=m;function*p(C,S){let L=0;for(let H of C)yield S(H,L++)}e.map=p;function*f(C,S){let L=0;for(let H of C)yield*S(H,L++)}e.flatMap=f;function*_(...C){for(let S of C)yield*S}e.concat=_;function w(C,S,L){let H=L;for(let F of C)H=S(H,F);return H}e.reduce=w;function*k(C,S,L=C.length){for(S<0&&(S+=C.length),L<0?L+=C.length:L>C.length&&(L=C.length);S<L;S++)yield C[S]}e.slice=k;function $(C,S=Number.POSITIVE_INFINITY){let L=[];if(S===0)return[L,C];let H=C[Symbol.iterator]();for(let F=0;F<S;F++){let W=H.next();if(W.done)return[L,e.empty()];L.push(W.value)}return[L,{[Symbol.iterator](){return H}}]}e.consume=$;async function y(C){let S=[];for await(let L of C)S.push(L);return Promise.resolve(S)}e.asyncToArray=y})(Pp||(Pp={}));hb=!1,Ui=null,db=class Bp{constructor(){this.livingDisposables=new Map}getDisposableData(t){let s=this.livingDisposables.get(t);return s||(s={parent:null,source:null,isSingleton:!1,value:t,idx:Bp.idx++},this.livingDisposables.set(t,s)),s}trackDisposable(t){let s=this.getDisposableData(t);s.source||(s.source=new Error().stack)}setParent(t,s){let i=this.getDisposableData(t);i.parent=s}markAsDisposed(t){this.livingDisposables.delete(t)}markAsSingleton(t){this.getDisposableData(t).isSingleton=!0}getRootParent(t,s){let i=s.get(t);if(i)return i;let r=t.parent?this.getRootParent(this.getDisposableData(t.parent),s):t;return s.set(t,r),r}getTrackedDisposables(){let t=new Map;return[...this.livingDisposables.entries()].filter(([,s])=>s.source!==null&&!this.getRootParent(s,t).isSingleton).flatMap(([s])=>s)}computeLeakingDisposables(t=10,s){let i;if(s)i=s;else{let c=new Map,l=[...this.livingDisposables.values()].filter(d=>d.source!==null&&!this.getRootParent(d,c).isSingleton);if(l.length===0)return;let h=new Set(l.map(d=>d.value));if(i=l.filter(d=>!(d.parent&&h.has(d.parent))),i.length===0)throw new Error("There are cyclic diposable chains!")}if(!i)return;function r(c){function l(d,m){for(;d.length>0&&m.some(p=>typeof p=="string"?p===d[0]:d[0].match(p));)d.shift()}let h=c.source.split(`
8
- `).map(d=>d.trim().replace("at ","")).filter(d=>d!=="");return l(h,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),h.reverse()}let o=new lb;for(let c of i){let l=r(c);for(let h=0;h<=l.length;h++)o.add(l.slice(0,h).join(`
9
- `),c)}i.sort(ob(c=>c.idx,nb));let n="",a=0;for(let c of i.slice(0,t)){a++;let l=r(c),h=[];for(let d=0;d<l.length;d++){let m=l[d];m=`(shared with ${o.get(l.slice(0,d+1).join(`
7
+ `+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)}},eb=new Qv;_c="Canceled";sb=class extends Error{constructor(){super(_c),this.name=this.message}};bu=class vc extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vc)return t;let s=new vc;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},bc=class Rp extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,Rp.prototype)}};ob=class Dp{constructor(t){this._array=t,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(Dp.assertInvariants){if(this._prevFindLastPredicate){for(let i of this._array)if(this._prevFindLastPredicate(i)&&!t(i))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}let s=rb(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=s+1,s===-1?void 0:this._array[s]}};ob.assertInvariants=!1;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function r(o){return o===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Lp||(Lp={}));ab=(e,t)=>e-t,yu=class yc{constructor(t){this.iterate=t}forEach(t){this.iterate(s=>(t(s),!0))}toArray(){let t=[];return this.iterate(s=>(t.push(s),!0)),t}filter(t){return new yc(s=>this.iterate(i=>t(i)?s(i):!0))}map(t){return new yc(s=>this.iterate(i=>s(t(i))))}some(t){let s=!1;return this.iterate(i=>(s=t(i),!s)),s}findFirst(t){let s;return this.iterate(i=>t(i)?(s=i,!1):!0),s}findLast(t){let s;return this.iterate(i=>(t(i)&&(s=i),!0)),s}findLastMaxBy(t){let s,i=!0;return this.iterate(r=>((i||Lp.isGreaterThan(t(r,s)))&&(i=!1,s=r),!0)),s}};yu.empty=new yu(e=>{});J$=class{constructor(e,t){this.toKey=t,this._map=new Map,this[wu]="SetWithKey";for(let s of e)this.add(s)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(s=>e.call(t,s,s,this))}[(Su=Symbol.iterator,wu=Symbol.toStringTag,Su)](){return this.values()}},cb=class{constructor(){this.map=new Map}add(e,t){let s=this.map.get(e);s||(s=new Set,this.map.set(e,s)),s.add(t)}delete(e,t){let s=this.map.get(e);s&&(s.delete(t),s.size===0&&this.map.delete(e))}forEach(e,t){let s=this.map.get(e);s&&s.forEach(t)}get(e){return this.map.get(e)||new Set}};(e=>{function t(C){return C&&typeof C=="object"&&typeof C[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(C){yield C}e.single=r;function o(C){return t(C)?C:r(C)}e.wrap=o;function n(C){return C||s}e.from=n;function*a(C){for(let S=C.length-1;S>=0;S--)yield C[S]}e.reverse=a;function c(C){return!C||C[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(C){return C[Symbol.iterator]().next().value}e.first=l;function h(C,S){let L=0;for(let H of C)if(S(H,L++))return!0;return!1}e.some=h;function d(C,S){for(let L of C)if(S(L))return L}e.find=d;function*m(C,S){for(let L of C)S(L)&&(yield L)}e.filter=m;function*p(C,S){let L=0;for(let H of C)yield S(H,L++)}e.map=p;function*f(C,S){let L=0;for(let H of C)yield*S(H,L++)}e.flatMap=f;function*_(...C){for(let S of C)yield*S}e.concat=_;function w(C,S,L){let H=L;for(let F of C)H=S(H,F);return H}e.reduce=w;function*k(C,S,L=C.length){for(S<0&&(S+=C.length),L<0?L+=C.length:L>C.length&&(L=C.length);S<L;S++)yield C[S]}e.slice=k;function $(C,S=Number.POSITIVE_INFINITY){let L=[];if(S===0)return[L,C];let H=C[Symbol.iterator]();for(let F=0;F<S;F++){let W=H.next();if(W.done)return[L,e.empty()];L.push(W.value)}return[L,{[Symbol.iterator](){return H}}]}e.consume=$;async function y(C){let S=[];for await(let L of C)S.push(L);return Promise.resolve(S)}e.asyncToArray=y})(Pp||(Pp={}));db=!1,Ui=null,ub=class Bp{constructor(){this.livingDisposables=new Map}getDisposableData(t){let s=this.livingDisposables.get(t);return s||(s={parent:null,source:null,isSingleton:!1,value:t,idx:Bp.idx++},this.livingDisposables.set(t,s)),s}trackDisposable(t){let s=this.getDisposableData(t);s.source||(s.source=new Error().stack)}setParent(t,s){let i=this.getDisposableData(t);i.parent=s}markAsDisposed(t){this.livingDisposables.delete(t)}markAsSingleton(t){this.getDisposableData(t).isSingleton=!0}getRootParent(t,s){let i=s.get(t);if(i)return i;let r=t.parent?this.getRootParent(this.getDisposableData(t.parent),s):t;return s.set(t,r),r}getTrackedDisposables(){let t=new Map;return[...this.livingDisposables.entries()].filter(([,s])=>s.source!==null&&!this.getRootParent(s,t).isSingleton).flatMap(([s])=>s)}computeLeakingDisposables(t=10,s){let i;if(s)i=s;else{let c=new Map,l=[...this.livingDisposables.values()].filter(d=>d.source!==null&&!this.getRootParent(d,c).isSingleton);if(l.length===0)return;let h=new Set(l.map(d=>d.value));if(i=l.filter(d=>!(d.parent&&h.has(d.parent))),i.length===0)throw new Error("There are cyclic diposable chains!")}if(!i)return;function r(c){function l(d,m){for(;d.length>0&&m.some(p=>typeof p=="string"?p===d[0]:d[0].match(p));)d.shift()}let h=c.source.split(`
8
+ `).map(d=>d.trim().replace("at ","")).filter(d=>d!=="");return l(h,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),h.reverse()}let o=new cb;for(let c of i){let l=r(c);for(let h=0;h<=l.length;h++)o.add(l.slice(0,h).join(`
9
+ `),c)}i.sort(nb(c=>c.idx,ab));let n="",a=0;for(let c of i.slice(0,t)){a++;let l=r(c),h=[];for(let d=0;d<l.length;d++){let m=l[d];m=`(shared with ${o.get(l.slice(0,d+1).join(`
10
10
  `)).size}/${i.length} leaks) at ${m}`;let p=o.get(l.slice(0,d).join(`
11
- `)),f=ab([...p].map(_=>r(_)[d]),_=>_);delete f[l[d]];for(let[_,w]of Object.entries(f))h.unshift(` - stacktraces of ${w.length} other leaks continue with ${_}`);h.unshift(m)}n+=`
11
+ `)),f=lb([...p].map(_=>r(_)[d]),_=>_);delete f[l[d]];for(let[_,w]of Object.entries(f))h.unshift(` - stacktraces of ${w.length} other leaks continue with ${_}`);h.unshift(m)}n+=`
12
12
 
13
13
 
14
14
  ==================== Leaking disposable ${a}/${i.length}: ${c.value.constructor.name} ====================
@@ -21,27 +21,27 @@ ${h.join(`
21
21
 
22
22
  ... and ${i.length-t} more leaking disposables
23
23
 
24
- `),{leaks:i,details:n}}};db.idx=0;if(hb){let e="__is_disposable_tracked__";ub(new class{trackDisposable(t){let s=new Error("Potentially leaked disposable").stack;setTimeout(()=>{t[e]||console.log(s)},3e3)}setParent(t,s){if(t&&t!==re.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==re.None)try{t[e]=!0}catch{}}markAsSingleton(t){}})}Mp=class Ip{constructor(){this._toDispose=new Set,this._isDisposed=!1,Ca(this)}dispose(){this._isDisposed||(xa(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{qi(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 Oo(t,this),this._isDisposed?Ip.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),Oo(t,null))}};Mp.DISABLE_DISPOSED_WARNING=!1;ci=Mp,re=class{constructor(){this._store=new ci,Ca(this),Oo(this._store,this)}dispose(){xa(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};re.None=Object.freeze({dispose(){}});Er=class{constructor(){this._isDisposed=!1,Ca(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Oo(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,xa(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Oo(e,null),e}},Mt=typeof window=="object"?window:globalThis,wc=class Sc{constructor(t){this.element=t,this.next=Sc.Undefined,this.prev=Sc.Undefined}};wc.Undefined=new wc(void 0);xe=wc,xu=class{constructor(){this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===xe.Undefined}clear(){let e=this._first;for(;e!==xe.Undefined;){let t=e.next;e.prev=xe.Undefined,e.next=xe.Undefined,e=t}this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new xe(e);if(this._first===xe.Undefined)this._first=s,this._last=s;else if(t){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==xe.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==xe.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==xe.Undefined&&e.next!==xe.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===xe.Undefined&&e.next===xe.Undefined?(this._first=xe.Undefined,this._last=xe.Undefined):e.next===xe.Undefined?(this._last=this._last.prev,this._last.next=xe.Undefined):e.prev===xe.Undefined&&(this._first=this._first.next,this._first.prev=xe.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==xe.Undefined;)yield e.element,e=e.next}},mb=globalThis.performance&&typeof globalThis.performance.now=="function",gb=class Op{static create(t){return new Op(t)}constructor(t){this._now=mb&&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}},_b=!1,ku=!1,vb=!1;(e=>{e.None=()=>re.None;function t(T){if(vb){let{onDidAddListener:x}=T,D=kc.create(),A=0;T.onDidAddListener=()=>{++A===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),D.print()),x?.()}}}function s(T,x){return m(T,()=>{},0,void 0,!0,void 0,x)}e.defer=s;function i(T){return(x,D=null,A)=>{let B=!1,P;return P=T(V=>{if(!B)return P?P.dispose():B=!0,x.call(D,V)},null,A),B&&P.dispose(),P}}e.once=i;function r(T,x,D){return h((A,B=null,P)=>T(V=>A.call(B,x(V)),null,P),D)}e.map=r;function o(T,x,D){return h((A,B=null,P)=>T(V=>{x(V),A.call(B,V)},null,P),D)}e.forEach=o;function n(T,x,D){return h((A,B=null,P)=>T(V=>x(V)&&A.call(B,V),null,P),D)}e.filter=n;function a(T){return T}e.signal=a;function c(...T){return(x,D=null,A)=>{let B=fb(...T.map(P=>P(V=>x.call(D,V))));return d(B,A)}}e.any=c;function l(T,x,D,A){let B=D;return r(T,P=>(B=x(B,P),B),A)}e.reduce=l;function h(T,x){let D,A={onWillAddFirstListener(){D=T(B.fire,B)},onDidRemoveLastListener(){D?.dispose()}};x||t(A);let B=new N(A);return x?.add(B),B.event}function d(T,x){return x instanceof Array?x.push(T):x&&x.add(T),T}function m(T,x,D=100,A=!1,B=!1,P,V){let se,de,tt,yt=0,Se,es={leakWarningThreshold:P,onWillAddFirstListener(){se=T(Es=>{yt++,de=x(de,Es),A&&!tt&&(Re.fire(de),de=void 0),Se=()=>{let Ti=de;de=void 0,tt=void 0,(!A||yt>1)&&Re.fire(Ti),yt=0},typeof D=="number"?(clearTimeout(tt),tt=setTimeout(Se,D)):tt===void 0&&(tt=0,queueMicrotask(Se))})},onWillRemoveListener(){B&&yt>0&&Se?.()},onDidRemoveLastListener(){Se=void 0,se.dispose()}};V||t(es);let Re=new N(es);return V?.add(Re),Re.event}e.debounce=m;function p(T,x=0,D){return e.debounce(T,(A,B)=>A?(A.push(B),A):[B],x,void 0,!0,void 0,D)}e.accumulate=p;function f(T,x=(A,B)=>A===B,D){let A=!0,B;return n(T,P=>{let V=A||!x(P,B);return A=!1,B=P,V},D)}e.latch=f;function _(T,x,D){return[e.filter(T,x,D),e.filter(T,A=>!x(A),D)]}e.split=_;function w(T,x=!1,D=[],A){let B=D.slice(),P=T(de=>{B?B.push(de):se.fire(de)});A&&A.add(P);let V=()=>{B?.forEach(de=>se.fire(de)),B=null},se=new N({onWillAddFirstListener(){P||(P=T(de=>se.fire(de)),A&&A.add(P))},onDidAddFirstListener(){B&&(x?setTimeout(V):V())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return A&&A.add(se),se.event}e.buffer=w;function k(T,x){return(D,A,B)=>{let P=x(new y);return T(function(V){let se=P.evaluate(V);se!==$&&D.call(A,se)},void 0,B)}}e.chain=k;let $=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(x){return this.steps.push(x),this}forEach(x){return this.steps.push(D=>(x(D),D)),this}filter(x){return this.steps.push(D=>x(D)?D:$),this}reduce(x,D){let A=D;return this.steps.push(B=>(A=x(A,B),A)),this}latch(x=(D,A)=>D===A){let D=!0,A;return this.steps.push(B=>{let P=D||!x(B,A);return D=!1,A=B,P?B:$}),this}evaluate(x){for(let D of this.steps)if(x=D(x),x===$)break;return x}}function C(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.on(x,A),P=()=>T.removeListener(x,A),V=new N({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromNodeEventEmitter=C;function S(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.addEventListener(x,A),P=()=>T.removeEventListener(x,A),V=new N({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromDOMEventEmitter=S;function L(T){return new Promise(x=>i(T)(x))}e.toPromise=L;function H(T){let x=new N;return T.then(D=>{x.fire(D)},()=>{x.fire(void 0)}).finally(()=>{x.dispose()}),x.event}e.fromPromise=H;function F(T,x){return T(D=>x.fire(D))}e.forward=F;function W(T,x,D){return x(D),T(A=>x(A))}e.runAndSubscribe=W;class ie{constructor(x,D){this._observable=x,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{x.addObserver(this)},onDidRemoveLastListener:()=>{x.removeObserver(this)}};D||t(A),this.emitter=new N(A),D&&D.add(this.emitter)}beginUpdate(x){this._counter++}handlePossibleChange(x){}handleChange(x,D){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 j(T,x){return new ie(T,x).emitter.event}e.fromObservable=j;function ce(T){return(x,D,A)=>{let B=0,P=!1,V={beginUpdate(){B++},endUpdate(){B--,B===0&&(T.reportChanges(),P&&(P=!1,x.call(D)))},handlePossibleChange(){},handleChange(){P=!0}};T.addObserver(V),T.reportChanges();let se={dispose(){T.removeObserver(V)}};return A instanceof ci?A.add(se):Array.isArray(A)&&A.push(se),se}}e.fromObservableLight=ce})(ot||(ot={}));Cc=class xc{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${xc._idPool++}`,xc.all.add(this)}start(t){this._stopWatch=new gb,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}}};Cc.all=new Set,Cc._idPool=0;bb=Cc,$u=-1,zp=class Np{constructor(t,s,i=(Np._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)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=i*.5;let[o,n]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${n}):`;console.warn(a),console.warn(o);let c=new wb(a,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s<r)&&(t=[i,r],s=r);return t}};zp._idPool=1;yb=zp,kc=class Fp{constructor(t){this.value=t}static create(){let t=new Error;return new Fp(t.stack??"")}print(){console.warn(this.value.split(`
24
+ `),{leaks:i,details:n}}};ub.idx=0;if(db){let e="__is_disposable_tracked__";pb(new class{trackDisposable(t){let s=new Error("Potentially leaked disposable").stack;setTimeout(()=>{t[e]||console.log(s)},3e3)}setParent(t,s){if(t&&t!==re.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==re.None)try{t[e]=!0}catch{}}markAsSingleton(t){}})}Mp=class Ip{constructor(){this._toDispose=new Set,this._isDisposed=!1,Ca(this)}dispose(){this._isDisposed||(xa(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{qi(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 Oo(t,this),this._isDisposed?Ip.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),Oo(t,null))}};Mp.DISABLE_DISPOSED_WARNING=!1;ci=Mp,re=class{constructor(){this._store=new ci,Ca(this),Oo(this._store,this)}dispose(){xa(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};re.None=Object.freeze({dispose(){}});Er=class{constructor(){this._isDisposed=!1,Ca(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Oo(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,xa(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Oo(e,null),e}},Mt=typeof window=="object"?window:globalThis,wc=class Sc{constructor(t){this.element=t,this.next=Sc.Undefined,this.prev=Sc.Undefined}};wc.Undefined=new wc(void 0);xe=wc,xu=class{constructor(){this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===xe.Undefined}clear(){let e=this._first;for(;e!==xe.Undefined;){let t=e.next;e.prev=xe.Undefined,e.next=xe.Undefined,e=t}this._first=xe.Undefined,this._last=xe.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new xe(e);if(this._first===xe.Undefined)this._first=s,this._last=s;else if(t){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==xe.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==xe.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==xe.Undefined&&e.next!==xe.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===xe.Undefined&&e.next===xe.Undefined?(this._first=xe.Undefined,this._last=xe.Undefined):e.next===xe.Undefined?(this._last=this._last.prev,this._last.next=xe.Undefined):e.prev===xe.Undefined&&(this._first=this._first.next,this._first.prev=xe.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==xe.Undefined;)yield e.element,e=e.next}},gb=globalThis.performance&&typeof globalThis.performance.now=="function",_b=class Op{static create(t){return new Op(t)}constructor(t){this._now=gb&&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}},vb=!1,ku=!1,bb=!1;(e=>{e.None=()=>re.None;function t(T){if(bb){let{onDidAddListener:x}=T,D=kc.create(),A=0;T.onDidAddListener=()=>{++A===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),D.print()),x?.()}}}function s(T,x){return m(T,()=>{},0,void 0,!0,void 0,x)}e.defer=s;function i(T){return(x,D=null,A)=>{let B=!1,P;return P=T(V=>{if(!B)return P?P.dispose():B=!0,x.call(D,V)},null,A),B&&P.dispose(),P}}e.once=i;function r(T,x,D){return h((A,B=null,P)=>T(V=>A.call(B,x(V)),null,P),D)}e.map=r;function o(T,x,D){return h((A,B=null,P)=>T(V=>{x(V),A.call(B,V)},null,P),D)}e.forEach=o;function n(T,x,D){return h((A,B=null,P)=>T(V=>x(V)&&A.call(B,V),null,P),D)}e.filter=n;function a(T){return T}e.signal=a;function c(...T){return(x,D=null,A)=>{let B=mb(...T.map(P=>P(V=>x.call(D,V))));return d(B,A)}}e.any=c;function l(T,x,D,A){let B=D;return r(T,P=>(B=x(B,P),B),A)}e.reduce=l;function h(T,x){let D,A={onWillAddFirstListener(){D=T(B.fire,B)},onDidRemoveLastListener(){D?.dispose()}};x||t(A);let B=new N(A);return x?.add(B),B.event}function d(T,x){return x instanceof Array?x.push(T):x&&x.add(T),T}function m(T,x,D=100,A=!1,B=!1,P,V){let se,de,tt,yt=0,Se,es={leakWarningThreshold:P,onWillAddFirstListener(){se=T(Es=>{yt++,de=x(de,Es),A&&!tt&&(Re.fire(de),de=void 0),Se=()=>{let Ti=de;de=void 0,tt=void 0,(!A||yt>1)&&Re.fire(Ti),yt=0},typeof D=="number"?(clearTimeout(tt),tt=setTimeout(Se,D)):tt===void 0&&(tt=0,queueMicrotask(Se))})},onWillRemoveListener(){B&&yt>0&&Se?.()},onDidRemoveLastListener(){Se=void 0,se.dispose()}};V||t(es);let Re=new N(es);return V?.add(Re),Re.event}e.debounce=m;function p(T,x=0,D){return e.debounce(T,(A,B)=>A?(A.push(B),A):[B],x,void 0,!0,void 0,D)}e.accumulate=p;function f(T,x=(A,B)=>A===B,D){let A=!0,B;return n(T,P=>{let V=A||!x(P,B);return A=!1,B=P,V},D)}e.latch=f;function _(T,x,D){return[e.filter(T,x,D),e.filter(T,A=>!x(A),D)]}e.split=_;function w(T,x=!1,D=[],A){let B=D.slice(),P=T(de=>{B?B.push(de):se.fire(de)});A&&A.add(P);let V=()=>{B?.forEach(de=>se.fire(de)),B=null},se=new N({onWillAddFirstListener(){P||(P=T(de=>se.fire(de)),A&&A.add(P))},onDidAddFirstListener(){B&&(x?setTimeout(V):V())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return A&&A.add(se),se.event}e.buffer=w;function k(T,x){return(D,A,B)=>{let P=x(new y);return T(function(V){let se=P.evaluate(V);se!==$&&D.call(A,se)},void 0,B)}}e.chain=k;let $=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(x){return this.steps.push(x),this}forEach(x){return this.steps.push(D=>(x(D),D)),this}filter(x){return this.steps.push(D=>x(D)?D:$),this}reduce(x,D){let A=D;return this.steps.push(B=>(A=x(A,B),A)),this}latch(x=(D,A)=>D===A){let D=!0,A;return this.steps.push(B=>{let P=D||!x(B,A);return D=!1,A=B,P?B:$}),this}evaluate(x){for(let D of this.steps)if(x=D(x),x===$)break;return x}}function C(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.on(x,A),P=()=>T.removeListener(x,A),V=new N({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromNodeEventEmitter=C;function S(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.addEventListener(x,A),P=()=>T.removeEventListener(x,A),V=new N({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromDOMEventEmitter=S;function L(T){return new Promise(x=>i(T)(x))}e.toPromise=L;function H(T){let x=new N;return T.then(D=>{x.fire(D)},()=>{x.fire(void 0)}).finally(()=>{x.dispose()}),x.event}e.fromPromise=H;function F(T,x){return T(D=>x.fire(D))}e.forward=F;function W(T,x,D){return x(D),T(A=>x(A))}e.runAndSubscribe=W;class ie{constructor(x,D){this._observable=x,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{x.addObserver(this)},onDidRemoveLastListener:()=>{x.removeObserver(this)}};D||t(A),this.emitter=new N(A),D&&D.add(this.emitter)}beginUpdate(x){this._counter++}handlePossibleChange(x){}handleChange(x,D){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 j(T,x){return new ie(T,x).emitter.event}e.fromObservable=j;function ce(T){return(x,D,A)=>{let B=0,P=!1,V={beginUpdate(){B++},endUpdate(){B--,B===0&&(T.reportChanges(),P&&(P=!1,x.call(D)))},handlePossibleChange(){},handleChange(){P=!0}};T.addObserver(V),T.reportChanges();let se={dispose(){T.removeObserver(V)}};return A instanceof ci?A.add(se):Array.isArray(A)&&A.push(se),se}}e.fromObservableLight=ce})(ot||(ot={}));Cc=class xc{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${xc._idPool++}`,xc.all.add(this)}start(t){this._stopWatch=new _b,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}}};Cc.all=new Set,Cc._idPool=0;yb=Cc,$u=-1,zp=class Np{constructor(t,s,i=(Np._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)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=i*.5;let[o,n]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${n}):`;console.warn(a),console.warn(o);let c=new Sb(a,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s<r)&&(t=[i,r],s=r);return t}};zp._idPool=1;wb=zp,kc=class Fp{constructor(t){this.value=t}static create(){let t=new Error;return new Fp(t.stack??"")}print(){console.warn(this.value.split(`
25
25
  `).slice(2).join(`
26
- `))}},wb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Sb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Cb=0,ia=class{constructor(e){this.value=e,this.id=Cb++}},xb=2,kb=(e,t)=>{if(e instanceof ia)t(e);else for(let s=0;s<e.length;s++){let i=e[s];i&&t(i)}};if(_b){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
27
- `)),e.length=0)},3e3),ra=new FinalizationRegistry(t=>{typeof t=="string"&&e.push(t)})}N=class{constructor(e){this._size=0,this._options=e,this._leakageMon=$u>0||this._options?.leakWarningThreshold?new yb(e?.onListenerError??sa,this._options?.leakWarningThreshold??$u):void 0,this._perfMon=this._options?._profName?new bb(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(ku){let e=this._listeners;queueMicrotask(()=>{kb(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??(this._event=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Sb(`${a}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(this._options?.onListenerError||sa)(l),re.None}if(this._disposed)return re.None;t&&(e=e.bind(t));let i=new ia(e),r,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=kc.create(),r=this._leakageMon.check(i.stack,this._size+1)),ku&&(i.stack=o??kc.create()),this._listeners?this._listeners instanceof ia?(this._deliveryQueue??(this._deliveryQueue=new $b),this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=we(()=>{ra?.unregister(n),r?.(),this._removeListener(i)});if(s instanceof ci?s.add(n):Array.isArray(s)&&s.push(n),ra){let a=new Error().stack.split(`
26
+ `))}},Sb=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Cb=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},xb=0,ia=class{constructor(e){this.value=e,this.id=xb++}},kb=2,$b=(e,t)=>{if(e instanceof ia)t(e);else for(let s=0;s<e.length;s++){let i=e[s];i&&t(i)}};if(vb){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
27
+ `)),e.length=0)},3e3),ra=new FinalizationRegistry(t=>{typeof t=="string"&&e.push(t)})}N=class{constructor(e){this._size=0,this._options=e,this._leakageMon=$u>0||this._options?.leakWarningThreshold?new wb(e?.onListenerError??sa,this._options?.leakWarningThreshold??$u):void 0,this._perfMon=this._options?._profName?new yb(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(ku){let e=this._listeners;queueMicrotask(()=>{$b(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??(this._event=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Cb(`${a}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(this._options?.onListenerError||sa)(l),re.None}if(this._disposed)return re.None;t&&(e=e.bind(t));let i=new ia(e),r,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=kc.create(),r=this._leakageMon.check(i.stack,this._size+1)),ku&&(i.stack=o??kc.create()),this._listeners?this._listeners instanceof ia?(this._deliveryQueue??(this._deliveryQueue=new Eb),this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=we(()=>{ra?.unregister(n),r?.(),this._removeListener(i)});if(s instanceof ci?s.add(n):Array.isArray(s)&&s.push(n),ra){let a=new Error().stack.split(`
28
28
  `).slice(2,3).join(`
29
- `).trim(),c=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);ra.register(n,c?.[2]??a,n)}return n}),this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-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[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*xb<=t.length){let r=0;for(let o=0;o<t.length;o++)t[o]?t[r++]=t[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||sa;if(!s){e.value(t);return}try{e.value(t)}catch(i){s(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof ia)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},$b=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},$c=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new N,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new N,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};$c.INSTANCE=new $c;Qc=$c;J$=Qc.INSTANCE.onDidChangeZoomLevel;Z$=Qc.INSTANCE.onDidChangeFullscreen,Ar=typeof navigator=="object"?navigator.userAgent:"",Ec=Ar.indexOf("Firefox")>=0,oa=Ar.indexOf("AppleWebKit")>=0,eh=Ar.indexOf("Chrome")>=0,Hp=!eh&&Ar.indexOf("Safari")>=0,Q$=Ar.indexOf("Electron/")>=0,eE=Ar.indexOf("Android")>=0,na=!1;if(typeof Mt.matchMedia=="function"){let e=Mt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Mt.matchMedia("(display-mode: fullscreen)");na=e.matches,Eb(Mt,e,({matches:s})=>{na&&t.matches||(na=s)})}$r="en",pa=!1,fa=!1,Mo=!1,Rb=!1,Wp=!1,jp=!1,Db=!1,Lb=!1,Pb=!1,Bb=!1,aa=$r,Eu=$r,Ns=globalThis;typeof Ns.vscode<"u"&&typeof Ns.vscode.process<"u"?Bt=Ns.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Bt=process);Vp=typeof Bt?.versions?.electron=="string",Ib=Vp&&Bt?.type==="renderer";if(typeof Bt=="object"){pa=Bt.platform==="win32",fa=Bt.platform==="darwin",Mo=Bt.platform==="linux",Rb=Mo&&!!Bt.env.SNAP&&!!Bt.env.SNAP_REVISION,Db=Vp,Pb=!!Bt.env.CI||!!Bt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Jn=$r,aa=$r;let e=Bt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Jn=t.userLocale,Eu=t.osLocale,aa=t.resolvedLanguage||$r,Mb=t.languagePack?.translationsConfigFile}catch{}Wp=!0}else typeof navigator=="object"&&!Ib?(Os=navigator.userAgent,pa=Os.indexOf("Windows")>=0,fa=Os.indexOf("Macintosh")>=0,Lb=(Os.indexOf("Macintosh")>=0||Os.indexOf("iPad")>=0||Os.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Mo=Os.indexOf("Linux")>=0,Bb=Os?.indexOf("Mobi")>=0,jp=!0,aa=globalThis._VSCODE_NLS_LANGUAGE||$r,Jn=navigator.language.toLowerCase(),Eu=Jn):console.error("Unable to resolve platform.");Zl=0;fa?Zl=1:pa?Zl=3:Mo&&(Zl=2);Up=pa,_s=fa,Ob=Mo,Ql=Wp,zb=jp&&typeof Ns.importScripts=="function",tE=zb?Ns.origin:void 0,vs=Os,ii=aa;(e=>{function t(){return ii}e.value=t;function s(){return ii.length===2?ii==="en":ii.length>=3?ii[0]==="e"&&ii[1]==="n"&&ii[2]==="-":!1}e.isDefaultVariant=s;function i(){return ii==="en"}e.isDefault=i})(Nb||(Nb={}));Fb=typeof Ns.postMessage=="function"&&!Ns.importScripts,Hb=(()=>{if(Fb){let e=[];Ns.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Ns.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),Wb=!!(vs&&vs.indexOf("Chrome")>=0),sE=!!(vs&&vs.indexOf("Firefox")>=0),iE=!!(!Wb&&vs&&vs.indexOf("Safari")>=0),rE=!!(vs&&vs.indexOf("Edg/")>=0),oE=!!(vs&&vs.indexOf("Android")>=0),ri=typeof navigator=="object"?navigator:{},nE={clipboard:{writeText:Ql||document.queryCommandSupported&&document.queryCommandSupported("copy")||!!(ri&&ri.clipboard&&ri.clipboard.writeText),readText:Ql||!!(ri&&ri.clipboard&&ri.clipboard.readText)},keyboard:Ql||Ab()?0:ri.keyboard||Hp?1:2,touch:"ontouchstart"in Mt||ri.maxTouchPoints>0,pointerEvents:Mt.PointerEvent&&("ontouchstart"in Mt||navigator.maxTouchPoints>0)},th=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}},ec=new th,Tu=new th,Au=new th,jb=new Array(230);(e=>{function t(a){return ec.keyCodeToStr(a)}e.toString=t;function s(a){return ec.strToKeyCode(a)}e.fromString=s;function i(a){return Tu.keyCodeToStr(a)}e.toUserSettingsUS=i;function r(a){return Au.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function o(a){return Tu.strToKeyCode(a)||Au.strToKeyCode(a)}e.fromUserSettings=o;function n(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 ec.keyCodeToStr(a)}e.toElectronAccelerator=n})(qp||(qp={}));Vb=class Kp{constructor(t,s,i,r,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(t){return t instanceof Kp&&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",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Ub([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Ub=class{constructor(e){if(e.length===0)throw sb("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;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}};Kb=_s?256:2048,Gb=512,Yb=1024,Xb=_s?2048:256,Tc=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=qb(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|=Kb),this.altKey&&(t|=Gb),this.shiftKey&&(t|=Yb),this.metaKey&&(t|=Xb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Vb(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ru=new WeakMap;Zb=class{static getSameOriginWindowChain(e){let t=Ru.get(e);if(!t){t=[],Ru.set(e,t);let s=e,i;do i=Jb(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(e);for(let o of r){let n=o.window.deref();if(s+=n?.scrollY??0,i+=n?.scrollX??0,n===t||!o.iframeElement)break;let a=o.iframeElement.getBoundingClientRect();s+=a.top,i+=a.left}return{top:s,left:i}}},Ao=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 s=Zb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Du=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(eh){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(e){let r=e,o=e,n=e.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*n):this.deltaY=r.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 a=e;a.deltaMode===a.DOM_DELTA_LINE?Ec&&!_s?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof r.wheelDeltaX<"u")Hp&&Up?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*n):this.deltaX=r.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 a=e;a.deltaMode===a.DOM_DELTA_LINE?Ec&&!_s?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*n):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Gp=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}});(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof e0?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ot.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gp})})(Qb||(Qb={}));e0=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?Gp:(this._emitter||(this._emitter=new N),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},sh=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 bc("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new bc("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},t0=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new bc("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=we(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?tc=(e,t)=>{Hb(()=>{if(s)return;let i=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,i-Date.now())}}))});let s=!1;return{dispose(){s||(s=!0)}}}:tc=(e,t,s)=>{let i=e.requestIdleCallback(t,typeof s=="number"?{timeout:s}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(i))}}},s0=e=>tc(globalThis,e)})();(e=>{async function t(i){let r,o=await Promise.all(i.map(n=>n.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(n){o(n)}})}e.withAsyncBody=s})(i0||(i0={}));Lu=class Vt{static fromArray(t){return new Vt(s=>{s.emitMany(t)})}static fromPromise(t){return new Vt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Vt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Vt(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new N,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.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 ot.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Vt(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Vt.map(this,t)}static filter(t,s){return new Vt(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Vt.filter(this,t)}static coalesce(t){return Vt.filter(t,s=>!!s)}coalesce(){return Vt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Vt.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())}};Lu.EMPTY=Lu.fromArray([]);d0=class Xp{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(t){let s=t.length;if(s===0)return;let i=this._buff,r=this._buffLen,o=this._leftoverHighSurrogate,n,a;for(o!==0?(n=o,a=-1,o=0):(n=t.charCodeAt(0),a=0);;){let c=n;if(r0(n))if(a+1<s){let l=t.charCodeAt(a+1);Pu(l)?(a++,c=o0(n,l)):c=65533}else{o=n;break}else Pu(n)&&(c=65533);if(r=this._push(i,r,c),a++,a<s)n=t.charCodeAt(a);else break}this._buffLen=r,this._leftoverHighSurrogate=o}_push(t,s,i){return i<128?t[s++]=i:i<2048?(t[s++]=192|(i&1984)>>>6,t[s++]=128|(i&63)>>>0):i<65536?(t[s++]=224|(i&61440)>>>12,t[s++]=128|(i&4032)>>>6,t[s++]=128|(i&63)>>>0):(t[s++]=240|(i&1835008)>>>18,t[s++]=128|(i&258048)>>>12,t[s++]=128|(i&4032)>>>6,t[s++]=128|(i&63)>>>0),s>=64&&(this._step(),s-=64,this._totalLen+=64,t[0]=t[64],t[1]=t[65],t[2]=t[66]),s}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),So(this._h0)+So(this._h1)+So(this._h2)+So(this._h3)+So(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Bu(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Bu(this._buff));let t=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(t/4294967296),!1),this._buffDV.setUint32(60,t%4294967296,!1),this._step()}_step(){let t=Xp._bigBlock32,s=this._buffDV;for(let d=0;d<64;d+=4)t.setUint32(d,s.getUint32(d,!1),!1);for(let d=64;d<320;d+=4)t.setUint32(d,sc(t.getUint32(d-12,!1)^t.getUint32(d-32,!1)^t.getUint32(d-56,!1)^t.getUint32(d-64,!1),1),!1);let i=this._h0,r=this._h1,o=this._h2,n=this._h3,a=this._h4,c,l,h;for(let d=0;d<80;d++)d<20?(c=r&o|~r&n,l=1518500249):d<40?(c=r^o^n,l=1859775393):d<60?(c=r&o|r&n|o&n,l=2400959708):(c=r^o^n,l=3395469782),h=sc(i,5)+c+a+l+t.getUint32(d*4,!1)&4294967295,a=n,n=o,o=sc(r,30),r=i,i=h;this._h0=this._h0+i&4294967295,this._h1=this._h1+r&4294967295,this._h2=this._h2+o&4294967295,this._h3=this._h3+n&4294967295,this._h4=this._h4+a&4294967295}};d0._bigBlock32=new DataView(new ArrayBuffer(320));({registerWindow:aE,getWindow:rs,getDocument:lE,getWindows:cE,getWindowsCount:hE,getWindowId:Mu,getWindowById:dE,hasWindow:uE,onDidRegisterWindow:u0,onWillUnregisterWindow:pE,onDidUnregisterWindow:fE}=(function(){let e=new Map,t={window:Mt,disposables:new ci};e.set(Mt.vscodeWindowId,t);let s=new N,i=new N,r=new N;function o(n,a){return(typeof n=="number"?e.get(n):void 0)??(a?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(n){if(e.has(n.vscodeWindowId))return re.None;let a=new ci,c={window:n,disposables:a.add(new ci)};return e.set(n.vscodeWindowId,c),a.add(we(()=>{e.delete(n.vscodeWindowId),i.fire(n)})),a.add(te(n,je.BEFORE_UNLOAD,()=>{r.fire(n)})),s.fire(c),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(n){return n.vscodeWindowId},hasWindow(n){return e.has(n)},getWindowById:o,getWindow(n){let a=n;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let c=n;return c?.view?c.view.window:Mt},getDocument(n){return rs(n).document}}})()),p0=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!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)}};Iu=function(e,t,s,i){let r=s;return t==="click"||t==="mousedown"||t==="contextmenu"?r=f0(rs(e),s):(t==="keydown"||t==="keypress"||t==="keyup")&&(r=m0(s)),te(e,t,r,i)},_0=class extends t0{constructor(e){super(),this.defaultTarget=e&&rs(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},ic=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){sa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let n=e.get(o)??[];for(t.set(o,n),e.set(o,[]),i.set(o,!0);n.length>0;)n.sort(ic.sort),n.shift().execute();i.set(o,!1)};ma=(o,n,a=0)=>{let c=Mu(o),l=new ic(n,a),h=e.get(c);return h||(h=[],e.set(c,h)),h.push(l),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>r(c))),l},g0=(o,n,a)=>{let c=Mu(o);if(i.get(c)){let l=new ic(n,a),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(l),l}else return ma(o,n,a)}})();Ou=class la{constructor(t,s){this.width=t,this.height=s}with(t=this.width,s=this.height){return t!==this.width||s!==this.height?new la(t,s):this}static is(t){return typeof t=="object"&&typeof t.height=="number"&&typeof t.width=="number"}static lift(t){return t instanceof la?t:new la(t.width,t.height)}static equals(t,s){return t===s?!0:!t||!s?!1:t.width===s.width&&t.height===s.height}};Ou.None=new Ou(0,0);mE=new class{constructor(){this.mutationObservers=new Map}observe(e,t,s){let i=this.mutationObservers.get(e);i||(i=new Map,this.mutationObservers.set(e,i));let r=n0(s),o=i.get(r);if(o)o.users+=1;else{let n=new N,a=new MutationObserver(l=>n.fire(l));a.observe(e,s);let c=o={users:1,observer:a,onDidMutate:n.event};t.add(we(()=>{c.users-=1,c.users===0&&(n.dispose(),a.disconnect(),i?.delete(r),i?.size===0&&this.mutationObservers.delete(e))})),i.set(r,o)}return o.onDidMutate}},je={CLICK:"click",AUXCLICK:"auxclick",DBLCLICK:"dblclick",MOUSE_UP:"mouseup",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_MOVE:"mousemove",MOUSE_OUT:"mouseout",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",POINTER_LEAVE:"pointerleave",CONTEXT_MENU:"contextmenu",WHEEL:"wheel",KEY_DOWN:"keydown",KEY_PRESS:"keypress",KEY_UP:"keyup",LOAD:"load",BEFORE_UNLOAD:"beforeunload",UNLOAD:"unload",PAGE_SHOW:"pageshow",PAGE_HIDE:"pagehide",PASTE:"paste",ABORT:"abort",ERROR:"error",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_CHANGE:"fullscreenchange",WK_FULLSCREEN_CHANGE:"webkitfullscreenchange",SELECT:"select",CHANGE:"change",SUBMIT:"submit",RESET:"reset",FOCUS:"focus",FOCUS_IN:"focusin",FOCUS_OUT:"focusout",BLUR:"blur",INPUT:"input",STORAGE:"storage",DRAG_START:"dragstart",DRAG:"drag",DRAG_ENTER:"dragenter",DRAG_LEAVE:"dragleave",DRAG_OVER:"dragover",DROP:"drop",DRAG_END:"dragend",ANIMATION_START:oa?"webkitAnimationStart":"animationstart",ANIMATION_END:oa?"webkitAnimationEnd":"animationend",ANIMATION_ITERATION:oa?"webkitAnimationIteration":"animationiteration"},b0=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;y0.SVG=function(e,t,...s){return Jp("http://www.w3.org/2000/svg",e,t,...s)};w0=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=xt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=xt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=xt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=xt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=xt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=xt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=xt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=xt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=xt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=xt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=xt(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=xt(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=xt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=xt(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};Zp=class{constructor(){this._hooks=new ci,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=e;try{e.setPointerCapture(t),this._hooks.add(we(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=rs(e)}this._hooks.add(te(o,je.POINTER_MOVE,n=>{if(n.buttons!==s){this.stopMonitoring(!0);return}n.preventDefault(),this._pointerMoveCallback(n)})),this._hooks.add(te(o,je.POINTER_UP,n=>this.stopMonitoring(!0)))}};(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(gs||(gs={}));Ro=class dt extends re{constructor(){super(),this.dispatched=!1,this.targets=new xu,this.ignoreTargets=new xu,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ot.runAndSubscribe(u0,({window:t,disposables:s})=>{s.add(te(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(te(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(te(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Mt,disposables:this._store}))}static addTarget(t){if(!dt.isTouchDevice())return re.None;dt.INSTANCE||(dt.INSTANCE=Cu(new dt));let s=dt.INSTANCE.targets.push(t);return we(s)}static ignoreTarget(t){if(!dt.isTouchDevice())return re.None;dt.INSTANCE||(dt.INSTANCE=Cu(new dt));let s=dt.INSTANCE.ignoreTargets.push(t);return we(s)}static isTouchDevice(){return"ontouchstart"in Mt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i<r;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let n=this.newGestureEvent(gs.Start,o.target);n.pageX=o.pageX,n.pageY=o.pageY,this.dispatchEvent(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,n=s.changedTouches.length;o<n;o++){let a=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],l=Date.now()-c.initialTimeStamp;if(l<dt.HOLD_DELAY&&Math.abs(c.initialPageX-Lt(c.rollingPageX))<30&&Math.abs(c.initialPageY-Lt(c.rollingPageY))<30){let h=this.newGestureEvent(gs.Tap,c.initialTarget);h.pageX=Lt(c.rollingPageX),h.pageY=Lt(c.rollingPageY),this.dispatchEvent(h)}else if(l>=dt.HOLD_DELAY&&Math.abs(c.initialPageX-Lt(c.rollingPageX))<30&&Math.abs(c.initialPageY-Lt(c.rollingPageY))<30){let h=this.newGestureEvent(gs.Contextmenu,c.initialTarget);h.pageX=Lt(c.rollingPageX),h.pageY=Lt(c.rollingPageY),this.dispatchEvent(h)}else if(r===1){let h=Lt(c.rollingPageX),d=Lt(c.rollingPageY),m=Lt(c.rollingTimestamps)-c.rollingTimestamps[0],p=h-c.rollingPageX[0],f=d-c.rollingPageY[0],_=[...this.targets].filter(w=>c.initialTarget instanceof Node&&w.contains(c.initialTarget));this.inertia(t,_,i,Math.abs(p)/m,p>0?1:-1,h,Math.abs(f)/m,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(gs.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===gs.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>dt.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===gs.Change||t.type===gs.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,o=t.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,o,n,a,c,l){this.handle=ma(t,()=>{let h=Date.now(),d=h-i,m=0,p=0,f=!0;r+=dt.SCROLL_FRICTION*d,a+=dt.SCROLL_FRICTION*d,r>0&&(f=!1,m=o*r*d),a>0&&(f=!1,p=c*a*d);let _=this.newGestureEvent(gs.Change);_.translationX=m,_.translationY=p,s.forEach(w=>w.dispatchEvent(_)),f||this.inertia(t,s,h,r,o,n+m,a,c,l+p)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i<r;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let n=this.activeTouches[o.identifier],a=this.newGestureEvent(gs.Change,n.initialTarget);a.translationX=o.pageX-Lt(n.rollingPageX),a.translationY=o.pageY-Lt(n.rollingPageY),a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(o.pageX),n.rollingPageY.push(o.pageY),n.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ro.SCROLL_FRICTION=-.005,Ro.HOLD_DELAY=700,Ro.CLEAR_TAP_COUNT_TIME=400,Ee([S0],Ro,"isTouchDevice",1);C0=Ro,rh=class extends re{onclick(e,t){this._register(te(e,je.CLICK,s=>t(new Ao(rs(e),s))))}onmousedown(e,t){this._register(te(e,je.MOUSE_DOWN,s=>t(new Ao(rs(e),s))))}onmouseover(e,t){this._register(te(e,je.MOUSE_OVER,s=>t(new Ao(rs(e),s))))}onmouseleave(e,t){this._register(te(e,je.MOUSE_LEAVE,s=>t(new Ao(rs(e),s))))}onkeydown(e,t){this._register(te(e,je.KEY_DOWN,s=>t(new Tc(s))))}onkeyup(e,t){this._register(te(e,je.KEY_UP,s=>t(new Tc(s))))}oninput(e,t){this._register(te(e,je.INPUT,t))}onblur(e,t){this._register(te(e,je.BLUR,t))}onfocus(e,t){this._register(te(e,je.FOCUS,t))}onchange(e,t){this._register(te(e,je.CHANGE,t))}ignoreGesture(e){return C0.ignoreTarget(e)}},zu=11,x0=class extends rh{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=zu+"px",this.domNode.style.height=zu+"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 Zp),this._register(Iu(this.bgDomNode,je.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Iu(this.domNode,je.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new _0),this._pointerdownScheduleRepeatTimer=this._register(new sh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,rs(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},k0=class Ac{constructor(t,s,i,r,o,n,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,n=n|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),a+o>n&&(a=n-o),a<0&&(a=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=n,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,s){return new Ac(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ac(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,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,n=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:n,scrollHeightChanged:a,scrollTopChanged:c}}},$0=class extends re{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new k0(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){let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Fu(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Fu.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Nu=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};Fu=class Rc{constructor(t,s,i,r){this.from=t,this.to=s,this.duration=r,this.startTime=i,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,s,i){if(Math.abs(t-s)>2.5*i){let r,o;return t<s?(r=t+.75*i,o=s-.75*i):(r=t-.75*i,o=s+.75*i),E0(rc(t,r),rc(o,s),.33)}return rc(t,s)}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 s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new Nu(i,r,!1)}return new Nu(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Rc.start(t,s,i)}static start(t,s,i){i=i+10;let r=Date.now()-10;return new Rc(t,s,r,i)}};R0=class extends re{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new sh)}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(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},D0=140,Qp=class extends rh{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 R0(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Zp),this._shouldRender=!0,this.domNode=Io(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(te(this.domNode.domNode,je.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new x0(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=Io(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(te(this.slider.domNode,je.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,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=v0(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),n=Math.abs(o-s);if(Up&&n>D0){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.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()}},ef=class Dc{constructor(t,s,i,r,o,n){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=n,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Dc(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,o){let n=Math.max(0,i-t),a=Math.max(0,n-2*s),c=r>0&&r>i;if(!c)return{computedAvailableSize:Math.round(n),computedIsNeeded:c,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*a/r))),h=(a-l)/(r-i),d=o*h;return{computedAvailableSize:Math.round(n),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:h,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=Dc._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},L0=class extends Qp{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ef(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.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}},P0=class extends Qp{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ef(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.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}},B0=500,Hu=50,Wu=!0,M0=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Lc=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,s=0,i=1,r=this._rear;do{let o=r===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(eh){let s=rs(t.browserEvent),i=Tb(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let r=null,o=new M0(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,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]=o),o.score=this._computeScore(o,r)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),n=Math.abs(s.deltaX),a=Math.abs(s.deltaY),c=Math.max(Math.min(r,n),1),l=Math.max(Math.min(o,a),1),h=Math.max(r,n),d=Math.max(o,a);h%c===0&&d%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Lc.INSTANCE=new Lc;I0=Lc,O0=class extends rh{constructor(e,t,s){super(),this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new N),this.onWillScroll=this._onWillScroll.event,this._options=N0(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new P0(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new L0(this._scrollable,this._options,i)),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=Io(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Io(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Io(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 sh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=qi(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,_s&&(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 Du(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=qi(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Du(s))};this._mouseWheelToDispose.push(te(this._listenOnDomNode,je.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=I0.INSTANCE;Wu&&t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let n=!_s&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||n)&&!o&&(o=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),c={};if(r){let l=Hu*r,h=a.scrollTop-(l<0?Math.floor(l):Math.ceil(l));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let l=Hu*o,h=a.scrollLeft-(l<0?Math.floor(l):Math.ceil(l));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(a.scrollLeft!==c.scrollLeft||a.scrollTop!==c.scrollTop)&&(Wu&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(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,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_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(),B0)}},z0=class extends O0{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};Pc=class extends re{constructor(e,t,s,i,r,o,n,a){super(),this._bufferService=s,this._optionsService=n,this._renderService=a,this._onRequestScrollLines=this._register(new N),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new $0({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>ma(i.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new z0(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ot.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(we(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(we(()=>this._styleElement.remove())),this._register(ot.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.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(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Pc=Ee([U(2,gt),U(3,Fs),U(4,kp),U(5,Tr),U(6,_t),U(7,Hs)],Pc);Bc=class extends re{constructor(e,t,s,i,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,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(o=>this._removeDecoration(o))),this._register(we(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Bc=Ee([U(1,gt),U(2,Fs),U(3,Wo),U(4,Hs)],Bc);F0=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},fs={full:0,left:0,center:0,right:0},oi={full:0,left:0,center:0,right:0},Co={full:0,left:0,center:0,right:0},ga=class extends re{constructor(e,t,s,i,r,o,n,a){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=n,this._coreBrowserService=a,this._colorZoneStore=new F0,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(we(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);oi.full=this._canvas.width,oi.left=e,oi.center=t,oi.right=e,this._refreshDrawHeightConstants(),Co.full=1,Co.left=1,Co.center=1+oi.left,Co.right=1+oi.left+oi.center}_refreshDrawHeightConstants(){fs.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);fs.left=t,fs.center=t,fs.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.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(Co[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-fs[e.position||"full"]/2),oi[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+fs[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}))}};ga=Ee([U(2,gt),U(3,Wo),U(4,Hs),U(5,_t),U(6,Tr),U(7,Fs)],ga);(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="\x7F"))(M||(M={}));(e=>(e.PAD="\x80",e.HOP="\x81",e.BPH="\x82",e.NBH="\x83",e.IND="\x84",e.NEL="\x85",e.SSA="\x86",e.ESA="\x87",e.HTS="\x88",e.HTJ="\x89",e.VTS="\x8A",e.PLD="\x8B",e.PLU="\x8C",e.RI="\x8D",e.SS2="\x8E",e.SS3="\x8F",e.DCS="\x90",e.PU1="\x91",e.PU2="\x92",e.STS="\x93",e.CCH="\x94",e.MW="\x95",e.SPA="\x96",e.EPA="\x97",e.SOS="\x98",e.SGCI="\x99",e.SCI="\x9A",e.CSI="\x9B",e.ST="\x9C",e.OSC="\x9D",e.PM="\x9E",e.APC="\x9F"))(ca||(ca={}));(e=>e.ST=`${M.ESC}\\`)(tf||(tf={}));Mc=class{constructor(e,t,s,i,r,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,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 s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${M.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),s=this._renderService.dimensions.css.cell.height,i=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=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Mc=Ee([U(2,gt),U(3,_t),U(4,Gi),U(5,Hs)],Mc);Ve=0,Ue=0,qe=0,$e=0,ju={css:"#00000000",rgba:0};(e=>{function t(r,o,n,a){return a!==void 0?`#${Hi(r)}${Hi(o)}${Hi(n)}${Hi(a)}`:`#${Hi(r)}${Hi(o)}${Hi(n)}`}e.toCss=t;function s(r,o,n,a=255){return(r<<24|o<<16|n<<8|a)>>>0}e.toRgba=s;function i(r,o,n,a){return{css:e.toCss(r,o,n,a),rgba:e.toRgba(r,o,n,a)}}e.toColor=i})(Le||(Le={}));(e=>{function t(c,l){if($e=(l.rgba&255)/255,$e===1)return{css:l.css,rgba:l.rgba};let h=l.rgba>>24&255,d=l.rgba>>16&255,m=l.rgba>>8&255,p=c.rgba>>24&255,f=c.rgba>>16&255,_=c.rgba>>8&255;Ve=p+Math.round((h-p)*$e),Ue=f+Math.round((d-f)*$e),qe=_+Math.round((m-_)*$e);let w=Le.toCss(Ve,Ue,qe),k=Le.toRgba(Ve,Ue,qe);return{css:w,rgba:k}}e.blend=t;function s(c){return(c.rgba&255)===255}e.isOpaque=s;function i(c,l,h){let d=ha.ensureContrastRatio(c.rgba,l.rgba,h);if(d)return Le.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=i;function r(c){let l=(c.rgba|255)>>>0;return[Ve,Ue,qe]=ha.toChannels(l),{css:Le.toCss(Ve,Ue,qe),rgba:l}}e.opaque=r;function o(c,l){return $e=Math.round(l*255),[Ve,Ue,qe]=ha.toChannels(c.rgba),{css:Le.toCss(Ve,Ue,qe,$e),rgba:Le.toRgba(Ve,Ue,qe,$e)}}e.opacity=o;function n(c,l){return $e=c.rgba&255,o(c,$e*l/255)}e.multiplyOpacity=n;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(ye||(ye={}));(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ve=parseInt(r.slice(1,2).repeat(2),16),Ue=parseInt(r.slice(2,3).repeat(2),16),qe=parseInt(r.slice(3,4).repeat(2),16),Le.toColor(Ve,Ue,qe);case 5:return Ve=parseInt(r.slice(1,2).repeat(2),16),Ue=parseInt(r.slice(2,3).repeat(2),16),qe=parseInt(r.slice(3,4).repeat(2),16),$e=parseInt(r.slice(4,5).repeat(2),16),Le.toColor(Ve,Ue,qe,$e);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 o=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(o)return Ve=parseInt(o[1]),Ue=parseInt(o[2]),qe=parseInt(o[3]),$e=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Le.toColor(Ve,Ue,qe,$e);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ve,Ue,qe,$e]=t.getImageData(0,0,1,1).data,$e!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Le.toRgba(Ve,Ue,qe,$e),css:r}}e.toColor=i})(ke||(ke={}));(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,o){let n=i/255,a=r/255,c=o/255,l=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return l*.2126+h*.7152+d*.0722}e.relativeLuminance2=s})(mt||(mt={}));(e=>{function t(n,a){if($e=(a&255)/255,$e===1)return a;let c=a>>24&255,l=a>>16&255,h=a>>8&255,d=n>>24&255,m=n>>16&255,p=n>>8&255;return Ve=d+Math.round((c-d)*$e),Ue=m+Math.round((l-m)*$e),qe=p+Math.round((h-p)*$e),Le.toRgba(Ve,Ue,qe)}e.blend=t;function s(n,a,c){let l=mt.relativeLuminance(n>>8),h=mt.relativeLuminance(a>>8);if(Is(l,h)<c){if(h<l){let p=i(n,a,c),f=Is(l,mt.relativeLuminance(p>>8));if(f<c){let _=r(n,a,c),w=Is(l,mt.relativeLuminance(_>>8));return f>w?p:_}return p}let d=r(n,a,c),m=Is(l,mt.relativeLuminance(d>>8));if(m<c){let p=i(n,a,c),f=Is(l,mt.relativeLuminance(p>>8));return m>f?d:p}return d}}e.ensureContrastRatio=s;function i(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,m=a>>24&255,p=a>>16&255,f=a>>8&255,_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));for(;_<c&&(m>0||p>0||f>0);)m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),f-=Math.max(0,Math.ceil(f*.1)),_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));return(m<<24|p<<16|f<<8|255)>>>0}e.reduceLuminance=i;function r(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,m=a>>24&255,p=a>>16&255,f=a>>8&255,_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));for(;_<c&&(m<255||p<255||f<255);)m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));return(m<<24|p<<16|f<<8|255)>>>0}e.increaseLuminance=r;function o(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]}e.toChannels=o})(ha||(ha={}));H0=class extends Ho{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}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()]}},_a=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new qt}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 s=[],i=t.translateToString(!0),r=0,o=0,n=0,a=t.getFg(0),c=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!==c){if(l-r>1){let h=this._getJoinedRanges(i,n,o,t,r);for(let d=0;d<h.length;d++)s.push(h[d])}r=l,n=o,a=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||li.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(i,n,o,t,r);for(let h=0;h<l.length;h++)s.push(l[h])}return s}_getJoinedRanges(e,t,s,i,r){let o=e.substring(t,s),n=[];try{n=this._characterJoiners[0].handler(o)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let c=this._characterJoiners[a].handler(o);for(let l=0;l<c.length;l++)_a._mergeRanges(n,c[l])}catch(c){console.error(c)}return this._stringRangesToCellRanges(n,i,r),n}_stringRangesToCellRanges(e,t,s){let i=0,r=!1,o=0,n=e[i];if(n){for(let a=s;a<this._bufferService.cols;a++){let c=t.getWidth(a),l=t.getString(a).length||li.length;if(c!==0){if(!r&&n[0]<=o&&(n[0]=a,r=!0),n[1]<=o){if(n[1]=a,n=e[++i],!n)break;n[0]<=o?(n[0]=a,r=!0):r=!1}o+=l}}n&&(n[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let r=e[i];if(s){if(t[1]<=r[0])return e[i-1][1]=t[1],e;if(t[1]<=r[1])return e[i-1][1]=Math.max(t[1],r[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=r[0])return e.splice(i,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]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};_a=Ee([U(0,gt)],_a);Ic=class{constructor(e,t,s,i,r,o,n){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=n,this._workCell=new qt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,r,o,n,a,c,l,h){let d=[],m=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,f=e.getNoBgTrimmedLength();s&&f<o+1&&(f=o+1);let _,w=0,k="",$=0,y=0,C=0,S=0,L=!1,H=0,F=!1,W=0,ie=0,j=[],ce=l!==-1&&h!==-1;for(let T=0;T<f;T++){e.loadCell(T,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let D=!1,A=T>=ie,B=T,P=this._workCell;if(m.length>0&&T===m[0][0]&&A){let pe=m.shift(),wl=this._isCellInSelection(pe[0],t);for($=pe[0]+1;$<pe[1];$++)A&&(A=wl===this._isCellInSelection($,t));A&&(A=!s||o<pe[0]||o>=pe[1]),A?(D=!0,P=new H0(this._workCell,e.translateToString(!0,pe[0],pe[1]),pe[1]-pe[0]),B=pe[1]-1,x=P.getWidth()):ie=pe[1]}let V=this._isCellInSelection(T,t),se=s&&T===o,de=ce&&T>=l&&T<=h,tt=!1;this._decorationService.forEachDecorationAtCell(T,t,void 0,pe=>{tt=!0});let yt=P.getChars()||li;if(yt===" "&&(P.isUnderline()||P.isOverline())&&(yt="\xA0"),W=x*a-c.get(yt,P.isBold(),P.isItalic()),!_)_=this._document.createElement("span");else if(w&&(V&&F||!V&&!F&&P.bg===y)&&(V&&F&&p.selectionForeground||P.fg===C)&&P.extended.ext===S&&de===L&&W===H&&!se&&!D&&!tt&&A){P.isInvisible()?k+=li:k+=yt,w++;continue}else w&&(_.textContent=k),_=this._document.createElement("span"),w=0,k="";if(y=P.bg,C=P.fg,S=P.extended.ext,L=de,H=W,F=V,D&&o>=T&&o<=B&&(o=T),!this._coreService.isCursorHidden&&se&&this._coreService.isCursorInitialized){if(j.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&j.push("xterm-cursor-blink"),j.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":j.push("xterm-cursor-outline");break;case"block":j.push("xterm-cursor-block");break;case"bar":j.push("xterm-cursor-bar");break;case"underline":j.push("xterm-cursor-underline");break;default:break}}if(P.isBold()&&j.push("xterm-bold"),P.isItalic()&&j.push("xterm-italic"),P.isDim()&&j.push("xterm-dim"),P.isInvisible()?k=li:k=P.getChars()||li,P.isUnderline()&&(j.push(`xterm-underline-${P.extended.underlineStyle}`),k===" "&&(k="\xA0"),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${Ho.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let pe=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&pe<8&&(pe+=8),_.style.textDecorationColor=p.ansi[pe].css}P.isOverline()&&(j.push("xterm-overline"),k===" "&&(k="\xA0")),P.isStrikethrough()&&j.push("xterm-strikethrough"),de&&(_.style.textDecoration="underline");let Se=P.getFgColor(),es=P.getFgColorMode(),Re=P.getBgColor(),Es=P.getBgColorMode(),Ti=!!P.isInverse();if(Ti){let pe=Se;Se=Re,Re=pe;let wl=es;es=Es,Es=wl}let Js,Pn,io=!1;this._decorationService.forEachDecorationAtCell(T,t,void 0,pe=>{pe.options.layer!=="top"&&io||(pe.backgroundColorRGB&&(Es=50331648,Re=pe.backgroundColorRGB.rgba>>8&16777215,Js=pe.backgroundColorRGB),pe.foregroundColorRGB&&(es=50331648,Se=pe.foregroundColorRGB.rgba>>8&16777215,Pn=pe.foregroundColorRGB),io=pe.options.layer==="top")}),!io&&V&&(Js=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,Re=Js.rgba>>8&16777215,Es=50331648,io=!0,p.selectionForeground&&(es=50331648,Se=p.selectionForeground.rgba>>8&16777215,Pn=p.selectionForeground)),io&&j.push("xterm-decoration-top");let Zs;switch(Es){case 16777216:case 33554432:Zs=p.ansi[Re],j.push(`xterm-bg-${Re}`);break;case 50331648:Zs=Le.toColor(Re>>16,Re>>8&255,Re&255),this._addStyle(_,`background-color:#${Vu((Re>>>0).toString(16),"0",6)}`);break;default:Ti?(Zs=p.foreground,j.push("xterm-bg-257")):Zs=p.background}switch(Js||P.isDim()&&(Js=ye.multiplyOpacity(Zs,.5)),es){case 16777216:case 33554432:P.isBold()&&Se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Se+=8),this._applyMinimumContrast(_,Zs,p.ansi[Se],P,Js,void 0)||j.push(`xterm-fg-${Se}`);break;case 50331648:let pe=Le.toColor(Se>>16&255,Se>>8&255,Se&255);this._applyMinimumContrast(_,Zs,pe,P,Js,Pn)||this._addStyle(_,`color:#${Vu(Se.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(_,Zs,p.foreground,P,Js,Pn)||Ti&&j.push("xterm-fg-257")}j.length&&(_.className=j.join(" "),j.length=0),!se&&!D&&!tt&&A?w++:_.textContent=k,W!==this.defaultSpacing&&(_.style.letterSpacing=`${W}px`),d.push(_),T=B}return _&&w&&(_.textContent=k),d}_applyMinimumContrast(e,t,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||V0(i.getCode()))return!1;let n=this._getContrastCache(i),a;if(!r&&!o&&(a=n.getColor(t.rgba,s.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ye.ensureContrastRatio(r||t,o||s,c),n.setColor((r||t).rgba,(o||s).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 s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Ic=Ee([U(1,Tp),U(2,_t),U(3,Fs),U(4,Gi),U(5,Wo),U(6,Tr)],Ic);q0=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),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,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let n=this._measure(e,0);return n>0&&(this._flat[i]=n),n}let r=e;t&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let n=0;t&&(n|=1),s&&(n|=2),o=this._measure(e,n),o>0&&this._holey.set(r,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},K0=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,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,o=t[1]-r,n=s[1]-r,a=Math.max(o,0),c=Math.min(n,e.rows-1);if(a>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=n,this.viewportCappedStartRow=a,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};oc="xterm-dom-renderer-owner-",jt="xterm-rows",Qn="xterm-fg-",Uu="xterm-bg-",xo="xterm-focus",ea="xterm-selection",Y0=1,Oc=class extends re{constructor(e,t,s,i,r,o,n,a,c,l,h,d,m,p){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=n,this._charSizeService=c,this._optionsService=l,this._bufferService=h,this._coreService=d,this._coreBrowserService=m,this._themeService=p,this._terminalClass=Y0++,this._rowElements=[],this._selectionRenderModel=G0(),this.onRequestRedraw=this._register(new N).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(jt),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(ea),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=U0(),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(Ic,document),this._element.classList.add(oc+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(we(()=>{this._element.classList.remove(oc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new q0(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${jt} 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} .${jt} { 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} .${jt} .xterm-dim { color: ${ye.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 s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 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} .${jt}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${jt}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${jt}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ea} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ea} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ea} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,n]of e.ansi.entries())t+=`${this._terminalSelector} .${Qn}${o} { color: ${n.css}; }${this._terminalSelector} .${Qn}${o}.xterm-dim { color: ${ye.multiplyOpacity(n,.5).css}; }${this._terminalSelector} .${Uu}${o} { background-color: ${n.css}; }`;t+=`${this._terminalSelector} .${Qn}257 { color: ${ye.opaque(e.background).css}; }${this._terminalSelector} .${Qn}257.xterm-dim { color: ${ye.multiplyOpacity(ye.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 s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}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(xo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(xo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,n=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let c=e[0]>t[0];a.appendChild(this._createSelectionElement(o,c?t[0]:e[0],c?e[0]:t[0],n-o+1))}else{let c=i===o?e[0]:0,l=o===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));let h=n-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==n){let d=r===n?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(s-t);return o+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${n}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 s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let l=c+s.ydisp,h=this._rowElements[c],d=s.lines.get(l);if(!h||!d)break;h.replaceChildren(...this._rowFactory.createRow(d,l,l===i,n,a,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${oc}${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,s,i,r,o){s<0&&(e=0),i<0&&(t=0);let n=this._bufferService.rows-1;s=Math.max(Math.min(s,n),0),i=Math.max(Math.min(i,n),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,l=Math.min(a.x,r-1),h=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=s;p<=i;++p){let f=p+a.ydisp,_=this._rowElements[p],w=a.lines.get(f);if(!_||!w)break;_.replaceChildren(...this._rowFactory.createRow(w,f,f===c,d,m,l,h,this.dimensions.css.cell.width,this._widthCache,o?p===s?e:0:-1,o?(p===i?t:r)-1:-1))}}};Oc=Ee([U(7,Jc),U(8,Sa),U(9,_t),U(10,gt),U(11,Gi),U(12,Fs),U(13,Tr)],Oc);zc=class extends re{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new N),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new J0(this._optionsService))}catch{this._measureStrategy=this._register(new X0(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())}};zc=Ee([U(2,_t)],zc);sf=class extends re{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)}},X0=class extends sf{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},J0=class extends sf{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}},Z0=class extends re{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Q0(this._window)),this._onDprChange=this._register(new N),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new N),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(ot.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(te(this._textarea,"focus",()=>this._isFocused=!0)),this._register(te(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}},Q0=class extends re{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Er),this._onDprChange=this._register(new N),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(we(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=te(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},ey=class extends re{constructor(){super(),this.linkProviders=[],this._register(we(()=>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)}}}};Nc=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return ty(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=oh(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Nc=Ee([U(0,Hs),U(1,Sa)],Nc);sy=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,s){this._rowCount=s,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=[]}},rf={};Nv(rf,{getSafariVersion:()=>ry,isChromeOS:()=>lf,isFirefox:()=>of,isIpad:()=>oy,isIphone:()=>ny,isLegacyEdge:()=>iy,isLinux:()=>nh,isMac:()=>va,isNode:()=>ka,isSafari:()=>nf,isWindows:()=>af});ka=typeof process<"u"&&"title"in process,jo=ka?"node":navigator.userAgent,Vo=ka?"node":navigator.platform,of=jo.includes("Firefox"),iy=jo.includes("Edge"),nf=/^((?!chrome|android).)*safari/i.test(jo);va=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Vo),oy=Vo==="iPad",ny=Vo==="iPhone",af=["Windows","Win16","Win32","WinCE"].includes(Vo),nh=Vo.indexOf("Linux")>=0,lf=/\bCrOS\b/.test(jo),cf=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,s=0,i=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),s=Math.max(t,s),r=e.timeRemaining(),s*1.5>r){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},ay=class extends cf{_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())}}},ly=class extends cf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ba=!ka&&"requestIdleCallback"in window?ly:ay,cy=class{constructor(){this._queue=new ba}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Fc=class extends re{constructor(e,t,s,i,r,o,n,a,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Er),this._pausedResizeTask=new cy,this._observerDisposable=this._register(new Er),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 N),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new N),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new N),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new sy((l,h)=>this._renderRows(l,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new hy(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(we(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(n.onResize(()=>this._fullRefresh())),this._register(n.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(n.cols,n.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(n.buffer.y,n.buffer.y,!0))),this._register(c.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 s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=we(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(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(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Fc=Ee([U(2,_t),U(3,Sa),U(4,Gi),U(5,Wo),U(6,gt),U(7,Fs),U(8,Tr)],Fc);hy=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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)}};vy=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)}};nc=50,by=15,yy=50,wy=500,Sy="\xA0",Cy=new RegExp(Sy,"g"),Hc=class extends re{constructor(e,t,s,i,r,o,n,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=n,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new qt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new N),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new N),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new N),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 vy(this._bufferService),this._activeSelectionMode=0,this._register(we(()=>{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 s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let n=e[1];n<=t[1];n++){let a=s.translateBufferLineToString(n,!0,r,o);i.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],r));for(let o=e[1]+1;o<=t[1]-1;o++){let n=s.lines.get(o),a=s.translateBufferLineToString(o,!0);n?.isWrapped?i[i.length-1]+=a:i.push(a)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),n=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(r=>r.replace(Cy," ")).join(af?`\r
29
+ `).trim(),c=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);ra.register(n,c?.[2]??a,n)}return n}),this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-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[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*kb<=t.length){let r=0;for(let o=0;o<t.length;o++)t[o]?t[r++]=t[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||sa;if(!s){e.value(t);return}try{e.value(t)}catch(i){s(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof ia)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},Eb=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},$c=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new N,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new N,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};$c.INSTANCE=new $c;Qc=$c;Q$=Qc.INSTANCE.onDidChangeZoomLevel;eE=Qc.INSTANCE.onDidChangeFullscreen,Ar=typeof navigator=="object"?navigator.userAgent:"",Ec=Ar.indexOf("Firefox")>=0,oa=Ar.indexOf("AppleWebKit")>=0,eh=Ar.indexOf("Chrome")>=0,Hp=!eh&&Ar.indexOf("Safari")>=0,tE=Ar.indexOf("Electron/")>=0,sE=Ar.indexOf("Android")>=0,na=!1;if(typeof Mt.matchMedia=="function"){let e=Mt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Mt.matchMedia("(display-mode: fullscreen)");na=e.matches,Tb(Mt,e,({matches:s})=>{na&&t.matches||(na=s)})}$r="en",pa=!1,fa=!1,Mo=!1,Db=!1,Wp=!1,jp=!1,Lb=!1,Pb=!1,Bb=!1,Mb=!1,aa=$r,Eu=$r,Ns=globalThis;typeof Ns.vscode<"u"&&typeof Ns.vscode.process<"u"?Bt=Ns.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Bt=process);Vp=typeof Bt?.versions?.electron=="string",Ob=Vp&&Bt?.type==="renderer";if(typeof Bt=="object"){pa=Bt.platform==="win32",fa=Bt.platform==="darwin",Mo=Bt.platform==="linux",Db=Mo&&!!Bt.env.SNAP&&!!Bt.env.SNAP_REVISION,Lb=Vp,Bb=!!Bt.env.CI||!!Bt.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Jn=$r,aa=$r;let e=Bt.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Jn=t.userLocale,Eu=t.osLocale,aa=t.resolvedLanguage||$r,Ib=t.languagePack?.translationsConfigFile}catch{}Wp=!0}else typeof navigator=="object"&&!Ob?(Os=navigator.userAgent,pa=Os.indexOf("Windows")>=0,fa=Os.indexOf("Macintosh")>=0,Pb=(Os.indexOf("Macintosh")>=0||Os.indexOf("iPad")>=0||Os.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Mo=Os.indexOf("Linux")>=0,Mb=Os?.indexOf("Mobi")>=0,jp=!0,aa=globalThis._VSCODE_NLS_LANGUAGE||$r,Jn=navigator.language.toLowerCase(),Eu=Jn):console.error("Unable to resolve platform.");Zl=0;fa?Zl=1:pa?Zl=3:Mo&&(Zl=2);Up=pa,_s=fa,zb=Mo,Ql=Wp,Nb=jp&&typeof Ns.importScripts=="function",iE=Nb?Ns.origin:void 0,vs=Os,ii=aa;(e=>{function t(){return ii}e.value=t;function s(){return ii.length===2?ii==="en":ii.length>=3?ii[0]==="e"&&ii[1]==="n"&&ii[2]==="-":!1}e.isDefaultVariant=s;function i(){return ii==="en"}e.isDefault=i})(Fb||(Fb={}));Hb=typeof Ns.postMessage=="function"&&!Ns.importScripts,Wb=(()=>{if(Hb){let e=[];Ns.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Ns.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),jb=!!(vs&&vs.indexOf("Chrome")>=0),rE=!!(vs&&vs.indexOf("Firefox")>=0),oE=!!(!jb&&vs&&vs.indexOf("Safari")>=0),nE=!!(vs&&vs.indexOf("Edg/")>=0),aE=!!(vs&&vs.indexOf("Android")>=0),ri=typeof navigator=="object"?navigator:{},lE={clipboard:{writeText:Ql||document.queryCommandSupported&&document.queryCommandSupported("copy")||!!(ri&&ri.clipboard&&ri.clipboard.writeText),readText:Ql||!!(ri&&ri.clipboard&&ri.clipboard.readText)},keyboard:Ql||Rb()?0:ri.keyboard||Hp?1:2,touch:"ontouchstart"in Mt||ri.maxTouchPoints>0,pointerEvents:Mt.PointerEvent&&("ontouchstart"in Mt||navigator.maxTouchPoints>0)},th=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}},ec=new th,Tu=new th,Au=new th,Vb=new Array(230);(e=>{function t(a){return ec.keyCodeToStr(a)}e.toString=t;function s(a){return ec.strToKeyCode(a)}e.fromString=s;function i(a){return Tu.keyCodeToStr(a)}e.toUserSettingsUS=i;function r(a){return Au.keyCodeToStr(a)}e.toUserSettingsGeneral=r;function o(a){return Tu.strToKeyCode(a)||Au.strToKeyCode(a)}e.fromUserSettings=o;function n(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 ec.keyCodeToStr(a)}e.toElectronAccelerator=n})(qp||(qp={}));Ub=class Kp{constructor(t,s,i,r,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=o}equals(t){return t instanceof Kp&&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",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new qb([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},qb=class{constructor(e){if(e.length===0)throw ib("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;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}};Gb=_s?256:2048,Yb=512,Xb=1024,Jb=_s?2048:256,Tc=class{constructor(e){this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState?.("AltGraph"),this.keyCode=Kb(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|=Gb),this.altKey&&(t|=Yb),this.shiftKey&&(t|=Xb),this.metaKey&&(t|=Jb),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Ub(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ru=new WeakMap;Qb=class{static getSameOriginWindowChain(e){let t=Ru.get(e);if(!t){t=[],Ru.set(e,t);let s=e,i;do i=Zb(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(e);for(let o of r){let n=o.window.deref();if(s+=n?.scrollY??0,i+=n?.scrollX??0,n===t||!o.iframeElement)break;let a=o.iframeElement.getBoundingClientRect();s+=a.top,i+=a.left}return{top:s,left:i}}},Ao=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 s=Qb.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Du=class{constructor(e,t=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(eh){let r=navigator.userAgent.match(/Chrome\/(\d+)/);i=(r?parseInt(r[1]):123)<=122}if(e){let r=e,o=e,n=e.view?.devicePixelRatio||1;if(typeof r.wheelDeltaY<"u")i?this.deltaY=r.wheelDeltaY/(120*n):this.deltaY=r.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 a=e;a.deltaMode===a.DOM_DELTA_LINE?Ec&&!_s?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof r.wheelDeltaX<"u")Hp&&Up?this.deltaX=-(r.wheelDeltaX/120):i?this.deltaX=r.wheelDeltaX/(120*n):this.deltaX=r.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 a=e;a.deltaMode===a.DOM_DELTA_LINE?Ec&&!_s?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*n):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},Gp=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}});(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof t0?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:ot.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Gp})})(e0||(e0={}));t0=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?Gp:(this._emitter||(this._emitter=new N),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},sh=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 bc("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new bc("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},s0=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new bc("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=we(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?tc=(e,t)=>{Wb(()=>{if(s)return;let i=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,i-Date.now())}}))});let s=!1;return{dispose(){s||(s=!0)}}}:tc=(e,t,s)=>{let i=e.requestIdleCallback(t,typeof s=="number"?{timeout:s}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(i))}}},i0=e=>tc(globalThis,e)})();(e=>{async function t(i){let r,o=await Promise.all(i.map(n=>n.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(n){o(n)}})}e.withAsyncBody=s})(r0||(r0={}));Lu=class Vt{static fromArray(t){return new Vt(s=>{s.emitMany(t)})}static fromPromise(t){return new Vt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Vt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Vt(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new N,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.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 ot.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Vt(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Vt.map(this,t)}static filter(t,s){return new Vt(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Vt.filter(this,t)}static coalesce(t){return Vt.filter(t,s=>!!s)}coalesce(){return Vt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Vt.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())}};Lu.EMPTY=Lu.fromArray([]);u0=class Xp{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(t){let s=t.length;if(s===0)return;let i=this._buff,r=this._buffLen,o=this._leftoverHighSurrogate,n,a;for(o!==0?(n=o,a=-1,o=0):(n=t.charCodeAt(0),a=0);;){let c=n;if(o0(n))if(a+1<s){let l=t.charCodeAt(a+1);Pu(l)?(a++,c=n0(n,l)):c=65533}else{o=n;break}else Pu(n)&&(c=65533);if(r=this._push(i,r,c),a++,a<s)n=t.charCodeAt(a);else break}this._buffLen=r,this._leftoverHighSurrogate=o}_push(t,s,i){return i<128?t[s++]=i:i<2048?(t[s++]=192|(i&1984)>>>6,t[s++]=128|(i&63)>>>0):i<65536?(t[s++]=224|(i&61440)>>>12,t[s++]=128|(i&4032)>>>6,t[s++]=128|(i&63)>>>0):(t[s++]=240|(i&1835008)>>>18,t[s++]=128|(i&258048)>>>12,t[s++]=128|(i&4032)>>>6,t[s++]=128|(i&63)>>>0),s>=64&&(this._step(),s-=64,this._totalLen+=64,t[0]=t[64],t[1]=t[65],t[2]=t[66]),s}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),So(this._h0)+So(this._h1)+So(this._h2)+So(this._h3)+So(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Bu(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Bu(this._buff));let t=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(t/4294967296),!1),this._buffDV.setUint32(60,t%4294967296,!1),this._step()}_step(){let t=Xp._bigBlock32,s=this._buffDV;for(let d=0;d<64;d+=4)t.setUint32(d,s.getUint32(d,!1),!1);for(let d=64;d<320;d+=4)t.setUint32(d,sc(t.getUint32(d-12,!1)^t.getUint32(d-32,!1)^t.getUint32(d-56,!1)^t.getUint32(d-64,!1),1),!1);let i=this._h0,r=this._h1,o=this._h2,n=this._h3,a=this._h4,c,l,h;for(let d=0;d<80;d++)d<20?(c=r&o|~r&n,l=1518500249):d<40?(c=r^o^n,l=1859775393):d<60?(c=r&o|r&n|o&n,l=2400959708):(c=r^o^n,l=3395469782),h=sc(i,5)+c+a+l+t.getUint32(d*4,!1)&4294967295,a=n,n=o,o=sc(r,30),r=i,i=h;this._h0=this._h0+i&4294967295,this._h1=this._h1+r&4294967295,this._h2=this._h2+o&4294967295,this._h3=this._h3+n&4294967295,this._h4=this._h4+a&4294967295}};u0._bigBlock32=new DataView(new ArrayBuffer(320));({registerWindow:cE,getWindow:rs,getDocument:hE,getWindows:dE,getWindowsCount:uE,getWindowId:Mu,getWindowById:pE,hasWindow:fE,onDidRegisterWindow:p0,onWillUnregisterWindow:mE,onDidUnregisterWindow:gE}=(function(){let e=new Map,t={window:Mt,disposables:new ci};e.set(Mt.vscodeWindowId,t);let s=new N,i=new N,r=new N;function o(n,a){return(typeof n=="number"?e.get(n):void 0)??(a?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(n){if(e.has(n.vscodeWindowId))return re.None;let a=new ci,c={window:n,disposables:a.add(new ci)};return e.set(n.vscodeWindowId,c),a.add(we(()=>{e.delete(n.vscodeWindowId),i.fire(n)})),a.add(te(n,je.BEFORE_UNLOAD,()=>{r.fire(n)})),s.fire(c),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(n){return n.vscodeWindowId},hasWindow(n){return e.has(n)},getWindowById:o,getWindow(n){let a=n;if(a?.ownerDocument?.defaultView)return a.ownerDocument.defaultView.window;let c=n;return c?.view?c.view.window:Mt},getDocument(n){return rs(n).document}}})()),f0=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!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)}};Iu=function(e,t,s,i){let r=s;return t==="click"||t==="mousedown"||t==="contextmenu"?r=m0(rs(e),s):(t==="keydown"||t==="keypress"||t==="keyup")&&(r=g0(s)),te(e,t,r,i)},v0=class extends s0{constructor(e){super(),this.defaultTarget=e&&rs(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},ic=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){sa(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=o=>{s.set(o,!1);let n=e.get(o)??[];for(t.set(o,n),e.set(o,[]),i.set(o,!0);n.length>0;)n.sort(ic.sort),n.shift().execute();i.set(o,!1)};ma=(o,n,a=0)=>{let c=Mu(o),l=new ic(n,a),h=e.get(c);return h||(h=[],e.set(c,h)),h.push(l),s.get(c)||(s.set(c,!0),o.requestAnimationFrame(()=>r(c))),l},_0=(o,n,a)=>{let c=Mu(o);if(i.get(c)){let l=new ic(n,a),h=t.get(c);return h||(h=[],t.set(c,h)),h.push(l),l}else return ma(o,n,a)}})();Ou=class la{constructor(t,s){this.width=t,this.height=s}with(t=this.width,s=this.height){return t!==this.width||s!==this.height?new la(t,s):this}static is(t){return typeof t=="object"&&typeof t.height=="number"&&typeof t.width=="number"}static lift(t){return t instanceof la?t:new la(t.width,t.height)}static equals(t,s){return t===s?!0:!t||!s?!1:t.width===s.width&&t.height===s.height}};Ou.None=new Ou(0,0);_E=new class{constructor(){this.mutationObservers=new Map}observe(e,t,s){let i=this.mutationObservers.get(e);i||(i=new Map,this.mutationObservers.set(e,i));let r=a0(s),o=i.get(r);if(o)o.users+=1;else{let n=new N,a=new MutationObserver(l=>n.fire(l));a.observe(e,s);let c=o={users:1,observer:a,onDidMutate:n.event};t.add(we(()=>{c.users-=1,c.users===0&&(n.dispose(),a.disconnect(),i?.delete(r),i?.size===0&&this.mutationObservers.delete(e))})),i.set(r,o)}return o.onDidMutate}},je={CLICK:"click",AUXCLICK:"auxclick",DBLCLICK:"dblclick",MOUSE_UP:"mouseup",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_MOVE:"mousemove",MOUSE_OUT:"mouseout",MOUSE_ENTER:"mouseenter",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",POINTER_LEAVE:"pointerleave",CONTEXT_MENU:"contextmenu",WHEEL:"wheel",KEY_DOWN:"keydown",KEY_PRESS:"keypress",KEY_UP:"keyup",LOAD:"load",BEFORE_UNLOAD:"beforeunload",UNLOAD:"unload",PAGE_SHOW:"pageshow",PAGE_HIDE:"pagehide",PASTE:"paste",ABORT:"abort",ERROR:"error",RESIZE:"resize",SCROLL:"scroll",FULLSCREEN_CHANGE:"fullscreenchange",WK_FULLSCREEN_CHANGE:"webkitfullscreenchange",SELECT:"select",CHANGE:"change",SUBMIT:"submit",RESET:"reset",FOCUS:"focus",FOCUS_IN:"focusin",FOCUS_OUT:"focusout",BLUR:"blur",INPUT:"input",STORAGE:"storage",DRAG_START:"dragstart",DRAG:"drag",DRAG_ENTER:"dragenter",DRAG_LEAVE:"dragleave",DRAG_OVER:"dragover",DROP:"drop",DRAG_END:"dragend",ANIMATION_START:oa?"webkitAnimationStart":"animationstart",ANIMATION_END:oa?"webkitAnimationEnd":"animationend",ANIMATION_ITERATION:oa?"webkitAnimationIteration":"animationiteration"},y0=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;w0.SVG=function(e,t,...s){return Jp("http://www.w3.org/2000/svg",e,t,...s)};S0=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=xt(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=xt(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=xt(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=xt(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=xt(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=xt(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=xt(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=xt(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=xt(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=xt(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=xt(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=xt(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=xt(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=xt(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};Zp=class{constructor(){this._hooks=new ci,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 s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let o=e;try{e.setPointerCapture(t),this._hooks.add(we(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=rs(e)}this._hooks.add(te(o,je.POINTER_MOVE,n=>{if(n.buttons!==s){this.stopMonitoring(!0);return}n.preventDefault(),this._pointerMoveCallback(n)})),this._hooks.add(te(o,je.POINTER_UP,n=>this.stopMonitoring(!0)))}};(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(gs||(gs={}));Ro=class dt extends re{constructor(){super(),this.dispatched=!1,this.targets=new xu,this.ignoreTargets=new xu,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(ot.runAndSubscribe(p0,({window:t,disposables:s})=>{s.add(te(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(te(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(te(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Mt,disposables:this._store}))}static addTarget(t){if(!dt.isTouchDevice())return re.None;dt.INSTANCE||(dt.INSTANCE=Cu(new dt));let s=dt.INSTANCE.targets.push(t);return we(s)}static ignoreTarget(t){if(!dt.isTouchDevice())return re.None;dt.INSTANCE||(dt.INSTANCE=Cu(new dt));let s=dt.INSTANCE.ignoreTargets.push(t);return we(s)}static isTouchDevice(){return"ontouchstart"in Mt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i<r;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let n=this.newGestureEvent(gs.Start,o.target);n.pageX=o.pageX,n.pageY=o.pageY,this.dispatchEvent(n)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let o=0,n=s.changedTouches.length;o<n;o++){let a=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let c=this.activeTouches[a.identifier],l=Date.now()-c.initialTimeStamp;if(l<dt.HOLD_DELAY&&Math.abs(c.initialPageX-Lt(c.rollingPageX))<30&&Math.abs(c.initialPageY-Lt(c.rollingPageY))<30){let h=this.newGestureEvent(gs.Tap,c.initialTarget);h.pageX=Lt(c.rollingPageX),h.pageY=Lt(c.rollingPageY),this.dispatchEvent(h)}else if(l>=dt.HOLD_DELAY&&Math.abs(c.initialPageX-Lt(c.rollingPageX))<30&&Math.abs(c.initialPageY-Lt(c.rollingPageY))<30){let h=this.newGestureEvent(gs.Contextmenu,c.initialTarget);h.pageX=Lt(c.rollingPageX),h.pageY=Lt(c.rollingPageY),this.dispatchEvent(h)}else if(r===1){let h=Lt(c.rollingPageX),d=Lt(c.rollingPageY),m=Lt(c.rollingTimestamps)-c.rollingTimestamps[0],p=h-c.rollingPageX[0],f=d-c.rollingPageY[0],_=[...this.targets].filter(w=>c.initialTarget instanceof Node&&w.contains(c.initialTarget));this.inertia(t,_,i,Math.abs(p)/m,p>0?1:-1,h,Math.abs(f)/m,f>0?1:-1,d)}this.dispatchEvent(this.newGestureEvent(gs.End,c.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===gs.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>dt.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===gs.Change||t.type===gs.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,o=t.initialTarget;for(;o&&o!==i;)r++,o=o.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,o,n,a,c,l){this.handle=ma(t,()=>{let h=Date.now(),d=h-i,m=0,p=0,f=!0;r+=dt.SCROLL_FRICTION*d,a+=dt.SCROLL_FRICTION*d,r>0&&(f=!1,m=o*r*d),a>0&&(f=!1,p=c*a*d);let _=this.newGestureEvent(gs.Change);_.translationX=m,_.translationY=p,s.forEach(w=>w.dispatchEvent(_)),f||this.inertia(t,s,h,r,o,n+m,a,c,l+p)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i<r;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let n=this.activeTouches[o.identifier],a=this.newGestureEvent(gs.Change,n.initialTarget);a.translationX=o.pageX-Lt(n.rollingPageX),a.translationY=o.pageY-Lt(n.rollingPageY),a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(o.pageX),n.rollingPageY.push(o.pageY),n.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ro.SCROLL_FRICTION=-.005,Ro.HOLD_DELAY=700,Ro.CLEAR_TAP_COUNT_TIME=400,Ee([C0],Ro,"isTouchDevice",1);x0=Ro,rh=class extends re{onclick(e,t){this._register(te(e,je.CLICK,s=>t(new Ao(rs(e),s))))}onmousedown(e,t){this._register(te(e,je.MOUSE_DOWN,s=>t(new Ao(rs(e),s))))}onmouseover(e,t){this._register(te(e,je.MOUSE_OVER,s=>t(new Ao(rs(e),s))))}onmouseleave(e,t){this._register(te(e,je.MOUSE_LEAVE,s=>t(new Ao(rs(e),s))))}onkeydown(e,t){this._register(te(e,je.KEY_DOWN,s=>t(new Tc(s))))}onkeyup(e,t){this._register(te(e,je.KEY_UP,s=>t(new Tc(s))))}oninput(e,t){this._register(te(e,je.INPUT,t))}onblur(e,t){this._register(te(e,je.BLUR,t))}onfocus(e,t){this._register(te(e,je.FOCUS,t))}onchange(e,t){this._register(te(e,je.CHANGE,t))}ignoreGesture(e){return x0.ignoreTarget(e)}},zu=11,k0=class extends rh{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=zu+"px",this.domNode.style.height=zu+"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 Zp),this._register(Iu(this.bgDomNode,je.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Iu(this.domNode,je.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new v0),this._pointerdownScheduleRepeatTimer=this._register(new sh)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,rs(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},$0=class Ac{constructor(t,s,i,r,o,n,a){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,o=o|0,n=n|0,a=a|0),this.rawScrollLeft=r,this.rawScrollTop=a,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),o<0&&(o=0),a+o>n&&(a=n-o),a<0&&(a=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=o,this.scrollHeight=n,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,s){return new Ac(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ac(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,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,n=this.height!==t.height,a=this.scrollHeight!==t.scrollHeight,c=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,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:i,scrollWidthChanged:r,scrollLeftChanged:o,heightChanged:n,scrollHeightChanged:a,scrollTopChanged:c}}},E0=class extends re{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new $0(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){let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),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 s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Fu(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Fu.start(this._state,s,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 s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Nu=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};Fu=class Rc{constructor(t,s,i,r){this.from=t,this.to=s,this.duration=r,this.startTime=i,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,s,i){if(Math.abs(t-s)>2.5*i){let r,o;return t<s?(r=t+.75*i,o=s-.75*i):(r=t-.75*i,o=s+.75*i),T0(rc(t,r),rc(o,s),.33)}return rc(t,s)}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 s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new Nu(i,r,!1)}return new Nu(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Rc.start(t,s,i)}static start(t,s,i){i=i+10;let r=Date.now()-10;return new Rc(t,s,r,i)}};D0=class extends re{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new sh)}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(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},L0=140,Qp=class extends rh{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 D0(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Zp),this._shouldRender=!0,this.domNode=Io(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(te(this.domNode.domNode,je.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new k0(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=Io(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(te(this.slider.domNode,je.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,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=b0(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let o=this._sliderOrthogonalPointerPosition(r),n=Math.abs(o-s);if(Up&&n>L0){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let a=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.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()}},ef=class Dc{constructor(t,s,i,r,o,n){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=o,this._scrollPosition=n,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Dc(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,o){let n=Math.max(0,i-t),a=Math.max(0,n-2*s),c=r>0&&r>i;if(!c)return{computedAvailableSize:Math.round(n),computedIsNeeded:c,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let l=Math.round(Math.max(20,Math.floor(i*a/r))),h=(a-l)/(r-i),d=o*h;return{computedAvailableSize:Math.round(n),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:h,computedSliderPosition:Math.round(d)}}_refreshComputedValues(){let t=Dc._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 s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},P0=class extends Qp{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ef(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.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}},B0=class extends Qp{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ef(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.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}},M0=500,Hu=50,Wu=!0,I0=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Lc=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,s=0,i=1,r=this._rear;do{let o=r===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[r].score*o,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(eh){let s=rs(t.browserEvent),i=Ab(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let r=null,o=new I0(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,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]=o),o.score=this._computeScore(o,r)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),o=Math.abs(t.deltaY),n=Math.abs(s.deltaX),a=Math.abs(s.deltaY),c=Math.max(Math.min(r,n),1),l=Math.max(Math.min(o,a),1),h=Math.max(r,n),d=Math.max(o,a);h%c===0&&d%l===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Lc.INSTANCE=new Lc;O0=Lc,z0=class extends rh{constructor(e,t,s){super(),this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new N),this.onWillScroll=this._onWillScroll.event,this._options=F0(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new B0(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new P0(this._scrollable,this._options,i)),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=Io(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Io(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Io(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 sh),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=qi(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,_s&&(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 Du(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=qi(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Du(s))};this._mouseWheelToDispose.push(te(this._listenOnDomNode,je.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=O0.INSTANCE;Wu&&t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,o=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+r===0?o=r=0:Math.abs(r)>=Math.abs(o)?o=0:r=0),this._options.flipAxes&&([r,o]=[o,r]);let n=!_s&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||n)&&!o&&(o=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,r=r*this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),c={};if(r){let l=Hu*r,h=a.scrollTop-(l<0?Math.floor(l):Math.ceil(l));this._verticalScrollbar.writeScrollPosition(c,h)}if(o){let l=Hu*o,h=a.scrollLeft-(l<0?Math.floor(l):Math.ceil(l));this._horizontalScrollbar.writeScrollPosition(c,h)}c=this._scrollable.validateScrollPosition(c),(a.scrollLeft!==c.scrollLeft||a.scrollTop!==c.scrollTop)&&(Wu&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(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,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${r}${i}`)}}_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(),M0)}},N0=class extends z0{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};Pc=class extends re{constructor(e,t,s,i,r,o,n,a){super(),this._bufferService=s,this._optionsService=n,this._renderService=a,this._onRequestScrollLines=this._register(new N),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new E0({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:l=>ma(i.window,l)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new N0(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(l=>{this._scrollableElement.updateOptions({handleMouseWheel:!(l&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(ot.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(we(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(we(()=>this._styleElement.remove())),this._register(ot.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.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(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Pc=Ee([U(2,gt),U(3,Fs),U(4,kp),U(5,Tr),U(6,_t),U(7,Hs)],Pc);Bc=class extends re{constructor(e,t,s,i,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,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(o=>this._removeDecoration(o))),this._register(we(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>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 s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};Bc=Ee([U(1,gt),U(2,Fs),U(3,Wo),U(4,Hs)],Bc);H0=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,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},fs={full:0,left:0,center:0,right:0},oi={full:0,left:0,center:0,right:0},Co={full:0,left:0,center:0,right:0},ga=class extends re{constructor(e,t,s,i,r,o,n,a){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=o,this._themeService=n,this._coreBrowserService=a,this._colorZoneStore=new H0,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(we(()=>this._canvas?.remove()));let c=this._canvas.getContext("2d");if(c)this._ctx=c;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);oi.full=this._canvas.width,oi.left=e,oi.center=t,oi.right=e,this._refreshDrawHeightConstants(),Co.full=1,Co.left=1,Co.center=1+oi.left,Co.right=1+oi.left+oi.center}_refreshDrawHeightConstants(){fs.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);fs.left=t,fs.center=t,fs.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*fs.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(Co[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-fs[e.position||"full"]/2),oi[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+fs[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}))}};ga=Ee([U(2,gt),U(3,Wo),U(4,Hs),U(5,_t),U(6,Tr),U(7,Fs)],ga);(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="\x7F"))(M||(M={}));(e=>(e.PAD="\x80",e.HOP="\x81",e.BPH="\x82",e.NBH="\x83",e.IND="\x84",e.NEL="\x85",e.SSA="\x86",e.ESA="\x87",e.HTS="\x88",e.HTJ="\x89",e.VTS="\x8A",e.PLD="\x8B",e.PLU="\x8C",e.RI="\x8D",e.SS2="\x8E",e.SS3="\x8F",e.DCS="\x90",e.PU1="\x91",e.PU2="\x92",e.STS="\x93",e.CCH="\x94",e.MW="\x95",e.SPA="\x96",e.EPA="\x97",e.SOS="\x98",e.SGCI="\x99",e.SCI="\x9A",e.CSI="\x9B",e.ST="\x9C",e.OSC="\x9D",e.PM="\x9E",e.APC="\x9F"))(ca||(ca={}));(e=>e.ST=`${M.ESC}\\`)(tf||(tf={}));Mc=class{constructor(e,t,s,i,r,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=o,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 s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!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,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${M.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),s=this._renderService.dimensions.css.cell.height,i=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=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Mc=Ee([U(2,gt),U(3,_t),U(4,Gi),U(5,Hs)],Mc);Ve=0,Ue=0,qe=0,$e=0,ju={css:"#00000000",rgba:0};(e=>{function t(r,o,n,a){return a!==void 0?`#${Hi(r)}${Hi(o)}${Hi(n)}${Hi(a)}`:`#${Hi(r)}${Hi(o)}${Hi(n)}`}e.toCss=t;function s(r,o,n,a=255){return(r<<24|o<<16|n<<8|a)>>>0}e.toRgba=s;function i(r,o,n,a){return{css:e.toCss(r,o,n,a),rgba:e.toRgba(r,o,n,a)}}e.toColor=i})(Le||(Le={}));(e=>{function t(c,l){if($e=(l.rgba&255)/255,$e===1)return{css:l.css,rgba:l.rgba};let h=l.rgba>>24&255,d=l.rgba>>16&255,m=l.rgba>>8&255,p=c.rgba>>24&255,f=c.rgba>>16&255,_=c.rgba>>8&255;Ve=p+Math.round((h-p)*$e),Ue=f+Math.round((d-f)*$e),qe=_+Math.round((m-_)*$e);let w=Le.toCss(Ve,Ue,qe),k=Le.toRgba(Ve,Ue,qe);return{css:w,rgba:k}}e.blend=t;function s(c){return(c.rgba&255)===255}e.isOpaque=s;function i(c,l,h){let d=ha.ensureContrastRatio(c.rgba,l.rgba,h);if(d)return Le.toColor(d>>24&255,d>>16&255,d>>8&255)}e.ensureContrastRatio=i;function r(c){let l=(c.rgba|255)>>>0;return[Ve,Ue,qe]=ha.toChannels(l),{css:Le.toCss(Ve,Ue,qe),rgba:l}}e.opaque=r;function o(c,l){return $e=Math.round(l*255),[Ve,Ue,qe]=ha.toChannels(c.rgba),{css:Le.toCss(Ve,Ue,qe,$e),rgba:Le.toRgba(Ve,Ue,qe,$e)}}e.opacity=o;function n(c,l){return $e=c.rgba&255,o(c,$e*l/255)}e.multiplyOpacity=n;function a(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}e.toColorRGB=a})(ye||(ye={}));(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Ve=parseInt(r.slice(1,2).repeat(2),16),Ue=parseInt(r.slice(2,3).repeat(2),16),qe=parseInt(r.slice(3,4).repeat(2),16),Le.toColor(Ve,Ue,qe);case 5:return Ve=parseInt(r.slice(1,2).repeat(2),16),Ue=parseInt(r.slice(2,3).repeat(2),16),qe=parseInt(r.slice(3,4).repeat(2),16),$e=parseInt(r.slice(4,5).repeat(2),16),Le.toColor(Ve,Ue,qe,$e);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 o=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(o)return Ve=parseInt(o[1]),Ue=parseInt(o[2]),qe=parseInt(o[3]),$e=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),Le.toColor(Ve,Ue,qe,$e);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Ve,Ue,qe,$e]=t.getImageData(0,0,1,1).data,$e!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Le.toRgba(Ve,Ue,qe,$e),css:r}}e.toColor=i})(ke||(ke={}));(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,o){let n=i/255,a=r/255,c=o/255,l=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4),h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return l*.2126+h*.7152+d*.0722}e.relativeLuminance2=s})(mt||(mt={}));(e=>{function t(n,a){if($e=(a&255)/255,$e===1)return a;let c=a>>24&255,l=a>>16&255,h=a>>8&255,d=n>>24&255,m=n>>16&255,p=n>>8&255;return Ve=d+Math.round((c-d)*$e),Ue=m+Math.round((l-m)*$e),qe=p+Math.round((h-p)*$e),Le.toRgba(Ve,Ue,qe)}e.blend=t;function s(n,a,c){let l=mt.relativeLuminance(n>>8),h=mt.relativeLuminance(a>>8);if(Is(l,h)<c){if(h<l){let p=i(n,a,c),f=Is(l,mt.relativeLuminance(p>>8));if(f<c){let _=r(n,a,c),w=Is(l,mt.relativeLuminance(_>>8));return f>w?p:_}return p}let d=r(n,a,c),m=Is(l,mt.relativeLuminance(d>>8));if(m<c){let p=i(n,a,c),f=Is(l,mt.relativeLuminance(p>>8));return m>f?d:p}return d}}e.ensureContrastRatio=s;function i(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,m=a>>24&255,p=a>>16&255,f=a>>8&255,_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));for(;_<c&&(m>0||p>0||f>0);)m-=Math.max(0,Math.ceil(m*.1)),p-=Math.max(0,Math.ceil(p*.1)),f-=Math.max(0,Math.ceil(f*.1)),_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));return(m<<24|p<<16|f<<8|255)>>>0}e.reduceLuminance=i;function r(n,a,c){let l=n>>24&255,h=n>>16&255,d=n>>8&255,m=a>>24&255,p=a>>16&255,f=a>>8&255,_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));for(;_<c&&(m<255||p<255||f<255);)m=Math.min(255,m+Math.ceil((255-m)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),f=Math.min(255,f+Math.ceil((255-f)*.1)),_=Is(mt.relativeLuminance2(m,p,f),mt.relativeLuminance2(l,h,d));return(m<<24|p<<16|f<<8|255)>>>0}e.increaseLuminance=r;function o(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]}e.toChannels=o})(ha||(ha={}));W0=class extends Ho{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}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()]}},_a=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new qt}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 s=[],i=t.translateToString(!0),r=0,o=0,n=0,a=t.getFg(0),c=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!==c){if(l-r>1){let h=this._getJoinedRanges(i,n,o,t,r);for(let d=0;d<h.length;d++)s.push(h[d])}r=l,n=o,a=this._workCell.fg,c=this._workCell.bg}o+=this._workCell.getChars().length||li.length}if(this._bufferService.cols-r>1){let l=this._getJoinedRanges(i,n,o,t,r);for(let h=0;h<l.length;h++)s.push(l[h])}return s}_getJoinedRanges(e,t,s,i,r){let o=e.substring(t,s),n=[];try{n=this._characterJoiners[0].handler(o)}catch(a){console.error(a)}for(let a=1;a<this._characterJoiners.length;a++)try{let c=this._characterJoiners[a].handler(o);for(let l=0;l<c.length;l++)_a._mergeRanges(n,c[l])}catch(c){console.error(c)}return this._stringRangesToCellRanges(n,i,r),n}_stringRangesToCellRanges(e,t,s){let i=0,r=!1,o=0,n=e[i];if(n){for(let a=s;a<this._bufferService.cols;a++){let c=t.getWidth(a),l=t.getString(a).length||li.length;if(c!==0){if(!r&&n[0]<=o&&(n[0]=a,r=!0),n[1]<=o){if(n[1]=a,n=e[++i],!n)break;n[0]<=o?(n[0]=a,r=!0):r=!1}o+=l}}n&&(n[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let r=e[i];if(s){if(t[1]<=r[0])return e[i-1][1]=t[1],e;if(t[1]<=r[1])return e[i-1][1]=Math.max(t[1],r[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=r[0])return e.splice(i,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]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};_a=Ee([U(0,gt)],_a);Ic=class{constructor(e,t,s,i,r,o,n){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=o,this._themeService=n,this._workCell=new qt,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,r,o,n,a,c,l,h){let d=[],m=this._characterJoinerService.getJoinedCharacters(t),p=this._themeService.colors,f=e.getNoBgTrimmedLength();s&&f<o+1&&(f=o+1);let _,w=0,k="",$=0,y=0,C=0,S=0,L=!1,H=0,F=!1,W=0,ie=0,j=[],ce=l!==-1&&h!==-1;for(let T=0;T<f;T++){e.loadCell(T,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let D=!1,A=T>=ie,B=T,P=this._workCell;if(m.length>0&&T===m[0][0]&&A){let pe=m.shift(),wl=this._isCellInSelection(pe[0],t);for($=pe[0]+1;$<pe[1];$++)A&&(A=wl===this._isCellInSelection($,t));A&&(A=!s||o<pe[0]||o>=pe[1]),A?(D=!0,P=new W0(this._workCell,e.translateToString(!0,pe[0],pe[1]),pe[1]-pe[0]),B=pe[1]-1,x=P.getWidth()):ie=pe[1]}let V=this._isCellInSelection(T,t),se=s&&T===o,de=ce&&T>=l&&T<=h,tt=!1;this._decorationService.forEachDecorationAtCell(T,t,void 0,pe=>{tt=!0});let yt=P.getChars()||li;if(yt===" "&&(P.isUnderline()||P.isOverline())&&(yt="\xA0"),W=x*a-c.get(yt,P.isBold(),P.isItalic()),!_)_=this._document.createElement("span");else if(w&&(V&&F||!V&&!F&&P.bg===y)&&(V&&F&&p.selectionForeground||P.fg===C)&&P.extended.ext===S&&de===L&&W===H&&!se&&!D&&!tt&&A){P.isInvisible()?k+=li:k+=yt,w++;continue}else w&&(_.textContent=k),_=this._document.createElement("span"),w=0,k="";if(y=P.bg,C=P.fg,S=P.extended.ext,L=de,H=W,F=V,D&&o>=T&&o<=B&&(o=T),!this._coreService.isCursorHidden&&se&&this._coreService.isCursorInitialized){if(j.push("xterm-cursor"),this._coreBrowserService.isFocused)n&&j.push("xterm-cursor-blink"),j.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":j.push("xterm-cursor-outline");break;case"block":j.push("xterm-cursor-block");break;case"bar":j.push("xterm-cursor-bar");break;case"underline":j.push("xterm-cursor-underline");break;default:break}}if(P.isBold()&&j.push("xterm-bold"),P.isItalic()&&j.push("xterm-italic"),P.isDim()&&j.push("xterm-dim"),P.isInvisible()?k=li:k=P.getChars()||li,P.isUnderline()&&(j.push(`xterm-underline-${P.extended.underlineStyle}`),k===" "&&(k="\xA0"),!P.isUnderlineColorDefault()))if(P.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${Ho.toColorRGB(P.getUnderlineColor()).join(",")})`;else{let pe=P.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&P.isBold()&&pe<8&&(pe+=8),_.style.textDecorationColor=p.ansi[pe].css}P.isOverline()&&(j.push("xterm-overline"),k===" "&&(k="\xA0")),P.isStrikethrough()&&j.push("xterm-strikethrough"),de&&(_.style.textDecoration="underline");let Se=P.getFgColor(),es=P.getFgColorMode(),Re=P.getBgColor(),Es=P.getBgColorMode(),Ti=!!P.isInverse();if(Ti){let pe=Se;Se=Re,Re=pe;let wl=es;es=Es,Es=wl}let Js,Pn,io=!1;this._decorationService.forEachDecorationAtCell(T,t,void 0,pe=>{pe.options.layer!=="top"&&io||(pe.backgroundColorRGB&&(Es=50331648,Re=pe.backgroundColorRGB.rgba>>8&16777215,Js=pe.backgroundColorRGB),pe.foregroundColorRGB&&(es=50331648,Se=pe.foregroundColorRGB.rgba>>8&16777215,Pn=pe.foregroundColorRGB),io=pe.options.layer==="top")}),!io&&V&&(Js=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,Re=Js.rgba>>8&16777215,Es=50331648,io=!0,p.selectionForeground&&(es=50331648,Se=p.selectionForeground.rgba>>8&16777215,Pn=p.selectionForeground)),io&&j.push("xterm-decoration-top");let Zs;switch(Es){case 16777216:case 33554432:Zs=p.ansi[Re],j.push(`xterm-bg-${Re}`);break;case 50331648:Zs=Le.toColor(Re>>16,Re>>8&255,Re&255),this._addStyle(_,`background-color:#${Vu((Re>>>0).toString(16),"0",6)}`);break;default:Ti?(Zs=p.foreground,j.push("xterm-bg-257")):Zs=p.background}switch(Js||P.isDim()&&(Js=ye.multiplyOpacity(Zs,.5)),es){case 16777216:case 33554432:P.isBold()&&Se<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Se+=8),this._applyMinimumContrast(_,Zs,p.ansi[Se],P,Js,void 0)||j.push(`xterm-fg-${Se}`);break;case 50331648:let pe=Le.toColor(Se>>16&255,Se>>8&255,Se&255);this._applyMinimumContrast(_,Zs,pe,P,Js,Pn)||this._addStyle(_,`color:#${Vu(Se.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(_,Zs,p.foreground,P,Js,Pn)||Ti&&j.push("xterm-fg-257")}j.length&&(_.className=j.join(" "),j.length=0),!se&&!D&&!tt&&A?w++:_.textContent=k,W!==this.defaultSpacing&&(_.style.letterSpacing=`${W}px`),d.push(_),T=B}return _&&w&&(_.textContent=k),d}_applyMinimumContrast(e,t,s,i,r,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||U0(i.getCode()))return!1;let n=this._getContrastCache(i),a;if(!r&&!o&&(a=n.getColor(t.rgba,s.rgba)),a===void 0){let c=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);a=ye.ensureContrastRatio(r||t,o||s,c),n.setColor((r||t).rgba,(o||s).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 s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};Ic=Ee([U(1,Tp),U(2,_t),U(3,Fs),U(4,Gi),U(5,Wo),U(6,Tr)],Ic);K0=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 s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,r,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(o),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,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let n=this._measure(e,0);return n>0&&(this._flat[i]=n),n}let r=e;t&&(r+="B"),s&&(r+="I");let o=this._holey.get(r);if(o===void 0){let n=0;t&&(n|=1),s&&(n|=2),o=this._measure(e,n),o>0&&this._holey.set(r,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},G0=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,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,o=t[1]-r,n=s[1]-r,a=Math.max(o,0),c=Math.min(n,e.rows-1);if(a>=e.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=n,this.viewportCappedStartRow=a,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};oc="xterm-dom-renderer-owner-",jt="xterm-rows",Qn="xterm-fg-",Uu="xterm-bg-",xo="xterm-focus",ea="xterm-selection",X0=1,Oc=class extends re{constructor(e,t,s,i,r,o,n,a,c,l,h,d,m,p){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=o,this._linkifier2=n,this._charSizeService=c,this._optionsService=l,this._bufferService=h,this._coreService=d,this._coreBrowserService=m,this._themeService=p,this._terminalClass=X0++,this._rowElements=[],this._selectionRenderModel=Y0(),this.onRequestRedraw=this._register(new N).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(jt),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(ea),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=q0(),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(Ic,document),this._element.classList.add(oc+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(we(()=>{this._element.classList.remove(oc+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new K0(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 s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${jt} 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} .${jt} { 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} .${jt} .xterm-dim { color: ${ye.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 s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 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} .${jt}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${jt}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${jt}.${xo} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${jt} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${ea} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${ea} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${ea} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,n]of e.ansi.entries())t+=`${this._terminalSelector} .${Qn}${o} { color: ${n.css}; }${this._terminalSelector} .${Qn}${o}.xterm-dim { color: ${ye.multiplyOpacity(n,.5).css}; }${this._terminalSelector} .${Uu}${o} { background-color: ${n.css}; }`;t+=`${this._terminalSelector} .${Qn}257 { color: ${ye.opaque(e.background).css}; }${this._terminalSelector} .${Qn}257.xterm-dim { color: ${ye.multiplyOpacity(ye.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 s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}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(xo),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(xo),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,n=this._selectionRenderModel.viewportCappedEndRow,a=this._document.createDocumentFragment();if(s){let c=e[0]>t[0];a.appendChild(this._createSelectionElement(o,c?t[0]:e[0],c?e[0]:t[0],n-o+1))}else{let c=i===o?e[0]:0,l=o===r?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(o,c,l));let h=n-o-1;if(a.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,h)),o!==n){let d=r===n?t[0]:this._bufferService.cols;a.appendChild(this._createSelectionElement(n,0,d))}}this._selectionContainer.appendChild(a)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,n=this.dimensions.css.cell.width*(s-t);return o+n>this.dimensions.css.canvas.width&&(n=this.dimensions.css.canvas.width-o),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${o}px`,r.style.width=`${n}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 s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,n=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,a=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let l=c+s.ydisp,h=this._rowElements[c],d=s.lines.get(l);if(!h||!d)break;h.replaceChildren(...this._rowFactory.createRow(d,l,l===i,n,a,r,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${oc}${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,s,i,r,o){s<0&&(e=0),i<0&&(t=0);let n=this._bufferService.rows-1;s=Math.max(Math.min(s,n),0),i=Math.max(Math.min(i,n),0),r=Math.min(r,this._bufferService.cols);let a=this._bufferService.buffer,c=a.ybase+a.y,l=Math.min(a.x,r-1),h=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,m=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=s;p<=i;++p){let f=p+a.ydisp,_=this._rowElements[p],w=a.lines.get(f);if(!_||!w)break;_.replaceChildren(...this._rowFactory.createRow(w,f,f===c,d,m,l,h,this.dimensions.css.cell.width,this._widthCache,o?p===s?e:0:-1,o?(p===i?t:r)-1:-1))}}};Oc=Ee([U(7,Jc),U(8,Sa),U(9,_t),U(10,gt),U(11,Gi),U(12,Fs),U(13,Tr)],Oc);zc=class extends re{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new N),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Z0(this._optionsService))}catch{this._measureStrategy=this._register(new J0(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())}};zc=Ee([U(2,_t)],zc);sf=class extends re{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)}},J0=class extends sf{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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}},Z0=class extends sf{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}},Q0=class extends re{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new ey(this._window)),this._onDprChange=this._register(new N),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new N),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(ot.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(te(this._textarea,"focus",()=>this._isFocused=!0)),this._register(te(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}},ey=class extends re{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Er),this._onDprChange=this._register(new N),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(we(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=te(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},ty=class extends re{constructor(){super(),this.linkProviders=[],this._register(we(()=>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)}}}};Nc=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return sy(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=oh(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Nc=Ee([U(0,Hs),U(1,Sa)],Nc);iy=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,s){this._rowCount=s,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=[]}},rf={};Fv(rf,{getSafariVersion:()=>oy,isChromeOS:()=>lf,isFirefox:()=>of,isIpad:()=>ny,isIphone:()=>ay,isLegacyEdge:()=>ry,isLinux:()=>nh,isMac:()=>va,isNode:()=>ka,isSafari:()=>nf,isWindows:()=>af});ka=typeof process<"u"&&"title"in process,jo=ka?"node":navigator.userAgent,Vo=ka?"node":navigator.platform,of=jo.includes("Firefox"),ry=jo.includes("Edge"),nf=/^((?!chrome|android).)*safari/i.test(jo);va=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Vo),ny=Vo==="iPad",ay=Vo==="iPhone",af=["Windows","Win16","Win32","WinCE"].includes(Vo),nh=Vo.indexOf("Linux")>=0,lf=/\bCrOS\b/.test(jo),cf=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,s=0,i=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),s=Math.max(t,s),r=e.timeRemaining(),s*1.5>r){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},ly=class extends cf{_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())}}},cy=class extends cf{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ba=!ka&&"requestIdleCallback"in window?cy:ly,hy=class{constructor(){this._queue=new ba}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Fc=class extends re{constructor(e,t,s,i,r,o,n,a,c){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=a,this._renderer=this._register(new Er),this._pausedResizeTask=new hy,this._observerDisposable=this._register(new Er),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 N),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new N),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new N),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new iy((l,h)=>this._renderRows(l,h),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new dy(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(we(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(n.onResize(()=>this._fullRefresh())),this._register(n.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(n.cols,n.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(n.buffer.y,n.buffer.y,!0))),this._register(c.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 s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=we(()=>s.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,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(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(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,s){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,t,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};Fc=Ee([U(2,_t),U(3,Sa),U(4,Gi),U(5,Wo),U(6,gt),U(7,Fs),U(8,Tr)],Fc);dy=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,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)}};by=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)}};nc=50,yy=15,wy=50,Sy=500,Cy="\xA0",xy=new RegExp(Cy,"g"),Hc=class extends re{constructor(e,t,s,i,r,o,n,a,c){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=o,this._optionsService=n,this._renderService=a,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new qt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new N),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new N),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new N),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 by(this._bufferService),this._activeSelectionMode=0,this._register(we(()=>{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 s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let n=e[1];n<=t[1];n++){let a=s.translateBufferLineToString(n,!0,r,o);i.push(a)}}else{let r=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],r));for(let o=e[1]+1;o<=t[1]-1;o++){let n=s.lines.get(o),a=s.translateBufferLineToString(o,!0);n?.isWrapped?i[i.length-1]+=a:i.push(a)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),n=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=n:i.push(n)}}return i.map(r=>r.replace(xy," ")).join(af?`\r
32
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())),nh&&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),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=qu(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,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=oh(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-nc),nc),t/=nc,t/Math.abs(t)+Math.round(t*(by-1)))}shouldForceSelection(e){return va?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(),yy)}_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&&!(va&&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 s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.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<wy&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=dy(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);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,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let n=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e[0]),c=a,l=e[0]-a,h=0,d=0,m=0,p=0;if(n.charAt(a)===" "){for(;a>0&&n.charAt(a-1)===" ";)a--;for(;c<n.length&&n.charAt(c+1)===" ";)c++}else{let w=e[0],k=e[0];o.getWidth(w)===0&&(h++,w--),o.getWidth(k)===2&&(d++,k++);let $=o.getString(k).length;for($>1&&(p+=$-1,c+=$-1);w>0&&a>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,w--):y>1&&(m+=y-1,a-=y-1),a--,w--}for(;k<o.length&&c+1<n.length&&!this._isCharWordSeparator(o.loadCell(k+1,this._workCell));){o.loadCell(k+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,k++):y>1&&(p+=y-1,c+=y-1),c++,k++}}c++;let f=a+l-h+m,_=Math.min(this._bufferService.cols,c-a+h+d-m-p);if(!(!t&&n.slice(a,c).trim()==="")){if(s&&f===0&&o.getCodePoint(0)!==32){let w=r.lines.get(e[1]-1);if(w&&o.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let $=this._bufferService.cols-k.start;f-=$,_+=$}}}if(i&&f+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=r.lines.get(e[1]+1);if(w?.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(_+=k.length)}}return{start:f,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=qu(s,this._bufferService.cols)}};Hc=Ee([U(3,gt),U(4,Gi),U(5,Zc),U(6,_t),U(7,Hs),U(8,Fs)],Hc);Ku=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Gu=class{constructor(){this._color=new Ku,this._css=new Ku}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Me=Object.freeze((()=>{let e=[ke.toColor("#2e3436"),ke.toColor("#cc0000"),ke.toColor("#4e9a06"),ke.toColor("#c4a000"),ke.toColor("#3465a4"),ke.toColor("#75507b"),ke.toColor("#06989a"),ke.toColor("#d3d7cf"),ke.toColor("#555753"),ke.toColor("#ef2929"),ke.toColor("#8ae234"),ke.toColor("#fce94f"),ke.toColor("#729fcf"),ke.toColor("#ad7fa8"),ke.toColor("#34e2e2"),ke.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],o=t[s%6];e.push({css:Le.toCss(i,r,o),rgba:Le.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Le.toCss(i,i,i),rgba:Le.toRgba(i,i,i)})}return e})()),Wi=ke.toColor("#ffffff"),Do=ke.toColor("#000000"),Yu=ke.toColor("#ffffff"),Xu=Do,ko={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},xy=Wi,Wc=class extends re{constructor(e){super(),this._optionsService=e,this._contrastCache=new Gu,this._halfContrastCache=new Gu,this._onChangeColors=this._register(new N),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Wi,background:Do,cursor:Yu,cursorAccent:Xu,selectionForeground:void 0,selectionBackgroundTransparent:ko,selectionBackgroundOpaque:ye.blend(Do,ko),selectionInactiveBackgroundTransparent:ko,selectionInactiveBackgroundOpaque:ye.blend(Do,ko),scrollbarSliderBackground:ye.opacity(Wi,.2),scrollbarSliderHoverBackground:ye.opacity(Wi,.4),scrollbarSliderActiveBackground:ye.opacity(Wi,.5),overviewRulerBorder:Wi,ansi:Me.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ge(e.foreground,Wi),t.background=ge(e.background,Do),t.cursor=ye.blend(t.background,ge(e.cursor,Yu)),t.cursorAccent=ye.blend(t.background,ge(e.cursorAccent,Xu)),t.selectionBackgroundTransparent=ge(e.selectionBackground,ko),t.selectionBackgroundOpaque=ye.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ge(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ye.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ge(e.selectionForeground,ju):void 0,t.selectionForeground===ju&&(t.selectionForeground=void 0),ye.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ye.opacity(t.selectionBackgroundTransparent,.3)),ye.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ye.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ge(e.scrollbarSliderBackground,ye.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ge(e.scrollbarSliderHoverBackground,ye.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ge(e.scrollbarSliderActiveBackground,ye.opacity(t.foreground,.5)),t.overviewRulerBorder=ge(e.overviewRulerBorder,xy),t.ansi=Me.slice(),t.ansi[0]=ge(e.black,Me[0]),t.ansi[1]=ge(e.red,Me[1]),t.ansi[2]=ge(e.green,Me[2]),t.ansi[3]=ge(e.yellow,Me[3]),t.ansi[4]=ge(e.blue,Me[4]),t.ansi[5]=ge(e.magenta,Me[5]),t.ansi[6]=ge(e.cyan,Me[6]),t.ansi[7]=ge(e.white,Me[7]),t.ansi[8]=ge(e.brightBlack,Me[8]),t.ansi[9]=ge(e.brightRed,Me[9]),t.ansi[10]=ge(e.brightGreen,Me[10]),t.ansi[11]=ge(e.brightYellow,Me[11]),t.ansi[12]=ge(e.brightBlue,Me[12]),t.ansi[13]=ge(e.brightMagenta,Me[13]),t.ansi[14]=ge(e.brightCyan,Me[14]),t.ansi[15]=ge(e.brightWhite,Me[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=ge(e.extendedAnsi[i],Me[i+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()}}};Wc=Ee([U(0,_t)],Wc);ky=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},$y=class{constructor(){this._services=new ky,this._services.set(Jc,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=qv(e).sort((o,n)=>o.index-n.index),i=[];for(let o of s){let n=this._services.get(o.id);if(!n)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(n)}let r=s.length>0?s[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,...i)}},Ey={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ty="xterm.js: ",jc=class extends re{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),Ay=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Ey[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,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Ty)+t,...s)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};jc=Ee([U(0,_t)],jc);Ju=class extends re{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new N),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new N),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new N),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 s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];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,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ae=3,De=Object.freeze(new Ho),ta=0,ac=2,Lo=class uf{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ae);let r=s||qt.fromCharData([0,wp,1,0]);for(let o=0;o<t;++o)this.setCell(o,r);this.length=t}get(t){let s=this._data[t*ae+0],i=s&2097151;return[this._data[t*ae+1],s&2097152?this._combined[t]:i?ai(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ae+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ae+0]=t|2097152|s[2]<<22):this._data[t*ae+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ae+0]>>22}hasWidth(t){return this._data[t*ae+0]&12582912}getFg(t){return this._data[t*ae+1]}getBg(t){return this._data[t*ae+2]}hasContent(t){return this._data[t*ae+0]&4194303}getCodePoint(t){let s=this._data[t*ae+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ae+0]&2097152}getString(t){let s=this._data[t*ae+0];return s&2097152?this._combined[t]:s&2097151?ai(s&2097151):""}isProtected(t){return this._data[t*ae+2]&536870912}loadCell(t,s){return ta=t*ae,s.content=this._data[ta+0],s.fg=this._data[ta+1],s.bg=this._data[ta+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ae+0]=s.content,this._data[t*ae+1]=s.fg,this._data[t*ae+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*ae+0]=s|i<<22,this._data[t*ae+1]=r.fg,this._data[t*ae+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*ae+0];r&2097152?this._combined[t]+=ai(s):r&2097151?(this._combined[t]=ai(r&2097151)+ai(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*ae+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let r=new qt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,r));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let r=new qt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*ac<this._data.buffer.byteLength;let i=t*ae;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let n=0;n<r.length;n++){let a=parseInt(r[n],10);a>=t&&delete this._combined[a]}let o=Object.keys(this._extendedAttrs);for(let n=0;n<o.length;n++){let a=parseInt(o[n],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,i*4*ac<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ac<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,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 s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new uf(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ae+0]&4194303)return t+(this._data[t*ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ae+0]&4194303||this._data[t*ae+2]&50331648)return t+(this._data[t*ae+0]>>22);return 0}copyCellsFrom(t,s,i,r,o){let n=t._data;if(o)for(let c=r-1;c>=0;c--){for(let l=0;l<ae;l++)this._data[(i+c)*ae+l]=n[(s+c)*ae+l];n[(s+c)*ae+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let l=0;l<ae;l++)this._data[(i+c)*ae+l]=n[(s+c)*ae+l];n[(s+c)*ae+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}let a=Object.keys(t._combined);for(let c=0;c<a.length;c++){let l=parseInt(a[c],10);l>=s&&(this._combined[l-s+i]=t._combined[l])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let n=this._data[s*ae+0],a=n&2097151,c=n&2097152?this._combined[s]:a?ai(a):li;if(o+=c,r)for(let l=0;l<c.length;++l)r.push(s);s+=n>>22||1}return r&&r.push(s),o}};pf=class ff{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ff._nextId++,this._onDispose=this.register(new N),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),qi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};pf._nextId=1;By=pf,Oe={},ji=Oe.B;Oe[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};Oe.A={"#":"\xA3"};Oe.B=void 0;Oe[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};Oe.C=Oe[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Oe.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};Oe.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};Oe.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};Oe.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};Oe.E=Oe[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};Oe.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};Oe.H=Oe[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Oe["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};Zu=4294967295,Qu=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=De.clone(),this.savedCharset=ji,this.markers=[],this._nullCell=qt.fromCharData([0,wp,1,0]),this._whitespaceCell=qt.fromCharData([0,li,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ba,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ju(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 ua),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 ua),this._whitespaceCell}getBlankLine(e,t){return new Lo(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>Zu?Zu:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=De);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 Ju(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(De),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(e,s);let o=0;if(this._rows<t)for(let n=this._rows;n<t;n++)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 Lo(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new Lo(e,s)));else for(let n=this._rows;n>t;n--)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 n=this.lines.length-r;n>0&&(this.lines.trimStart(n),this.ybase=Math.max(this.ybase-n,0),this.ydisp=Math.max(this.ydisp-n,0),this.savedY=Math.max(this.savedY-n,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),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 o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.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 s=this._optionsService.rawOptions.reflowCursorLine,i=Ry(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(De),s);if(i.length>0){let r=Dy(this.lines,i);Ly(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(De),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Lo(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(De),r=[],o=0;for(let n=this.lines.length-1;n>=0;n--){let a=this.lines.get(n);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&n>0;)a=this.lines.get(--n),c.unshift(a);if(!s){let y=this.ybase+this.y;if(y>=n&&y<n+c.length)continue}let l=c[c.length-1].getTrimmedLength(),h=Py(c,this._cols,e),d=h.length-c.length,m;this.ybase===0&&this.y!==this.lines.length-1?m=Math.max(0,this.y-this.lines.maxLength+d):m=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let y=0;y<d;y++){let C=this.getBlankLine(De,!0);p.push(C)}p.length>0&&(r.push({start:n+c.length+o,newLines:p}),o+=p.length),c.push(...p);let f=h.length-1,_=h[f];_===0&&(f--,_=h[f]);let w=c.length-d-1,k=l;for(;w>=0;){let y=Math.min(k,_);if(c[f]===void 0)break;if(c[f].copyCellsFrom(c[w],k-y,_-y,y,!0),_-=y,_===0&&(f--,_=h[f]),k-=y,k===0){w--;let C=Math.max(w,0);k=Fo(c,C,this._cols)}}for(let y=0;y<c.length;y++)h[y]<e&&c[y].setCell(h[y],i);let $=d-m;for(;$-- >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+o)-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 n=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let c=this.lines.length,l=c-1,h=0,d=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let m=0;for(let _=Math.min(this.lines.maxLength-1,c+o-1);_>=0;_--)if(d&&d.start>l+m){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(_--,d.newLines[w]);_++,n.push({index:l+1,amount:d.newLines.length}),m+=d.newLines.length,d=r[++h]}else this.lines.set(_,a[l--]);let p=0;for(let _=n.length-1;_>=0;_--)n[_].index+=p,this.lines.onInsertEmitter.fire(n[_]),p+=n[_].amount;let f=Math.max(0,c+o-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}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 By(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},My=class extends re{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new N),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 Qu(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Qu(!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)}},mf=2,gf=1,Vc=class extends re{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new N),this.onResize=this._onResize.event,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,mf),this.rows=Math.max(e.rawOptions.rows||0,gf),this.buffers=this._register(new My(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let n=s.lines.isFull;o===s.lines.length-1?n?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),n?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let n=o-r+1;s.lines.shiftElements(r+1,n-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Vc=Ee([U(0,_t)],Vc);kr={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:va,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Iy=["normal","bold","100","200","300","400","500","600","700","800","900"],Oy=class extends re{constructor(e){super(),this._onOptionChange=this._register(new N),this.onOptionChange=this._onOptionChange.event;let t={...kr};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(we(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in kr))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in kr))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=kr[e]),!zy(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=kr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Iy.includes(t)?t:kr[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}};ep=Object.freeze({insertMode:!1}),tp=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Uc=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new N),this.onData=this._onData.event,this._onUserInput=this._register(new N),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new N),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new N),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Po(ep),this.decPrivateModes=Po(tp)}reset(){this.modes=Po(ep),this.decPrivateModes=Po(tp)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.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))}};Uc=Ee([U(0,gt),U(1,$p),U(2,_t)],Uc);sp={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}};cc=String.fromCharCode,ip={DEFAULT:e=>{let t=[lc(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${cc(t[0])}${cc(t[1])}${cc(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lc(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lc(e,!0)};${e.x};${e.y}${t}`}},qc=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new N),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(sp))this.addProtocol(i,sp[i]);for(let i of Object.keys(ip))this.addEncoding(i,ip[i]);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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+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,s){if(s){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)}};qc=Ee([U(0,gt),U(1,Gi),U(2,_t)],qc);hc=[[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]],Ny=[[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]];Hy=class{constructor(){if(this.version="6",!Ie){Ie=new Uint8Array(65536),Ie.fill(1),Ie[0]=0,Ie.fill(0,1,32),Ie.fill(0,127,160),Ie.fill(2,4352,4448),Ie[9001]=2,Ie[9002]=2,Ie.fill(2,11904,42192),Ie[12351]=1,Ie.fill(2,44032,55204),Ie.fill(2,63744,64256),Ie.fill(2,65040,65050),Ie.fill(2,65072,65136),Ie.fill(2,65280,65377),Ie.fill(2,65504,65511);for(let e=0;e<hc.length;++e)Ie.fill(0,hc[e][0],hc[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ie[e]:Fy(e,Ny)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=Vi.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return Vi.createPropertyValue(0,s,i)}},Vi=class da{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new N,this.onChange=this._onChange.event;let t=new Hy;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,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?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 s=0,i=0,r=t.length;for(let o=0;o<r;++o){let n=t.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return s+this.wcwidth(n);let l=t.charCodeAt(o);56320<=l&&l<=57343?n=(n-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(n,i),c=da.extractWidth(a);da.extractShouldJoin(a)&&(c-=da.extractWidth(i)),s+=c,i=a}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},Wy=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)}};$o=2147483647,jy=256,_f=class Kc{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>jy)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Kc;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let r=t[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let t=new Kc(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 s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,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>$o?$o: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>$o?$o:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,$o):t}},Eo=[],Vy=class{constructor(){this._state=0,this._active=Eo,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,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=Eo}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=Eo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Eo,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",wa(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}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 s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Eo,this._id=-1,this._state=0}}},Pt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=wa(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},To=[],Uy=class{constructor(){this._handlers=Object.create(null),this._active=To,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=To}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,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=To,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||To,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",wa(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=To,this._ident=0}},Bo=new _f;Bo.addParam(0);op=class{constructor(e){this._handler=e,this._data="",this._params=Bo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Bo,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=wa(e,t,s),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(s=>(this._params=Bo,this._data="",this._hitLimit=!1,s));return this._params=Bo,this._data="",this._hitLimit=!1,t}},qy=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=s<<4|i}},Ut=160,Ky=(function(){let e=new qy(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),s=(a,c)=>t.slice(a,c),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),n;e.setDefault(1,0),e.addMany(i,0,2,0);for(n in o)e.addMany([24,26,153,154],n,3,0),e.addMany(s(128,144),n,3,0),e.addMany(s(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,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(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,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(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(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(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Ut,0,2,0),e.add(Ut,8,5,8),e.add(Ut,6,0,6),e.add(Ut,11,0,11),e.add(Ut,13,13,13),e})(),Gy=class extends re{constructor(e=Ky){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 _f,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(we(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Vy),this._dcsParser=this._register(new Uy),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>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 o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.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,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,o=0,n;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===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,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](this._params),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],n=this._dcsParser.unhook(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],n=this._oscParser.end(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=o;a<t;++a){switch(i=e[a],r=this._transitions.table[this.currentState<<8|(i<160?i:Ut)],r>>4){case 2:for(let m=a+1;;++m){if(m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}if(++m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}if(++m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}if(++m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(n=c[l](this._params),n!==!0);l--)if(n instanceof Promise)return this._preserveStack(3,c,l,r,a),n;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a<t&&(i=e[a])>47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let h=this._escHandlers[this._collect<<8|i],d=h?h.length-1:-1;for(;d>=0&&(n=h[d](),n!==!0);d--)if(n instanceof Promise)return this._preserveStack(4,h,d,r,a),n;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let m=a+1;;++m)if(m>=t||(i=e[m])===24||i===26||i===27||i>127&&i<Ut){this._dcsParser.put(e,a,m),a=m-1;break}break;case 14:if(n=this._dcsParser.unhook(i!==24&&i!==26),n)return this._preserveStack(6,[],0,r,a),n;i===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 m=a+1;;m++)if(m>=t||(i=e[m])<32||i>127&&i<Ut){this._oscParser.put(e,a,m),a=m-1;break}break;case 6:if(n=this._oscParser.end(i!==24&&i!==26),n)return this._preserveStack(5,[],0,r,a),n;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Yy=/^([\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})$/,Xy=/^[\da-f]+$/;Zy={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ni=131072,ap=10;cp=5e3,hp=0,Qy=class extends re{constructor(e,t,s,i,r,o,n,a,c=new Gy){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=n,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Vv,this._utf8Decoder=new Uv,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=De.clone(),this._eraseAttrDataInternal=De.clone(),this._onRequestBell=this._register(new N),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new N),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new N),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new N),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new N),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new N),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new N),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new N),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new N),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new N),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 Gc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:h.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,h,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:h,data:d})}),this._parser.setDcsHandlerFallback((l,h,d)=>{h==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:h,payload:d})}),this._parser.setPrintHandler((l,h,d)=>this.print(l,h,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(M.BEL,()=>this.bell()),this._parser.setExecuteHandler(M.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(M.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(M.BS,()=>this.backspace()),this._parser.setExecuteHandler(M.HT,()=>this.tab()),this._parser.setExecuteHandler(M.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(M.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ca.IND,()=>this.index()),this._parser.setExecuteHandler(ca.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ca.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Pt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Pt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Pt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Pt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Pt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Pt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Pt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Pt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Pt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Pt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Pt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Pt(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 Oe)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 op((l,h)=>this.requestStatusString(l,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),cp))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${cp} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,n=this._parseStack.paused;if(n){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ni&&(o=this._parseStack.position+ni)}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<ni&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ni))),n||this._dirtyRowTracker.clearRange(),e.length>ni)for(let l=o;l<e.length;l+=ni){let h=l+ni<e.length?l+ni:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,l),this._logSlowResolvingAsync(s),s}else if(!n){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,r,l,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,s){let i,r,o=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,h=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let m=this._parser.precedingJoinState;for(let p=t;p<s;++p){if(i=e[p],i<127&&o){let k=o[String.fromCharCode(i)];k&&(i=k.charCodeAt(0))}let f=this._unicodeService.charProperties(i,m);r=Vi.extractWidth(f);let _=Vi.extractShouldJoin(f),w=_?Vi.extractWidth(m):0;if(m=f,n&&this._onA11yChar.fire(ai(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-w>a){if(c){let k=d,$=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),w>0&&d instanceof Lo&&d.copyCellsFrom(k,$,0,w,!1);$<a;)k.setCellFromCodepoint($++,0,1,h)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let k=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-k,i,r);for(let $=r-w;--$>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-w,this._activeBuffer.getNullCell(h)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,h)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,h),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=m,this._activeBuffer.x<a&&s-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>lp(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new op(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Pt(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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 s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(r-1,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}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 s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,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}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(De));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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=e.params[0]||1,i=Vi.extractWidth(t),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),n=new Uint32Array(o.length*s),a=0;for(let l=0;l<o.length;){let h=o.codePointAt(l)||0;n[a++]=h,l+=h>65535?2:1}let c=a;for(let l=1;l<s;++l)n.copyWithin(c,0,a),c+=a;return this.print(n,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(M.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(M.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(M.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(M.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(M.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,ji),this._charsetService.setgCharset(1,ji),this._charsetService.setgCharset(2,ji),this._charsetService.setgCharset(3,ji);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){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,n=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:l,alt:h}=a,d=this._optionsService.rawOptions,m=(_,w)=>(n.triggerDataEvent(`${M.ESC}[${t?"":"?"}${_};${w}$y`),!0),p=_=>_?1:2,f=e.params[0];return t?f===2?m(f,4):f===4?m(f,p(n.modes.insertMode)):f===12?m(f,3):f===20?m(f,p(d.convertEol)):m(f,0):f===1?m(f,p(i.applicationCursorKeys)):f===3?m(f,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):f===6?m(f,p(i.origin)):f===7?m(f,p(i.wraparound)):f===8?m(f,3):f===9?m(f,p(r==="X10")):f===12?m(f,p(d.cursorBlink)):f===25?m(f,p(!n.isCursorHidden)):f===45?m(f,p(i.reverseWraparound)):f===66?m(f,p(i.applicationKeypad)):f===67?m(f,4):f===1e3?m(f,p(r==="VT200")):f===1002?m(f,p(r==="DRAG")):f===1003?m(f,p(r==="ANY")):f===1004?m(f,p(i.sendFocus)):f===1005?m(f,4):f===1006?m(f,p(o==="SGR")):f===1015?m(f,4):f===1016?m(f,p(o==="SGR_PIXELS")):f===1048?m(f,1):f===47||f===1047||f===1049?m(f,p(l===h)):f===2004?m(f,p(i.bracketedPasteMode)):f===2026?m(f,p(i.synchronizedOutput)):m(f,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=Ho.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=e.params[t+o],e.hasSubParams(t+o)){let n=e.getSubParams(t+o),a=0;do i[1]===5&&(r=1),i[o+a+1+r]=n[a];while(++a<n.length&&a+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+t<e.length&&o+r<i.length);for(let n=2;n<i.length;++n)i[n]===-1&&(i[n]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_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=De.fg,e.bg=De.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,s,i=this._curAttrData;for(let r=0;r<t;r++)s=e.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=De.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=De.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=De.fg&16777215,i.bg&=-67108864,i.bg|=De.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${M.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[?${t};${s}R`);break;case 15:break;case 25:break;case 26:break;case 53: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=De.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!lp(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(`${M.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ap&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ap&&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=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(dp(o))if(r==="?")t.push({type:0,index:o});else{let n=np(r);n&&t.push({type:1,index:o,color:n})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,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 s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=np(s[i]);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=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);dp(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,ji),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Zy[e[0]],Oe[e[1]]||ji),!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=De.clone(),this._eraseAttrDataInternal=De.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 qt;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 s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=n=>(this._coreService.triggerDataEvent(`${M.ESC}${n}${M.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.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)}},Gc=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&&(hp=e,e=t,t=hp),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Gc=Ee([U(0,gt)],Gc);ew=5e7,up=12,tw=50,sw=class extends re{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 N),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 s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>ew)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let n=a=>performance.now()-s>=up?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(n);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=up)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>tw&&(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()}},Yc=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),c={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._dataByLinkId.set(c.id,c),c.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let o=t.addMarker(t.ybase+t.y),n={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(n,o)),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Yc=Ee([U(0,gt)],Yc);pp=!1,iw=class extends re{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Er),this._onBinary=this._register(new N),this.onBinary=this._onBinary.event,this._onData=this._register(new N),this.onData=this._onData.event,this._onLineFeed=this._register(new N),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new N),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new N),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new N),this._instantiationService=new $y,this.optionsService=this._register(new Oy(e)),this._instantiationService.setService(_t,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vc)),this._instantiationService.setService(gt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(jc)),this._instantiationService.setService($p,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Uc)),this._instantiationService.setService(Gi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(qc)),this._instantiationService.setService(kp,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Vi)),this._instantiationService.setService(Yv,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Wy),this._instantiationService.setService(Gv,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Yc),this._instantiationService.setService(Ep,this._oscLinkService),this._inputHandler=this._register(new Qy(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ot.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ot.forward(this._bufferService.onResize,this._onResize)),this._register(ot.forward(this.coreService.onData,this._onData)),this._register(ot.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 sw((t,s)=>this._inputHandler.parse(t,s))),this._register(ot.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new N),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!pp&&(this._logService.warn("writeSync is unreliable and will be removed soon."),pp=!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,mf),t=Math.max(t,gf),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(rp.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(rp(this._bufferService),!1))),this._windowsWrappingHeuristics.value=we(()=>{for(let t of e)t.dispose()})}}},rw={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:["'",'"']};Ae=0,nw=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ba,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ba,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,o)=>this._getKey(r)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,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||(Ae=this._search(t),Ae===-1)||this._getKey(this._array[Ae])!==t)return!1;do if(this._array[Ae]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ae),!0;while(++Ae<this._array.length&&this._getKey(this._array[Ae])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,o)=>r-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:s[i++]=this._array[r];this._array=s,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&&(Ae=this._search(e),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===e))do yield this._array[Ae];while(++Ae<this._array.length&&this._getKey(this._array[Ae])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ae=this._search(e),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===e))do t(this._array[Ae]);while(++Ae<this._array.length&&this._getKey(this._array[Ae])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},uc=0,fp=0,aw=class extends re{constructor(){super(),this._decorations=new nw(e=>e?.marker.line),this._onDecorationRegistered=this._register(new N),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new N),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(we(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new lw(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,r=i+(o.options.width??1),e>=i&&e<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,r=>{uc=r.options.x??0,fp=uc+(r.options.width??1),e>=uc&&e<fp&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},lw=class extends ci{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new N),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new N),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=ke.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ke.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},cw=1e3,hw=class{constructor(e,t=cw){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,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 i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_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)}},mp=20,gp=!1,ya=class extends re{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,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 o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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 hw(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");gp?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=r.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(r.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(r.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
33
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),nh&&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),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=qu(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,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=oh(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-nc),nc),t/=nc,t/Math.abs(t)+Math.round(t*(yy-1)))}shouldForceSelection(e){return va?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(),wy)}_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&&!(va&&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 s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.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<Sy&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=uy(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);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,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,o=r.lines.get(e[1]);if(!o)return;let n=r.translateBufferLineToString(e[1],!1),a=this._convertViewportColToCharacterIndex(o,e[0]),c=a,l=e[0]-a,h=0,d=0,m=0,p=0;if(n.charAt(a)===" "){for(;a>0&&n.charAt(a-1)===" ";)a--;for(;c<n.length&&n.charAt(c+1)===" ";)c++}else{let w=e[0],k=e[0];o.getWidth(w)===0&&(h++,w--),o.getWidth(k)===2&&(d++,k++);let $=o.getString(k).length;for($>1&&(p+=$-1,c+=$-1);w>0&&a>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===0?(h++,w--):y>1&&(m+=y-1,a-=y-1),a--,w--}for(;k<o.length&&c+1<n.length&&!this._isCharWordSeparator(o.loadCell(k+1,this._workCell));){o.loadCell(k+1,this._workCell);let y=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,k++):y>1&&(p+=y-1,c+=y-1),c++,k++}}c++;let f=a+l-h+m,_=Math.min(this._bufferService.cols,c-a+h+d-m-p);if(!(!t&&n.slice(a,c).trim()==="")){if(s&&f===0&&o.getCodePoint(0)!==32){let w=r.lines.get(e[1]-1);if(w&&o.isWrapped&&w.getCodePoint(this._bufferService.cols-1)!==32){let k=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(k){let $=this._bufferService.cols-k.start;f-=$,_+=$}}}if(i&&f+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=r.lines.get(e[1]+1);if(w?.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(_+=k.length)}}return{start:f,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={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=qu(s,this._bufferService.cols)}};Hc=Ee([U(3,gt),U(4,Gi),U(5,Zc),U(6,_t),U(7,Hs),U(8,Fs)],Hc);Ku=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Gu=class{constructor(){this._color=new Ku,this._css=new Ku}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Me=Object.freeze((()=>{let e=[ke.toColor("#2e3436"),ke.toColor("#cc0000"),ke.toColor("#4e9a06"),ke.toColor("#c4a000"),ke.toColor("#3465a4"),ke.toColor("#75507b"),ke.toColor("#06989a"),ke.toColor("#d3d7cf"),ke.toColor("#555753"),ke.toColor("#ef2929"),ke.toColor("#8ae234"),ke.toColor("#fce94f"),ke.toColor("#729fcf"),ke.toColor("#ad7fa8"),ke.toColor("#34e2e2"),ke.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],o=t[s%6];e.push({css:Le.toCss(i,r,o),rgba:Le.toRgba(i,r,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Le.toCss(i,i,i),rgba:Le.toRgba(i,i,i)})}return e})()),Wi=ke.toColor("#ffffff"),Do=ke.toColor("#000000"),Yu=ke.toColor("#ffffff"),Xu=Do,ko={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ky=Wi,Wc=class extends re{constructor(e){super(),this._optionsService=e,this._contrastCache=new Gu,this._halfContrastCache=new Gu,this._onChangeColors=this._register(new N),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Wi,background:Do,cursor:Yu,cursorAccent:Xu,selectionForeground:void 0,selectionBackgroundTransparent:ko,selectionBackgroundOpaque:ye.blend(Do,ko),selectionInactiveBackgroundTransparent:ko,selectionInactiveBackgroundOpaque:ye.blend(Do,ko),scrollbarSliderBackground:ye.opacity(Wi,.2),scrollbarSliderHoverBackground:ye.opacity(Wi,.4),scrollbarSliderActiveBackground:ye.opacity(Wi,.5),overviewRulerBorder:Wi,ansi:Me.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ge(e.foreground,Wi),t.background=ge(e.background,Do),t.cursor=ye.blend(t.background,ge(e.cursor,Yu)),t.cursorAccent=ye.blend(t.background,ge(e.cursorAccent,Xu)),t.selectionBackgroundTransparent=ge(e.selectionBackground,ko),t.selectionBackgroundOpaque=ye.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ge(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=ye.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ge(e.selectionForeground,ju):void 0,t.selectionForeground===ju&&(t.selectionForeground=void 0),ye.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=ye.opacity(t.selectionBackgroundTransparent,.3)),ye.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=ye.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ge(e.scrollbarSliderBackground,ye.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ge(e.scrollbarSliderHoverBackground,ye.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ge(e.scrollbarSliderActiveBackground,ye.opacity(t.foreground,.5)),t.overviewRulerBorder=ge(e.overviewRulerBorder,ky),t.ansi=Me.slice(),t.ansi[0]=ge(e.black,Me[0]),t.ansi[1]=ge(e.red,Me[1]),t.ansi[2]=ge(e.green,Me[2]),t.ansi[3]=ge(e.yellow,Me[3]),t.ansi[4]=ge(e.blue,Me[4]),t.ansi[5]=ge(e.magenta,Me[5]),t.ansi[6]=ge(e.cyan,Me[6]),t.ansi[7]=ge(e.white,Me[7]),t.ansi[8]=ge(e.brightBlack,Me[8]),t.ansi[9]=ge(e.brightRed,Me[9]),t.ansi[10]=ge(e.brightGreen,Me[10]),t.ansi[11]=ge(e.brightYellow,Me[11]),t.ansi[12]=ge(e.brightBlue,Me[12]),t.ansi[13]=ge(e.brightMagenta,Me[13]),t.ansi[14]=ge(e.brightCyan,Me[14]),t.ansi[15]=ge(e.brightWhite,Me[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=ge(e.extendedAnsi[i],Me[i+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()}}};Wc=Ee([U(0,_t)],Wc);$y=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Ey=class{constructor(){this._services=new $y,this._services.set(Jc,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=Kv(e).sort((o,n)=>o.index-n.index),i=[];for(let o of s){let n=this._services.get(o.id);if(!n)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(n)}let r=s.length>0?s[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,...i)}},Ty={trace:0,debug:1,info:2,warn:3,error:4,off:5},Ay="xterm.js: ",jc=class extends re{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),Ry=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Ty[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,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":Ay)+t,...s)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};jc=Ee([U(0,_t)],jc);Ju=class extends re{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new N),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new N),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new N),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 s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];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,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ae=3,De=Object.freeze(new Ho),ta=0,ac=2,Lo=class uf{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ae);let r=s||qt.fromCharData([0,wp,1,0]);for(let o=0;o<t;++o)this.setCell(o,r);this.length=t}get(t){let s=this._data[t*ae+0],i=s&2097151;return[this._data[t*ae+1],s&2097152?this._combined[t]:i?ai(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ae+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ae+0]=t|2097152|s[2]<<22):this._data[t*ae+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ae+0]>>22}hasWidth(t){return this._data[t*ae+0]&12582912}getFg(t){return this._data[t*ae+1]}getBg(t){return this._data[t*ae+2]}hasContent(t){return this._data[t*ae+0]&4194303}getCodePoint(t){let s=this._data[t*ae+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ae+0]&2097152}getString(t){let s=this._data[t*ae+0];return s&2097152?this._combined[t]:s&2097151?ai(s&2097151):""}isProtected(t){return this._data[t*ae+2]&536870912}loadCell(t,s){return ta=t*ae,s.content=this._data[ta+0],s.fg=this._data[ta+1],s.bg=this._data[ta+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ae+0]=s.content,this._data[t*ae+1]=s.fg,this._data[t*ae+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*ae+0]=s|i<<22,this._data[t*ae+1]=r.fg,this._data[t*ae+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*ae+0];r&2097152?this._combined[t]+=ai(s):r&2097151?(this._combined[t]=ai(r&2097151)+ai(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*ae+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let r=new qt;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,r));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let r=new qt;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,r));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*ac<this._data.buffer.byteLength;let i=t*ae;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let n=0;n<r.length;n++){let a=parseInt(r[n],10);a>=t&&delete this._combined[a]}let o=Object.keys(this._extendedAttrs);for(let n=0;n<o.length;n++){let a=parseInt(o[n],10);a>=t&&delete this._extendedAttrs[a]}}return this.length=t,i*4*ac<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*ac<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,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 s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new uf(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ae+0]&4194303)return t+(this._data[t*ae+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ae+0]&4194303||this._data[t*ae+2]&50331648)return t+(this._data[t*ae+0]>>22);return 0}copyCellsFrom(t,s,i,r,o){let n=t._data;if(o)for(let c=r-1;c>=0;c--){for(let l=0;l<ae;l++)this._data[(i+c)*ae+l]=n[(s+c)*ae+l];n[(s+c)*ae+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}else for(let c=0;c<r;c++){for(let l=0;l<ae;l++)this._data[(i+c)*ae+l]=n[(s+c)*ae+l];n[(s+c)*ae+2]&268435456&&(this._extendedAttrs[i+c]=t._extendedAttrs[s+c])}let a=Object.keys(t._combined);for(let c=0;c<a.length;c++){let l=parseInt(a[c],10);l>=s&&(this._combined[l-s+i]=t._combined[l])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let o="";for(;s<i;){let n=this._data[s*ae+0],a=n&2097151,c=n&2097152?this._combined[s]:a?ai(a):li;if(o+=c,r)for(let l=0;l<c.length;++l)r.push(s);s+=n>>22||1}return r&&r.push(s),o}};pf=class ff{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=ff._nextId++,this._onDispose=this.register(new N),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),qi(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};pf._nextId=1;My=pf,Oe={},ji=Oe.B;Oe[0]={"`":"\u25C6",a:"\u2592",b:"\u2409",c:"\u240C",d:"\u240D",e:"\u240A",f:"\xB0",g:"\xB1",h:"\u2424",i:"\u240B",j:"\u2518",k:"\u2510",l:"\u250C",m:"\u2514",n:"\u253C",o:"\u23BA",p:"\u23BB",q:"\u2500",r:"\u23BC",s:"\u23BD",t:"\u251C",u:"\u2524",v:"\u2534",w:"\u252C",x:"\u2502",y:"\u2264",z:"\u2265","{":"\u03C0","|":"\u2260","}":"\xA3","~":"\xB7"};Oe.A={"#":"\xA3"};Oe.B=void 0;Oe[4]={"#":"\xA3","@":"\xBE","[":"ij","\\":"\xBD","]":"|","{":"\xA8","|":"f","}":"\xBC","~":"\xB4"};Oe.C=Oe[5]={"[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Oe.R={"#":"\xA3","@":"\xE0","[":"\xB0","\\":"\xE7","]":"\xA7","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xA8"};Oe.Q={"@":"\xE0","[":"\xE2","\\":"\xE7","]":"\xEA","^":"\xEE","`":"\xF4","{":"\xE9","|":"\xF9","}":"\xE8","~":"\xFB"};Oe.K={"@":"\xA7","[":"\xC4","\\":"\xD6","]":"\xDC","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xDF"};Oe.Y={"#":"\xA3","@":"\xA7","[":"\xB0","\\":"\xE7","]":"\xE9","`":"\xF9","{":"\xE0","|":"\xF2","}":"\xE8","~":"\xEC"};Oe.E=Oe[6]={"@":"\xC4","[":"\xC6","\\":"\xD8","]":"\xC5","^":"\xDC","`":"\xE4","{":"\xE6","|":"\xF8","}":"\xE5","~":"\xFC"};Oe.Z={"#":"\xA3","@":"\xA7","[":"\xA1","\\":"\xD1","]":"\xBF","{":"\xB0","|":"\xF1","}":"\xE7"};Oe.H=Oe[7]={"@":"\xC9","[":"\xC4","\\":"\xD6","]":"\xC5","^":"\xDC","`":"\xE9","{":"\xE4","|":"\xF6","}":"\xE5","~":"\xFC"};Oe["="]={"#":"\xF9","@":"\xE0","[":"\xE9","\\":"\xE7","]":"\xEA","^":"\xEE",_:"\xE8","`":"\xF4","{":"\xE4","|":"\xF6","}":"\xFC","~":"\xFB"};Zu=4294967295,Qu=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=De.clone(),this.savedCharset=ji,this.markers=[],this._nullCell=qt.fromCharData([0,wp,1,0]),this._whitespaceCell=qt.fromCharData([0,li,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ba,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Ju(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 ua),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 ua),this._whitespaceCell}getBlankLine(e,t){return new Lo(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>Zu?Zu:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=De);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 Ju(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(De),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(e,s);let o=0;if(this._rows<t)for(let n=this._rows;n<t;n++)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 Lo(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new Lo(e,s)));else for(let n=this._rows;n>t;n--)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 n=this.lines.length-r;n>0&&(this.lines.trimStart(n),this.ybase=Math.max(this.ybase-n,0),this.ydisp=Math.max(this.ydisp-n,0),this.savedY=Math.max(this.savedY-n,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),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 o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.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 s=this._optionsService.rawOptions.reflowCursorLine,i=Dy(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(De),s);if(i.length>0){let r=Ly(this.lines,i);Py(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(De),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new Lo(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(De),r=[],o=0;for(let n=this.lines.length-1;n>=0;n--){let a=this.lines.get(n);if(!a||!a.isWrapped&&a.getTrimmedLength()<=e)continue;let c=[a];for(;a.isWrapped&&n>0;)a=this.lines.get(--n),c.unshift(a);if(!s){let y=this.ybase+this.y;if(y>=n&&y<n+c.length)continue}let l=c[c.length-1].getTrimmedLength(),h=By(c,this._cols,e),d=h.length-c.length,m;this.ybase===0&&this.y!==this.lines.length-1?m=Math.max(0,this.y-this.lines.maxLength+d):m=Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let y=0;y<d;y++){let C=this.getBlankLine(De,!0);p.push(C)}p.length>0&&(r.push({start:n+c.length+o,newLines:p}),o+=p.length),c.push(...p);let f=h.length-1,_=h[f];_===0&&(f--,_=h[f]);let w=c.length-d-1,k=l;for(;w>=0;){let y=Math.min(k,_);if(c[f]===void 0)break;if(c[f].copyCellsFrom(c[w],k-y,_-y,y,!0),_-=y,_===0&&(f--,_=h[f]),k-=y,k===0){w--;let C=Math.max(w,0);k=Fo(c,C,this._cols)}}for(let y=0;y<c.length;y++)h[y]<e&&c[y].setCell(h[y],i);let $=d-m;for(;$-- >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+o)-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 n=[],a=[];for(let _=0;_<this.lines.length;_++)a.push(this.lines.get(_));let c=this.lines.length,l=c-1,h=0,d=r[h];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let m=0;for(let _=Math.min(this.lines.maxLength-1,c+o-1);_>=0;_--)if(d&&d.start>l+m){for(let w=d.newLines.length-1;w>=0;w--)this.lines.set(_--,d.newLines[w]);_++,n.push({index:l+1,amount:d.newLines.length}),m+=d.newLines.length,d=r[++h]}else this.lines.set(_,a[l--]);let p=0;for(let _=n.length-1;_>=0;_--)n[_].index+=p,this.lines.onInsertEmitter.fire(n[_]),p+=n[_].amount;let f=Math.max(0,c+o-this.lines.maxLength);f>0&&this.lines.onTrimEmitter.fire(f)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}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 My(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Iy=class extends re{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new N),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 Qu(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Qu(!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)}},mf=2,gf=1,Vc=class extends re{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new N),this.onResize=this._onResize.event,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,mf),this.rows=Math.max(e.rawOptions.rows||0,gf),this.buffers=this._register(new Iy(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let n=s.lines.isFull;o===s.lines.length-1?n?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),n?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let n=o-r+1;s.lines.shiftElements(r+1,n-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Vc=Ee([U(0,_t)],Vc);kr={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:va,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Oy=["normal","bold","100","200","300","400","500","600","700","800","900"],zy=class extends re{constructor(e){super(),this._onOptionChange=this._register(new N),this.onOptionChange=this._onOptionChange.event;let t={...kr};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(we(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in kr))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in kr))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=kr[e]),!Ny(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=kr[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Oy.includes(t)?t:kr[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}};ep=Object.freeze({insertMode:!1}),tp=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Uc=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new N),this.onData=this._onData.event,this._onUserInput=this._register(new N),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new N),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new N),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Po(ep),this.decPrivateModes=Po(tp)}reset(){this.modes=Po(ep),this.decPrivateModes=Po(tp)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.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))}};Uc=Ee([U(0,gt),U(1,$p),U(2,_t)],Uc);sp={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}};cc=String.fromCharCode,ip={DEFAULT:e=>{let t=[lc(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${cc(t[0])}${cc(t[1])}${cc(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lc(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${lc(e,!0)};${e.x};${e.y}${t}`}},qc=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new N),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(sp))this.addProtocol(i,sp[i]);for(let i of Object.keys(ip))this.addEncoding(i,ip[i]);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,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+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,s){if(s){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)}};qc=Ee([U(0,gt),U(1,Gi),U(2,_t)],qc);hc=[[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]],Fy=[[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]];Wy=class{constructor(){if(this.version="6",!Ie){Ie=new Uint8Array(65536),Ie.fill(1),Ie[0]=0,Ie.fill(0,1,32),Ie.fill(0,127,160),Ie.fill(2,4352,4448),Ie[9001]=2,Ie[9002]=2,Ie.fill(2,11904,42192),Ie[12351]=1,Ie.fill(2,44032,55204),Ie.fill(2,63744,64256),Ie.fill(2,65040,65050),Ie.fill(2,65072,65136),Ie.fill(2,65280,65377),Ie.fill(2,65504,65511);for(let e=0;e<hc.length;++e)Ie.fill(0,hc[e][0],hc[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ie[e]:Hy(e,Fy)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=Vi.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return Vi.createPropertyValue(0,s,i)}},Vi=class da{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new N,this.onChange=this._onChange.event;let t=new Wy;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,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?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 s=0,i=0,r=t.length;for(let o=0;o<r;++o){let n=t.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=r)return s+this.wcwidth(n);let l=t.charCodeAt(o);56320<=l&&l<=57343?n=(n-55296)*1024+l-56320+65536:s+=this.wcwidth(l)}let a=this.charProperties(n,i),c=da.extractWidth(a);da.extractShouldJoin(a)&&(c-=da.extractWidth(i)),s+=c,i=a}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},jy=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)}};$o=2147483647,Vy=256,_f=class Kc{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>Vy)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Kc;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let r=t[i];if(Array.isArray(r))for(let o=0;o<r.length;++o)s.addSubParam(r[o]);else s.addParam(r)}return s}clone(){let t=new Kc(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 s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,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>$o?$o: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>$o?$o:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,$o):t}},Eo=[],Uy=class{constructor(){this._state=0,this._active=Eo,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 s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,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=Eo}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=Eo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Eo,!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,s){if(!this._active.length)this._handlerFb(this._id,"PUT",wa(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}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 s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Eo,this._id=-1,this._state=0}}},Pt=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=wa(e,t,s),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(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},To=[],qy=class{constructor(){this._handlers=Object.create(null),this._active=To,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=To}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,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=To,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||To,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",wa(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=To,this._ident=0}},Bo=new _f;Bo.addParam(0);op=class{constructor(e){this._handler=e,this._data="",this._params=Bo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Bo,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=wa(e,t,s),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(s=>(this._params=Bo,this._data="",this._hitLimit=!1,s));return this._params=Bo,this._data="",this._hitLimit=!1,t}},Ky=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=s<<4|i}},Ut=160,Gy=(function(){let e=new Ky(4095),t=Array.apply(null,Array(256)).map((a,c)=>c),s=(a,c)=>t.slice(a,c),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let o=s(0,14),n;e.setDefault(1,0),e.addMany(i,0,2,0);for(n in o)e.addMany([24,26,153,154],n,3,0),e.addMany(s(128,144),n,3,0),e.addMany(s(144,152),n,3,0),e.add(156,n,0,0),e.add(27,n,11,1),e.add(157,n,4,8),e.addMany([152,158,159],n,0,7),e.add(155,n,11,3),e.add(144,n,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(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,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(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(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(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Ut,0,2,0),e.add(Ut,8,5,8),e.add(Ut,6,0,6),e.add(Ut,11,0,11),e.add(Ut,13,13,13),e})(),Yy=class extends re{constructor(e=Gy){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 _f,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},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(we(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Uy),this._dcsParser=this._register(new qy),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>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 o=e.intermediates.charCodeAt(r);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}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 s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.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 s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.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,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,o=0,n;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===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,c=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](this._params),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 4:if(s===!1&&c>-1){for(;c>=0&&(n=a[c](),n!==!0);c--)if(n instanceof Promise)return this._parseStack.handlerPos=c,n}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],n=this._dcsParser.unhook(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],n=this._oscParser.end(i!==24&&i!==26,s),n)return n;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let a=o;a<t;++a){switch(i=e[a],r=this._transitions.table[this.currentState<<8|(i<160?i:Ut)],r>>4){case 2:for(let m=a+1;;++m){if(m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}if(++m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}if(++m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}if(++m>=t||(i=e[m])<32||i>126&&i<Ut){this._printHandler(e,a,m),a=m-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:a,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let c=this._csiHandlers[this._collect<<8|i],l=c?c.length-1:-1;for(;l>=0&&(n=c[l](this._params),n!==!0);l--)if(n instanceof Promise)return this._preserveStack(3,c,l,r,a),n;l<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++a<t&&(i=e[a])>47&&i<60);a--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let h=this._escHandlers[this._collect<<8|i],d=h?h.length-1:-1;for(;d>=0&&(n=h[d](),n!==!0);d--)if(n instanceof Promise)return this._preserveStack(4,h,d,r,a),n;d<0&&this._escHandlerFb(this._collect<<8|i),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|i,this._params);break;case 13:for(let m=a+1;;++m)if(m>=t||(i=e[m])===24||i===26||i===27||i>127&&i<Ut){this._dcsParser.put(e,a,m),a=m-1;break}break;case 14:if(n=this._dcsParser.unhook(i!==24&&i!==26),n)return this._preserveStack(6,[],0,r,a),n;i===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 m=a+1;;m++)if(m>=t||(i=e[m])<32||i>127&&i<Ut){this._oscParser.put(e,a,m),a=m-1;break}break;case 6:if(n=this._oscParser.end(i!==24&&i!==26),n)return this._preserveStack(5,[],0,r,a),n;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},Xy=/^([\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})$/,Jy=/^[\da-f]+$/;Qy={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ni=131072,ap=10;cp=5e3,hp=0,ew=class extends re{constructor(e,t,s,i,r,o,n,a,c=new Yy){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=o,this._coreMouseService=n,this._unicodeService=a,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Uv,this._utf8Decoder=new qv,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=De.clone(),this._eraseAttrDataInternal=De.clone(),this._onRequestBell=this._register(new N),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new N),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new N),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new N),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new N),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new N),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new N),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new N),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new N),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new N),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new N),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 Gc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(l=>this._activeBuffer=l.activeBuffer)),this._parser.setCsiHandlerFallback((l,h)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(l),params:h.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,h,d)=>{this._logService.debug("Unknown OSC code: ",{identifier:l,action:h,data:d})}),this._parser.setDcsHandlerFallback((l,h,d)=>{h==="HOOK"&&(d=d.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(l),action:h,payload:d})}),this._parser.setPrintHandler((l,h,d)=>this.print(l,h,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(M.BEL,()=>this.bell()),this._parser.setExecuteHandler(M.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(M.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(M.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(M.BS,()=>this.backspace()),this._parser.setExecuteHandler(M.HT,()=>this.tab()),this._parser.setExecuteHandler(M.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(M.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(ca.IND,()=>this.index()),this._parser.setExecuteHandler(ca.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(ca.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Pt(l=>(this.setTitle(l),this.setIconName(l),!0))),this._parser.registerOscHandler(1,new Pt(l=>this.setIconName(l))),this._parser.registerOscHandler(2,new Pt(l=>this.setTitle(l))),this._parser.registerOscHandler(4,new Pt(l=>this.setOrReportIndexedColor(l))),this._parser.registerOscHandler(8,new Pt(l=>this.setHyperlink(l))),this._parser.registerOscHandler(10,new Pt(l=>this.setOrReportFgColor(l))),this._parser.registerOscHandler(11,new Pt(l=>this.setOrReportBgColor(l))),this._parser.registerOscHandler(12,new Pt(l=>this.setOrReportCursorColor(l))),this._parser.registerOscHandler(104,new Pt(l=>this.restoreIndexedColor(l))),this._parser.registerOscHandler(110,new Pt(l=>this.restoreFgColor(l))),this._parser.registerOscHandler(111,new Pt(l=>this.restoreBgColor(l))),this._parser.registerOscHandler(112,new Pt(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 Oe)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 op((l,h)=>this.requestStatusString(l,h)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),cp))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${cp} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,o=0,n=this._parseStack.paused;if(n){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ni&&(o=this._parseStack.position+ni)}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<ni&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ni))),n||this._dirtyRowTracker.clearRange(),e.length>ni)for(let l=o;l<e.length;l+=ni){let h=l+ni<e.length?l+ni:e.length,d=typeof e=="string"?this._stringDecoder.decode(e.substring(l,h),this._parseBuffer):this._utf8Decoder.decode(e.subarray(l,h),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,d))return this._preserveStack(i,r,d,l),this._logSlowResolvingAsync(s),s}else if(!n){let l=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,l))return this._preserveStack(i,r,l,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let a=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(a,this._bufferService.rows-1)})}print(e,t,s){let i,r,o=this._charsetService.charset,n=this._optionsService.rawOptions.screenReaderMode,a=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,h=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,h);let m=this._parser.precedingJoinState;for(let p=t;p<s;++p){if(i=e[p],i<127&&o){let k=o[String.fromCharCode(i)];k&&(i=k.charCodeAt(0))}let f=this._unicodeService.charProperties(i,m);r=Vi.extractWidth(f);let _=Vi.extractShouldJoin(f),w=_?Vi.extractWidth(m):0;if(m=f,n&&this._onA11yChar.fire(ai(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-w>a){if(c){let k=d,$=this._activeBuffer.x-w;for(this._activeBuffer.x=w,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),w>0&&d instanceof Lo&&d.copyCellsFrom(k,$,0,w,!1);$<a;)k.setCellFromCodepoint($++,0,1,h)}else if(this._activeBuffer.x=a-1,r===2)continue}if(_&&this._activeBuffer.x){let k=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-k,i,r);for(let $=r-w;--$>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h);continue}if(l&&(d.insertCells(this._activeBuffer.x,r-w,this._activeBuffer.getNullCell(h)),d.getWidth(a-1)===2&&d.setCellFromCodepoint(a-1,0,1,h)),d.setCellFromCodepoint(this._activeBuffer.x++,i,r,h),r>0)for(;--r;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,h)}this._parser.precedingJoinState=m,this._activeBuffer.x<a&&s-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,h),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>lp(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new op(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Pt(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let i=this._activeBuffer.lines.length-this._bufferService.rows;i>0&&(this._activeBuffer.lines.trimStart(i),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-i,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-i,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 s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(r-1,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}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 s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,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}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(De));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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.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 s=e.params[0]||1,i=Vi.extractWidth(t),r=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),n=new Uint32Array(o.length*s),a=0;for(let l=0;l<o.length;){let h=o.codePointAt(l)||0;n[a++]=h,l+=h>65535?2:1}let c=a;for(let l=1;l<s;++l)n.copyWithin(c,0,a),c+=a;return this.print(n,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(M.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(M.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(M.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(M.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(M.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,ji),this._charsetService.setgCharset(1,ji),this._charsetService.setgCharset(2,ji),this._charsetService.setgCharset(3,ji);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){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:o}=this._coreMouseService,n=this._coreService,{buffers:a,cols:c}=this._bufferService,{active:l,alt:h}=a,d=this._optionsService.rawOptions,m=(_,w)=>(n.triggerDataEvent(`${M.ESC}[${t?"":"?"}${_};${w}$y`),!0),p=_=>_?1:2,f=e.params[0];return t?f===2?m(f,4):f===4?m(f,p(n.modes.insertMode)):f===12?m(f,3):f===20?m(f,p(d.convertEol)):m(f,0):f===1?m(f,p(i.applicationCursorKeys)):f===3?m(f,d.windowOptions.setWinLines?c===80?2:c===132?1:0:0):f===6?m(f,p(i.origin)):f===7?m(f,p(i.wraparound)):f===8?m(f,3):f===9?m(f,p(r==="X10")):f===12?m(f,p(d.cursorBlink)):f===25?m(f,p(!n.isCursorHidden)):f===45?m(f,p(i.reverseWraparound)):f===66?m(f,p(i.applicationKeypad)):f===67?m(f,4):f===1e3?m(f,p(r==="VT200")):f===1002?m(f,p(r==="DRAG")):f===1003?m(f,p(r==="ANY")):f===1004?m(f,p(i.sendFocus)):f===1005?m(f,4):f===1006?m(f,p(o==="SGR")):f===1015?m(f,4):f===1016?m(f,p(o==="SGR_PIXELS")):f===1048?m(f,1):f===47||f===1047||f===1049?m(f,p(l===h)):f===2004?m(f,p(i.bracketedPasteMode)):f===2026?m(f,p(i.synchronizedOutput)):m(f,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=Ho.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,o=0;do{if(i[o+r]=e.params[t+o],e.hasSubParams(t+o)){let n=e.getSubParams(t+o),a=0;do i[1]===5&&(r=1),i[o+a+1+r]=n[a];while(++a<n.length&&a+o+1+r<i.length);break}if(i[1]===5&&o+r>=2||i[1]===2&&o+r>=5)break;i[1]&&(r=1)}while(++o+t<e.length&&o+r<i.length);for(let n=2;n<i.length;++n)i[n]===-1&&(i[n]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_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=De.fg,e.bg=De.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,s,i=this._curAttrData;for(let r=0;r<t;r++)s=e.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=De.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=De.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=De.fg&16777215,i.bg&=-67108864,i.bg|=De.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${M.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${M.ESC}[?${t};${s}R`);break;case 15:break;case 25:break;case 26:break;case 53: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=De.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 s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!lp(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(`${M.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ap&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ap&&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=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(dp(o))if(r==="?")t.push({type:0,index:o});else{let n=np(r);n&&t.push({type:1,index:o,color:n})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(o=>o.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,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 s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=np(s[i]);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=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);dp(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,ji),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Qy[e[0]],Oe[e[1]]||ji),!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=De.clone(),this._eraseAttrDataInternal=De.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 qt;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 s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=n=>(this._coreService.triggerDataEvent(`${M.ESC}${n}${M.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.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)}},Gc=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&&(hp=e,e=t,t=hp),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Gc=Ee([U(0,gt)],Gc);tw=5e7,up=12,sw=50,iw=class extends re{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 N),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 s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>tw)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 s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let n=a=>performance.now()-s>=up?setTimeout(()=>this._innerWrite(0,a)):this._innerWrite(s,a);r.catch(a=>(queueMicrotask(()=>{throw a}),Promise.resolve(!1))).then(n);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=up)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>sw&&(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()}},Yc=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),c={data:e,id:this._nextId++,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(c,a)),this._dataByLinkId.set(c.id,c),c.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let o=t.addMarker(t.ybase+t.y),n={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(n,o)),this._entriesWithId.set(n.key,n),this._dataByLinkId.set(n.id,n),n.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Yc=Ee([U(0,gt)],Yc);pp=!1,rw=class extends re{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Er),this._onBinary=this._register(new N),this.onBinary=this._onBinary.event,this._onData=this._register(new N),this.onData=this._onData.event,this._onLineFeed=this._register(new N),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new N),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new N),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new N),this._instantiationService=new Ey,this.optionsService=this._register(new zy(e)),this._instantiationService.setService(_t,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Vc)),this._instantiationService.setService(gt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(jc)),this._instantiationService.setService($p,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Uc)),this._instantiationService.setService(Gi,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(qc)),this._instantiationService.setService(kp,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Vi)),this._instantiationService.setService(Xv,this.unicodeService),this._charsetService=this._instantiationService.createInstance(jy),this._instantiationService.setService(Yv,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Yc),this._instantiationService.setService(Ep,this._oscLinkService),this._inputHandler=this._register(new ew(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(ot.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(ot.forward(this._bufferService.onResize,this._onResize)),this._register(ot.forward(this.coreService.onData,this._onData)),this._register(ot.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 iw((t,s)=>this._inputHandler.parse(t,s))),this._register(ot.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new N),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!pp&&(this._logService.warn("writeSync is unreliable and will be removed soon."),pp=!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,mf),t=Math.max(t,gf),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(rp.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(rp(this._bufferService),!1))),this._windowsWrappingHeuristics.value=we(()=>{for(let t of e)t.dispose()})}}},ow={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:["'",'"']};Ae=0,aw=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ba,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ba,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,o)=>this._getKey(r)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,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||(Ae=this._search(t),Ae===-1)||this._getKey(this._array[Ae])!==t)return!1;do if(this._array[Ae]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Ae),!0;while(++Ae<this._array.length&&this._getKey(this._array[Ae])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,o)=>r-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:s[i++]=this._array[r];this._array=s,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&&(Ae=this._search(e),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===e))do yield this._array[Ae];while(++Ae<this._array.length&&this._getKey(this._array[Ae])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Ae=this._search(e),!(Ae<0||Ae>=this._array.length)&&this._getKey(this._array[Ae])===e))do t(this._array[Ae]);while(++Ae<this._array.length&&this._getKey(this._array[Ae])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},uc=0,fp=0,lw=class extends re{constructor(){super(),this._decorations=new aw(e=>e?.marker.line),this._onDecorationRegistered=this._register(new N),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new N),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(we(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new cw(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.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,s){let i=0,r=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,r=i+(o.options.width??1),e>=i&&e<r&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,r=>{uc=r.options.x??0,fp=uc+(r.options.width??1),e>=uc&&e<fp&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},cw=class extends ci{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new N),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new N),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=ke.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ke.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},hw=1e3,dw=class{constructor(e,t=hw){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,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 i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,o=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_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)}},mp=20,gp=!1,ya=class extends re{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,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 o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,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 dw(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");gp?(this._accessibilityContainer.classList.add("debug"),this._rowContainer.classList.add("debug"),this._debugRootContainer=r.createElement("div"),this._debugRootContainer.classList.add("xterm"),this._debugRootContainer.appendChild(r.createTextNode("------start a11y------")),this._debugRootContainer.appendChild(this._accessibilityContainer),this._debugRootContainer.appendChild(r.createTextNode("------end a11y------")),this._terminal.element.insertAdjacentElement("afterend",this._debugRootContainer)):this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
34
34
  `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(te(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(we(()=>{gp?this._debugRootContainer.remove():this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<mp+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
35
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===mp+1&&(this._liveRegion.textContent+=fc.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let o=s.lines.get(s.ydisp+r),n=[],a=o?.translateToString(!0,void 0,void 0,n)||"",c=(s.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent="\xA0",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,n)),l.setAttribute("aria-posinset",c),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||e.relatedTarget!==i)return;let n,a;if(t===0?(n=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(n=this._rowElements.shift(),a=s,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:a,offset:c})=>{let l=a instanceof Text?a.parentNode:a,h=parseInt(l?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(l);if(!d)return console.warn("columns is null. Race condition?"),null;let m=c<d.length?d[c]:d.slice(-1)[0]+1;return m>=this._terminal.cols&&(++h,m=0),{row:h,column:m}},o=r(t),n=r(s);if(!(!o||!n)){if(o.row>n.row||o.row===n.row&&o.column>=n.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(n.row-o.row)*this._terminal.cols-o.column+n.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){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};ya=Ee([U(1,Jc),U(2,Fs),U(3,Hs)],ya);Xc=class extends re{constructor(e,t,s,i,r){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new N),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new N),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(we(()=>{qi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(te(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(te(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(te(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(te(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 s=e.composedPath();for(let i=0;i<s.length;i++){let r=s[i];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){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):r.provideLinks(e.y,o=>{if(this._isMouseOut)return;let n=o?.map(a=>({link:a}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let r=t.get(i);if(r)for(let o=0;o<r.length;o++){let n=r[o],a=n.link.range.start.y<e?0:n.link.range.start.x,c=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let l=a;l<=c;l++){if(s.has(l)){r.splice(o--,1);break}s.add(l)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let i=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&&i){let o=i.find(n=>this._linkAtPosition(n.link,t));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let n=this._activeProviderReplies.get(o)?.find(a=>this._linkAtPosition(a.link,t));if(n){s=!0,this._handleNewLink(n);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&dw(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,qi(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:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Xc=Ee([U(1,Zc),U(2,Hs),U(3,gt),U(4,Ap)],Xc);uw=class extends iw{constructor(e={}){super(e),this._linkifier=this._register(new Er),this.browser=rf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Er),this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new N),this.onKey=this._onKey.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new N),this.onBell=this._onBell.event,this._onFocus=this._register(new N),this._onBlur=this._register(new N),this._onA11yCharEmitter=this._register(new N),this._onA11yTabEmitter=this._register(new N),this._onWillOpen=this._register(new N),this._setup(),this._decorationService=this._instantiationService.createInstance(aw),this._instantiationService.setService(Wo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ey),this._instantiationService.setService(Ap,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(gc)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??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(ot.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ot.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ot.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ot.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(we(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=ye.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${M.ESC}]${i};${Jy(r)}${tf.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Le.toColor(...t.color));else{let o=s;this._themeService.modifyColors(n=>n[o]=Le.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(ya,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.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 s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,n=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=n+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(te(this.element,"copy",t=>{this.hasSelection()&&Wv(t,this._selectionService)}));let e=t=>jv(t,this.textarea,this.coreService,this.optionsService);this._register(te(this.textarea,"paste",e)),this._register(te(this.element,"paste",e)),of?this._register(te(this.element,"mousedown",t=>{t.button===2&&_u(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(te(this.element,"contextmenu",t=>{_u(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nh&&this._register(te(this.element,"auxclick",t=>{t.button===1&&yp(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(te(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(te(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(te(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(te(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(te(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(te(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(te(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){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"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(te(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",pc.get()),lf||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Z0,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Fs,this._coreBrowserService),this._register(te(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(te(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(zc,this._document,this._helperContainer),this._instantiationService.setService(Sa,this._charSizeService),this._themeService=this._instantiationService.createInstance(Wc),this._instantiationService.setService(Tr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_a),this._instantiationService.setService(Tp,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Fc,this.rows,this.screenElement)),this._instantiationService.setService(Hs,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Mc,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Nc),this._instantiationService.setService(Zc,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Xc,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(Pc,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Hc,this.element,this.screenElement,i)),this._instantiationService.setService(Jv,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(ot.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Bc,this.screenElement)),this._register(te(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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(ya,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ga,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ga,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Oc,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){let n=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!n)return!1;let a,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(a=3,o.button!==void 0&&(a=o.button<3?o.button:3)):a=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,a=o.button<3?o.button:3;break;case"mousedown":c=1,a=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let l=o.deltaY;if(l===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;c=l<0?0:1,a=4;break;default:return!1}return c===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:a,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(te(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(te(t,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let n=M.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(n,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){bp(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,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=ow(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===M.ETX||s.key===M.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(pw(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(De));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(M.ESC+"[I"):this.coreService.triggerDataEvent(M.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[6;${r};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};fw=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;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)}},mw=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 qt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},_p=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 mw(t)}getNullCell(){return new qt}},gw=class extends re{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new N),this.onBufferChange=this._onBufferChange.event,this._normal=new _p(this._core.buffers.normal,"normal"),this._alternate=new _p(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)}},_w=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.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)}},vw=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}},bw=["cols","rows"],ms=0,yw=class extends re{constructor(e){super(),this._core=this._register(new uw(e)),this._addonManager=this._register(new fw),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(bw.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 _w(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new vw(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 gw(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 pc.get()},set promptLabel(e){pc.set(e)},get tooMuchOutput(){return fc.get()},set tooMuchOutput(e){fc.set(e)}}}_verifyIntegers(...e){for(ms of e)if(ms===1/0||isNaN(ms)||ms%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ms of e)if(ms&&(ms===1/0||isNaN(ms)||ms%1!==0||ms<0))throw new Error("This API only accepts positive integers")}}});var ch={};Cl(ch,{FitAddon:()=>Cw});var ww,Sw,Cw,hh=Sl(()=>{ww=2,Sw=1,Cw=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),n={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},a=n.top+n.bottom,c=n.right+n.left,l=i-a,h=r-c-t;return{cols:Math.max(ww,Math.floor(h/e.css.cell.width)),rows:Math.max(Sw,Math.floor(l/e.css.cell.height))}}}});var Gf={};Cl(Gf,{SearchAddon:()=>C1});function _h(e){Rw(e)||Aw.onUnexpectedError(e)}function Rw(e){return e instanceof Dw?!0:e instanceof Error&&e.name===yh&&e.message===yh}function Lw(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function Bw(e,t){return(s,i)=>t(e(s),e(i))}function Iw(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function zw(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function Hw(e){Lr=e}function Ma(e){return Lr?.trackDisposable(e),e}function Ia(e){Lr?.markAsDisposed(e)}function Ko(e,t){Lr?.setParent(e,t)}function Ww(e,t){if(Lr)for(let s of e)Lr.setParent(s,t)}function qo(e){if(Mf.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}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 Of(...e){let t=Pr(()=>qo(e));return Ww(e,t),t}function Pr(e){let t=Ma({dispose:zw(()=>{Ia(t),e()})});return t}function Kf(e,t=0,s){let i=setTimeout(()=>{e(),s&&r.dispose()},t),r=Pr(()=>{clearTimeout(i),s?.deleteAndLeak(r)});return s?.add(r),r}var Tw,Aw,yh,Dw,xf,Pw,Bf,Mw,kf,$f,Ef,$A,Ow,Mf,Nw,Lr,Fw,zf,Ah,ys,Ba,Tf,jw,Vw,Uw,Af,qw,Rh,xh,Kw,Rf,Hf,Gw,$h,Yw,Xw,Jw,Ra,Zw,Qw,Da,bs,e1,Vf,t1,s1,Dr,Eh,Th,La,i1,r1,Uf,o1,n1,a1,l1,Aa,Pa,Df,c1,Ws,js,It,qf,h1,vh,d1,EA,ws,di,u1,p1,f1,m1,TA,AA,RA,DA,g1,bh,_1,Lf,v1,b1,y1,w1,S1,C1,Yf=Sl(()=>{Tw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xf.isErrorNoTelemetry(e)?new xf(e.message+`
35
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===mp+1&&(this._liveRegion.textContent+=fc.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let o=s.lines.get(s.ydisp+r),n=[],a=o?.translateToString(!0,void 0,void 0,n)||"",c=(s.ydisp+r+1).toString(),l=this._rowElements[r];l&&(a.length===0?(l.textContent="\xA0",this._rowColumns.set(l,[0,1])):(l.textContent=a,this._rowColumns.set(l,n)),l.setAttribute("aria-posinset",c),l.setAttribute("aria-setsize",i),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===o||e.relatedTarget!==i)return;let n,a;if(t===0?(n=s,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(n=this._rowElements.shift(),a=s,this._rowContainer.removeChild(n)),n.removeEventListener("focus",this._topBoundaryFocusListener),a.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let c=this._createAccessibilityTreeNode();this._rowElements.unshift(c),this._rowContainer.insertAdjacentElement("afterbegin",c)}else{let c=this._createAccessibilityTreeNode();this._rowElements.push(c),this._rowContainer.appendChild(c)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){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},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,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 i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:i.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let r=({node:a,offset:c})=>{let l=a instanceof Text?a.parentNode:a,h=parseInt(l?.getAttribute("aria-posinset"),10)-1;if(isNaN(h))return console.warn("row is invalid. Race condition?"),null;let d=this._rowColumns.get(l);if(!d)return console.warn("columns is null. Race condition?"),null;let m=c<d.length?d[c]:d.slice(-1)[0]+1;return m>=this._terminal.cols&&(++h,m=0),{row:h,column:m}},o=r(t),n=r(s);if(!(!o||!n)){if(o.row>n.row||o.row===n.row&&o.column>=n.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(n.row-o.row)*this._terminal.cols-o.column+n.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){e.style.transform="";let t=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};ya=Ee([U(1,Jc),U(2,Fs),U(3,Hs)],ya);Xc=class extends re{constructor(e,t,s,i,r){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new N),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new N),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(we(()=>{qi(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(te(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(te(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(te(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(te(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 s=e.composedPath();for(let i=0;i<s.length;i++){let r=s[i];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){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(i=>{i?.forEach(r=>{r.link.dispose&&r.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[i,r]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(i)&&(s=this._checkLinkProviderResult(i,e,s)):r.provideLinks(e.y,o=>{if(this._isMouseOut)return;let n=o?.map(a=>({link:a}));this._activeProviderReplies?.set(i,n),s=this._checkLinkProviderResult(i,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let r=t.get(i);if(r)for(let o=0;o<r.length;o++){let n=r[o],a=n.link.range.start.y<e?0:n.link.range.start.x,c=n.link.range.end.y>e?this._bufferService.cols:n.link.range.end.x;for(let l=a;l<=c;l++){if(s.has(l)){r.splice(o--,1);break}s.add(l)}}}}_checkLinkProviderResult(e,t,s){if(!this._activeProviderReplies)return s;let i=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&&i){let o=i.find(n=>this._linkAtPosition(n.link,t));o&&(s=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let o=0;o<this._activeProviderReplies.size;o++){let n=this._activeProviderReplies.get(o)?.find(a=>this._linkAtPosition(a.link,t));if(n){s=!0,this._handleNewLink(n);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&uw(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,qi(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:()=>this._currentLink?.state?.decorations.pointerCursor,set:s=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:s=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};Xc=Ee([U(1,Zc),U(2,Hs),U(3,gt),U(4,Ap)],Xc);pw=class extends rw{constructor(e={}){super(e),this._linkifier=this._register(new Er),this.browser=rf,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Er),this._onCursorMove=this._register(new N),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new N),this.onKey=this._onKey.event,this._onRender=this._register(new N),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new N),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new N),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new N),this.onBell=this._onBell.event,this._onFocus=this._register(new N),this._onBlur=this._register(new N),this._onA11yCharEmitter=this._register(new N),this._onA11yTabEmitter=this._register(new N),this._onWillOpen=this._register(new N),this._setup(),this._decorationService=this._instantiationService.createInstance(lw),this._instantiationService.setService(Wo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ty),this._instantiationService.setService(Ap,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(gc)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??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(ot.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(ot.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(ot.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(ot.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(we(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=ye.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${M.ESC}]${i};${Zy(r)}${tf.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Le.toColor(...t.color));else{let o=s;this._themeService.modifyColors(n=>n[o]=Le.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(ya,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(M.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 s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*r,n=this.buffer.y*this._renderService.dimensions.css.cell.height,a=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=a+"px",this.textarea.style.top=n+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(te(this.element,"copy",t=>{this.hasSelection()&&jv(t,this._selectionService)}));let e=t=>Vv(t,this.textarea,this.coreService,this.optionsService);this._register(te(this.textarea,"paste",e)),this._register(te(this.element,"paste",e)),of?this._register(te(this.element,"mousedown",t=>{t.button===2&&_u(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(te(this.element,"contextmenu",t=>{_u(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),nh&&this._register(te(this.element,"auxclick",t=>{t.button===1&&yp(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(te(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(te(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(te(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(te(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(te(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(te(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(te(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){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"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(te(this.screenElement,"mousemove",r=>this.updateCursorStyle(r))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",pc.get()),lf||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",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Q0,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Fs,this._coreBrowserService),this._register(te(this.textarea,"focus",r=>this._handleTextAreaFocus(r))),this._register(te(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(zc,this._document,this._helperContainer),this._instantiationService.setService(Sa,this._charSizeService),this._themeService=this._instantiationService.createInstance(Wc),this._instantiationService.setService(Tr,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(_a),this._instantiationService.setService(Tp,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Fc,this.rows,this.screenElement)),this._instantiationService.setService(Hs,this._renderService),this._register(this._renderService.onRenderedViewportChange(r=>this._onRender.fire(r))),this.onResize(r=>this._renderService.resize(r.cols,r.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Mc,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Nc),this._instantiationService.setService(Zc,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Xc,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(Pc,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(r=>{super.scrollLines(r,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Hc,this.element,this.screenElement,i)),this._instantiationService.setService(Zv,this._selectionService),this._register(this._selectionService.onRequestScrollLines(r=>this.scrollLines(r.amount,r.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(r=>this._renderService.handleSelectionChanged(r.start,r.end,r.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(r=>{this.textarea.value=r,this.textarea.focus(),this.textarea.select()})),this._register(ot.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Bc,this.screenElement)),this._register(te(this.element,"mousedown",r=>this._selectionService.handleMouseDown(r))),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(ya,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",r=>this._handleScreenReaderModeOptionChange(r))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ga,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",r=>{!this._overviewRulerRenderer&&r&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ga,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Oc,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){let n=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!n)return!1;let a,c;switch(o.overrideType||o.type){case"mousemove":c=32,o.buttons===void 0?(a=3,o.button!==void 0&&(a=o.button<3?o.button:3)):a=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":c=0,a=o.button<3?o.button:3;break;case"mousedown":c=1,a=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let l=o.deltaY;if(l===0||e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;c=l<0?0:1,a=4;break;default:return!1}return c===void 0||a===void 0||a>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:a,action:c,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),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()),o&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(te(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(te(t,"wheel",o=>{if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(o,!0);let n=M.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(n,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){bp(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,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=nw(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.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((s.key===M.ETX||s.key===M.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=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"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(fw(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(De));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(M.ESC+"[I"):this.coreService.triggerDataEvent(M.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${M.ESC}[6;${r};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};mw=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;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)}},gw=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 qt)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},_p=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 gw(t)}getNullCell(){return new qt}},_w=class extends re{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new N),this.onBufferChange=this._onBufferChange.event,this._normal=new _p(this._core.buffers.normal,"normal"),this._alternate=new _p(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)}},vw=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.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)}},bw=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}},yw=["cols","rows"],ms=0,ww=class extends re{constructor(e){super(),this._core=this._register(new pw(e)),this._addonManager=this._register(new mw),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(yw.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 vw(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new bw(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 _w(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,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}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 pc.get()},set promptLabel(e){pc.set(e)},get tooMuchOutput(){return fc.get()},set tooMuchOutput(e){fc.set(e)}}}_verifyIntegers(...e){for(ms of e)if(ms===1/0||isNaN(ms)||ms%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(ms of e)if(ms&&(ms===1/0||isNaN(ms)||ms%1!==0||ms<0))throw new Error("This API only accepts positive integers")}}});var ch={};Cl(ch,{FitAddon:()=>xw});var Sw,Cw,xw,hh=Sl(()=>{Sw=2,Cw=1,xw=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),n={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},a=n.top+n.bottom,c=n.right+n.left,l=i-a,h=r-c-t;return{cols:Math.max(Sw,Math.floor(h/e.css.cell.width)),rows:Math.max(Cw,Math.floor(l/e.css.cell.height))}}}});var Gf={};Cl(Gf,{SearchAddon:()=>x1});function _h(e){Dw(e)||Rw.onUnexpectedError(e)}function Dw(e){return e instanceof Lw?!0:e instanceof Error&&e.name===yh&&e.message===yh}function Pw(e,t,s=0,i=e.length){let r=s,o=i;for(;r<o;){let n=Math.floor((r+o)/2);t(e[n])?r=n+1:o=n}return r-1}function Mw(e,t){return(s,i)=>t(e(s),e(i))}function Ow(e,t){let s=Object.create(null);for(let i of e){let r=t(i),o=s[r];o||(o=s[r]=[]),o.push(i)}return s}function Nw(e,t){let s=this,i=!1,r;return function(){if(i)return r;if(i=!0,t)try{r=e.apply(s,arguments)}finally{t()}else r=e.apply(s,arguments);return r}}function Ww(e){Lr=e}function Ma(e){return Lr?.trackDisposable(e),e}function Ia(e){Lr?.markAsDisposed(e)}function Ko(e,t){Lr?.setParent(e,t)}function jw(e,t){if(Lr)for(let s of e)Lr.setParent(s,t)}function qo(e){if(Mf.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}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 Of(...e){let t=Pr(()=>qo(e));return jw(e,t),t}function Pr(e){let t=Ma({dispose:Nw(()=>{Ia(t),e()})});return t}function Kf(e,t=0,s){let i=setTimeout(()=>{e(),s&&r.dispose()},t),r=Pr(()=>{clearTimeout(i),s?.deleteAndLeak(r)});return s?.add(r),r}var Aw,Rw,yh,Lw,xf,Bw,Bf,Iw,kf,$f,Ef,TA,zw,Mf,Fw,Lr,Hw,zf,Ah,ys,Ba,Tf,Vw,Uw,qw,Af,Kw,Rh,xh,Gw,Rf,Hf,Yw,$h,Xw,Jw,Zw,Ra,Qw,e1,Da,bs,t1,Vf,s1,i1,Dr,Eh,Th,La,r1,o1,Uf,n1,a1,l1,c1,Aa,Pa,Df,h1,Ws,js,It,qf,d1,vh,u1,AA,ws,di,p1,f1,m1,g1,RA,DA,LA,PA,_1,bh,v1,Lf,b1,y1,w1,S1,C1,x1,Yf=Sl(()=>{Aw=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?xf.isErrorNoTelemetry(e)?new xf(e.message+`
37
37
 
38
38
  `+e.stack):new Error(e.message+`
39
39
 
40
- `+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)}},Aw=new Tw;yh="Canceled";Dw=class extends Error{constructor(){super(yh),this.name=this.message}},xf=class wh extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof wh)return t;let s=new wh;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};Pw=class Pf{constructor(t){this._array=t,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(Pf.assertInvariants){if(this._prevFindLastPredicate){for(let i of this._array)if(this._prevFindLastPredicate(i)&&!t(i))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}let s=Lw(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=s+1,s===-1?void 0:this._array[s]}};Pw.assertInvariants=!1;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function r(o){return o===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Bf||(Bf={}));Mw=(e,t)=>e-t,kf=class Sh{constructor(t){this.iterate=t}forEach(t){this.iterate(s=>(t(s),!0))}toArray(){let t=[];return this.iterate(s=>(t.push(s),!0)),t}filter(t){return new Sh(s=>this.iterate(i=>t(i)?s(i):!0))}map(t){return new Sh(s=>this.iterate(i=>s(t(i))))}some(t){let s=!1;return this.iterate(i=>(s=t(i),!s)),s}findFirst(t){let s;return this.iterate(i=>t(i)?(s=i,!1):!0),s}findLast(t){let s;return this.iterate(i=>(t(i)&&(s=i),!0)),s}findLastMaxBy(t){let s,i=!0;return this.iterate(r=>((i||Bf.isGreaterThan(t(r,s)))&&(i=!1,s=r),!0)),s}};kf.empty=new kf(e=>{});$A=class{constructor(e,t){this.toKey=t,this._map=new Map,this[$f]="SetWithKey";for(let s of e)this.add(s)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(s=>e.call(t,s,s,this))}[(Ef=Symbol.iterator,$f=Symbol.toStringTag,Ef)](){return this.values()}},Ow=class{constructor(){this.map=new Map}add(e,t){let s=this.map.get(e);s||(s=new Set,this.map.set(e,s)),s.add(t)}delete(e,t){let s=this.map.get(e);s&&(s.delete(t),s.size===0&&this.map.delete(e))}forEach(e,t){let s=this.map.get(e);s&&s.forEach(t)}get(e){return this.map.get(e)||new Set}};(e=>{function t(C){return C&&typeof C=="object"&&typeof C[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(C){yield C}e.single=r;function o(C){return t(C)?C:r(C)}e.wrap=o;function n(C){return C||s}e.from=n;function*a(C){for(let S=C.length-1;S>=0;S--)yield C[S]}e.reverse=a;function c(C){return!C||C[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(C){return C[Symbol.iterator]().next().value}e.first=l;function h(C,S){let L=0;for(let H of C)if(S(H,L++))return!0;return!1}e.some=h;function d(C,S){for(let L of C)if(S(L))return L}e.find=d;function*m(C,S){for(let L of C)S(L)&&(yield L)}e.filter=m;function*p(C,S){let L=0;for(let H of C)yield S(H,L++)}e.map=p;function*f(C,S){let L=0;for(let H of C)yield*S(H,L++)}e.flatMap=f;function*_(...C){for(let S of C)yield*S}e.concat=_;function w(C,S,L){let H=L;for(let F of C)H=S(H,F);return H}e.reduce=w;function*k(C,S,L=C.length){for(S<0&&(S+=C.length),L<0?L+=C.length:L>C.length&&(L=C.length);S<L;S++)yield C[S]}e.slice=k;function $(C,S=Number.POSITIVE_INFINITY){let L=[];if(S===0)return[L,C];let H=C[Symbol.iterator]();for(let F=0;F<S;F++){let W=H.next();if(W.done)return[L,e.empty()];L.push(W.value)}return[L,{[Symbol.iterator](){return H}}]}e.consume=$;async function y(C){let S=[];for await(let L of C)S.push(L);return Promise.resolve(S)}e.asyncToArray=y})(Mf||(Mf={}));Nw=!1,Lr=null,Fw=class If{constructor(){this.livingDisposables=new Map}getDisposableData(t){let s=this.livingDisposables.get(t);return s||(s={parent:null,source:null,isSingleton:!1,value:t,idx:If.idx++},this.livingDisposables.set(t,s)),s}trackDisposable(t){let s=this.getDisposableData(t);s.source||(s.source=new Error().stack)}setParent(t,s){let i=this.getDisposableData(t);i.parent=s}markAsDisposed(t){this.livingDisposables.delete(t)}markAsSingleton(t){this.getDisposableData(t).isSingleton=!0}getRootParent(t,s){let i=s.get(t);if(i)return i;let r=t.parent?this.getRootParent(this.getDisposableData(t.parent),s):t;return s.set(t,r),r}getTrackedDisposables(){let t=new Map;return[...this.livingDisposables.entries()].filter(([,s])=>s.source!==null&&!this.getRootParent(s,t).isSingleton).flatMap(([s])=>s)}computeLeakingDisposables(t=10,s){let i;if(s)i=s;else{let c=new Map,l=[...this.livingDisposables.values()].filter(d=>d.source!==null&&!this.getRootParent(d,c).isSingleton);if(l.length===0)return;let h=new Set(l.map(d=>d.value));if(i=l.filter(d=>!(d.parent&&h.has(d.parent))),i.length===0)throw new Error("There are cyclic diposable chains!")}if(!i)return;function r(c){function l(d,m){for(;d.length>0&&m.some(p=>typeof p=="string"?p===d[0]:d[0].match(p));)d.shift()}let h=c.source.split(`
41
- `).map(d=>d.trim().replace("at ","")).filter(d=>d!=="");return l(h,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),h.reverse()}let o=new Ow;for(let c of i){let l=r(c);for(let h=0;h<=l.length;h++)o.add(l.slice(0,h).join(`
42
- `),c)}i.sort(Bw(c=>c.idx,Mw));let n="",a=0;for(let c of i.slice(0,t)){a++;let l=r(c),h=[];for(let d=0;d<l.length;d++){let m=l[d];m=`(shared with ${o.get(l.slice(0,d+1).join(`
40
+ `+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)}},Rw=new Aw;yh="Canceled";Lw=class extends Error{constructor(){super(yh),this.name=this.message}},xf=class wh extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof wh)return t;let s=new wh;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}};Bw=class Pf{constructor(t){this._array=t,this._findLastMonotonousLastIdx=0}findLastMonotonous(t){if(Pf.assertInvariants){if(this._prevFindLastPredicate){for(let i of this._array)if(this._prevFindLastPredicate(i)&&!t(i))throw new Error("MonotonousArray: current predicate must be weaker than (or equal to) the previous predicate.")}this._prevFindLastPredicate=t}let s=Pw(this._array,t,this._findLastMonotonousLastIdx);return this._findLastMonotonousLastIdx=s+1,s===-1?void 0:this._array[s]}};Bw.assertInvariants=!1;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function r(o){return o===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Bf||(Bf={}));Iw=(e,t)=>e-t,kf=class Sh{constructor(t){this.iterate=t}forEach(t){this.iterate(s=>(t(s),!0))}toArray(){let t=[];return this.iterate(s=>(t.push(s),!0)),t}filter(t){return new Sh(s=>this.iterate(i=>t(i)?s(i):!0))}map(t){return new Sh(s=>this.iterate(i=>s(t(i))))}some(t){let s=!1;return this.iterate(i=>(s=t(i),!s)),s}findFirst(t){let s;return this.iterate(i=>t(i)?(s=i,!1):!0),s}findLast(t){let s;return this.iterate(i=>(t(i)&&(s=i),!0)),s}findLastMaxBy(t){let s,i=!0;return this.iterate(r=>((i||Bf.isGreaterThan(t(r,s)))&&(i=!1,s=r),!0)),s}};kf.empty=new kf(e=>{});TA=class{constructor(e,t){this.toKey=t,this._map=new Map,this[$f]="SetWithKey";for(let s of e)this.add(s)}get size(){return this._map.size}add(e){let t=this.toKey(e);return this._map.set(t,e),this}delete(e){return this._map.delete(this.toKey(e))}has(e){return this._map.has(this.toKey(e))}*entries(){for(let e of this._map.values())yield[e,e]}keys(){return this.values()}*values(){for(let e of this._map.values())yield e}clear(){this._map.clear()}forEach(e,t){this._map.forEach(s=>e.call(t,s,s,this))}[(Ef=Symbol.iterator,$f=Symbol.toStringTag,Ef)](){return this.values()}},zw=class{constructor(){this.map=new Map}add(e,t){let s=this.map.get(e);s||(s=new Set,this.map.set(e,s)),s.add(t)}delete(e,t){let s=this.map.get(e);s&&(s.delete(t),s.size===0&&this.map.delete(e))}forEach(e,t){let s=this.map.get(e);s&&s.forEach(t)}get(e){return this.map.get(e)||new Set}};(e=>{function t(C){return C&&typeof C=="object"&&typeof C[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(C){yield C}e.single=r;function o(C){return t(C)?C:r(C)}e.wrap=o;function n(C){return C||s}e.from=n;function*a(C){for(let S=C.length-1;S>=0;S--)yield C[S]}e.reverse=a;function c(C){return!C||C[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(C){return C[Symbol.iterator]().next().value}e.first=l;function h(C,S){let L=0;for(let H of C)if(S(H,L++))return!0;return!1}e.some=h;function d(C,S){for(let L of C)if(S(L))return L}e.find=d;function*m(C,S){for(let L of C)S(L)&&(yield L)}e.filter=m;function*p(C,S){let L=0;for(let H of C)yield S(H,L++)}e.map=p;function*f(C,S){let L=0;for(let H of C)yield*S(H,L++)}e.flatMap=f;function*_(...C){for(let S of C)yield*S}e.concat=_;function w(C,S,L){let H=L;for(let F of C)H=S(H,F);return H}e.reduce=w;function*k(C,S,L=C.length){for(S<0&&(S+=C.length),L<0?L+=C.length:L>C.length&&(L=C.length);S<L;S++)yield C[S]}e.slice=k;function $(C,S=Number.POSITIVE_INFINITY){let L=[];if(S===0)return[L,C];let H=C[Symbol.iterator]();for(let F=0;F<S;F++){let W=H.next();if(W.done)return[L,e.empty()];L.push(W.value)}return[L,{[Symbol.iterator](){return H}}]}e.consume=$;async function y(C){let S=[];for await(let L of C)S.push(L);return Promise.resolve(S)}e.asyncToArray=y})(Mf||(Mf={}));Fw=!1,Lr=null,Hw=class If{constructor(){this.livingDisposables=new Map}getDisposableData(t){let s=this.livingDisposables.get(t);return s||(s={parent:null,source:null,isSingleton:!1,value:t,idx:If.idx++},this.livingDisposables.set(t,s)),s}trackDisposable(t){let s=this.getDisposableData(t);s.source||(s.source=new Error().stack)}setParent(t,s){let i=this.getDisposableData(t);i.parent=s}markAsDisposed(t){this.livingDisposables.delete(t)}markAsSingleton(t){this.getDisposableData(t).isSingleton=!0}getRootParent(t,s){let i=s.get(t);if(i)return i;let r=t.parent?this.getRootParent(this.getDisposableData(t.parent),s):t;return s.set(t,r),r}getTrackedDisposables(){let t=new Map;return[...this.livingDisposables.entries()].filter(([,s])=>s.source!==null&&!this.getRootParent(s,t).isSingleton).flatMap(([s])=>s)}computeLeakingDisposables(t=10,s){let i;if(s)i=s;else{let c=new Map,l=[...this.livingDisposables.values()].filter(d=>d.source!==null&&!this.getRootParent(d,c).isSingleton);if(l.length===0)return;let h=new Set(l.map(d=>d.value));if(i=l.filter(d=>!(d.parent&&h.has(d.parent))),i.length===0)throw new Error("There are cyclic diposable chains!")}if(!i)return;function r(c){function l(d,m){for(;d.length>0&&m.some(p=>typeof p=="string"?p===d[0]:d[0].match(p));)d.shift()}let h=c.source.split(`
41
+ `).map(d=>d.trim().replace("at ","")).filter(d=>d!=="");return l(h,["Error",/^trackDisposable \(.*\)$/,/^DisposableTracker.trackDisposable \(.*\)$/]),h.reverse()}let o=new zw;for(let c of i){let l=r(c);for(let h=0;h<=l.length;h++)o.add(l.slice(0,h).join(`
42
+ `),c)}i.sort(Mw(c=>c.idx,Iw));let n="",a=0;for(let c of i.slice(0,t)){a++;let l=r(c),h=[];for(let d=0;d<l.length;d++){let m=l[d];m=`(shared with ${o.get(l.slice(0,d+1).join(`
43
43
  `)).size}/${i.length} leaks) at ${m}`;let p=o.get(l.slice(0,d).join(`
44
- `)),f=Iw([...p].map(_=>r(_)[d]),_=>_);delete f[l[d]];for(let[_,w]of Object.entries(f))h.unshift(` - stacktraces of ${w.length} other leaks continue with ${_}`);h.unshift(m)}n+=`
44
+ `)),f=Ow([...p].map(_=>r(_)[d]),_=>_);delete f[l[d]];for(let[_,w]of Object.entries(f))h.unshift(` - stacktraces of ${w.length} other leaks continue with ${_}`);h.unshift(m)}n+=`
45
45
 
46
46
 
47
47
  ==================== Leaking disposable ${a}/${i.length}: ${c.value.constructor.name} ====================
@@ -54,15 +54,15 @@ ${h.join(`
54
54
 
55
55
  ... and ${i.length-t} more leaking disposables
56
56
 
57
- `),{leaks:i,details:n}}};Fw.idx=0;if(Nw){let e="__is_disposable_tracked__";Hw(new class{trackDisposable(t){let s=new Error("Potentially leaked disposable").stack;setTimeout(()=>{t[e]||console.log(s)},3e3)}setParent(t,s){if(t&&t!==ys.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==ys.None)try{t[e]=!0}catch{}}markAsSingleton(t){}})}zf=class Nf{constructor(){this._toDispose=new Set,this._isDisposed=!1,Ma(this)}dispose(){this._isDisposed||(Ia(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{qo(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 Ko(t,this),this._isDisposed?Nf.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),Ko(t,null))}};zf.DISABLE_DISPOSED_WARNING=!1;Ah=zf,ys=class{constructor(){this._store=new Ah,Ma(this),Ko(this._store,this)}dispose(){Ia(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ys.None=Object.freeze({dispose(){}});Ba=class{constructor(){this._isDisposed=!1,Ma(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Ko(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Ia(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Ko(e,null),e}},Tf=class Ch{constructor(t){this.element=t,this.next=Ch.Undefined,this.prev=Ch.Undefined}};Tf.Undefined=new Tf(void 0);jw=globalThis.performance&&typeof globalThis.performance.now=="function",Vw=class Ff{static create(t){return new Ff(t)}constructor(t){this._now=jw&&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}},Uw=!1,Af=!1,qw=!1;(e=>{e.None=()=>ys.None;function t(T){if(qw){let{onDidAddListener:x}=T,D=$h.create(),A=0;T.onDidAddListener=()=>{++A===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),D.print()),x?.()}}}function s(T,x){return m(T,()=>{},0,void 0,!0,void 0,x)}e.defer=s;function i(T){return(x,D=null,A)=>{let B=!1,P;return P=T(V=>{if(!B)return P?P.dispose():B=!0,x.call(D,V)},null,A),B&&P.dispose(),P}}e.once=i;function r(T,x,D){return h((A,B=null,P)=>T(V=>A.call(B,x(V)),null,P),D)}e.map=r;function o(T,x,D){return h((A,B=null,P)=>T(V=>{x(V),A.call(B,V)},null,P),D)}e.forEach=o;function n(T,x,D){return h((A,B=null,P)=>T(V=>x(V)&&A.call(B,V),null,P),D)}e.filter=n;function a(T){return T}e.signal=a;function c(...T){return(x,D=null,A)=>{let B=Of(...T.map(P=>P(V=>x.call(D,V))));return d(B,A)}}e.any=c;function l(T,x,D,A){let B=D;return r(T,P=>(B=x(B,P),B),A)}e.reduce=l;function h(T,x){let D,A={onWillAddFirstListener(){D=T(B.fire,B)},onDidRemoveLastListener(){D?.dispose()}};x||t(A);let B=new bs(A);return x?.add(B),B.event}function d(T,x){return x instanceof Array?x.push(T):x&&x.add(T),T}function m(T,x,D=100,A=!1,B=!1,P,V){let se,de,tt,yt=0,Se,es={leakWarningThreshold:P,onWillAddFirstListener(){se=T(Es=>{yt++,de=x(de,Es),A&&!tt&&(Re.fire(de),de=void 0),Se=()=>{let Ti=de;de=void 0,tt=void 0,(!A||yt>1)&&Re.fire(Ti),yt=0},typeof D=="number"?(clearTimeout(tt),tt=setTimeout(Se,D)):tt===void 0&&(tt=0,queueMicrotask(Se))})},onWillRemoveListener(){B&&yt>0&&Se?.()},onDidRemoveLastListener(){Se=void 0,se.dispose()}};V||t(es);let Re=new bs(es);return V?.add(Re),Re.event}e.debounce=m;function p(T,x=0,D){return e.debounce(T,(A,B)=>A?(A.push(B),A):[B],x,void 0,!0,void 0,D)}e.accumulate=p;function f(T,x=(A,B)=>A===B,D){let A=!0,B;return n(T,P=>{let V=A||!x(P,B);return A=!1,B=P,V},D)}e.latch=f;function _(T,x,D){return[e.filter(T,x,D),e.filter(T,A=>!x(A),D)]}e.split=_;function w(T,x=!1,D=[],A){let B=D.slice(),P=T(de=>{B?B.push(de):se.fire(de)});A&&A.add(P);let V=()=>{B?.forEach(de=>se.fire(de)),B=null},se=new bs({onWillAddFirstListener(){P||(P=T(de=>se.fire(de)),A&&A.add(P))},onDidAddFirstListener(){B&&(x?setTimeout(V):V())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return A&&A.add(se),se.event}e.buffer=w;function k(T,x){return(D,A,B)=>{let P=x(new y);return T(function(V){let se=P.evaluate(V);se!==$&&D.call(A,se)},void 0,B)}}e.chain=k;let $=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(x){return this.steps.push(x),this}forEach(x){return this.steps.push(D=>(x(D),D)),this}filter(x){return this.steps.push(D=>x(D)?D:$),this}reduce(x,D){let A=D;return this.steps.push(B=>(A=x(A,B),A)),this}latch(x=(D,A)=>D===A){let D=!0,A;return this.steps.push(B=>{let P=D||!x(B,A);return D=!1,A=B,P?B:$}),this}evaluate(x){for(let D of this.steps)if(x=D(x),x===$)break;return x}}function C(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.on(x,A),P=()=>T.removeListener(x,A),V=new bs({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromNodeEventEmitter=C;function S(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.addEventListener(x,A),P=()=>T.removeEventListener(x,A),V=new bs({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromDOMEventEmitter=S;function L(T){return new Promise(x=>i(T)(x))}e.toPromise=L;function H(T){let x=new bs;return T.then(D=>{x.fire(D)},()=>{x.fire(void 0)}).finally(()=>{x.dispose()}),x.event}e.fromPromise=H;function F(T,x){return T(D=>x.fire(D))}e.forward=F;function W(T,x,D){return x(D),T(A=>x(A))}e.runAndSubscribe=W;class ie{constructor(x,D){this._observable=x,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{x.addObserver(this)},onDidRemoveLastListener:()=>{x.removeObserver(this)}};D||t(A),this.emitter=new bs(A),D&&D.add(this.emitter)}beginUpdate(x){this._counter++}handlePossibleChange(x){}handleChange(x,D){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 j(T,x){return new ie(T,x).emitter.event}e.fromObservable=j;function ce(T){return(x,D,A)=>{let B=0,P=!1,V={beginUpdate(){B++},endUpdate(){B--,B===0&&(T.reportChanges(),P&&(P=!1,x.call(D)))},handlePossibleChange(){},handleChange(){P=!0}};T.addObserver(V),T.reportChanges();let se={dispose(){T.removeObserver(V)}};return A instanceof Ah?A.add(se):Array.isArray(A)&&A.push(se),se}}e.fromObservableLight=ce})(Rh||(Rh={}));xh=class kh{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${kh._idPool++}`,kh.all.add(this)}start(t){this._stopWatch=new Vw,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}}};xh.all=new Set,xh._idPool=0;Kw=xh,Rf=-1,Hf=class Wf{constructor(t,s,i=(Wf._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)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=i*.5;let[o,n]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${n}):`;console.warn(a),console.warn(o);let c=new Yw(a,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s<r)&&(t=[i,r],s=r);return t}};Hf._idPool=1;Gw=Hf,$h=class jf{constructor(t){this.value=t}static create(){let t=new Error;return new jf(t.stack??"")}print(){console.warn(this.value.split(`
57
+ `),{leaks:i,details:n}}};Hw.idx=0;if(Fw){let e="__is_disposable_tracked__";Ww(new class{trackDisposable(t){let s=new Error("Potentially leaked disposable").stack;setTimeout(()=>{t[e]||console.log(s)},3e3)}setParent(t,s){if(t&&t!==ys.None)try{t[e]=!0}catch{}}markAsDisposed(t){if(t&&t!==ys.None)try{t[e]=!0}catch{}}markAsSingleton(t){}})}zf=class Nf{constructor(){this._toDispose=new Set,this._isDisposed=!1,Ma(this)}dispose(){this._isDisposed||(Ia(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{qo(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 Ko(t,this),this._isDisposed?Nf.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),Ko(t,null))}};zf.DISABLE_DISPOSED_WARNING=!1;Ah=zf,ys=class{constructor(){this._store=new Ah,Ma(this),Ko(this._store,this)}dispose(){Ia(this),this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};ys.None=Object.freeze({dispose(){}});Ba=class{constructor(){this._isDisposed=!1,Ma(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Ko(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Ia(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Ko(e,null),e}},Tf=class Ch{constructor(t){this.element=t,this.next=Ch.Undefined,this.prev=Ch.Undefined}};Tf.Undefined=new Tf(void 0);Vw=globalThis.performance&&typeof globalThis.performance.now=="function",Uw=class Ff{static create(t){return new Ff(t)}constructor(t){this._now=Vw&&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}},qw=!1,Af=!1,Kw=!1;(e=>{e.None=()=>ys.None;function t(T){if(Kw){let{onDidAddListener:x}=T,D=$h.create(),A=0;T.onDidAddListener=()=>{++A===2&&(console.warn("snapshotted emitter LIKELY used public and SHOULD HAVE BEEN created with DisposableStore. snapshotted here"),D.print()),x?.()}}}function s(T,x){return m(T,()=>{},0,void 0,!0,void 0,x)}e.defer=s;function i(T){return(x,D=null,A)=>{let B=!1,P;return P=T(V=>{if(!B)return P?P.dispose():B=!0,x.call(D,V)},null,A),B&&P.dispose(),P}}e.once=i;function r(T,x,D){return h((A,B=null,P)=>T(V=>A.call(B,x(V)),null,P),D)}e.map=r;function o(T,x,D){return h((A,B=null,P)=>T(V=>{x(V),A.call(B,V)},null,P),D)}e.forEach=o;function n(T,x,D){return h((A,B=null,P)=>T(V=>x(V)&&A.call(B,V),null,P),D)}e.filter=n;function a(T){return T}e.signal=a;function c(...T){return(x,D=null,A)=>{let B=Of(...T.map(P=>P(V=>x.call(D,V))));return d(B,A)}}e.any=c;function l(T,x,D,A){let B=D;return r(T,P=>(B=x(B,P),B),A)}e.reduce=l;function h(T,x){let D,A={onWillAddFirstListener(){D=T(B.fire,B)},onDidRemoveLastListener(){D?.dispose()}};x||t(A);let B=new bs(A);return x?.add(B),B.event}function d(T,x){return x instanceof Array?x.push(T):x&&x.add(T),T}function m(T,x,D=100,A=!1,B=!1,P,V){let se,de,tt,yt=0,Se,es={leakWarningThreshold:P,onWillAddFirstListener(){se=T(Es=>{yt++,de=x(de,Es),A&&!tt&&(Re.fire(de),de=void 0),Se=()=>{let Ti=de;de=void 0,tt=void 0,(!A||yt>1)&&Re.fire(Ti),yt=0},typeof D=="number"?(clearTimeout(tt),tt=setTimeout(Se,D)):tt===void 0&&(tt=0,queueMicrotask(Se))})},onWillRemoveListener(){B&&yt>0&&Se?.()},onDidRemoveLastListener(){Se=void 0,se.dispose()}};V||t(es);let Re=new bs(es);return V?.add(Re),Re.event}e.debounce=m;function p(T,x=0,D){return e.debounce(T,(A,B)=>A?(A.push(B),A):[B],x,void 0,!0,void 0,D)}e.accumulate=p;function f(T,x=(A,B)=>A===B,D){let A=!0,B;return n(T,P=>{let V=A||!x(P,B);return A=!1,B=P,V},D)}e.latch=f;function _(T,x,D){return[e.filter(T,x,D),e.filter(T,A=>!x(A),D)]}e.split=_;function w(T,x=!1,D=[],A){let B=D.slice(),P=T(de=>{B?B.push(de):se.fire(de)});A&&A.add(P);let V=()=>{B?.forEach(de=>se.fire(de)),B=null},se=new bs({onWillAddFirstListener(){P||(P=T(de=>se.fire(de)),A&&A.add(P))},onDidAddFirstListener(){B&&(x?setTimeout(V):V())},onDidRemoveLastListener(){P&&P.dispose(),P=null}});return A&&A.add(se),se.event}e.buffer=w;function k(T,x){return(D,A,B)=>{let P=x(new y);return T(function(V){let se=P.evaluate(V);se!==$&&D.call(A,se)},void 0,B)}}e.chain=k;let $=Symbol("HaltChainable");class y{constructor(){this.steps=[]}map(x){return this.steps.push(x),this}forEach(x){return this.steps.push(D=>(x(D),D)),this}filter(x){return this.steps.push(D=>x(D)?D:$),this}reduce(x,D){let A=D;return this.steps.push(B=>(A=x(A,B),A)),this}latch(x=(D,A)=>D===A){let D=!0,A;return this.steps.push(B=>{let P=D||!x(B,A);return D=!1,A=B,P?B:$}),this}evaluate(x){for(let D of this.steps)if(x=D(x),x===$)break;return x}}function C(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.on(x,A),P=()=>T.removeListener(x,A),V=new bs({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromNodeEventEmitter=C;function S(T,x,D=A=>A){let A=(...se)=>V.fire(D(...se)),B=()=>T.addEventListener(x,A),P=()=>T.removeEventListener(x,A),V=new bs({onWillAddFirstListener:B,onDidRemoveLastListener:P});return V.event}e.fromDOMEventEmitter=S;function L(T){return new Promise(x=>i(T)(x))}e.toPromise=L;function H(T){let x=new bs;return T.then(D=>{x.fire(D)},()=>{x.fire(void 0)}).finally(()=>{x.dispose()}),x.event}e.fromPromise=H;function F(T,x){return T(D=>x.fire(D))}e.forward=F;function W(T,x,D){return x(D),T(A=>x(A))}e.runAndSubscribe=W;class ie{constructor(x,D){this._observable=x,this._counter=0,this._hasChanged=!1;let A={onWillAddFirstListener:()=>{x.addObserver(this)},onDidRemoveLastListener:()=>{x.removeObserver(this)}};D||t(A),this.emitter=new bs(A),D&&D.add(this.emitter)}beginUpdate(x){this._counter++}handlePossibleChange(x){}handleChange(x,D){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 j(T,x){return new ie(T,x).emitter.event}e.fromObservable=j;function ce(T){return(x,D,A)=>{let B=0,P=!1,V={beginUpdate(){B++},endUpdate(){B--,B===0&&(T.reportChanges(),P&&(P=!1,x.call(D)))},handlePossibleChange(){},handleChange(){P=!0}};T.addObserver(V),T.reportChanges();let se={dispose(){T.removeObserver(V)}};return A instanceof Ah?A.add(se):Array.isArray(A)&&A.push(se),se}}e.fromObservableLight=ce})(Rh||(Rh={}));xh=class kh{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${kh._idPool++}`,kh.all.add(this)}start(t){this._stopWatch=new Uw,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}}};xh.all=new Set,xh._idPool=0;Gw=xh,Rf=-1,Hf=class Wf{constructor(t,s,i=(Wf._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)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=i*.5;let[o,n]=this.getMostFrequentStack(),a=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${n}):`;console.warn(a),console.warn(o);let c=new Xw(a,o);this._errorHandler(c)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s<r)&&(t=[i,r],s=r);return t}};Hf._idPool=1;Yw=Hf,$h=class jf{constructor(t){this.value=t}static create(){let t=new Error;return new jf(t.stack??"")}print(){console.warn(this.value.split(`
58
58
  `).slice(2).join(`
59
- `))}},Yw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Xw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Jw=0,Ra=class{constructor(e){this.value=e,this.id=Jw++}},Zw=2,Qw=(e,t)=>{if(e instanceof Ra)t(e);else for(let s=0;s<e.length;s++){let i=e[s];i&&t(i)}};if(Uw){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
60
- `)),e.length=0)},3e3),Da=new FinalizationRegistry(t=>{typeof t=="string"&&e.push(t)})}bs=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Rf>0||this._options?.leakWarningThreshold?new Gw(e?.onListenerError??_h,this._options?.leakWarningThreshold??Rf):void 0,this._perfMon=this._options?._profName?new Kw(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Af){let e=this._listeners;queueMicrotask(()=>{Qw(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??(this._event=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Xw(`${a}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(this._options?.onListenerError||_h)(l),ys.None}if(this._disposed)return ys.None;t&&(e=e.bind(t));let i=new Ra(e),r,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=$h.create(),r=this._leakageMon.check(i.stack,this._size+1)),Af&&(i.stack=o??$h.create()),this._listeners?this._listeners instanceof Ra?(this._deliveryQueue??(this._deliveryQueue=new e1),this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=Pr(()=>{Da?.unregister(n),r?.(),this._removeListener(i)});if(s instanceof Ah?s.add(n):Array.isArray(s)&&s.push(n),Da){let a=new Error().stack.split(`
59
+ `))}},Xw=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Jw=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Zw=0,Ra=class{constructor(e){this.value=e,this.id=Zw++}},Qw=2,e1=(e,t)=>{if(e instanceof Ra)t(e);else for(let s=0;s<e.length;s++){let i=e[s];i&&t(i)}};if(qw){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
60
+ `)),e.length=0)},3e3),Da=new FinalizationRegistry(t=>{typeof t=="string"&&e.push(t)})}bs=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Rf>0||this._options?.leakWarningThreshold?new Yw(e?.onListenerError??_h,this._options?.leakWarningThreshold??Rf):void 0,this._perfMon=this._options?._profName?new Gw(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Af){let e=this._listeners;queueMicrotask(()=>{e1(e,t=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??(this._event=(e,t,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let c=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],l=new Jw(`${a}. HINT: Stack shows most frequent listener (${c[1]}-times)`,c[0]);return(this._options?.onListenerError||_h)(l),ys.None}if(this._disposed)return ys.None;t&&(e=e.bind(t));let i=new Ra(e),r,o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(i.stack=$h.create(),r=this._leakageMon.check(i.stack,this._size+1)),Af&&(i.stack=o??$h.create()),this._listeners?this._listeners instanceof Ra?(this._deliveryQueue??(this._deliveryQueue=new t1),this._listeners=[this._listeners,i]):this._listeners.push(i):(this._options?.onWillAddFirstListener?.(this),this._listeners=i,this._options?.onDidAddFirstListener?.(this)),this._size++;let n=Pr(()=>{Da?.unregister(n),r?.(),this._removeListener(i)});if(s instanceof Ah?s.add(n):Array.isArray(s)&&s.push(n),Da){let a=new Error().stack.split(`
61
61
  `).slice(2,3).join(`
62
- `).trim(),c=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);Da.register(n,c?.[2]??a,n)}return n}),this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-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[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Zw<=t.length){let r=0;for(let o=0;o<t.length;o++)t[o]?t[r++]=t[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||_h;if(!s){e.value(t);return}try{e.value(t)}catch(i){s(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Ra)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},e1=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vf=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}});(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof s1?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Rh.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vf})})(t1||(t1={}));s1=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?Vf:(this._emitter||(this._emitter=new bs),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dr="en",Eh=!1,Th=!1,La=!1,i1=!1,r1=!1,Uf=!1,o1=!1,n1=!1,a1=!1,l1=!1,Pa=Dr,Df=Dr,js=globalThis;typeof js.vscode<"u"&&typeof js.vscode.process<"u"?It=js.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(It=process);qf=typeof It?.versions?.electron=="string",h1=qf&&It?.type==="renderer";if(typeof It=="object"){Eh=It.platform==="win32",Th=It.platform==="darwin",La=It.platform==="linux",i1=La&&!!It.env.SNAP&&!!It.env.SNAP_REVISION,o1=qf,a1=!!It.env.CI||!!It.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Aa=Dr,Pa=Dr;let e=It.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Aa=t.userLocale,Df=t.osLocale,Pa=t.resolvedLanguage||Dr,c1=t.languagePack?.translationsConfigFile}catch{}r1=!0}else typeof navigator=="object"&&!h1?(Ws=navigator.userAgent,Eh=Ws.indexOf("Windows")>=0,Th=Ws.indexOf("Macintosh")>=0,n1=(Ws.indexOf("Macintosh")>=0||Ws.indexOf("iPad")>=0||Ws.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,La=Ws.indexOf("Linux")>=0,l1=Ws?.indexOf("Mobi")>=0,Uf=!0,Pa=globalThis._VSCODE_NLS_LANGUAGE||Dr,Aa=navigator.language.toLowerCase(),Df=Aa):console.error("Unable to resolve platform.");vh=0;Th?vh=1:Eh?vh=3:La&&(vh=2);d1=Uf&&typeof js.importScripts=="function",EA=d1?js.origin:void 0,ws=Ws,di=Pa;(e=>{function t(){return di}e.value=t;function s(){return di.length===2?di==="en":di.length>=3?di[0]==="e"&&di[1]==="n"&&di[2]==="-":!1}e.isDefaultVariant=s;function i(){return di==="en"}e.isDefault=i})(u1||(u1={}));p1=typeof js.postMessage=="function"&&!js.importScripts,f1=(()=>{if(p1){let e=[];js.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),js.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),m1=!!(ws&&ws.indexOf("Chrome")>=0),TA=!!(ws&&ws.indexOf("Firefox")>=0),AA=!!(!m1&&ws&&ws.indexOf("Safari")>=0),RA=!!(ws&&ws.indexOf("Edg/")>=0),DA=!!(ws&&ws.indexOf("Android")>=0);(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?bh=(e,t)=>{f1(()=>{if(s)return;let i=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,i-Date.now())}}))});let s=!1;return{dispose(){s||(s=!0)}}}:bh=(e,t,s)=>{let i=e.requestIdleCallback(t,typeof s=="number"?{timeout:s}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(i))}}},g1=e=>bh(globalThis,e)})();(e=>{async function t(i){let r,o=await Promise.all(i.map(n=>n.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(n){o(n)}})}e.withAsyncBody=s})(_1||(_1={}));Lf=class Kt{static fromArray(t){return new Kt(s=>{s.emitMany(t)})}static fromPromise(t){return new Kt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Kt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Kt(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new bs,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.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 Rh.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Kt(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Kt.map(this,t)}static filter(t,s){return new Kt(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Kt.filter(this,t)}static coalesce(t){return Kt.filter(t,s=>!!s)}coalesce(){return Kt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Kt.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())}};Lf.EMPTY=Lf.fromArray([]);v1=class extends ys{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Ba),this._linesCacheDisposables=this._register(new Ba),this._register(Pr(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Of(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Kf(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let s=[],i=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let o=this._terminal.buffer.active.getLine(e+1),n=o?o.isWrapped:!1,a=r.translateToString(!n&&t);if(n&&o){let c=r.getCell(r.length-1);c&&c.getCode()===0&&c.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(s.push(a),n)i.push(i[i.length-1]+a.length);else break;e++,r=o}return[s.join(""),i]}},b1=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},y1=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,s,i){if(!e||e.length===0){this._terminal.clearSelection();return}if(s>this._terminal.cols)throw new Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:s},o=this._findInLine(e,r,i);if(!o)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=n,r.startCol=0,o=this._findInLine(e,r,i),!o);n++);return o}findNextWithSelection(e,t,s){if(!e||e.length===0){this._terminal.clearSelection();return}let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,o=0;i&&(s===e?(r=i.end.x,o=i.end.y):(r=i.start.x,o=i.start.y)),this._lineCache.initLinesCache();let n={startRow:o,startCol:r},a=this._findInLine(e,n,t);if(!a)for(let c=o+1;c<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=c,n.startCol=0,a=this._findInLine(e,n,t),!a);c++);if(!a&&o!==0)for(let c=0;c<o&&(n.startRow=c,n.startCol=0,a=this._findInLine(e,n,t),!a);c++);return!a&&i&&(n.startRow=i.start.y,n.startCol=0,a=this._findInLine(e,n,t)),a}findPreviousWithSelection(e,t,s){if(!e||e.length===0){this._terminal.clearSelection();return}let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,o=this._terminal.cols,n=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:o},c;if(i&&(a.startRow=r=i.start.y,a.startCol=o=i.start.x,s!==e&&(c=this._findInLine(e,a,t,!1),c||(a.startRow=r=i.end.y,a.startCol=o=i.end.x))),c||(c=this._findInLine(e,a,t,n)),!c){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let l=r-1;l>=0&&(a.startRow=l,c=this._findInLine(e,a,t,n),!c);l--);}if(!c&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let l=this._terminal.buffer.active.baseY+this._terminal.rows-1;l>=r&&(a.startRow=l,c=this._findInLine(e,a,t,n),!c);l--);return c}_isWholeWord(e,t,s){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+s.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+s.length]))}_findInLine(e,t,s={},i=!1){let r=t.startRow,o=t.startCol;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(i){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,s)}let n=this._lineCache.getLineFromCache(r);n||(n=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,n));let[a,c]=n,l=this._bufferColsToStringOffset(r,o),h=e,d=a;s.regex||(h=s.caseSensitive?e:e.toLowerCase(),d=s.caseSensitive?a:a.toLowerCase());let m=-1;if(s.regex){let p=RegExp(h,s.caseSensitive?"g":"gi"),f;if(i)for(;f=p.exec(d.slice(0,l));)m=p.lastIndex-f[0].length,e=f[0],p.lastIndex-=e.length-1;else f=p.exec(d.slice(l)),f&&f[0].length>0&&(m=l+(p.lastIndex-f[0].length),e=f[0])}else i?l-h.length>=0&&(m=d.lastIndexOf(h,l-h.length)):m=d.indexOf(h,l);if(m>=0){if(s.wholeWord&&!this._isWholeWord(m,d,e))return;let p=0;for(;p<c.length-1&&m>=c[p+1];)p++;let f=p;for(;f<c.length-1&&m+e.length>=c[f+1];)f++;let _=m-c[p],w=m+e.length-c[f],k=this._stringLengthToBufferSize(r+p,_),$=this._stringLengthToBufferSize(r+f,w)-k+this._terminal.cols*(f-p);return{term:e,col:k,row:r+p,size:$}}}_stringLengthToBufferSize(e,t){let s=this._terminal.buffer.active.getLine(e);if(!s)return 0;for(let i=0;i<t;i++){let r=s.getCell(i);if(!r)break;let o=r.getChars();o.length>1&&(t-=o.length-1);let n=s.getCell(i+1);n&&n.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let s=e,i=0,r=this._terminal.buffer.active.getLine(s);for(;t>0&&r;){for(let o=0;o<t&&o<this._terminal.cols;o++){let n=r.getCell(o);if(!n)break;n.getWidth()&&(i+=n.getCode()===0?1:n.getChars().length)}if(s++,r=this._terminal.buffer.active.getLine(s),r&&!r.isWrapped)break;t-=this._terminal.cols}return i}},w1=class extends ys{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Pr(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let s of e){let i=this._createResultDecorations(s,t,!1);if(i)for(let r of i)this._storeDecoration(r,s)}}createActiveDecoration(e,t){let s=this._createResultDecorations(e,t,!0);if(s)return{decorations:s,match:e,dispose(){qo(s)}}}clearHighlightDecorations(){qo(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,s){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),s&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,s){let i=[],r=e.col,o=e.size,n=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;o>0;){let c=Math.min(this._terminal.cols-r,o);i.push([n,r,c]),r=0,o-=c,n++}let a=[];for(let c of i){let l=this._terminal.registerMarker(c[0]),h=this._terminal.registerDecoration({marker:l,x:c[1],width:c[2],backgroundColor:s?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(l.line)?void 0:{color:s?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(h){let d=[];d.push(l),d.push(h.onRender(m=>this._applyStyles(m,s?t.activeMatchBorder:t.matchBorder,!1))),d.push(h.onDispose(()=>qo(d))),a.push(h)}}return a.length===0?void 0:a}},S1=class extends ys{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new bs)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let s=this._searchResults[t];if(s.row===e.row&&s.col===e.col&&s.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},C1=class extends ys{constructor(e){super(),this._highlightTimeout=this._register(new Ba),this._lineCache=this._register(new Ba),this._state=new b1,this._resultTracker=this._register(new S1),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new v1(e),this._engine=new y1(e,this._lineCache.value),this._decorationManager=new w1(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Pr(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Kf(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let i=this._findNextAndSelect(e,t,s);return this._fireResults(t),this._state.cachedSearchTerm=e,i}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let s=[],i,r=this._engine.find(e,0,0,t);for(;r&&(i?.row!==r.row||i?.col!==r.col)&&!(s.length>=this._highlightLimit);)i=r,s.push(i),r=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(s,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(s,t.decorations)}_findNextAndSelect(e,t,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let i=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(i,t?.decorations,s?.noScroll)}findPrevious(e,t,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let i=this._findPreviousAndSelect(e,t,s);return this._fireResults(t),this._state.cachedSearchTerm=e,i}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let i=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(i,t?.decorations,s?.noScroll)}_selectResult(e,t,s){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!s&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let i=e.row-this._terminal.buffer.active.viewportY;i-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(i)}return!0}}});var oo=globalThis,Id=e=>e,Bn=oo.trustedTypes,Od=Bn?Bn.createPolicy("lit-html",{createHTML:e=>e}):void 0,kl="$lit$",Ts=`lit$${Math.random().toFixed(9).slice(2)}$`,$l="?"+Ts,Q_=`<${$l}>`,Di=document,no=()=>Di.createComment(""),ao=e=>e===null||typeof e!="object"&&typeof e!="function",El=Array.isArray,jd=e=>El(e)||typeof e?.[Symbol.iterator]=="function",xl=`[
62
+ `).trim(),c=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);Da.register(n,c?.[2]??a,n)}return n}),this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,s=t.indexOf(e);if(s===-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[s]=void 0;let i=this._deliveryQueue.current===this;if(this._size*Qw<=t.length){let r=0;for(let o=0;o<t.length;o++)t[o]?t[r++]=t[o]:i&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let s=this._options?.onListenerError||_h;if(!s){e.value(t);return}try{e.value(t)}catch(i){s(i)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Ra)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},t1=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vf=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}});(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof i1?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Rh.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vf})})(s1||(s1={}));i1=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?Vf:(this._emitter||(this._emitter=new bs),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Dr="en",Eh=!1,Th=!1,La=!1,r1=!1,o1=!1,Uf=!1,n1=!1,a1=!1,l1=!1,c1=!1,Pa=Dr,Df=Dr,js=globalThis;typeof js.vscode<"u"&&typeof js.vscode.process<"u"?It=js.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(It=process);qf=typeof It?.versions?.electron=="string",d1=qf&&It?.type==="renderer";if(typeof It=="object"){Eh=It.platform==="win32",Th=It.platform==="darwin",La=It.platform==="linux",r1=La&&!!It.env.SNAP&&!!It.env.SNAP_REVISION,n1=qf,l1=!!It.env.CI||!!It.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Aa=Dr,Pa=Dr;let e=It.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Aa=t.userLocale,Df=t.osLocale,Pa=t.resolvedLanguage||Dr,h1=t.languagePack?.translationsConfigFile}catch{}o1=!0}else typeof navigator=="object"&&!d1?(Ws=navigator.userAgent,Eh=Ws.indexOf("Windows")>=0,Th=Ws.indexOf("Macintosh")>=0,a1=(Ws.indexOf("Macintosh")>=0||Ws.indexOf("iPad")>=0||Ws.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,La=Ws.indexOf("Linux")>=0,c1=Ws?.indexOf("Mobi")>=0,Uf=!0,Pa=globalThis._VSCODE_NLS_LANGUAGE||Dr,Aa=navigator.language.toLowerCase(),Df=Aa):console.error("Unable to resolve platform.");vh=0;Th?vh=1:Eh?vh=3:La&&(vh=2);u1=Uf&&typeof js.importScripts=="function",AA=u1?js.origin:void 0,ws=Ws,di=Pa;(e=>{function t(){return di}e.value=t;function s(){return di.length===2?di==="en":di.length>=3?di[0]==="e"&&di[1]==="n"&&di[2]==="-":!1}e.isDefaultVariant=s;function i(){return di==="en"}e.isDefault=i})(p1||(p1={}));f1=typeof js.postMessage=="function"&&!js.importScripts,m1=(()=>{if(f1){let e=[];js.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),js.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})(),g1=!!(ws&&ws.indexOf("Chrome")>=0),RA=!!(ws&&ws.indexOf("Firefox")>=0),DA=!!(!g1&&ws&&ws.indexOf("Safari")>=0),LA=!!(ws&&ws.indexOf("Edg/")>=0),PA=!!(ws&&ws.indexOf("Android")>=0);(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?bh=(e,t)=>{m1(()=>{if(s)return;let i=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,i-Date.now())}}))});let s=!1;return{dispose(){s||(s=!0)}}}:bh=(e,t,s)=>{let i=e.requestIdleCallback(t,typeof s=="number"?{timeout:s}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(i))}}},_1=e=>bh(globalThis,e)})();(e=>{async function t(i){let r,o=await Promise.all(i.map(n=>n.then(a=>a,a=>{r||(r=a)})));if(typeof r<"u")throw r;return o}e.settled=t;function s(i){return new Promise(async(r,o)=>{try{await i(r,o)}catch(n){o(n)}})}e.withAsyncBody=s})(v1||(v1={}));Lf=class Kt{static fromArray(t){return new Kt(s=>{s.emitMany(t)})}static fromPromise(t){return new Kt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new Kt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new Kt(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new bs,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.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 Rh.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,s){return new Kt(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return Kt.map(this,t)}static filter(t,s){return new Kt(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return Kt.filter(this,t)}static coalesce(t){return Kt.filter(t,s=>!!s)}coalesce(){return Kt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return Kt.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())}};Lf.EMPTY=Lf.fromArray([]);b1=class extends ys{constructor(e){super(),this._terminal=e,this._linesCacheTimeout=this._register(new Ba),this._linesCacheDisposables=this._register(new Ba),this._register(Pr(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=new Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Of(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Kf(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let s=[],i=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let o=this._terminal.buffer.active.getLine(e+1),n=o?o.isWrapped:!1,a=r.translateToString(!n&&t);if(n&&o){let c=r.getCell(r.length-1);c&&c.getCode()===0&&c.getWidth()===1&&o.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(s.push(a),n)i.push(i[i.length-1]+a.length);else break;e++,r=o}return[s.join(""),i]}},y1=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},w1=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,s,i){if(!e||e.length===0){this._terminal.clearSelection();return}if(s>this._terminal.cols)throw new Error(`Invalid col: ${s} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:s},o=this._findInLine(e,r,i);if(!o)for(let n=t+1;n<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=n,r.startCol=0,o=this._findInLine(e,r,i),!o);n++);return o}findNextWithSelection(e,t,s){if(!e||e.length===0){this._terminal.clearSelection();return}let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,o=0;i&&(s===e?(r=i.end.x,o=i.end.y):(r=i.start.x,o=i.start.y)),this._lineCache.initLinesCache();let n={startRow:o,startCol:r},a=this._findInLine(e,n,t);if(!a)for(let c=o+1;c<this._terminal.buffer.active.baseY+this._terminal.rows&&(n.startRow=c,n.startCol=0,a=this._findInLine(e,n,t),!a);c++);if(!a&&o!==0)for(let c=0;c<o&&(n.startRow=c,n.startCol=0,a=this._findInLine(e,n,t),!a);c++);return!a&&i&&(n.startRow=i.start.y,n.startCol=0,a=this._findInLine(e,n,t)),a}findPreviousWithSelection(e,t,s){if(!e||e.length===0){this._terminal.clearSelection();return}let i=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,o=this._terminal.cols,n=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:o},c;if(i&&(a.startRow=r=i.start.y,a.startCol=o=i.start.x,s!==e&&(c=this._findInLine(e,a,t,!1),c||(a.startRow=r=i.end.y,a.startCol=o=i.end.x))),c||(c=this._findInLine(e,a,t,n)),!c){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let l=r-1;l>=0&&(a.startRow=l,c=this._findInLine(e,a,t,n),!c);l--);}if(!c&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let l=this._terminal.buffer.active.baseY+this._terminal.rows-1;l>=r&&(a.startRow=l,c=this._findInLine(e,a,t,n),!c);l--);return c}_isWholeWord(e,t,s){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+s.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+s.length]))}_findInLine(e,t,s={},i=!1){let r=t.startRow,o=t.startCol;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(i){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,s)}let n=this._lineCache.getLineFromCache(r);n||(n=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,n));let[a,c]=n,l=this._bufferColsToStringOffset(r,o),h=e,d=a;s.regex||(h=s.caseSensitive?e:e.toLowerCase(),d=s.caseSensitive?a:a.toLowerCase());let m=-1;if(s.regex){let p=RegExp(h,s.caseSensitive?"g":"gi"),f;if(i)for(;f=p.exec(d.slice(0,l));)m=p.lastIndex-f[0].length,e=f[0],p.lastIndex-=e.length-1;else f=p.exec(d.slice(l)),f&&f[0].length>0&&(m=l+(p.lastIndex-f[0].length),e=f[0])}else i?l-h.length>=0&&(m=d.lastIndexOf(h,l-h.length)):m=d.indexOf(h,l);if(m>=0){if(s.wholeWord&&!this._isWholeWord(m,d,e))return;let p=0;for(;p<c.length-1&&m>=c[p+1];)p++;let f=p;for(;f<c.length-1&&m+e.length>=c[f+1];)f++;let _=m-c[p],w=m+e.length-c[f],k=this._stringLengthToBufferSize(r+p,_),$=this._stringLengthToBufferSize(r+f,w)-k+this._terminal.cols*(f-p);return{term:e,col:k,row:r+p,size:$}}}_stringLengthToBufferSize(e,t){let s=this._terminal.buffer.active.getLine(e);if(!s)return 0;for(let i=0;i<t;i++){let r=s.getCell(i);if(!r)break;let o=r.getChars();o.length>1&&(t-=o.length-1);let n=s.getCell(i+1);n&&n.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let s=e,i=0,r=this._terminal.buffer.active.getLine(s);for(;t>0&&r;){for(let o=0;o<t&&o<this._terminal.cols;o++){let n=r.getCell(o);if(!n)break;n.getWidth()&&(i+=n.getCode()===0?1:n.getChars().length)}if(s++,r=this._terminal.buffer.active.getLine(s),r&&!r.isWrapped)break;t-=this._terminal.cols}return i}},S1=class extends ys{constructor(e){super(),this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(Pr(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let s of e){let i=this._createResultDecorations(s,t,!1);if(i)for(let r of i)this._storeDecoration(r,s)}}createActiveDecoration(e,t){let s=this._createResultDecorations(e,t,!0);if(s)return{decorations:s,match:e,dispose(){qo(s)}}}clearHighlightDecorations(){qo(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,s){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),s&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,s){let i=[],r=e.col,o=e.size,n=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;o>0;){let c=Math.min(this._terminal.cols-r,o);i.push([n,r,c]),r=0,o-=c,n++}let a=[];for(let c of i){let l=this._terminal.registerMarker(c[0]),h=this._terminal.registerDecoration({marker:l,x:c[1],width:c[2],backgroundColor:s?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(l.line)?void 0:{color:s?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(h){let d=[];d.push(l),d.push(h.onRender(m=>this._applyStyles(m,s?t.activeMatchBorder:t.matchBorder,!1))),d.push(h.onDispose(()=>qo(d))),a.push(h)}}return a.length===0?void 0:a}},C1=class extends ys{constructor(){super(...arguments),this._searchResults=[],this._onDidChangeResults=this._register(new bs)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let s=this._searchResults[t];if(s.row===e.row&&s.col===e.col&&s.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},x1=class extends ys{constructor(e){super(),this._highlightTimeout=this._register(new Ba),this._lineCache=this._register(new Ba),this._state=new y1,this._resultTracker=this._register(new C1),this._highlightLimit=e?.highlightLimit??1e3}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new b1(e),this._engine=new w1(e,this._lineCache.value),this._decorationManager=new S1(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(Pr(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Kf(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let i=this._findNextAndSelect(e,t,s);return this._fireResults(t),this._state.cachedSearchTerm=e,i}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw new Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let s=[],i,r=this._engine.find(e,0,0,t);for(;r&&(i?.row!==r.row||i?.col!==r.col)&&!(s.length>=this._highlightLimit);)i=r,s.push(i),r=this._engine.find(e,i.col+i.term.length>=this._terminal.cols?i.row+1:i.row,i.col+i.term.length>=this._terminal.cols?0:i.col+1,t);this._resultTracker.updateResults(s,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(s,t.decorations)}_findNextAndSelect(e,t,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let i=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(i,t?.decorations,s?.noScroll)}findPrevious(e,t,s){if(!this._terminal||!this._engine)throw new Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let i=this._findPreviousAndSelect(e,t,s);return this._fireResults(t),this._state.cachedSearchTerm=e,i}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,s){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let i=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(i,t?.decorations,s?.noScroll)}_selectResult(e,t,s){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let i=this._decorationManager.createActiveDecoration(e,t);i&&(this._resultTracker.selectedDecoration=i)}if(!s&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let i=e.row-this._terminal.buffer.active.viewportY;i-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(i)}return!0}}});var oo=globalThis,Id=e=>e,Bn=oo.trustedTypes,Od=Bn?Bn.createPolicy("lit-html",{createHTML:e=>e}):void 0,kl="$lit$",Ts=`lit$${Math.random().toFixed(9).slice(2)}$`,$l="?"+Ts,ev=`<${$l}>`,Di=document,no=()=>Di.createComment(""),ao=e=>e===null||typeof e!="object"&&typeof e!="function",El=Array.isArray,jd=e=>El(e)||typeof e?.[Symbol.iterator]=="function",xl=`[
63
63
  \f\r]`,ro=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,zd=/-->/g,Nd=/>/g,Ai=RegExp(`>|${xl}(?:([^\\s"'>=/]+)(${xl}*=${xl}*(?:[^
64
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Fd=/'/g,Hd=/"/g,Vd=/^(?:script|style|textarea|title)$/i,Tl=e=>(t,...s)=>({_$litType$:e,strings:t,values:s}),u=Tl(1),Ud=Tl(2),qd=Tl(3),ct=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),Wd=new WeakMap,Ri=Di.createTreeWalker(Di,129);function Kd(e,t){if(!El(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Od!==void 0?Od.createHTML(t):t}var Gd=(e,t)=>{let s=e.length-1,i=[],r,o=t===2?"<svg>":t===3?"<math>":"",n=ro;for(let a=0;a<s;a++){let c=e[a],l,h,d=-1,m=0;for(;m<c.length&&(n.lastIndex=m,h=n.exec(c),h!==null);)m=n.lastIndex,n===ro?h[1]==="!--"?n=zd:h[1]!==void 0?n=Nd:h[2]!==void 0?(Vd.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=Ai):h[3]!==void 0&&(n=Ai):n===Ai?h[0]===">"?(n=r??ro,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,l=h[1],n=h[3]===void 0?Ai:h[3]==='"'?Hd:Fd):n===Hd||n===Fd?n=Ai:n===zd||n===Nd?n=ro:(n=Ai,r=void 0);let p=n===Ai&&e[a+1].startsWith("/>")?" ":"";o+=n===ro?c+Q_:d>=0?(i.push(l),c.slice(0,d)+kl+c.slice(d)+Ts+p):c+Ts+(d===-2?a:p)}return[Kd(e,o+(e[s]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},lo=class e{constructor({strings:t,_$litType$:s},i){let r;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[l,h]=Gd(t,s);if(this.el=e.createElement(l,i),Ri.currentNode=this.el.content,s===2||s===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=Ri.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let d of r.getAttributeNames())if(d.endsWith(kl)){let m=h[n++],p=r.getAttribute(d).split(Ts),f=/([.?@])?(.*)/.exec(m);c.push({type:1,index:o,name:f[2],strings:p,ctor:f[1]==="."?In:f[1]==="?"?On:f[1]==="@"?zn:Pi}),r.removeAttribute(d)}else d.startsWith(Ts)&&(c.push({type:6,index:o}),r.removeAttribute(d));if(Vd.test(r.tagName)){let d=r.textContent.split(Ts),m=d.length-1;if(m>0){r.textContent=Bn?Bn.emptyScript:"";for(let p=0;p<m;p++)r.append(d[p],no()),Ri.nextNode(),c.push({type:2,index:++o});r.append(d[m],no())}}}else if(r.nodeType===8)if(r.data===$l)c.push({type:2,index:o});else{let d=-1;for(;(d=r.data.indexOf(Ts,d+1))!==-1;)c.push({type:7,index:o}),d+=Ts.length-1}o++}}static createElement(t,s){let i=Di.createElement("template");return i.innerHTML=t,i}};function Li(e,t,s=e,i){if(t===ct)return t;let r=i!==void 0?s._$Co?.[i]:s._$Cl,o=ao(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,s,i)),i!==void 0?(s._$Co??(s._$Co=[]))[i]=r:s._$Cl=r),r!==void 0&&(t=Li(e,r._$AS(e,t.values),r,i)),t}var Mn=class{constructor(t,s){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:s},parts:i}=this._$AD,r=(t?.creationScope??Di).importNode(s,!0);Ri.currentNode=r;let o=Ri.nextNode(),n=0,a=0,c=i[0];for(;c!==void 0;){if(n===c.index){let l;c.type===2?l=new fr(o,o.nextSibling,this,t):c.type===1?l=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(l=new Nn(o,this,t)),this._$AV.push(l),c=i[++a]}n!==c?.index&&(o=Ri.nextNode(),n++)}return Ri.currentNode=Di,r}p(t){let s=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,s),s+=i.strings.length-2):i._$AI(t[s])),s++}},fr=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,s,i,r){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=s,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,s=this._$AM;return s!==void 0&&t?.nodeType===11&&(t=s.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,s=this){t=Li(this,t,s),ao(t)?t===b||t==null||t===""?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==ct&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):jd(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&ao(this._$AH)?this._$AA.nextSibling.data=t:this.T(Di.createTextNode(t)),this._$AH=t}$(t){let{values:s,_$litType$:i}=t,r=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=lo.createElement(Kd(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(s);else{let o=new Mn(r,this),n=o.u(this.options);o.p(s),this.T(n),this._$AH=o}}_$AC(t){let s=Wd.get(t.strings);return s===void 0&&Wd.set(t.strings,s=new lo(t)),s}k(t){El(this._$AH)||(this._$AH=[],this._$AR());let s=this._$AH,i,r=0;for(let o of t)r===s.length?s.push(i=new e(this.O(no()),this.O(no()),this,this.options)):i=s[r],i._$AI(o),r++;r<s.length&&(this._$AR(i&&i._$AB.nextSibling,r),s.length=r)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){let i=Id(t).nextSibling;Id(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},Pi=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,s,i,r,o){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=s,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=b}_$AI(t,s=this,i,r){let o=this.strings,n=!1;if(o===void 0)t=Li(this,t,s,0),n=!ao(t)||t!==this._$AH&&t!==ct,n&&(this._$AH=t);else{let a=t,c,l;for(t=o[0],c=0;c<o.length-1;c++)l=Li(this,a[i+c],s,c),l===ct&&(l=this._$AH[c]),n||(n=!ao(l)||l!==this._$AH[c]),l===b?t=b:t!==b&&(t+=(l??"")+o[c+1]),this._$AH[c]=l}n&&!r&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},In=class extends Pi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}},On=class extends Pi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}},zn=class extends Pi{constructor(t,s,i,r,o){super(t,s,i,r,o),this.type=5}_$AI(t,s=this){if((t=Li(this,t,s,0)??b)===ct)return;let i=this._$AH,r=t===b&&i!==b||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==b&&(i===b||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Nn=class{constructor(t,s,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=s,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Li(this,t)}},Yd={M:kl,P:Ts,A:$l,C:1,L:Gd,R:Mn,D:jd,V:Li,I:fr,H:Pi,N:On,U:zn,B:In,F:Nn},ev=oo.litHtmlPolyfillSupport;ev?.(lo,fr),(oo.litHtmlVersions??(oo.litHtmlVersions=[])).push("3.3.2");var Fn=(e,t,s)=>{let i=s?.renderBefore??t,r=i._$litPart$;if(r===void 0){let o=s?.renderBefore??null;i._$litPart$=r=new fr(t.insertBefore(no(),o),o,void 0,s??{})}return r._$AI(e),r};var ts={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},mr=e=>(...t)=>({_$litDirective$:e,values:t}),Qs=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,s,i){this._$Ct=t,this._$AM=s,this._$Ci=i}_$AS(t,s){return this.update(t,s)}update(t,s){return this.render(...s)}};var co=class extends Qs{constructor(t){if(super(t),this.it=b,t.type!==ts.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===b||t==null)return this._t=void 0,this.it=t;if(t===ct)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let s=[t];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}};co.directiveName="unsafeHTML",co.resultType=1;var E=mr(co);function Al(e){let t=(e||"").replace(/^#\/?/,""),[s,i]=t.split("?"),r=s.split("/").filter(Boolean);if(r[0]==="project"&&r.length>=3)return{section:r[2],runId:r[3]||null,projectId:r[1]};let o=r[0]||"active",n=r[1]||null,a=new URLSearchParams(i||"");return{section:o,runId:n||a.get("run")||null,projectId:a.get("project")||null}}function tv(e,t,s){if(s){let r=`#/project/${s}/${e}`;return t?`${r}/${t}`:r}let i=`#/${e}`;return t?`${i}/${t}`:i}function Xd(e){let t=()=>e(Al(location.hash));return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function st(e,t,s){location.hash=tv(e,t,s)}var gr={run_completed:{severity:"info",title:"Pipeline Complete",requireInteraction:!1},run_failed:{severity:"critical",title:"Pipeline Failed",requireInteraction:!1},approval_needed:{severity:"critical",title:"Approval Required",requireInteraction:!0},test_failures:{severity:"warning",title:"Tests Failed",requireInteraction:!1},loop_limit_warning:{severity:"warning",title:"Loop Limit Warning",requireInteraction:!1}};function sv(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{};if(Object.values(n).some(h=>h.status==="error"))return null;let c=ho(t),l=i?`[${i}] "${c}" finished successfully`:`"${c}" finished successfully`;return{event:"run_completed",title:gr.run_completed.title,body:l,tag:`worca-complete-${e}`,requireInteraction:!1,runId:e}}function iv(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{},a=Object.entries(n).find(([,h])=>h.status==="error");if(!a)return null;let c=ho(t),l=i?`[${i}] "${c}" failed at ${a[0]} stage`:`"${c}" failed at ${a[0]} stage`;return{event:"run_failed",title:gr.run_failed.title,body:l,tag:`worca-failed-${e}`,requireInteraction:!1,runId:e}}function rv(e,t,s,i){if(!t)return null;let r=t.stages||{},o=s?.stages||{};for(let[n,a]of Object.entries(r))if(a.status==="waiting_approval"&&o[n]?.status!=="waiting_approval"){let l=ho(t),h=n==="pr"?"PR":n,d=i?`[${i}] "${l}" is waiting for ${h} approval`:`"${l}" is waiting for ${h} approval`;return{event:"approval_needed",title:gr.approval_needed.title,body:d,tag:`worca-approval-${e}-${n}`,requireInteraction:!0,runId:e}}return null}function ov(e,t,s,i){if(!t)return null;let r=t.stages?.test;if(!r)return null;let o=r.iterations||[],n=s?.stages?.test?.iterations||[];if(o.length>n.length){let a=o[o.length-1];if(a&&a.result==="failed"){let c=ho(t),l=i?`[${i}] "${c}" test iteration ${o.length} failed`:`"${c}" test iteration ${o.length} failed`;return{event:"test_failures",title:gr.test_failures.title,body:l,tag:`worca-test-${e}-iter${o.length}`,requireInteraction:!1,runId:e}}}return null}function nv(e,t,s,i,r){if(!t||!i)return null;let o=i?.worca?.loops;if(!o)return null;let n=t.stages||{},a={implement_test:["implement","test"],pr_changes:["pr"],restart_planning:["plan"],plan_review:["plan_review"]};for(let[c,l]of Object.entries(o)){if(!l||l<2)continue;let h=a[c];if(h)for(let d of h){let m=n[d];if(!m)continue;let p=(m.iterations||[]).filter(f=>f.trigger!=="initial").length;if(p>0&&p===l-1){let f=`${e}-${d}`;if(r.has(f))continue;r.add(f);let _=ho(t);return{event:"loop_limit_warning",title:gr.loop_limit_warning.title,body:`"${_}" ${d} stage approaching loop limit (${p}/${l})`,tag:`worca-loop-${e}-${d}`,requireInteraction:!1,runId:e}}}}return null}function ho(e){let s=(e?.work_request?.title||e?.id||"Pipeline").split(`
65
- `)[0];return s.length>60?`${s.slice(0,60)}\u2026`:s}var As=null;function av(){try{As||(As=new AudioContext);let e=As.createOscillator(),t=As.createGain();e.type="sine",e.frequency.value=440,t.gain.value=.3,e.connect(t),t.connect(As.destination),e.start(),e.stop(As.currentTime+.2)}catch{}}var Hn={enabled:!0,sound:!1,events:{run_completed:!0,run_failed:!0,approval_needed:!0,test_failures:!0,loop_limit_warning:!0}};function Jd({store:e,ws:t,getSettings:s}){let i=typeof Notification<"u"?Notification.permission:"denied",r=new Set,o=!1,n=null;function a(_){n=_}function c(){return typeof Notification<"u"&&(i=Notification.permission),i}async function l(){if(typeof Notification>"u")return"denied";let _=await Notification.requestPermission();return i=_,n&&n(),_}function h(){let _=e.getState().preferences.notifications;return _?{enabled:_.enabled??Hn.enabled,sound:_.sound??Hn.sound,events:{...Hn.events,..._.events||{}}}:{...Hn}}function d({event:_,title:w,body:k,tag:$,requireInteraction:y,runId:C}){if(typeof Notification>"u")return;let S=new Notification(w,{body:k,icon:"/favicon.svg",tag:$,requireInteraction:y});S.onclick=()=>{window.focus(),st("active",C),S.close()};let L=h(),H=gr[_];L.sound&&H&&H.severity==="critical"&&av()}function m(_,w,k){if(typeof Notification>"u"||Notification.permission!=="granted")return;let $=h();if(!$.enabled)return;let y=s(),C=e.getState(),S=C.projects?.length>1?C.projectName:null,L=[sv,iv,rv,ov];for(let F of L){let W=F(_,w,k,S);W&&$.events[W.event]&&d(W)}let H=nv(_,w,k,y,r);H&&$.events[H.event]&&d(H)}function p(){return typeof Notification>"u"?b:(c(),i==="default"?u`
64
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Fd=/'/g,Hd=/"/g,Vd=/^(?:script|style|textarea|title)$/i,Tl=e=>(t,...s)=>({_$litType$:e,strings:t,values:s}),u=Tl(1),Ud=Tl(2),qd=Tl(3),ct=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),Wd=new WeakMap,Ri=Di.createTreeWalker(Di,129);function Kd(e,t){if(!El(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Od!==void 0?Od.createHTML(t):t}var Gd=(e,t)=>{let s=e.length-1,i=[],r,o=t===2?"<svg>":t===3?"<math>":"",n=ro;for(let a=0;a<s;a++){let c=e[a],l,h,d=-1,m=0;for(;m<c.length&&(n.lastIndex=m,h=n.exec(c),h!==null);)m=n.lastIndex,n===ro?h[1]==="!--"?n=zd:h[1]!==void 0?n=Nd:h[2]!==void 0?(Vd.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=Ai):h[3]!==void 0&&(n=Ai):n===Ai?h[0]===">"?(n=r??ro,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,l=h[1],n=h[3]===void 0?Ai:h[3]==='"'?Hd:Fd):n===Hd||n===Fd?n=Ai:n===zd||n===Nd?n=ro:(n=Ai,r=void 0);let p=n===Ai&&e[a+1].startsWith("/>")?" ":"";o+=n===ro?c+ev:d>=0?(i.push(l),c.slice(0,d)+kl+c.slice(d)+Ts+p):c+Ts+(d===-2?a:p)}return[Kd(e,o+(e[s]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},lo=class e{constructor({strings:t,_$litType$:s},i){let r;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[l,h]=Gd(t,s);if(this.el=e.createElement(l,i),Ri.currentNode=this.el.content,s===2||s===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=Ri.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(let d of r.getAttributeNames())if(d.endsWith(kl)){let m=h[n++],p=r.getAttribute(d).split(Ts),f=/([.?@])?(.*)/.exec(m);c.push({type:1,index:o,name:f[2],strings:p,ctor:f[1]==="."?In:f[1]==="?"?On:f[1]==="@"?zn:Pi}),r.removeAttribute(d)}else d.startsWith(Ts)&&(c.push({type:6,index:o}),r.removeAttribute(d));if(Vd.test(r.tagName)){let d=r.textContent.split(Ts),m=d.length-1;if(m>0){r.textContent=Bn?Bn.emptyScript:"";for(let p=0;p<m;p++)r.append(d[p],no()),Ri.nextNode(),c.push({type:2,index:++o});r.append(d[m],no())}}}else if(r.nodeType===8)if(r.data===$l)c.push({type:2,index:o});else{let d=-1;for(;(d=r.data.indexOf(Ts,d+1))!==-1;)c.push({type:7,index:o}),d+=Ts.length-1}o++}}static createElement(t,s){let i=Di.createElement("template");return i.innerHTML=t,i}};function Li(e,t,s=e,i){if(t===ct)return t;let r=i!==void 0?s._$Co?.[i]:s._$Cl,o=ao(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,s,i)),i!==void 0?(s._$Co??(s._$Co=[]))[i]=r:s._$Cl=r),r!==void 0&&(t=Li(e,r._$AS(e,t.values),r,i)),t}var Mn=class{constructor(t,s){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:s},parts:i}=this._$AD,r=(t?.creationScope??Di).importNode(s,!0);Ri.currentNode=r;let o=Ri.nextNode(),n=0,a=0,c=i[0];for(;c!==void 0;){if(n===c.index){let l;c.type===2?l=new fr(o,o.nextSibling,this,t):c.type===1?l=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(l=new Nn(o,this,t)),this._$AV.push(l),c=i[++a]}n!==c?.index&&(o=Ri.nextNode(),n++)}return Ri.currentNode=Di,r}p(t){let s=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,s),s+=i.strings.length-2):i._$AI(t[s])),s++}},fr=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,s,i,r){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=s,this._$AM=i,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,s=this._$AM;return s!==void 0&&t?.nodeType===11&&(t=s.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,s=this){t=Li(this,t,s),ao(t)?t===b||t==null||t===""?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==ct&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):jd(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&ao(this._$AH)?this._$AA.nextSibling.data=t:this.T(Di.createTextNode(t)),this._$AH=t}$(t){let{values:s,_$litType$:i}=t,r=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=lo.createElement(Kd(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===r)this._$AH.p(s);else{let o=new Mn(r,this),n=o.u(this.options);o.p(s),this.T(n),this._$AH=o}}_$AC(t){let s=Wd.get(t.strings);return s===void 0&&Wd.set(t.strings,s=new lo(t)),s}k(t){El(this._$AH)||(this._$AH=[],this._$AR());let s=this._$AH,i,r=0;for(let o of t)r===s.length?s.push(i=new e(this.O(no()),this.O(no()),this,this.options)):i=s[r],i._$AI(o),r++;r<s.length&&(this._$AR(i&&i._$AB.nextSibling,r),s.length=r)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){let i=Id(t).nextSibling;Id(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},Pi=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,s,i,r,o){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=s,this._$AM=r,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=b}_$AI(t,s=this,i,r){let o=this.strings,n=!1;if(o===void 0)t=Li(this,t,s,0),n=!ao(t)||t!==this._$AH&&t!==ct,n&&(this._$AH=t);else{let a=t,c,l;for(t=o[0],c=0;c<o.length-1;c++)l=Li(this,a[i+c],s,c),l===ct&&(l=this._$AH[c]),n||(n=!ao(l)||l!==this._$AH[c]),l===b?t=b:t!==b&&(t+=(l??"")+o[c+1]),this._$AH[c]=l}n&&!r&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},In=class extends Pi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}},On=class extends Pi{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}},zn=class extends Pi{constructor(t,s,i,r,o){super(t,s,i,r,o),this.type=5}_$AI(t,s=this){if((t=Li(this,t,s,0)??b)===ct)return;let i=this._$AH,r=t===b&&i!==b||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==b&&(i===b||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Nn=class{constructor(t,s,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=s,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Li(this,t)}},Yd={M:kl,P:Ts,A:$l,C:1,L:Gd,R:Mn,D:jd,V:Li,I:fr,H:Pi,N:On,U:zn,B:In,F:Nn},tv=oo.litHtmlPolyfillSupport;tv?.(lo,fr),(oo.litHtmlVersions??(oo.litHtmlVersions=[])).push("3.3.2");var Fn=(e,t,s)=>{let i=s?.renderBefore??t,r=i._$litPart$;if(r===void 0){let o=s?.renderBefore??null;i._$litPart$=r=new fr(t.insertBefore(no(),o),o,void 0,s??{})}return r._$AI(e),r};var ts={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},mr=e=>(...t)=>({_$litDirective$:e,values:t}),Qs=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,s,i){this._$Ct=t,this._$AM=s,this._$Ci=i}_$AS(t,s){return this.update(t,s)}update(t,s){return this.render(...s)}};var co=class extends Qs{constructor(t){if(super(t),this.it=b,t.type!==ts.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===b||t==null)return this._t=void 0,this.it=t;if(t===ct)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let s=[t];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}};co.directiveName="unsafeHTML",co.resultType=1;var E=mr(co);function Al(e){let t=(e||"").replace(/^#\/?/,""),[s,i]=t.split("?"),r=s.split("/").filter(Boolean);if(r[0]==="project"&&r.length>=3)return{section:r[2],runId:r[3]||null,projectId:r[1]};let o=r[0]||"active",n=r[1]||null,a=new URLSearchParams(i||"");return{section:o,runId:n||a.get("run")||null,projectId:a.get("project")||null}}function sv(e,t,s){if(s){let r=`#/project/${s}/${e}`;return t?`${r}/${t}`:r}let i=`#/${e}`;return t?`${i}/${t}`:i}function Xd(e){let t=()=>e(Al(location.hash));return window.addEventListener("hashchange",t),()=>window.removeEventListener("hashchange",t)}function st(e,t,s){location.hash=sv(e,t,s)}var gr={run_completed:{severity:"info",title:"Pipeline Complete",requireInteraction:!1},run_failed:{severity:"critical",title:"Pipeline Failed",requireInteraction:!1},approval_needed:{severity:"critical",title:"Approval Required",requireInteraction:!0},test_failures:{severity:"warning",title:"Tests Failed",requireInteraction:!1},loop_limit_warning:{severity:"warning",title:"Loop Limit Warning",requireInteraction:!1}};function iv(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{};if(Object.values(n).some(h=>h.status==="error"))return null;let c=ho(t),l=i?`[${i}] "${c}" finished successfully`:`"${c}" finished successfully`;return{event:"run_completed",title:gr.run_completed.title,body:l,tag:`worca-complete-${e}`,requireInteraction:!1,runId:e}}function rv(e,t,s,i){if(!s||!t)return null;let r=s.active===!0,o=t.active===!1;if(!r||!o)return null;let n=t.stages||{},a=Object.entries(n).find(([,h])=>h.status==="error");if(!a)return null;let c=ho(t),l=i?`[${i}] "${c}" failed at ${a[0]} stage`:`"${c}" failed at ${a[0]} stage`;return{event:"run_failed",title:gr.run_failed.title,body:l,tag:`worca-failed-${e}`,requireInteraction:!1,runId:e}}function ov(e,t,s,i){if(!t)return null;let r=t.stages||{},o=s?.stages||{};for(let[n,a]of Object.entries(r))if(a.status==="waiting_approval"&&o[n]?.status!=="waiting_approval"){let l=ho(t),h=n==="pr"?"PR":n,d=i?`[${i}] "${l}" is waiting for ${h} approval`:`"${l}" is waiting for ${h} approval`;return{event:"approval_needed",title:gr.approval_needed.title,body:d,tag:`worca-approval-${e}-${n}`,requireInteraction:!0,runId:e}}return null}function nv(e,t,s,i){if(!t)return null;let r=t.stages?.test;if(!r)return null;let o=r.iterations||[],n=s?.stages?.test?.iterations||[];if(o.length>n.length){let a=o[o.length-1];if(a&&a.result==="failed"){let c=ho(t),l=i?`[${i}] "${c}" test iteration ${o.length} failed`:`"${c}" test iteration ${o.length} failed`;return{event:"test_failures",title:gr.test_failures.title,body:l,tag:`worca-test-${e}-iter${o.length}`,requireInteraction:!1,runId:e}}}return null}function av(e,t,s,i,r){if(!t||!i)return null;let o=i?.worca?.loops;if(!o)return null;let n=t.stages||{},a={implement_test:["implement","test"],pr_changes:["pr"],restart_planning:["plan"],plan_review:["plan_review"]};for(let[c,l]of Object.entries(o)){if(!l||l<2)continue;let h=a[c];if(h)for(let d of h){let m=n[d];if(!m)continue;let p=(m.iterations||[]).filter(f=>f.trigger!=="initial").length;if(p>0&&p===l-1){let f=`${e}-${d}`;if(r.has(f))continue;r.add(f);let _=ho(t);return{event:"loop_limit_warning",title:gr.loop_limit_warning.title,body:`"${_}" ${d} stage approaching loop limit (${p}/${l})`,tag:`worca-loop-${e}-${d}`,requireInteraction:!1,runId:e}}}}return null}function ho(e){let s=(e?.work_request?.title||e?.id||"Pipeline").split(`
65
+ `)[0];return s.length>60?`${s.slice(0,60)}\u2026`:s}var As=null;function lv(){try{As||(As=new AudioContext);let e=As.createOscillator(),t=As.createGain();e.type="sine",e.frequency.value=440,t.gain.value=.3,e.connect(t),t.connect(As.destination),e.start(),e.stop(As.currentTime+.2)}catch{}}var Hn={enabled:!0,sound:!1,events:{run_completed:!0,run_failed:!0,approval_needed:!0,test_failures:!0,loop_limit_warning:!0}};function Jd({store:e,ws:t,getSettings:s}){let i=typeof Notification<"u"?Notification.permission:"denied",r=new Set,o=!1,n=null;function a(_){n=_}function c(){return typeof Notification<"u"&&(i=Notification.permission),i}async function l(){if(typeof Notification>"u")return"denied";let _=await Notification.requestPermission();return i=_,n&&n(),_}function h(){let _=e.getState().preferences.notifications;return _?{enabled:_.enabled??Hn.enabled,sound:_.sound??Hn.sound,events:{...Hn.events,..._.events||{}}}:{...Hn}}function d({event:_,title:w,body:k,tag:$,requireInteraction:y,runId:C}){if(typeof Notification>"u")return;let S=new Notification(w,{body:k,icon:"/favicon.svg",tag:$,requireInteraction:y});S.onclick=()=>{window.focus(),st("active",C),S.close()};let L=h(),H=gr[_];L.sound&&H&&H.severity==="critical"&&lv()}function m(_,w,k){if(typeof Notification>"u"||Notification.permission!=="granted")return;let $=h();if(!$.enabled)return;let y=s(),C=e.getState(),S=C.projects?.length>1?C.projectName:null,L=[iv,rv,ov,nv];for(let F of L){let W=F(_,w,k,S);W&&$.events[W.event]&&d(W)}let H=av(_,w,k,y,r);H&&$.events[H.event]&&d(H)}function p(){return typeof Notification>"u"?b:(c(),i==="default"?u`
66
66
  <div class="notification-banner notification-banner--info">
67
67
  <span class="notification-banner-text">
68
68
  Enable browser notifications to stay informed about pipeline events
@@ -86,7 +86,7 @@ ${h.join(`
86
86
  <sl-button variant=${i} @click=${()=>Rl(o)}>${s}</sl-button>
87
87
  </div>
88
88
  </sl-dialog>
89
- `}var Bi=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var po=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}],["path",{d:"M10 12h4"}]];var Dl=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Ll=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Pl=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var Rs=[["circle",{cx:"12",cy:"12",r:"10"}]];var Ds=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]];var Ls=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var _r=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9"}]];var He=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var Ps=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];var Nt=[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48"}],["path",{d:"M15 6h1v4"}],["path",{d:"m6.134 14.768.866-.5 2 3.464"}],["circle",{cx:"16",cy:"8",r:"6"}]];var Bl=[["path",{d:"M12 20v2"}],["path",{d:"M12 2v2"}],["path",{d:"M17 20v2"}],["path",{d:"M17 2v2"}],["path",{d:"M2 12h2"}],["path",{d:"M2 17h2"}],["path",{d:"M2 7h2"}],["path",{d:"M20 12h2"}],["path",{d:"M20 17h2"}],["path",{d:"M20 7h2"}],["path",{d:"M7 20v2"}],["path",{d:"M7 2v2"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1"}]];var Ml=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]];var fo=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var mo=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var go=[["path",{d:"M15 6a9 9 0 0 0-9 9V3"}],["circle",{cx:"18",cy:"6",r:"3"}],["circle",{cx:"6",cy:"18",r:"3"}]];var Il=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Ol=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}],["path",{d:"M9 18h6"}],["path",{d:"M10 22h4"}]];var vr=[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]];var Pe=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var zl=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var St=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var Mi=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var ds=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Be=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var Ii=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}]];var us=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var ei=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var _o=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Nl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}]];var Fl=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];var ti=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Hl=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var vo=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var At=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var br=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var Wl=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}],["circle",{cx:"9",cy:"7",r:"4"}]];var jl=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2"}]];var Oi=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var pt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function lv(e){return e.map(([t,s])=>{let i=Object.entries(s).map(([r,o])=>`${r}="${o}"`).join(" ");return`<${t} ${i}/>`}).join("")}function R(e,t=16,s=""){let i=s?` class="${s}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"${i}>${lv(e)}</svg>`}function ft(e){return[...e].sort((t,s)=>{let i=t.started_at||"",r=s.started_at||"";return!i&&!r?0:i?r?r.localeCompare(i):-1:1})}var cv={stop:{running:!0},pause:{running:!0},resume:{paused:!0,failed:!0,interrupted:!0},cancel:{pending:!0,running:!0,paused:!0,failed:!0,interrupted:!0},archive:{pending:!0,paused:!0,completed:!0,failed:!0,interrupted:!0,cancelled:!0},unarchive:{completed:!0,failed:!0,interrupted:!0,cancelled:!0},delete:{pending:!0,paused:!0,completed:!0,failed:!0,interrupted:!0,cancelled:!0},learn:{paused:!0,completed:!0,failed:!0,interrupted:!0,cancelled:!0}};function it(e,t){return!!cv[e]?.[t]}var hv={pending:"status-pending",running:"status-running",paused:"status-paused",completed:"status-completed",failed:"status-failed",skipped:"status-skipped",cancelled:"status-cancelled",in_progress:"status-in-progress",error:"status-error",interrupted:"status-interrupted"},dv={pending:Rs,running:Pe,paused:St,completed:Ls,failed:Ds,skipped:_r,cancelled:_r,in_progress:Pe,error:Ds,interrupted:St};function yr(e,t){return e==="in_progress"&&t===!1?"interrupted":e}function si(e){return hv[e]||"status-unknown"}function Rt(e,t=14){let s=dv[e];return s?R(s,t,e==="in_progress"||e==="running"?"icon-spin":""):"?"}function bo(e){document.documentElement.setAttribute("data-theme",e),document.documentElement.classList.toggle("sl-theme-dark",e==="dark")}function eu(e){return e?`${e} \u2014 worca`:"worca"}function tu(e){if(!e)return{parts:[],rc:1/0};let t=e.match(/^(.+?)[-.]?rc\.?(\d+)$/),s=t?t[1]:e,i=t?parseInt(t[2],10):1/0;return{parts:s.split(".").map(o=>parseInt(o,10)||0),rc:i}}function yo(e,t){if(!e||!t)return!1;let s=tu(e),i=tu(t),r=Math.max(s.parts.length,i.parts.length);for(let o=0;o<r;o++){let n=s.parts[o]||0,a=i.parts[o]||0;if(n<a)return!0;if(n>a)return!1}return s.rc<i.rc}var Vn="",Vl=!1,Ft="single",Ht=[],We=new Set,Fi=!1,Ms="",Cr=!1,ht=null,Ni=null,Wt=new Map,ql=!1,zi=[],Bs=new Map,wr=!1,Sr=!1,wo=null,xr=null,Kl=null;function Ul(e,t,s){if(clearTimeout(Ni),!e||!e.startsWith("/")){ht&&(ht.abort(),ht=null),Ht=[],We=new Set,Wt=new Map,Ms="",Fi=!1,Cr=!1,s?.();return}Ni=setTimeout(()=>{ht&&ht.abort(),ht=new AbortController;let i=ht;Fi=!0,Ms="",s?.(),fetch("/api/scan-directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e}),signal:i.signal}).then(r=>r.json()).then(r=>{if(r.ok){Cr=!0,Ht=r.subfolders||[],xr==null&&fetch("/api/versions").then(d=>d.json()).then(d=>{xr=d?.activeWorcaCc||null,s?.()}).catch(()=>{});let o=new Set((t.projects||[]).map(d=>(d.path||"").replace(/\/+$/,""))),n=new Set((t.projects||[]).map(d=>d.name));We=new Set;let a=[];Ht.forEach((d,m)=>{o.has((d.path||"").replace(/\/+$/,""))||(We.add(m),a.push({index:m,name:d.name}))});let c=a.filter(d=>Un(d.name)!==""),l=c.map(d=>Un(d.name)),h=fv(l,[...n]);Wt=new Map,c.forEach((d,m)=>{Wt.set(d.index,h[m])});for(let d of a)Un(d.name)===""&&We.delete(d.index)}else Ms=r.error||"Scan failed",Ht=[],We=new Set,Wt=new Map}).catch(r=>{r.name!=="AbortError"&&(Ms=r.message||"Scan failed",Ht=[],We=new Set,Wt=new Map)}).finally(()=>{i.signal.aborted||(Fi=!1,s?.())})},300)}function ps(e){Vn=e;let t=document.getElementById("add-project-error");t&&(t.textContent=e,t.style.display=e?"block":"none")}function su(e,{onProjectAdd:t,onClose:s,rerender:i}){let{addProjectDialogOpen:r}=e;if(!r)return Ft="single",Ht=[],We=new Set,Wt=new Map,Ms="",Cr=!1,ht&&(ht.abort(),ht=null),clearTimeout(Ni),b;function o(w){if(w.preventDefault(),Ft==="workspace"){if(We.size===0)return;let F=Ht.map((W,ie)=>({...W,index:ie})).filter(W=>We.has(W.index)&&Wt.has(W.index)).map(W=>({name:Wt.get(W.index),path:W.path}));if(F.length===0)return;ps(""),fetch("/api/projects/batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projects:F})}).then(W=>W.json()).then(W=>{W.ok?(t?.(W.projects),pv(W.projects,i,()=>t?.(W.projects))):ps(W.error||"Failed to add projects")}).catch(W=>{ps(W.message||"Network error")});return}let k=document.getElementById("add-project-name"),$=document.getElementById("add-project-path"),y=k?.value?.trim()||"",C=$?.value?.trim()||"";if(!y){ps("Name is required");return}if(!C||!C.startsWith("/")){ps("Path must be an absolute path");return}let S=C.replace(/\/+$/,""),H=(e.projects||[]).find(F=>(F.path||"").replace(/\/+$/,"")===S);if(H){ps(`A project with this path already exists: "${H.name}"`);return}ps(""),fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,path:C})}).then(F=>F.json()).then(F=>{F.ok?(ps(""),t?.(F.project),uv(y,i)):ps(F.error||"Failed to add project")}).catch(F=>{ps(F.message||"Network error")})}function n(w){if(Vl)return;let k=document.getElementById("add-project-name");if(!k)return;let $=w.replace(/\/+$/,"").split("/"),C=($[$.length-1]||"").toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/^-+/,"").replace(/-+$/,"");k.value=C}function a(w){let k=w.target.value||"";Ft==="single"?n(k):Ul(k,e,i)}function c(){Vl=!0}async function l(){try{let k=await(await fetch("/api/choose-directory",{method:"POST"})).json();if(k.ok&&k.path){let $=document.getElementById("add-project-path");$&&($.value=k.path),Ft==="single"?n(k.path):Ul(k.path,e,i)}}catch{}}function h(w){if(Ft=w.target.value,Ht=[],We=new Set,Wt=new Map,Fi=!1,Ms="",Cr=!1,clearTimeout(Ni),Ni=null,ht&&(ht.abort(),ht=null),Ft==="workspace"){let $=document.getElementById("add-project-path")?.value?.trim()||"";$&&Ul($,e,i)}i?.()}function d(w){w.target.isConnected&&(Vn="",Vl=!1,Ft="single",Ht=[],We=new Set,Wt=new Map,Fi=!1,Ms="",Cr=!1,clearTimeout(Ni),Ni=null,ht&&(ht.abort(),ht=null),s?.())}function m(){if(Fi)return u`
89
+ `}var Bi=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];var po=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"}],["path",{d:"M10 12h4"}]];var Dl=[["path",{d:"M12 5v14"}],["path",{d:"m19 12-7 7-7-7"}]];var Ll=[["path",{d:"m12 19-7-7 7-7"}],["path",{d:"M19 12H5"}]];var Pl=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"}]];var Rs=[["circle",{cx:"12",cy:"12",r:"10"}]];var Ds=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16"}]];var Ls=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"m9 12 2 2 4-4"}]];var _r=[["circle",{cx:"12",cy:"12",r:"10"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9"}]];var He=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4"}],["path",{d:"M21 14H11"}],["path",{d:"m15 10-4 4 4 4"}]];var Ps=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 6v6l4 2"}]];var Nt=[["path",{d:"M13.744 17.736a6 6 0 1 1-7.48-7.48"}],["path",{d:"M15 6h1v4"}],["path",{d:"m6.134 14.768.866-.5 2 3.464"}],["circle",{cx:"16",cy:"8",r:"6"}]];var Bl=[["path",{d:"M12 20v2"}],["path",{d:"M12 2v2"}],["path",{d:"M17 20v2"}],["path",{d:"M17 2v2"}],["path",{d:"M2 12h2"}],["path",{d:"M2 17h2"}],["path",{d:"M2 7h2"}],["path",{d:"M20 12h2"}],["path",{d:"M20 17h2"}],["path",{d:"M20 7h2"}],["path",{d:"M7 20v2"}],["path",{d:"M7 2v2"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1"}]];var Ml=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]];var fo=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];var mo=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}]];var go=[["path",{d:"M15 6a9 9 0 0 0-9 9V3"}],["circle",{cx:"18",cy:"6",r:"3"}],["circle",{cx:"6",cy:"18",r:"3"}]];var Il=[["line",{x1:"4",x2:"20",y1:"9",y2:"9"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21"}]];var Ol=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}],["path",{d:"M9 18h6"}],["path",{d:"M10 22h4"}]];var vr=[["path",{d:"M3 5h.01"}],["path",{d:"M3 12h.01"}],["path",{d:"M3 19h.01"}],["path",{d:"M8 5h13"}],["path",{d:"M8 12h13"}],["path",{d:"M8 19h13"}]];var Pe=[["path",{d:"M12 2v4"}],["path",{d:"m16.2 7.8 2.9-2.9"}],["path",{d:"M18 12h4"}],["path",{d:"m16.2 16.2 2.9 2.9"}],["path",{d:"M12 18v4"}],["path",{d:"m4.9 19.1 2.9-2.9"}],["path",{d:"M2 12h4"}],["path",{d:"m4.9 4.9 2.9 2.9"}]];var zl=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}]];var St=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1"}]];var Mi=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]];var ds=[["path",{d:"M5 12h14"}],["path",{d:"M12 5v14"}]];var Be=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}],["path",{d:"M21 3v5h-5"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}],["path",{d:"M8 16H3v5"}]];var Ii=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}],["path",{d:"M3 3v5h5"}]];var us=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7"}]];var ei=[["path",{d:"m21 21-4.34-4.34"}],["circle",{cx:"11",cy:"11",r:"8"}]];var _o=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"}],["circle",{cx:"12",cy:"12",r:"3"}]];var Nl=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}]];var Fl=[["path",{d:"M10 5H3"}],["path",{d:"M12 19H3"}],["path",{d:"M14 3v4"}],["path",{d:"M16 17v4"}],["path",{d:"M21 12h-9"}],["path",{d:"M21 19h-5"}],["path",{d:"M21 5h-7"}],["path",{d:"M8 10v4"}],["path",{d:"M8 12H3"}]];var ti=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}]];var Hl=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"}]];var vo=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];var At=[["path",{d:"M10 11v6"}],["path",{d:"M14 11v6"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}],["path",{d:"M3 6h18"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}]];var br=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}],["path",{d:"M12 9v4"}],["path",{d:"M12 17h.01"}]];var Wl=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}],["circle",{cx:"9",cy:"7",r:"4"}]];var jl=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2"}]];var Oi=[["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]];var pt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"}]];function cv(e){return e.map(([t,s])=>{let i=Object.entries(s).map(([r,o])=>`${r}="${o}"`).join(" ");return`<${t} ${i}/>`}).join("")}function R(e,t=16,s=""){let i=s?` class="${s}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"${i}>${cv(e)}</svg>`}function ft(e){return[...e].sort((t,s)=>{let i=t.started_at||"",r=s.started_at||"";return!i&&!r?0:i?r?r.localeCompare(i):-1:1})}var hv={stop:{running:!0},pause:{running:!0},resume:{paused:!0,failed:!0,interrupted:!0},cancel:{pending:!0,running:!0,paused:!0,failed:!0,interrupted:!0},archive:{pending:!0,paused:!0,completed:!0,failed:!0,interrupted:!0,cancelled:!0},unarchive:{completed:!0,failed:!0,interrupted:!0,cancelled:!0},delete:{pending:!0,paused:!0,completed:!0,failed:!0,interrupted:!0,cancelled:!0},learn:{paused:!0,completed:!0,failed:!0,interrupted:!0,cancelled:!0}};function it(e,t){return!!hv[e]?.[t]}var dv={pending:"status-pending",running:"status-running",paused:"status-paused",completed:"status-completed",failed:"status-failed",skipped:"status-skipped",cancelled:"status-cancelled",in_progress:"status-in-progress",error:"status-error",interrupted:"status-interrupted"},uv={pending:Rs,running:Pe,paused:St,completed:Ls,failed:Ds,skipped:_r,cancelled:_r,in_progress:Pe,error:Ds,interrupted:St};function yr(e,t){return e==="in_progress"&&t===!1?"interrupted":e}function si(e){return dv[e]||"status-unknown"}function Rt(e,t=14){let s=uv[e];return s?R(s,t,e==="in_progress"||e==="running"?"icon-spin":""):"?"}function bo(e){document.documentElement.setAttribute("data-theme",e),document.documentElement.classList.toggle("sl-theme-dark",e==="dark")}function eu(e){return e?`${e} \u2014 worca`:"worca"}function tu(e){if(!e)return{parts:[],rc:1/0};let t=e.match(/^(.+?)[-.]?rc\.?(\d+)$/),s=t?t[1]:e,i=t?parseInt(t[2],10):1/0;return{parts:s.split(".").map(o=>parseInt(o,10)||0),rc:i}}function yo(e,t){if(!e||!t)return!1;let s=tu(e),i=tu(t),r=Math.max(s.parts.length,i.parts.length);for(let o=0;o<r;o++){let n=s.parts[o]||0,a=i.parts[o]||0;if(n<a)return!0;if(n>a)return!1}return s.rc<i.rc}var Vn="",Vl=!1,Ft="single",Ht=[],We=new Set,Fi=!1,Ms="",Cr=!1,ht=null,Ni=null,Wt=new Map,ql=!1,zi=[],Bs=new Map,wr=!1,Sr=!1,wo=null,xr=null,Kl=null;function Ul(e,t,s){if(clearTimeout(Ni),!e||!e.startsWith("/")){ht&&(ht.abort(),ht=null),Ht=[],We=new Set,Wt=new Map,Ms="",Fi=!1,Cr=!1,s?.();return}Ni=setTimeout(()=>{ht&&ht.abort(),ht=new AbortController;let i=ht;Fi=!0,Ms="",s?.(),fetch("/api/scan-directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e}),signal:i.signal}).then(r=>r.json()).then(r=>{if(r.ok){Cr=!0,Ht=r.subfolders||[],xr==null&&fetch("/api/versions").then(d=>d.json()).then(d=>{xr=d?.activeWorcaCc||null,s?.()}).catch(()=>{});let o=new Set((t.projects||[]).map(d=>(d.path||"").replace(/\/+$/,""))),n=new Set((t.projects||[]).map(d=>d.name));We=new Set;let a=[];Ht.forEach((d,m)=>{o.has((d.path||"").replace(/\/+$/,""))||(We.add(m),a.push({index:m,name:d.name}))});let c=a.filter(d=>Un(d.name)!==""),l=c.map(d=>Un(d.name)),h=mv(l,[...n]);Wt=new Map,c.forEach((d,m)=>{Wt.set(d.index,h[m])});for(let d of a)Un(d.name)===""&&We.delete(d.index)}else Ms=r.error||"Scan failed",Ht=[],We=new Set,Wt=new Map}).catch(r=>{r.name!=="AbortError"&&(Ms=r.message||"Scan failed",Ht=[],We=new Set,Wt=new Map)}).finally(()=>{i.signal.aborted||(Fi=!1,s?.())})},300)}function ps(e){Vn=e;let t=document.getElementById("add-project-error");t&&(t.textContent=e,t.style.display=e?"block":"none")}function su(e,{onProjectAdd:t,onClose:s,rerender:i}){let{addProjectDialogOpen:r}=e;if(!r)return Ft="single",Ht=[],We=new Set,Wt=new Map,Ms="",Cr=!1,ht&&(ht.abort(),ht=null),clearTimeout(Ni),b;function o(w){if(w.preventDefault(),Ft==="workspace"){if(We.size===0)return;let F=Ht.map((W,ie)=>({...W,index:ie})).filter(W=>We.has(W.index)&&Wt.has(W.index)).map(W=>({name:Wt.get(W.index),path:W.path}));if(F.length===0)return;ps(""),fetch("/api/projects/batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projects:F})}).then(W=>W.json()).then(W=>{W.ok?(t?.(W.projects),fv(W.projects,i,()=>t?.(W.projects))):ps(W.error||"Failed to add projects")}).catch(W=>{ps(W.message||"Network error")});return}let k=document.getElementById("add-project-name"),$=document.getElementById("add-project-path"),y=k?.value?.trim()||"",C=$?.value?.trim()||"";if(!y){ps("Name is required");return}if(!C||!C.startsWith("/")){ps("Path must be an absolute path");return}let S=C.replace(/\/+$/,""),H=(e.projects||[]).find(F=>(F.path||"").replace(/\/+$/,"")===S);if(H){ps(`A project with this path already exists: "${H.name}"`);return}ps(""),fetch("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,path:C})}).then(F=>F.json()).then(F=>{F.ok?(ps(""),t?.(F.project),pv(y,i)):ps(F.error||"Failed to add project")}).catch(F=>{ps(F.message||"Network error")})}function n(w){if(Vl)return;let k=document.getElementById("add-project-name");if(!k)return;let $=w.replace(/\/+$/,"").split("/"),C=($[$.length-1]||"").toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/^-+/,"").replace(/-+$/,"");k.value=C}function a(w){let k=w.target.value||"";Ft==="single"?n(k):Ul(k,e,i)}function c(){Vl=!0}async function l(){try{let k=await(await fetch("/api/choose-directory",{method:"POST"})).json();if(k.ok&&k.path){let $=document.getElementById("add-project-path");$&&($.value=k.path),Ft==="single"?n(k.path):Ul(k.path,e,i)}}catch{}}function h(w){if(Ft=w.target.value,Ht=[],We=new Set,Wt=new Map,Fi=!1,Ms="",Cr=!1,clearTimeout(Ni),Ni=null,ht&&(ht.abort(),ht=null),Ft==="workspace"){let $=document.getElementById("add-project-path")?.value?.trim()||"";$&&Ul($,e,i)}i?.()}function d(w){w.target.isConnected&&(Vn="",Vl=!1,Ft="single",Ht=[],We=new Set,Wt=new Map,Fi=!1,Ms="",Cr=!1,clearTimeout(Ni),Ni=null,ht&&(ht.abort(),ht=null),s?.())}function m(){if(Fi)return u`
90
90
  <div id="workspace-scan-area" style="padding: 8px; display: flex; align-items: center; gap: 8px; margin-bottom: 16px;">
91
91
  <sl-spinner></sl-spinner>
92
92
  <span>Scanning…</span>
@@ -188,7 +188,7 @@ ${h.join(`
188
188
  </div>
189
189
  </form>
190
190
  </sl-dialog>
191
- `}function uv(e,t){t&&fetch(`/api/projects/${e}/worca-status`).then(s=>s.json()).then(s=>{if(!s.ok)return;let i=s.installed,r=i?"Update Worca":"Install Worca",o=i?`Update worca in "${e}" with the latest pipeline files?`:`Install worca pipeline in "${e}"?`;wt({label:r,message:o,confirmLabel:"Yes",cancelLabel:"No",confirmVariant:"primary",onConfirm:()=>{fetch(`/api/projects/${e}/worca-setup`,{method:"POST"}).catch(()=>{})}},t)}).catch(()=>{})}function pv(e,t,s){if(!t||!e||e.length===0)return;Kl=typeof s=="function"?s:null;let i=e.map(o=>fetch(`/api/projects/${o.name}/worca-status`).then(n=>n.json()).catch(()=>({ok:!1,installed:!1,version:null}))),r=fetch("/api/versions").then(o=>o.json()).catch(()=>null);Promise.all([Promise.all(i),r]).then(([o,n])=>{wo=n?.activeWorcaCc||null,zi=e.map((a,c)=>{let l=o[c],h=!!(l.ok&&l.installed),d=h?l.version:null;return{name:a.name,installed:h,version:d,checked:!0}}),Bs=new Map,wr=!1,Sr=!1,ql=!0,t()}).catch(()=>{})}function iu(e){if(!ql)return b;function t(l,h){let d=zi.find(m=>m.name===l);d&&(d.checked=h.target.checked),e?.()}function s(){ql=!1,zi=[],Bs=new Map,wr=!1,Sr=!1;let l=Kl;Kl=null,e?.(),l?.()}async function i(){let l=zi.filter(h=>h.checked);if(l.length!==0){Sr=!1,wr=!0;for(let h of l)Bs.set(h.name,{state:"pending"});e?.();for(let h of l){try{let d=await fetch(`/api/projects/${h.name}/worca-setup`,{method:"POST"});if(d.ok)Bs.set(h.name,{state:"started"});else{let m=`HTTP ${d.status}`;try{let p=await d.json();p?.error&&(m=p.error)}catch{}Bs.set(h.name,{state:"failed",error:m})}}catch(d){Bs.set(h.name,{state:"failed",error:d.message||"Failed"})}e?.()}wr=!1,Sr=!0,e?.()}}let r=zi.filter(l=>l.checked).length,o=zi.length,n=[...Bs.values()].filter(l=>l.state==="started").length,a=[...Bs.values()].filter(l=>l.state==="failed").length,c=Sr?`Installed: ${n}${a?`, Failed: ${a}`:""}`:"Install worca on these projects?";return u`
191
+ `}function pv(e,t){t&&fetch(`/api/projects/${e}/worca-status`).then(s=>s.json()).then(s=>{if(!s.ok)return;let i=s.installed,r=i?"Update Worca":"Install Worca",o=i?`Update worca in "${e}" with the latest pipeline files?`:`Install worca pipeline in "${e}"?`;wt({label:r,message:o,confirmLabel:"Yes",cancelLabel:"No",confirmVariant:"primary",onConfirm:()=>{fetch(`/api/projects/${e}/worca-setup`,{method:"POST"}).catch(()=>{})}},t)}).catch(()=>{})}function fv(e,t,s){if(!t||!e||e.length===0)return;Kl=typeof s=="function"?s:null;let i=e.map(o=>fetch(`/api/projects/${o.name}/worca-status`).then(n=>n.json()).catch(()=>({ok:!1,installed:!1,version:null}))),r=fetch("/api/versions").then(o=>o.json()).catch(()=>null);Promise.all([Promise.all(i),r]).then(([o,n])=>{wo=n?.activeWorcaCc||null,zi=e.map((a,c)=>{let l=o[c],h=!!(l.ok&&l.installed),d=h?l.version:null;return{name:a.name,installed:h,version:d,checked:!0}}),Bs=new Map,wr=!1,Sr=!1,ql=!0,t()}).catch(()=>{})}function iu(e){if(!ql)return b;function t(l,h){let d=zi.find(m=>m.name===l);d&&(d.checked=h.target.checked),e?.()}function s(){ql=!1,zi=[],Bs=new Map,wr=!1,Sr=!1;let l=Kl;Kl=null,e?.(),l?.()}async function i(){let l=zi.filter(h=>h.checked);if(l.length!==0){Sr=!1,wr=!0;for(let h of l)Bs.set(h.name,{state:"pending"});e?.();for(let h of l){try{let d=await fetch(`/api/projects/${h.name}/worca-setup`,{method:"POST"});if(d.ok)Bs.set(h.name,{state:"started"});else{let m=`HTTP ${d.status}`;try{let p=await d.json();p?.error&&(m=p.error)}catch{}Bs.set(h.name,{state:"failed",error:m})}}catch(d){Bs.set(h.name,{state:"failed",error:d.message||"Failed"})}e?.()}wr=!1,Sr=!0,e?.()}}let r=zi.filter(l=>l.checked).length,o=zi.length,n=[...Bs.values()].filter(l=>l.state==="started").length,a=[...Bs.values()].filter(l=>l.state==="failed").length,c=Sr?`Installed: ${n}${a?`, Failed: ${a}`:""}`:"Install worca on these projects?";return u`
192
192
  <sl-dialog id="batch-setup-dialog" label="Worca Setup" open @sl-after-hide=${s}>
193
193
  <div class="dialog-meta-row">
194
194
  <span>Projects added: <strong>${o}</strong></span>
@@ -232,7 +232,7 @@ ${h.join(`
232
232
  `}
233
233
  </div>
234
234
  </sl-dialog>
235
- `}function Un(e){return e.toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function fv(e,t){let s=new Set(t),i=[];for(let r of e)if(!s.has(r))s.add(r),i.push(r);else{let o=2,n=`-${o}`,a=`${r.slice(0,64-n.length)}${n}`;for(;s.has(a);)o+=1,n=`-${o}`,a=`${r.slice(0,64-n.length)}${n}`;s.add(a),i.push(a)}return i}function ve(e){let t=Math.floor(e/1e3),s=Math.floor(t/3600),i=Math.floor(t%3600/60),r=t%60;return s>0?`${s}h ${i}m ${r}s`:i>0?`${i}m ${r}s`:`${r}s`}function rt(e,t){let s=new Date(e).getTime();return(t?new Date(t).getTime():Date.now())-s}function Ct(e){if(!e)return"N/A";let t=new Date(e),s=i=>String(i).padStart(2,"0");return`${t.getFullYear()}.${s(t.getMonth()+1)}.${s(t.getDate())} ${s(t.getHours())}:${s(t.getMinutes())}`}var Dt=["preflight","plan","plan_review","coordinate","implement","test","review","pr","learn"],b$=["orchestrator",...Dt];function qn(e){return[...e].sort(([t],[s])=>{let i=Dt.indexOf(t),r=Dt.indexOf(s);return(i===-1?999:i)-(r===-1?999:r)})}function ru(e){return[...e].sort((t,s)=>{let i=Dt.indexOf(t),r=Dt.indexOf(s);return(i===-1?999:i)-(r===-1?999:r)})}function mv(e){return Object.entries(e).sort(([s],[i])=>{let r=Dt.indexOf(s),o=Dt.indexOf(i);return(r===-1?999:r)-(o===-1?999:o)})}var gv={completed:"success",in_progress:"primary",error:"danger",interrupted:"warning",cancelled:"neutral",pending:"neutral"};function _v(e,t){let s=e.status_changed_at||(t==="completed"||t==="failed"?e.completed_at:null)||e.started_at;if(!s)return null;let i=rt(s,null),r=ve(i);return t==="running"?`Running for ${r}`:`${t.charAt(0).toUpperCase()+t.slice(1)} ${r} ago`}function vv(e){if(!e)return null;let t=null;for(let s of Object.values(e))s.completed_at&&(!t||s.completed_at>t)&&(t=s.completed_at);return t}function bv(e){let t=0;for(let s of Object.values(e.stages||{}))for(let i of s.iterations||[])t+=i.cost_usd||0;return t}function ou(e){return e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Gl(e){let t=0,s=0;if(typeof e=="number"?t=e:e&&typeof e=="object"&&(t=e.total||0,s=e.done||0),t<=0)return b;let i=s>=t?"success":"primary";return u`<sl-badge variant="${i}" pill class="run-card-stage-badge">${s}/${t} Beads</sl-badge>`}function ss(e,{onClick:t,beadsCount:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:a,onUnarchive:c}={}){let l=e.work_request?.title||"Untitled",h=e.active,d=e.pipeline_status||(h?"running":e.stage==="error"?"failed":"completed"),m=_v(e,d),p=e.completed_at||(h?null:vv(e.stages)),f=e.started_at&&h?ve(rt(e.started_at,null)):e.started_at&&p?ve(rt(e.started_at,p)):"N/A",_=e.branch||e.work_request?.branch||"",w=e.stages?mv(e.stages):[],k=bv(e),$=i&&it("pause",d)?u`
235
+ `}function Un(e){return e.toLowerCase().replace(/[^a-z0-9_-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function mv(e,t){let s=new Set(t),i=[];for(let r of e)if(!s.has(r))s.add(r),i.push(r);else{let o=2,n=`-${o}`,a=`${r.slice(0,64-n.length)}${n}`;for(;s.has(a);)o+=1,n=`-${o}`,a=`${r.slice(0,64-n.length)}${n}`;s.add(a),i.push(a)}return i}function ve(e){let t=Math.floor(e/1e3),s=Math.floor(t/3600),i=Math.floor(t%3600/60),r=t%60;return s>0?`${s}h ${i}m ${r}s`:i>0?`${i}m ${r}s`:`${r}s`}function rt(e,t){let s=new Date(e).getTime();return(t?new Date(t).getTime():Date.now())-s}function Ct(e){if(!e)return"N/A";let t=new Date(e),s=i=>String(i).padStart(2,"0");return`${t.getFullYear()}.${s(t.getMonth()+1)}.${s(t.getDate())} ${s(t.getHours())}:${s(t.getMinutes())}`}var Dt=["preflight","plan","plan_review","coordinate","implement","test","review","pr","learn"],w$=["orchestrator",...Dt];function qn(e){return[...e].sort(([t],[s])=>{let i=Dt.indexOf(t),r=Dt.indexOf(s);return(i===-1?999:i)-(r===-1?999:r)})}function ru(e){return[...e].sort((t,s)=>{let i=Dt.indexOf(t),r=Dt.indexOf(s);return(i===-1?999:i)-(r===-1?999:r)})}function gv(e){return Object.entries(e).sort(([s],[i])=>{let r=Dt.indexOf(s),o=Dt.indexOf(i);return(r===-1?999:r)-(o===-1?999:o)})}var _v={completed:"success",in_progress:"primary",error:"danger",interrupted:"warning",cancelled:"neutral",pending:"neutral"};function vv(e,t){let s=e.status_changed_at||(t==="completed"||t==="failed"?e.completed_at:null)||e.started_at;if(!s)return null;let i=rt(s,null),r=ve(i);return t==="running"?`Running for ${r}`:`${t.charAt(0).toUpperCase()+t.slice(1)} ${r} ago`}function bv(e){if(!e)return null;let t=null;for(let s of Object.values(e))s.completed_at&&(!t||s.completed_at>t)&&(t=s.completed_at);return t}function yv(e){let t=0;for(let s of Object.values(e.stages||{}))for(let i of s.iterations||[])t+=i.cost_usd||0;return t}function ou(e){return e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Gl(e){let t=0,s=0;if(typeof e=="number"?t=e:e&&typeof e=="object"&&(t=e.total||0,s=e.done||0),t<=0)return b;let i=s>=t?"success":"primary";return u`<sl-badge variant="${i}" pill class="run-card-stage-badge">${s}/${t} Beads</sl-badge>`}function ss(e,{onClick:t,beadsCount:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:a,onUnarchive:c}={}){let l=e.work_request?.title||"Untitled",h=e.active,d=e.pipeline_status||(h?"running":e.stage==="error"?"failed":"completed"),m=vv(e,d),p=e.completed_at||(h?null:bv(e.stages)),f=e.started_at&&h?ve(rt(e.started_at,null)):e.started_at&&p?ve(rt(e.started_at,p)):"N/A",_=e.branch||e.work_request?.branch||"",w=e.stages?gv(e.stages):[],k=yv(e),$=i&&it("pause",d)?u`
236
236
  <sl-button size="small" variant="warning" outline class="btn-quick-pause" @click=${W=>{W.stopPropagation(),i(e.id)}}>
237
237
  ${E(R(St,12))} Pause
238
238
  </sl-button>
@@ -273,7 +273,7 @@ ${h.join(`
273
273
  </div>
274
274
  ${w.length>0?u`
275
275
  <div class="run-card-stages">
276
- ${w.map(([W,ie])=>{let j=yr(ie.status||"pending",h),ce=gv[j]||"neutral",T=W.replace(/_/g," ").toUpperCase();return u`<sl-badge variant="${ce}" pill class="run-card-stage-badge">${T}</sl-badge>`})}
276
+ ${w.map(([W,ie])=>{let j=yr(ie.status||"pending",h),ce=_v[j]||"neutral",T=W.replace(/_/g," ").toUpperCase();return u`<sl-badge variant="${ce}" pill class="run-card-stage-badge">${T}</sl-badge>`})}
277
277
  ${Gl(s)}
278
278
  </div>
279
279
  `:Gl(s)!==b?u`
@@ -285,10 +285,10 @@ ${h.join(`
285
285
  ${$}${y}${C}${S}${L}${H}
286
286
  </div>
287
287
  </div>
288
- `}function Kn(e){return e===0||e===1?"danger":e===2?"warning":"neutral"}function Yl(e,t=null){return t?.blocked_by&&t.blocked_by.length>0?"warning":e==="open"?"success":e==="in_progress"?"primary":"neutral"}function au(e){return e.status==="closed"?"closed":e.blocked_by&&e.blocked_by.length>0?"blocked":e.status}var nu={open:{icon:Rs,color:"var(--status-completed)"},in_progress:{icon:Pe,color:"var(--status-in-progress)"},closed:{icon:Ls,color:"var(--status-completed)"},blocked:{icon:zl,color:"var(--status-blocked)"}};function yv(e,t){let s=t.get(e);if(!s)return R(Rs,10);let i=au(s),r=nu[i]||nu.open,o=i==="in_progress"?"icon-spin":"";return`<span style="color:${r.color};display:inline-flex">${R(r.icon,10,o)}</span>`}function wv(e){let t=new Set(e.map(r=>r.id)),s=new Map(e.map(r=>[r.id,0])),i=!0;for(;i;){i=!1;for(let r of e)for(let o of r.depends_on){if(!t.has(o))continue;let n=(s.get(o)??0)+1;n>s.get(r.id)&&(s.set(r.id,n),i=!0)}}return s}function lu(e){if(!e||e.length===0)return{svg:"",nodes:[]};let t=140,s=40,i=60,r=24,o=16,n=new Map(e.map($=>[$.id,$])),a=wv(e),c=Math.max(...a.values(),0),l=new Map;for(let $ of e){let y=a.get($.id)??0;l.has(y)||l.set(y,[]),l.get(y).push($)}let h=Math.max(...[...l.values()].map($=>$.length),1),d=Math.round(o*2+(c+1)*(t+i)),m=Math.round(o*2+h*(s+r)),p=new Map;for(let[$,y]of l)for(let C=0;C<y.length;C++)p.set(y[C].id,{x:Math.round(o+$*(t+i)),y:Math.round(o+C*(s+r))});let f="";for(let $ of e){let y=p.get($.id);if(y)for(let C of $.depends_on){let S=p.get(C);if(!S)continue;let L=S.x+t,H=S.y+s/2,F=y.x,W=y.y+s/2,ie=Math.round((L+F)/2),j=n.get(C),ce=j&&j.status==="closed";f+=`<path class="${ce?"beads-graph-edge beads-graph-edge--satisfied":"beads-graph-edge beads-graph-edge--blocking"}" d="M${L},${H} C${ie},${H} ${ie},${W} ${F},${W}" marker-end="${ce?"url(#beads-arrow-satisfied)":"url(#beads-arrow-blocking)"}"/>`}}let _="",w=[];for(let $ of e){let y=p.get($.id);if(!y)continue;let C=au($),S=$.title||"",L=S.length>18?`${S.slice(0,18)}...`:S;_+=`<g class="beads-graph-node beads-graph-node--${C}" transform="translate(${y.x},${y.y})">
288
+ `}function Kn(e){return e===0||e===1?"danger":e===2?"warning":"neutral"}function Yl(e,t=null){return t?.blocked_by&&t.blocked_by.length>0?"warning":e==="open"?"success":e==="in_progress"?"primary":"neutral"}function au(e){return e.status==="closed"?"closed":e.blocked_by&&e.blocked_by.length>0?"blocked":e.status}var nu={open:{icon:Rs,color:"var(--status-completed)"},in_progress:{icon:Pe,color:"var(--status-in-progress)"},closed:{icon:Ls,color:"var(--status-completed)"},blocked:{icon:zl,color:"var(--status-blocked)"}};function wv(e,t){let s=t.get(e);if(!s)return R(Rs,10);let i=au(s),r=nu[i]||nu.open,o=i==="in_progress"?"icon-spin":"";return`<span style="color:${r.color};display:inline-flex">${R(r.icon,10,o)}</span>`}function Sv(e){let t=new Set(e.map(r=>r.id)),s=new Map(e.map(r=>[r.id,0])),i=!0;for(;i;){i=!1;for(let r of e)for(let o of r.depends_on){if(!t.has(o))continue;let n=(s.get(o)??0)+1;n>s.get(r.id)&&(s.set(r.id,n),i=!0)}}return s}function lu(e){if(!e||e.length===0)return{svg:"",nodes:[]};let t=140,s=40,i=60,r=24,o=16,n=new Map(e.map($=>[$.id,$])),a=Sv(e),c=Math.max(...a.values(),0),l=new Map;for(let $ of e){let y=a.get($.id)??0;l.has(y)||l.set(y,[]),l.get(y).push($)}let h=Math.max(...[...l.values()].map($=>$.length),1),d=Math.round(o*2+(c+1)*(t+i)),m=Math.round(o*2+h*(s+r)),p=new Map;for(let[$,y]of l)for(let C=0;C<y.length;C++)p.set(y[C].id,{x:Math.round(o+$*(t+i)),y:Math.round(o+C*(s+r))});let f="";for(let $ of e){let y=p.get($.id);if(y)for(let C of $.depends_on){let S=p.get(C);if(!S)continue;let L=S.x+t,H=S.y+s/2,F=y.x,W=y.y+s/2,ie=Math.round((L+F)/2),j=n.get(C),ce=j&&j.status==="closed";f+=`<path class="${ce?"beads-graph-edge beads-graph-edge--satisfied":"beads-graph-edge beads-graph-edge--blocking"}" d="M${L},${H} C${ie},${H} ${ie},${W} ${F},${W}" marker-end="${ce?"url(#beads-arrow-satisfied)":"url(#beads-arrow-blocking)"}"/>`}}let _="",w=[];for(let $ of e){let y=p.get($.id);if(!y)continue;let C=au($),S=$.title||"",L=S.length>18?`${S.slice(0,18)}...`:S;_+=`<g class="beads-graph-node beads-graph-node--${C}" transform="translate(${y.x},${y.y})">
289
289
  <rect width="${t}" height="${s}" rx="6"/>
290
290
  <text x="8" y="14" class="beads-graph-node-id">#${$.id}</text>
291
- <text x="8" y="28">${Sv(L)}</text>
291
+ <text x="8" y="28">${Cv(L)}</text>
292
292
  </g>`,w.push({issue:$,x:y.x,y:y.y,w:t,h:s})}return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${m}" viewBox="0 0 ${d} ${m}">
293
293
  <defs>
294
294
  <marker id="beads-arrow-satisfied" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
@@ -300,12 +300,12 @@ ${h.join(`
300
300
  </defs>
301
301
  ${f}
302
302
  ${_}
303
- </svg>`,nodes:w}}function Sv(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Cv(e){let t=`**Bead ID:** ${e.id} | **Priority:** P${e.priority} | **Status:** ${e.status}`;return t+=`
303
+ </svg>`,nodes:w}}function Cv(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xv(e){let t=`**Bead ID:** ${e.id} | **Priority:** P${e.priority} | **Status:** ${e.status}`;return t+=`
304
304
 
305
305
  **Title:** ${e.title}`,e.body&&(t+=`
306
306
 
307
307
  **Description:**
308
- ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget;navigator.clipboard.writeText(Cv(e)).then(()=>{i.textContent="Copied!",setTimeout(()=>{i.textContent="Copy"},1500)})};return u`
308
+ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget;navigator.clipboard.writeText(xv(e)).then(()=>{i.textContent="Copied!",setTimeout(()=>{i.textContent="Copy"},1500)})};return u`
309
309
  <div class="bead-tooltip-content">
310
310
  <div class="bead-tooltip-header">
311
311
  <span class="bead-tooltip-id">Bead ID: ${e.id}</span>
@@ -326,7 +326,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
326
326
  <div class="run-list">
327
327
  ${n.map(a=>ss(a,{onClick:t,beadsCount:s[a.id]||0}))}
328
328
  </div>
329
- `}function xv(e,{starting:t,onStartIssue:s}){let i=new Map(e.map(n=>[n.id,n])),r=[{key:"open",label:"Open",items:[]},{key:"in_progress",label:"In Progress",items:[]},{key:"closed",label:"Closed",items:[]}],o=new Map(r.map(n=>[n.key,n]));for(let n of e)(o.get(n.status)||o.get("open")).items.push(n);for(let n of r)n.items.sort((a,c)=>a.priority-c.priority);return u`
329
+ `}function kv(e,{starting:t,onStartIssue:s}){let i=new Map(e.map(n=>[n.id,n])),r=[{key:"open",label:"Open",items:[]},{key:"in_progress",label:"In Progress",items:[]},{key:"closed",label:"Closed",items:[]}],o=new Map(r.map(n=>[n.key,n]));for(let n of e)(o.get(n.status)||o.get("open")).items.push(n);for(let n of r)n.items.sort((a,c)=>a.priority-c.priority);return u`
330
330
  <div class="beads-kanban">
331
331
  ${r.map(n=>u`
332
332
  <div class="beads-kanban-column">
@@ -350,7 +350,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
350
350
  <div class="beads-kanban-card-deps">
351
351
  ${a.blocked_by.map(l=>u`
352
352
  <span class="beads-dep-chip beads-dep-chip--blocking">
353
- ${E(yv(l,i))}
353
+ ${E(wv(l,i))}
354
354
  #${l}
355
355
  </span>
356
356
  `)}
@@ -406,7 +406,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
406
406
  <div class="beads-panel">
407
407
  ${k}
408
408
  ${$}
409
- ${xv(p,{starting:i,onStartIssue:a})}
409
+ ${kv(p,{starting:i,onStartIssue:a})}
410
410
  ${r?u`
411
411
  <sl-dialog label="Could Not Start Pipeline" open @sl-after-hide=${c}>
412
412
  <p>${r}</p>
@@ -416,7 +416,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
416
416
  </sl-dialog>
417
417
  `:""}
418
418
  </div>
419
- `}function kv(e){let t=0;for(let s of e)for(let i of Object.values(s.stages||{}))for(let r of i.iterations||[])t+=r.cost_usd||0;return t}function $v(e){return e==null||e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Xl(e,t){return e.filter(s=>t.includes(s.pipeline_status))}function Ev(e,t,s){let i={},r={};for(let o of e)i[o.name]=0,r[o.name]=null;for(let o of t){let n=o.projectId||e[0]?.name;n&&i[n]!==void 0&&(o.active&&i[n]++,(!r[n]||(o.started_at||"")>(r[n].started_at||""))&&(r[n]=o))}return u`
419
+ `}function $v(e){let t=0;for(let s of e)for(let i of Object.values(s.stages||{}))for(let r of i.iterations||[])t+=r.cost_usd||0;return t}function Ev(e){return e==null||e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Xl(e,t){return e.filter(s=>t.includes(s.pipeline_status))}function Tv(e,t,s){let i={},r={};for(let o of e)i[o.name]=0,r[o.name]=null;for(let o of t){let n=o.projectId||e[0]?.name;n&&i[n]!==void 0&&(o.active&&i[n]++,(!r[n]||(o.started_at||"")>(r[n].started_at||""))&&(r[n]=o))}return u`
420
420
  <div class="project-cards">
421
421
  ${e.map(o=>{let n=i[o.name]||0,a=r[o.name],c=a?a.pipeline_status||"unknown":"no runs";return u`
422
422
  <div class="project-card" @click=${()=>s?.("active",null,o.name)}>
@@ -427,9 +427,9 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
427
427
  </div>
428
428
  `})}
429
429
  </div>
430
- `}function du(e,{onSelectRun:t,onNavigate:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:a}={}){let c=Object.values(e.runs),l=c.filter(F=>F.active),h=c.filter(F=>!F.active),d=c.filter(F=>(F.stages?Object.values(F.stages):[]).some(ie=>ie.status==="error")),m=c.length,p=kv(c),f=ft(l),_=ft(Xl(c,["paused"])),w=3,k=ft(Xl(c,["failed"])),$=k.slice(0,w),y=ft(Xl(c,["completed"])),C=y.slice(0,w),S=e.projects||[],L=e.currentProjectId,H=S.length>1&&!L;return u`
430
+ `}function du(e,{onSelectRun:t,onNavigate:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:a}={}){let c=Object.values(e.runs),l=c.filter(F=>F.active),h=c.filter(F=>!F.active),d=c.filter(F=>(F.stages?Object.values(F.stages):[]).some(ie=>ie.status==="error")),m=c.length,p=$v(c),f=ft(l),_=ft(Xl(c,["paused"])),w=3,k=ft(Xl(c,["failed"])),$=k.slice(0,w),y=ft(Xl(c,["completed"])),C=y.slice(0,w),S=e.projects||[],L=e.currentProjectId,H=S.length>1&&!L;return u`
431
431
  <div class="dashboard">
432
- ${H?Ev(S,c,s):b}
432
+ ${H?Tv(S,c,s):b}
433
433
  <div class="dashboard-stats">
434
434
  <div class="stat-card stat-total">
435
435
  <div class="stat-icon-ring">${E(R(pt,20))}</div>
@@ -462,7 +462,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
462
462
  <div class="stat-card stat-cost-total" style="cursor:pointer" @click=${()=>s?.("costs")}>
463
463
  <div class="stat-icon-ring">${E(R(Nt,20))}</div>
464
464
  <div class="stat-body">
465
- <span class="stat-number">${$v(p)}</span>
465
+ <span class="stat-number">${Ev(p)}</span>
466
466
  <span class="stat-label">Total Cost</span>
467
467
  </div>
468
468
  </div>
@@ -517,13 +517,13 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
517
517
  </div>
518
518
  `:b}
519
519
  </div>
520
- `}function is(e){let t=e.target;if(!t)return;let s=t.closest(".main-content")||t.closest(".run-detail-layout__logs");if(!s){t.scrollIntoView({behavior:"smooth",block:"nearest"});return}let i=t.getBoundingClientRect(),r=s.getBoundingClientRect();if(i.bottom>r.bottom){let o=s.scrollTop+(i.top-r.top)-12;s.scrollTo({top:o,behavior:"smooth"})}}function Tv(e){switch(e){case"critical":return"danger";case"high":return"warning";case"medium":return"primary";case"low":return"neutral";default:return"neutral"}}function Yn(e,t){let s=e?ve(rt(e,t||null)):"";return u`
520
+ `}function is(e){let t=e.target;if(!t)return;let s=t.closest(".main-content")||t.closest(".run-detail-layout__logs");if(!s){t.scrollIntoView({behavior:"smooth",block:"nearest"});return}let i=t.getBoundingClientRect(),r=s.getBoundingClientRect();if(i.bottom>r.bottom){let o=s.scrollTop+(i.top-r.top)-12;s.scrollTo({top:o,behavior:"smooth"})}}function Av(e){switch(e){case"critical":return"danger";case"high":return"warning";case"medium":return"primary";case"low":return"neutral";default:return"neutral"}}function Yn(e,t){let s=e?ve(rt(e,t||null)):"";return u`
521
521
  <div class="timing-strip">
522
522
  ${e?u`<span class="timing-strip-item"><span class="meta-label">Started:</span> <span class="meta-value">${Ct(e)}</span></span>`:b}
523
523
  ${t?u`<span class="timing-strip-item"><span class="meta-label">Finished:</span> <span class="meta-value">${Ct(t)}</span></span>`:b}
524
524
  ${s?u`<span class="timing-strip-item"><span class="meta-label">Duration:</span> <span class="meta-value">${s}</span></span>`:b}
525
525
  </div>
526
- `}function Av(e){return`Investigate the following observation from a pipeline learning analysis and suggest concrete fixes.
526
+ `}function Rv(e){return`Investigate the following observation from a pipeline learning analysis and suggest concrete fixes.
527
527
 
528
528
  ## Observation
529
529
  - **Category**: ${e.category}
@@ -537,7 +537,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
537
537
  2. Find the specific files and code sections involved.
538
538
  3. Propose concrete changes to prevent this from recurring.
539
539
  4. If this relates to test failures or loops, identify what test coverage or prompt changes would help.
540
- `}function Rv(e){return`Implement the following suggestion from a pipeline learning analysis.
540
+ `}function Dv(e){return`Implement the following suggestion from a pipeline learning analysis.
541
541
 
542
542
  ## Suggestion
543
543
  - **Target**: ${e.target}
@@ -549,14 +549,14 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
549
549
  2. Understand the current behavior and why the suggestion was made.
550
550
  3. Implement the suggested change with minimal disruption.
551
551
  4. Verify the change doesn't break existing functionality.
552
- `}function pu(e,t){navigator.clipboard.writeText(e).then(()=>{let s=t.querySelector(".copy-icon");s&&(s.classList.add("copy-success"),setTimeout(()=>s.classList.remove("copy-success"),1500))})}function Dv(e){return e?u`
552
+ `}function pu(e,t){navigator.clipboard.writeText(e).then(()=>{let s=t.querySelector(".copy-icon");s&&(s.classList.add("copy-success"),setTimeout(()=>s.classList.remove("copy-success"),1500))})}function Lv(e){return e?u`
553
553
  <div class="learnings-summary-strip">
554
554
  <span><span class="meta-label">Termination:</span> <span class="meta-value">${e.termination}</span></span>
555
555
  <span><span class="meta-label">Iterations:</span> <span class="meta-value">${e.total_iterations}</span></span>
556
556
  ${e.test_fix_loops!=null?u`<span><span class="meta-label">Test-fix loops:</span> <span class="meta-value">${e.test_fix_loops}</span></span>`:b}
557
557
  ${e.review_fix_loops!=null?u`<span><span class="meta-label">Review-fix loops:</span> <span class="meta-value">${e.review_fix_loops}</span></span>`:b}
558
558
  </div>
559
- `:b}var uu={critical:0,high:1,medium:2,low:3};function Lv(e){return[...e].sort((t,s)=>(uu[t.importance]??4)-(uu[s.importance]??4))}function Pv(e){let t=Lv(e);return u`
559
+ `:b}var uu={critical:0,high:1,medium:2,low:3};function Pv(e){return[...e].sort((t,s)=>(uu[t.importance]??4)-(uu[s.importance]??4))}function Bv(e){let t=Pv(e);return u`
560
560
  <h4 class="learnings-table-title">Observations</h4>
561
561
  <div class="learnings-table">
562
562
  <div class="learnings-table-header">
@@ -570,7 +570,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
570
570
  ${t.map(s=>u`
571
571
  <div class="learnings-table-row">
572
572
  <span class="col-center">
573
- <sl-badge variant="${Tv(s.importance)}" pill>
573
+ <sl-badge variant="${Av(s.importance)}" pill>
574
574
  ${s.importance}
575
575
  </sl-badge>
576
576
  </span>
@@ -579,14 +579,14 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
579
579
  <span class="learnings-evidence">${s.evidence}</span>
580
580
  <span class="col-center">${s.occurrences||1}</span>
581
581
  <sl-tooltip content="Copy investigation prompt">
582
- <button class="learnings-copy-btn" @click=${i=>pu(Av(s),i.currentTarget)}>
582
+ <button class="learnings-copy-btn" @click=${i=>pu(Rv(s),i.currentTarget)}>
583
583
  <span class="copy-icon">${E(R(He,14))}</span>
584
584
  </button>
585
585
  </sl-tooltip>
586
586
  </div>
587
587
  `)}
588
588
  </div>
589
- `}function Bv(e){return u`
589
+ `}function Mv(e){return u`
590
590
  <h4 class="learnings-table-title">Suggestions</h4>
591
591
  <div class="learnings-table">
592
592
  <div class="learnings-table-header learnings-table-header--suggestions">
@@ -601,14 +601,14 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
601
601
  <span>${t.description}</span>
602
602
  <span class="learnings-rationale">${t.rationale}</span>
603
603
  <sl-tooltip content="Copy implementation prompt">
604
- <button class="learnings-copy-btn" @click=${s=>pu(Rv(t),s.currentTarget)}>
604
+ <button class="learnings-copy-btn" @click=${s=>pu(Dv(t),s.currentTarget)}>
605
605
  <span class="copy-icon">${E(R(He,14))}</span>
606
606
  </button>
607
607
  </sl-tooltip>
608
608
  </div>
609
609
  `)}
610
610
  </div>
611
- `}function Mv(e){if(!e)return b;let t=e.cross_bead||[],s=e.test_fix_loops||[],i=e.review_fix_loops||[];return t.length===0&&s.length===0&&i.length===0?b:u`
611
+ `}function Iv(e){if(!e)return b;let t=e.cross_bead||[],s=e.test_fix_loops||[],i=e.review_fix_loops||[];return t.length===0&&s.length===0&&i.length===0?b:u`
612
612
  <h4 class="learnings-table-title">Recurring Patterns</h4>
613
613
  ${t.length>0?u`
614
614
  <h5 class="learnings-subtable-title">Cross-Bead</h5>
@@ -665,7 +665,7 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
665
665
  `)}
666
666
  </div>
667
667
  `:b}
668
- `}var Iv=900*1e3;function fu(e,t={}){let s=e?.status,i=e?.iterations?.[0]?.output,r=i?.observations,o=e?.error||e?.iterations?.[0]?.error,n=e?.started_at||e?.iterations?.[0]?.started_at,a=e?.completed_at||e?.iterations?.[0]?.completed_at,c;if(s==="in_progress"||s==="pending"){let m=n?new Date(n):null;(m?Date.now()-m.getTime():0)>Iv?c=u`
668
+ `}var Ov=900*1e3;function fu(e,t={}){let s=e?.status,i=e?.iterations?.[0]?.output,r=i?.observations,o=e?.error||e?.iterations?.[0]?.error,n=e?.started_at||e?.iterations?.[0]?.started_at,a=e?.completed_at||e?.iterations?.[0]?.completed_at,c;if(s==="in_progress"||s==="pending"){let m=n?new Date(n):null;(m?Date.now()-m.getTime():0)>Ov?c=u`
669
669
  <div class="learnings-error">
670
670
  <div class="learnings-error-icon">
671
671
  ${E(R(br,20))}
@@ -709,10 +709,10 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
709
709
  ${_?u`<span class="stage-info-item"><span class="meta-label">API Duration:</span> <span class="meta-value">${ve(_)}${w>0?` (${Math.round(_/w*100)}%)`:""}</span></span>`:b}
710
710
  ${f!=null?u`<span class="stage-info-item"><span class="meta-label">Cost:</span> <span class="meta-value">$${Number(f).toFixed(2)}</span></span>`:b}
711
711
  </div>
712
- ${Dv(i.run_summary)}
713
- ${Pv(i.observations)}
714
- ${Bv(i.suggestions||[])}
715
- ${Mv(i.recurring_patterns)}
712
+ ${Lv(i.run_summary)}
713
+ ${Bv(i.observations)}
714
+ ${Mv(i.suggestions||[])}
715
+ ${Iv(i.recurring_patterns)}
716
716
  ${t.onRunLearn?u`<div class="learnings-rerun">
717
717
  <sl-button variant="text" size="small" @click=${t.onRunLearn}>
718
718
  ${E(R(Be,12))} Re-run Analysis
@@ -742,11 +742,11 @@ ${e.body}`),t}function Gn(e){let t=s=>{s.stopPropagation();let i=s.currentTarget
742
742
  ${c}
743
743
  </sl-details>
744
744
  </div>
745
- `}function Ov(e){if(!e)return"";let t=e.buffer.active,s=[];for(let i=0;i<t.length;i++){let r=t.getLine(i);s.push(r?r.translateToString(!0):"")}for(;s.length>0&&s[s.length-1].trim()==="";)s.pop();return s.join(`
746
- `)}async function Xn(e,t){let s=Ov(e);try{await navigator.clipboard.writeText(s),t.classList.add("copy-success"),setTimeout(()=>t.classList.remove("copy-success"),1500)}catch{}}var vf=["\x1B[36m","\x1B[33m","\x1B[35m","\x1B[32m","\x1B[34m","\x1B[91m","\x1B[96m","\x1B[93m"],Ea="\x1B[0m",ph="\x1B[2m",dh=new Map,bf=0;function xw(e){return e?new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function kw(e){return dh.has(e)||(dh.set(e,vf[bf%vf.length]),bf++),dh.get(e)}var nt=null,Yi=null,Uo=null,uh=null,Rr=null,hi=null;async function $w(e){if(nt&&e.querySelector(".xterm")){Yi.fit();return}if(Rr){await Rr;return}Rr=(async()=>{let[{Terminal:t},{FitAddon:s}]=await Promise.all([Promise.resolve().then(()=>(lh(),ah)),Promise.resolve().then(()=>(hh(),ch))]);nt=new t({theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#60a5fa",selectionBackground:"rgba(96, 165, 250, 0.3)"},fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:13,lineHeight:1.4,scrollback:1e4,convertEol:!0,cursorBlink:!1,disableStdin:!0}),Yi=new s,nt.loadAddon(Yi),nt.open(e),Yi.fit(),Uo=new ResizeObserver(()=>{Yi&&Yi.fit()}),Uo.observe(e)})(),await Rr,Rr=null}function fh(e){if(!nt||!hi||e.stage!==hi)return;let t=e.timestamp?`${ph}${xw(e.timestamp)}${Ea} `:"",s=e.stage?`${kw(e.stage)}[${e.stage.toUpperCase()}]${Ea} `:"",i=e.line||e;nt.writeln(`${t}${s}${i}`)}function yf(e){nt&&nt.writeln(`
745
+ `}function zv(e){if(!e)return"";let t=e.buffer.active,s=[];for(let i=0;i<t.length;i++){let r=t.getLine(i);s.push(r?r.translateToString(!0):"")}for(;s.length>0&&s[s.length-1].trim()==="";)s.pop();return s.join(`
746
+ `)}async function Xn(e,t){let s=zv(e);try{await navigator.clipboard.writeText(s),t.classList.add("copy-success"),setTimeout(()=>t.classList.remove("copy-success"),1500)}catch{}}var vf=["\x1B[36m","\x1B[33m","\x1B[35m","\x1B[32m","\x1B[34m","\x1B[91m","\x1B[96m","\x1B[93m"],Ea="\x1B[0m",ph="\x1B[2m",dh=new Map,bf=0;function kw(e){return e?new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function $w(e){return dh.has(e)||(dh.set(e,vf[bf%vf.length]),bf++),dh.get(e)}var nt=null,Yi=null,Uo=null,uh=null,Rr=null,hi=null;async function Ew(e){if(nt&&e.querySelector(".xterm")){Yi.fit();return}if(Rr){await Rr;return}Rr=(async()=>{let[{Terminal:t},{FitAddon:s}]=await Promise.all([Promise.resolve().then(()=>(lh(),ah)),Promise.resolve().then(()=>(hh(),ch))]);nt=new t({theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#60a5fa",selectionBackground:"rgba(96, 165, 250, 0.3)"},fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:13,lineHeight:1.4,scrollback:1e4,convertEol:!0,cursorBlink:!1,disableStdin:!0}),Yi=new s,nt.loadAddon(Yi),nt.open(e),Yi.fit(),Uo=new ResizeObserver(()=>{Yi&&Yi.fit()}),Uo.observe(e)})(),await Rr,Rr=null}function fh(e){if(!nt||!hi||e.stage!==hi)return;let t=e.timestamp?`${ph}${kw(e.timestamp)}${Ea} `:"",s=e.stage?`${$w(e.stage)}[${e.stage.toUpperCase()}]${Ea} `:"",i=e.line||e;nt.writeln(`${t}${s}${i}`)}function yf(e){nt&&nt.writeln(`
747
747
  ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
748
- `)}function mh(){nt&&nt.clear()}function wf(){Uo&&Uo.disconnect(),nt&&nt.dispose(),nt=null,Yi=null,Uo=null,Rr=null,uh=null,hi=null}function Ew(e){if(!e)return null;for(let[i,r]of Object.entries(e))if(r.status==="in_progress")return i;let t=null,s=null;for(let[i,r]of Object.entries(e))r.started_at&&(!s||r.started_at>s)&&(s=r.started_at,t=i);return t}function Ta(e){let t=e?.stages,s=Ew(t);if(s!==hi){let i=hi;return hi=s,nt&&i!==null&&(nt.clear(),s&&nt.writeln(`${ph}--- Switched to stage: ${s.toUpperCase()} ---${Ea}
749
- `)),{changed:!0,activeStage:s}}return{changed:!1,activeStage:hi}}function gh(){return hi}async function Sf(e){let t=document.getElementById("live-output-terminal");t&&(e!==uh&&(mh(),uh=e),await $w(t))}function Cf(e,t){if(!t)return b;let s=e?e.replace(/_/g," ").toUpperCase():"WAITING";return u`
748
+ `)}function mh(){nt&&nt.clear()}function wf(){Uo&&Uo.disconnect(),nt&&nt.dispose(),nt=null,Yi=null,Uo=null,Rr=null,uh=null,hi=null}function Tw(e){if(!e)return null;for(let[i,r]of Object.entries(e))if(r.status==="in_progress")return i;let t=null,s=null;for(let[i,r]of Object.entries(e))r.started_at&&(!s||r.started_at>s)&&(s=r.started_at,t=i);return t}function Ta(e){let t=e?.stages,s=Tw(t);if(s!==hi){let i=hi;return hi=s,nt&&i!==null&&(nt.clear(),s&&nt.writeln(`${ph}--- Switched to stage: ${s.toUpperCase()} ---${Ea}
749
+ `)),{changed:!0,activeStage:s}}return{changed:!1,activeStage:hi}}function gh(){return hi}async function Sf(e){let t=document.getElementById("live-output-terminal");t&&(e!==uh&&(mh(),uh=e),await Ew(t))}function Cf(e,t){if(!t)return b;let s=e?e.replace(/_/g," ").toUpperCase():"WAITING";return u`
750
750
  <div class="live-output-container">
751
751
  <sl-details open class="live-output-panel" @sl-after-show=${is}>
752
752
  <div slot="summary" class="live-output-header">
@@ -765,7 +765,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
765
765
  </div>
766
766
  </sl-details>
767
767
  </div>
768
- `}var Xf=["\x1B[36m","\x1B[33m","\x1B[35m","\x1B[32m","\x1B[34m","\x1B[91m","\x1B[96m","\x1B[93m"],Jf="\x1B[0m",x1="\x1B[2m",Oa=new Map,Dh=0;function k1(e){return e?new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function $1(e){return Oa.has(e)||(Oa.set(e,Xf[Dh%Xf.length]),Dh++),Oa.get(e)}var kt=null,ui=null,Br=null,Lh=null,pi=null,Xi=null;async function E1(e){if(kt&&e.querySelector(".xterm")){ui.fit();return}if(Xi){await Xi;return}Xi=(async()=>{let[{Terminal:t},{FitAddon:s},{SearchAddon:i}]=await Promise.all([Promise.resolve().then(()=>(lh(),ah)),Promise.resolve().then(()=>(hh(),ch)),Promise.resolve().then(()=>(Yf(),Gf))]);kt=new t({theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#60a5fa",selectionBackground:"rgba(96, 165, 250, 0.3)"},fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:13,lineHeight:1.4,scrollback:5e4,convertEol:!0,cursorBlink:!1,disableStdin:!0}),ui=new s,Br=new i,kt.loadAddon(ui),kt.loadAddon(Br),kt.open(e),ui.fit(),pi=new ResizeObserver(()=>{ui&&ui.fit()}),pi.observe(e)})(),await Xi,Xi=null}function Zf(e){if(!kt)return;let t=e.timestamp?`${x1}${k1(e.timestamp)}${Jf} `:"",s=e.stage?`${$1(e.stage)}[${e.stage.toUpperCase()}]${Jf} `:"",i=e.line||e;kt.writeln(`${t}${s}${i}`)}function Mr(){pi&&pi.disconnect(),kt&&kt.dispose(),kt=null,ui=null,Br=null,pi=null,Xi=null,Oa.clear(),Dh=0}function Qf(){pi&&pi.disconnect(),kt&&kt.dispose(),kt=null,ui=null,Br=null,pi=null,Xi=null,Lh=null}function em(e){Br&&e&&Br.findNext(e,{incremental:!0})}async function tm(e){let t=document.getElementById("log-terminal");t&&(e!==Lh&&(Mr(),Lh=e),await E1(t))}function sm(e,{onStageFilter:t,onIterationFilter:s,onSearch:i,onToggleAutoScroll:r,autoScroll:o,stageIterations:n,runStages:a}){let c=w=>{let k=w.filter($=>$!=="orchestrator");return["orchestrator",...ru(k)]},l=a?c(Object.keys(a)):null,h=c([...new Set(e.logLines.map(w=>w.stage).filter(Boolean))]),d=l||h,m=e.currentLogStage,p=n?.[m]||0,f=m&&m!=="*"&&p>0,_=m&&m!=="*";return u`
768
+ `}var Xf=["\x1B[36m","\x1B[33m","\x1B[35m","\x1B[32m","\x1B[34m","\x1B[91m","\x1B[96m","\x1B[93m"],Jf="\x1B[0m",k1="\x1B[2m",Oa=new Map,Dh=0;function $1(e){return e?new Date(e).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function E1(e){return Oa.has(e)||(Oa.set(e,Xf[Dh%Xf.length]),Dh++),Oa.get(e)}var kt=null,ui=null,Br=null,Lh=null,pi=null,Xi=null;async function T1(e){if(kt&&e.querySelector(".xterm")){ui.fit();return}if(Xi){await Xi;return}Xi=(async()=>{let[{Terminal:t},{FitAddon:s},{SearchAddon:i}]=await Promise.all([Promise.resolve().then(()=>(lh(),ah)),Promise.resolve().then(()=>(hh(),ch)),Promise.resolve().then(()=>(Yf(),Gf))]);kt=new t({theme:{background:"#0f172a",foreground:"#e2e8f0",cursor:"#60a5fa",selectionBackground:"rgba(96, 165, 250, 0.3)"},fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",fontSize:13,lineHeight:1.4,scrollback:5e4,convertEol:!0,cursorBlink:!1,disableStdin:!0}),ui=new s,Br=new i,kt.loadAddon(ui),kt.loadAddon(Br),kt.open(e),ui.fit(),pi=new ResizeObserver(()=>{ui&&ui.fit()}),pi.observe(e)})(),await Xi,Xi=null}function Zf(e){if(!kt)return;let t=e.timestamp?`${k1}${$1(e.timestamp)}${Jf} `:"",s=e.stage?`${E1(e.stage)}[${e.stage.toUpperCase()}]${Jf} `:"",i=e.line||e;kt.writeln(`${t}${s}${i}`)}function Mr(){pi&&pi.disconnect(),kt&&kt.dispose(),kt=null,ui=null,Br=null,pi=null,Xi=null,Oa.clear(),Dh=0}function Qf(){pi&&pi.disconnect(),kt&&kt.dispose(),kt=null,ui=null,Br=null,pi=null,Xi=null,Lh=null}function em(e){Br&&e&&Br.findNext(e,{incremental:!0})}async function tm(e){let t=document.getElementById("log-terminal");t&&(e!==Lh&&(Mr(),Lh=e),await T1(t))}function sm(e,{onStageFilter:t,onIterationFilter:s,onSearch:i,onToggleAutoScroll:r,autoScroll:o,stageIterations:n,runStages:a}){let c=w=>{let k=w.filter($=>$!=="orchestrator");return["orchestrator",...ru(k)]},l=a?c(Object.keys(a)):null,h=c([...new Set(e.logLines.map(w=>w.stage).filter(Boolean))]),d=l||h,m=e.currentLogStage,p=n?.[m]||0,f=m&&m!=="*"&&p>0,_=m&&m!=="*";return u`
769
769
  <div class="log-history-container">
770
770
  <sl-details class="log-history-panel" @sl-after-show=${is}>
771
771
  <div slot="summary" class="log-history-header">
@@ -830,7 +830,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
830
830
  </div>
831
831
  </sl-details>
832
832
  </div>
833
- `}var Ji=new Set(["general-purpose"]),im=[{name:"Explore",label:"(built-in)",group:"Built-in"},{name:"general-purpose",label:"(built-in)",group:"Built-in"},{name:"Plan",label:"(built-in)",group:"Built-in"},{name:"statusline-setup",label:"(built-in)",group:"Built-in"},{name:"claude-code-guide",label:"(built-in)",group:"Built-in"}];function za(e,t,s=Ji){let i=t.trim();return i?(s instanceof Set?s.has(i):s.includes(i))?{tags:e,rejected:!0,reason:`${i} is on the subagent denylist`}:e.includes(i)?{tags:e,rejected:!1}:{tags:[...e,i],rejected:!1}:{tags:e,rejected:!1}}function Ph(e,t){return e.filter(s=>s!==t)}function rm(e,t,s,i=Ji){let r=e.trim().toLowerCase();return t.filter(o=>!s.includes(o.name)).filter(o=>!r||o.name.toLowerCase().startsWith(r)).map(o=>({...o,denied:i instanceof Set?i.has(o.name):i.includes(o.name)}))}function om(e,t){if(e.length!==t.length)return!0;let s=[...e].sort(),i=[...t].sort();return s.some((r,o)=>r!==i[o])}var Bh={telegram:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#26A5E4"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>',discord:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#5865F2"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/></svg>',slack:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#4A154B"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/></svg>'},T1=["pipeline.run.started","pipeline.run.completed","pipeline.run.failed","pipeline.run.interrupted","pipeline.run.cancelled","pipeline.run.paused","pipeline.run.resumed","pipeline.run.resumed_from_pause","pipeline.stage.started","pipeline.stage.completed","pipeline.stage.interrupted","pipeline.git.pr_created","pipeline.git.pr_merged","pipeline.circuit_breaker.tripped","pipeline.cost.budget_warning"],A1=[{key:"telegram",label:"Telegram",icon:Bh.telegram,desc:"Two-way: notifications + inbound commands",tokenLabel:"Bot Token",tokenPlaceholder:"Paste token from @BotFather",tokenHint:"Create a bot via @BotFather in Telegram, then paste the token here.",idLabel:"Chat ID",idPlaceholder:"Click Detect after sending /start",idHint:"Send /start to the bot in Telegram, then click Detect."},{key:"discord",label:"Discord",icon:Bh.discord,desc:"Outbound notifications via bot",tokenLabel:"Bot Token",tokenPlaceholder:"Paste bot token from Discord Developer Portal",tokenHint:"Create a bot at discord.com/developers, copy the token.",idLabel:"Channel ID",idPlaceholder:"e.g. 1234567890",idHint:"Right-click the channel \u2192 Copy Channel ID (enable Developer Mode in settings)."},{key:"slack",label:"Slack",icon:Bh.slack,desc:"Outbound notifications via incoming webhook",tokenLabel:"Webhook URL",tokenPlaceholder:"https://hooks.slack.com/services/...",tokenHint:"Create an Incoming Webhook in your Slack workspace settings.",idLabel:"Channel ID",idPlaceholder:"e.g. C0123456789",idHint:"Right-click the channel \u2192 View channel details \u2192 copy the ID."}];function R1(e){if(!e)return"Never";let t=new Date(e),i=new Date-t;return i<6e4?"Just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:t.toLocaleDateString()}function D1(e,t){return t?.adapters&&t.adapters.find(s=>s.name===e)||null}function L1(e,t){return t?.[e]||null}function P1(e,t,s,{editing:i,form:r,onEdit:o,onCancel:n,onFieldChange:a,onEventToggle:c,onSave:l,onRemove:h,onDetect:d,onToggleEnabled:m}){let p=s?.enabled!==!1,f=t?.persistent,_=t?.connection,w=t?.connection_error;function k(){return!f||!p?b:_==="connected"?u`<sl-badge variant="success" pill>Connected</sl-badge>`:_==="connecting"?u`<sl-badge variant="neutral" pill>Connecting\u2026</sl-badge>`:u`<sl-tooltip content=${w||"Connection lost"}><sl-badge variant="warning" pill>Disconnected</sl-badge></sl-tooltip>`}return u`
833
+ `}var Ji=new Set(["general-purpose"]),im=[{name:"Explore",label:"(built-in)",group:"Built-in"},{name:"general-purpose",label:"(built-in)",group:"Built-in"},{name:"Plan",label:"(built-in)",group:"Built-in"},{name:"statusline-setup",label:"(built-in)",group:"Built-in"},{name:"claude-code-guide",label:"(built-in)",group:"Built-in"}];function za(e,t,s=Ji){let i=t.trim();return i?(s instanceof Set?s.has(i):s.includes(i))?{tags:e,rejected:!0,reason:`${i} is on the subagent denylist`}:e.includes(i)?{tags:e,rejected:!1}:{tags:[...e,i],rejected:!1}:{tags:e,rejected:!1}}function Ph(e,t){return e.filter(s=>s!==t)}function rm(e,t,s,i=Ji){let r=e.trim().toLowerCase();return t.filter(o=>!s.includes(o.name)).filter(o=>!r||o.name.toLowerCase().startsWith(r)).map(o=>({...o,denied:i instanceof Set?i.has(o.name):i.includes(o.name)}))}function om(e,t){if(e.length!==t.length)return!0;let s=[...e].sort(),i=[...t].sort();return s.some((r,o)=>r!==i[o])}var Bh={telegram:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#26A5E4"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>',discord:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#5865F2"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028 14.09 14.09 0 0 0 1.226-1.994.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/></svg>',slack:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#4A154B"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/></svg>'},A1=["pipeline.run.started","pipeline.run.completed","pipeline.run.failed","pipeline.run.interrupted","pipeline.run.cancelled","pipeline.run.paused","pipeline.run.resumed","pipeline.run.resumed_from_pause","pipeline.stage.started","pipeline.stage.completed","pipeline.stage.interrupted","pipeline.git.pr_created","pipeline.git.pr_merged","pipeline.circuit_breaker.tripped","pipeline.cost.budget_warning"],R1=[{key:"telegram",label:"Telegram",icon:Bh.telegram,desc:"Two-way: notifications + inbound commands",tokenLabel:"Bot Token",tokenPlaceholder:"Paste token from @BotFather",tokenHint:"Create a bot via @BotFather in Telegram, then paste the token here.",idLabel:"Chat ID",idPlaceholder:"Click Detect after sending /start",idHint:"Send /start to the bot in Telegram, then click Detect."},{key:"discord",label:"Discord",icon:Bh.discord,desc:"Outbound notifications via bot",tokenLabel:"Bot Token",tokenPlaceholder:"Paste bot token from Discord Developer Portal",tokenHint:"Create a bot at discord.com/developers, copy the token.",idLabel:"Channel ID",idPlaceholder:"e.g. 1234567890",idHint:"Right-click the channel \u2192 Copy Channel ID (enable Developer Mode in settings)."},{key:"slack",label:"Slack",icon:Bh.slack,desc:"Outbound notifications via incoming webhook",tokenLabel:"Webhook URL",tokenPlaceholder:"https://hooks.slack.com/services/...",tokenHint:"Create an Incoming Webhook in your Slack workspace settings.",idLabel:"Channel ID",idPlaceholder:"e.g. C0123456789",idHint:"Right-click the channel \u2192 View channel details \u2192 copy the ID."}];function D1(e){if(!e)return"Never";let t=new Date(e),i=new Date-t;return i<6e4?"Just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:t.toLocaleDateString()}function L1(e,t){return t?.adapters&&t.adapters.find(s=>s.name===e)||null}function P1(e,t){return t?.[e]||null}function B1(e,t,s,{editing:i,form:r,onEdit:o,onCancel:n,onFieldChange:a,onEventToggle:c,onSave:l,onRemove:h,onDetect:d,onToggleEnabled:m}){let p=s?.enabled!==!1,f=t?.persistent,_=t?.connection,w=t?.connection_error;function k(){return!f||!p?b:_==="connected"?u`<sl-badge variant="success" pill>Connected</sl-badge>`:_==="connecting"?u`<sl-badge variant="neutral" pill>Connecting\u2026</sl-badge>`:u`<sl-tooltip content=${w||"Connection lost"}><sl-badge variant="warning" pill>Disconnected</sl-badge></sl-tooltip>`}return u`
834
834
  <div class="ig-card ${p?"ig-card--connected":"ig-card--disabled"}">
835
835
  <div class="ig-card-header">
836
836
  <span class="ig-card-icon">${E(e.icon)}</span>
@@ -845,7 +845,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
845
845
  </div>
846
846
  ${p&&t?u`
847
847
  <div class="ig-card-stats">
848
- <span>Last event: ${R1(t.last_event_at)}</span>
848
+ <span>Last event: ${D1(t.last_event_at)}</span>
849
849
  ${(t.dropped_messages||0)>0?u`<span class="stat-warn">Dropped: ${t.dropped_messages}</span>`:b}
850
850
  </div>
851
851
  `:b}
@@ -861,7 +861,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
861
861
  </div>
862
862
  `}
863
863
  </div>
864
- `}function B1(e,{editing:t,form:s,onConfigure:i,onCancel:r,onFieldChange:o,onEventToggle:n,onSave:a,onDetect:c}){return u`
864
+ `}function M1(e,{editing:t,form:s,onConfigure:i,onCancel:r,onFieldChange:o,onEventToggle:n,onSave:a,onDetect:c}){return u`
865
865
  <div class="ig-card ig-card--disconnected">
866
866
  <div class="ig-card-header">
867
867
  <span class="ig-card-icon">${E(e.icon)}</span>
@@ -907,7 +907,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
907
907
  <div class="ig-form-field">
908
908
  <label>Events to forward</label>
909
909
  <div class="ig-event-grid">
910
- ${T1.map(a=>{let c=a.replace("pipeline.",""),l=(t.events||[]).includes(a);return u`
910
+ ${A1.map(a=>{let c=a.replace("pipeline.",""),l=(t.events||[]).includes(a);return u`
911
911
  <sl-checkbox ?checked=${l} @sl-change=${()=>i(a)}>
912
912
  ${c}
913
913
  </sl-checkbox>
@@ -927,10 +927,10 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
927
927
  <div class="ig-page">
928
928
  <p class="ig-subtitle">Receive pipeline notifications in chat apps.</p>
929
929
  <div class="ig-cards">
930
- ${A1.map(a=>{let c=D1(a.key,s),l=L1(a.key,i),h=!!l,d=r===a.key,m=o?.[a.key]||{chatId:"",events:["pipeline.run.completed","pipeline.run.failed"],saving:!1,error:null,saved:!1},p={editing:d,form:m,onEdit:()=>t.onStartEdit(a.key),onConfigure:()=>t.onStartEdit(a.key),onCancel:()=>t.onCancelEdit(),onFieldChange:(f,_)=>t.onFieldChange(a.key,f,_),onEventToggle:f=>t.onEventToggle(a.key,f),onSave:()=>t.onSave(a.key),onRemove:()=>t.onRemove(a.key),onDetect:()=>t.onDetect?.(a.key),onToggleEnabled:f=>t.onToggleEnabled?.(a.key,f)};return h?P1(a,c,l,p):B1(a,p)})}
930
+ ${R1.map(a=>{let c=L1(a.key,s),l=P1(a.key,i),h=!!l,d=r===a.key,m=o?.[a.key]||{chatId:"",events:["pipeline.run.completed","pipeline.run.failed"],saving:!1,error:null,saved:!1},p={editing:d,form:m,onEdit:()=>t.onStartEdit(a.key),onConfigure:()=>t.onStartEdit(a.key),onCancel:()=>t.onCancelEdit(),onFieldChange:(f,_)=>t.onFieldChange(a.key,f,_),onEventToggle:f=>t.onEventToggle(a.key,f),onSave:()=>t.onSave(a.key),onRemove:()=>t.onRemove(a.key),onDetect:()=>t.onDetect?.(a.key),onToggleEnabled:f=>t.onToggleEnabled?.(a.key,f)};return h?B1(a,c,l,p):M1(a,p)})}
931
931
  </div>
932
932
  </div>
933
- `}var M1={plan:"planner",plan_review:"plan_reviewer",coordinate:"coordinator",implement:"implementer",test:"tester",review:"reviewer",pr:"guardian",learn:"learner"},Mh=Dt.filter(e=>e!=="preflight"),Xo=["planner","plan_reviewer","coordinator","implementer","tester","reviewer","guardian","learner"],cm=["opus","sonnet","haiku"],I1=[["parallel","cleanup_policy"],["parallel","max_concurrent_pipelines"],["ui","worktree_disk_warning_bytes"],["circuit_breaker","classifier_model"]],O1=["pr_approval","deploy_approval"];function z1(e){if(!e)return!1;for(let[s,i]of I1)if(e[s]?.[i]!==void 0)return!0;let t=e.milestones;if(t){for(let s of O1)if(t[s]===!0)return!0}return!1}function hm(e){if(!e)return 0;let t=0;if(e.globalExtracted)for(let s of Object.values(e.globalExtracted))t+=Object.keys(s).length;return e.removedMilestones&&(t+=e.removedMilestones.length),t}var Yo={plan:{agent:"planner",enabled:!0},plan_review:{agent:"plan_reviewer",enabled:!1},coordinate:{agent:"coordinator",enabled:!0},implement:{agent:"implementer",enabled:!0},test:{agent:"tester",enabled:!0},review:{agent:"reviewer",enabled:!0},pr:{agent:"guardian",enabled:!0},learn:{agent:"learner",enabled:!1}},Ih=["opus","sonnet","haiku"],Ha=[{key:"input_per_mtok",label:"Input/MTok ($)"},{key:"output_per_mtok",label:"Output/MTok ($)"},{key:"cache_write_per_mtok",label:"Cache Write 5m/MTok ($)"},{key:"cache_write_1h_per_mtok",label:"Cache Write 1h/MTok ($)"},{key:"cache_read_per_mtok",label:"Cache Read/MTok ($)"}],dm=Object.fromEntries(Ha.map(e=>[e.key,0])),um=[{key:"block_rm_rf",label:"Block rm -rf",description:"Prevent recursive force-delete commands"},{key:"block_env_write",label:"Block .env writes",description:"Prevent writing to .env files"},{key:"block_force_push",label:"Block force push",description:"Prevent git push --force"},{key:"restrict_git_commit",label:"Restrict git commit",description:"Only guardian agent may commit"}],gi={guards:{block_rm_rf:!0,block_env_write:!0,block_force_push:!0,restrict_git_commit:!0},test_gate_strikes:2,subagent_dispatch:{planner:["Explore"],coordinator:[],implementer:["Explore"],tester:["Explore"],reviewer:["Explore"],guardian:["Explore"],plan_reviewer:["Explore"],learner:["Explore"]}},K=null,fe=null,ze="",Zi=null,Wa=!1,ja=!1,Go={},pm=null;function N1(e,t){return Go[e]||(Go[e]={tags:[...t||[]],input:"",showSuggestions:!1,activeIndex:-1}),Go[e]}function F1(){Go={}}function Va(e,t=""){return e?`/api/projects/${e}/settings${t}`:`/api/settings${t}`}async function _i(e){var t,s,i,r,o;Zi=e||null;try{let n=await fetch(Va(e));if(!n.ok)throw new Error(`HTTP ${n.status}`);if(K=await n.json(),K.worca||(K.worca={}),!K.worca.stages)K.worca.stages={...Yo};else for(let a of Mh)K.worca.stages[a]||(K.worca.stages[a]={...Yo[a]});if(!K.worca.stages.preflight)K.worca.stages.preflight={enabled:!0,script:".claude/worca/scripts/preflight_checks.py",require:[]};else{let a=K.worca.stages.preflight;a.enabled===void 0&&(a.enabled=!0),a.script||(a.script=".claude/worca/scripts/preflight_checks.py"),a.require||(a.require=[])}K.worca.plan_path_template||(K.worca.plan_path_template="docs/plans/{timestamp}-{title_slug}.md"),K.worca.defaults||(K.worca.defaults={msize:1,mloops:1}),K.worca.pricing||(K.worca.pricing={models:{},server_tools:{},currency:"USD"}),K.worca.pricing.models||(K.worca.pricing.models={});for(let a of Ih)K.worca.pricing.models[a]={...dm,...K.worca.pricing.models[a]||{}};if(K.worca.pricing.server_tools||(K.worca.pricing.server_tools={}),!K.worca.governance)K.worca.governance={...gi};else{let a=K.worca.governance,c=a.subagent_dispatch!==void 0,l=a.dispatch!==void 0&&!c;K.worca.governance={...gi,...a,guards:{...gi.guards,...a.guards||{}},subagent_dispatch:{...gi.subagent_dispatch,...c?a.subagent_dispatch:l?a.dispatch:{}},_legacy_dispatch:l}}K.worca.milestones?(t=K.worca.milestones).plan_approval??(t.plan_approval=!0):K.worca.milestones={plan_approval:!0},K.worca.circuit_breaker?((s=K.worca.circuit_breaker).enabled??(s.enabled=!0),(i=K.worca.circuit_breaker).max_consecutive_failures??(i.max_consecutive_failures=3)):K.worca.circuit_breaker={enabled:!0,max_consecutive_failures:3},K.worca.parallel?((r=K.worca.parallel).worktree_base_dir??(r.worktree_base_dir=".worktrees"),(o=K.worca.parallel).default_base_branch??(o.default_base_branch="main")):K.worca.parallel={worktree_base_dir:".worktrees",default_base_branch:"main"},K.worca.events||(K.worca.events={enabled:!0,agent_telemetry:!1,hook_events:!0,rate_limit_ms:1e3}),K.worca.budget||(K.worca.budget={}),K.worca.webhooks||(K.worca.webhooks=[]),Wa=z1(K.worca),ja=!1,F1();try{let a=await fetch("/api/subagents");if(a.ok){let c=await a.json();c?.ok&&Array.isArray(c.subagents)&&(pm=c.subagents)}}catch{}}catch(n){K=null,fe="error",ze=`Failed to load settings: ${n.message}`}}async function Jo(e,t,s){fe="saving",ze="",t();try{let i=await fetch(Va(s||Zi),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();K={worca:r.worca,permissions:r.permissions};let o=hm(r.autoMigrated);o>0&&(Wa=!1,ja=!0),fe="success",ze=o>0?`${o} project setting${o===1?" was":"s were"} moved to global Preferences`:"Settings saved successfully"}catch(i){fe="error",ze=`Failed to save: ${i.message}`}t(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",t())},3e3)}async function H1(e,t,s){fe="saving",ze="",t();try{let i=await fetch(Va(s||Zi,`/${e}`),{method:"DELETE"});if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();K={worca:r.worca,permissions:r.permissions},await _i(s||Zi),fe="success",ze=`${e.charAt(0).toUpperCase()+e.slice(1)} reset to defaults`}catch(i){fe="error",ze=`Failed to reset: ${i.message}`}t(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",t())},3e3)}function Zo(e,t){let s=e.charAt(0).toUpperCase()+e.slice(1);wt({label:`Reset ${s}`,message:u`Are you sure you want to reset <strong>${s}</strong> settings to their defaults?`,confirmLabel:"Reset",confirmVariant:"danger",onConfirm:()=>H1(e,t)},t)}function W1(){let e={};for(let t of Xo){let s=document.getElementById(`agent-${t}-model`),i=document.getElementById(`agent-${t}-turns`);e[t]={model:s?.value||"sonnet",max_turns:parseInt(i?.value,10)||30}}return e}function j1(){let e={};for(let h of["implement_test","pr_changes","restart_planning"]){let d=document.getElementById(`loop-${h}`);e[h]=parseInt(d?.value,10)||0}let s=document.getElementById("plan-path-template")?.value?.trim()||"",i=document.getElementById("defaults-msize"),r=document.getElementById("defaults-mloops"),o={msize:parseInt(i?.value,10)||1,mloops:parseInt(r?.value,10)||1},n={plan_approval:document.getElementById("milestone-plan-approval")?.checked??!0};document.getElementById("milestone-pr-approval")?.checked===!0&&(n.pr_approval=!0);let c={enabled:document.getElementById("cb-enabled")?.checked??!0,max_consecutive_failures:parseInt(document.getElementById("cb-max-failures")?.value,10)||3},l={worktree_base_dir:document.getElementById("parallel-worktree-base-dir")?.value?.trim()||".worktrees",default_base_branch:document.getElementById("parallel-default-base-branch")?.value?.trim()||"main"};return{loops:e,plan_path_template:s,defaults:o,milestones:n,circuit_breaker:c,parallel:l}}function V1(){let e={};for(let t of Mh){let s=document.getElementById(`stage-${t}-enabled`),i=document.getElementById(`stage-${t}-agent`);e[t]={agent:i?.value||Yo[t].agent,enabled:s?.checked??!0}}return e}function U1(){let e=document.getElementById("preflight-enabled"),t=document.getElementById("preflight-script"),i=(document.getElementById("preflight-require")?.value||"").trim();return{enabled:e?.checked??!0,script:t?.value?.trim()||".claude/worca/scripts/preflight_checks.py",require:i?i.split(",").map(r=>r.trim()).filter(Boolean):[]}}function q1(){let e={};for(let r of um){let o=document.getElementById(`guard-${r.key}`);e[r.key]=o?.checked??!0}let t=document.getElementById("test-gate-strikes"),s=parseInt(t?.value,10)||2,i={};for(let r of Xo)i[r]=[...Go[r]?.tags||[]];return{guards:e,test_gate_strikes:s,subagent_dispatch:i}}function K1(e){return e>=1e9?{value:e/1e9,unit:"GB"}:{value:e/1e6,unit:"MB"}}function G1(){let e=document.getElementById("global-disk-threshold-value"),t=document.getElementById("global-disk-threshold-unit"),s=parseFloat(e?.value)||2,r=(t?.value||"GB")==="GB"?1e9:1e6;return s*r}function Y1(){let e=G1(),t=document.getElementById("global-cleanup-policy"),s=document.getElementById("global-classifier-model"),i=document.getElementById("global-max-concurrent");return{worca:{ui:{worktree_disk_warning_bytes:e},parallel:{cleanup_policy:t?.value||"never",max_concurrent_pipelines:parseInt(i?.value,10)||10},circuit_breaker:{classifier_model:s?.value||"haiku"}}}}async function X1(e,t,s){fe="saving",ze="",t();try{let i=await fetch("/api/preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(r.ok&&s){let o=r.preferences?.worca??{};s({worktreeDiskWarningBytes:o.ui?.worktree_disk_warning_bytes??2e9,classifierModel:o.circuit_breaker?.classifier_model??"haiku",cleanupPolicy:o.parallel?.cleanup_policy??"never",maxConcurrentPipelines:o.parallel?.max_concurrent_pipelines??10})}fe="success",ze="Preferences saved successfully"}catch(i){fe="error",ze=`Failed to save: ${i.message}`}t(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",t())},3e3)}function J1(){let e=document.querySelectorAll(".perm-input");return Array.from(e).map(t=>t.value.trim()).filter(t=>t.length>0)}function Z1(){let e={};for(let i of Ih){e[i]={};for(let r of Ha){let o=document.getElementById(`pricing-${i}-${r.key}`);e[i][r.key]=parseFloat(o?.value)||0}}let t=document.getElementById("pricing-server_tools-web_search_per_request"),s=document.getElementById("pricing-server_tools-web_fetch_per_request");return{models:e,server_tools:{web_search_per_request:parseFloat(t?.value)||0,web_fetch_per_request:parseFloat(s?.value)||0},currency:K?.worca?.pricing?.currency||"USD",last_updated:new Date().toISOString().slice(0,10)}}function Oh(){return K?.worca?.defaults||{msize:1,mloops:1}}function Q1(e,t){let s=e.agents||{};return u`
933
+ `}var I1={plan:"planner",plan_review:"plan_reviewer",coordinate:"coordinator",implement:"implementer",test:"tester",review:"reviewer",pr:"guardian",learn:"learner"},Mh=Dt.filter(e=>e!=="preflight"),Xo=["planner","plan_reviewer","coordinator","implementer","tester","reviewer","guardian","learner"],cm=["opus","sonnet","haiku"],O1=[["parallel","cleanup_policy"],["parallel","max_concurrent_pipelines"],["ui","worktree_disk_warning_bytes"],["circuit_breaker","classifier_model"]],z1=["pr_approval","deploy_approval"];function N1(e){if(!e)return!1;for(let[s,i]of O1)if(e[s]?.[i]!==void 0)return!0;let t=e.milestones;if(t){for(let s of z1)if(t[s]===!0)return!0}return!1}function hm(e){if(!e)return 0;let t=0;if(e.globalExtracted)for(let s of Object.values(e.globalExtracted))t+=Object.keys(s).length;return e.removedMilestones&&(t+=e.removedMilestones.length),t}var Yo={plan:{agent:"planner",enabled:!0},plan_review:{agent:"plan_reviewer",enabled:!1},coordinate:{agent:"coordinator",enabled:!0},implement:{agent:"implementer",enabled:!0},test:{agent:"tester",enabled:!0},review:{agent:"reviewer",enabled:!0},pr:{agent:"guardian",enabled:!0},learn:{agent:"learner",enabled:!1}},Ih=["opus","sonnet","haiku"],Ha=[{key:"input_per_mtok",label:"Input/MTok ($)"},{key:"output_per_mtok",label:"Output/MTok ($)"},{key:"cache_write_per_mtok",label:"Cache Write 5m/MTok ($)"},{key:"cache_write_1h_per_mtok",label:"Cache Write 1h/MTok ($)"},{key:"cache_read_per_mtok",label:"Cache Read/MTok ($)"}],dm=Object.fromEntries(Ha.map(e=>[e.key,0])),um=[{key:"block_rm_rf",label:"Block rm -rf",description:"Prevent recursive force-delete commands"},{key:"block_env_write",label:"Block .env writes",description:"Prevent writing to .env files"},{key:"block_force_push",label:"Block force push",description:"Prevent git push --force"},{key:"restrict_git_commit",label:"Restrict git commit",description:"Only guardian agent may commit"}],gi={guards:{block_rm_rf:!0,block_env_write:!0,block_force_push:!0,restrict_git_commit:!0},test_gate_strikes:2,subagent_dispatch:{planner:["Explore"],coordinator:[],implementer:["Explore"],tester:["Explore"],reviewer:["Explore"],guardian:["Explore"],plan_reviewer:["Explore"],learner:["Explore"]}},K=null,fe=null,ze="",Zi=null,Wa=!1,ja=!1,Go={},pm=null;function F1(e,t){return Go[e]||(Go[e]={tags:[...t||[]],input:"",showSuggestions:!1,activeIndex:-1}),Go[e]}function H1(){Go={}}function Va(e,t=""){return e?`/api/projects/${e}/settings${t}`:`/api/settings${t}`}async function _i(e){var t,s,i,r,o;Zi=e||null;try{let n=await fetch(Va(e));if(!n.ok)throw new Error(`HTTP ${n.status}`);if(K=await n.json(),K.worca||(K.worca={}),!K.worca.stages)K.worca.stages={...Yo};else for(let a of Mh)K.worca.stages[a]||(K.worca.stages[a]={...Yo[a]});if(!K.worca.stages.preflight)K.worca.stages.preflight={enabled:!0,script:".claude/worca/scripts/preflight_checks.py",require:[]};else{let a=K.worca.stages.preflight;a.enabled===void 0&&(a.enabled=!0),a.script||(a.script=".claude/worca/scripts/preflight_checks.py"),a.require||(a.require=[])}K.worca.plan_path_template||(K.worca.plan_path_template="docs/plans/{timestamp}-{title_slug}.md"),K.worca.defaults||(K.worca.defaults={msize:1,mloops:1}),K.worca.pricing||(K.worca.pricing={models:{},server_tools:{},currency:"USD"}),K.worca.pricing.models||(K.worca.pricing.models={});for(let a of Ih)K.worca.pricing.models[a]={...dm,...K.worca.pricing.models[a]||{}};if(K.worca.pricing.server_tools||(K.worca.pricing.server_tools={}),!K.worca.governance)K.worca.governance={...gi};else{let a=K.worca.governance,c=a.subagent_dispatch!==void 0,l=a.dispatch!==void 0&&!c;K.worca.governance={...gi,...a,guards:{...gi.guards,...a.guards||{}},subagent_dispatch:{...gi.subagent_dispatch,...c?a.subagent_dispatch:l?a.dispatch:{}},_legacy_dispatch:l}}K.worca.milestones?(t=K.worca.milestones).plan_approval??(t.plan_approval=!0):K.worca.milestones={plan_approval:!0},K.worca.circuit_breaker?((s=K.worca.circuit_breaker).enabled??(s.enabled=!0),(i=K.worca.circuit_breaker).max_consecutive_failures??(i.max_consecutive_failures=3)):K.worca.circuit_breaker={enabled:!0,max_consecutive_failures:3},K.worca.parallel?((r=K.worca.parallel).worktree_base_dir??(r.worktree_base_dir=".worktrees"),(o=K.worca.parallel).default_base_branch??(o.default_base_branch="main")):K.worca.parallel={worktree_base_dir:".worktrees",default_base_branch:"main"},K.worca.events||(K.worca.events={enabled:!0,agent_telemetry:!1,hook_events:!0,rate_limit_ms:1e3}),K.worca.budget||(K.worca.budget={}),K.worca.webhooks||(K.worca.webhooks=[]),Wa=N1(K.worca),ja=!1,H1();try{let a=await fetch("/api/subagents");if(a.ok){let c=await a.json();c?.ok&&Array.isArray(c.subagents)&&(pm=c.subagents)}}catch{}}catch(n){K=null,fe="error",ze=`Failed to load settings: ${n.message}`}}async function Jo(e,t,s){fe="saving",ze="",t();try{let i=await fetch(Va(s||Zi),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();K={worca:r.worca,permissions:r.permissions};let o=hm(r.autoMigrated);o>0&&(Wa=!1,ja=!0),fe="success",ze=o>0?`${o} project setting${o===1?" was":"s were"} moved to global Preferences`:"Settings saved successfully"}catch(i){fe="error",ze=`Failed to save: ${i.message}`}t(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",t())},3e3)}async function W1(e,t,s){fe="saving",ze="",t();try{let i=await fetch(Va(s||Zi,`/${e}`),{method:"DELETE"});if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();K={worca:r.worca,permissions:r.permissions},await _i(s||Zi),fe="success",ze=`${e.charAt(0).toUpperCase()+e.slice(1)} reset to defaults`}catch(i){fe="error",ze=`Failed to reset: ${i.message}`}t(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",t())},3e3)}function Zo(e,t){let s=e.charAt(0).toUpperCase()+e.slice(1);wt({label:`Reset ${s}`,message:u`Are you sure you want to reset <strong>${s}</strong> settings to their defaults?`,confirmLabel:"Reset",confirmVariant:"danger",onConfirm:()=>W1(e,t)},t)}function j1(){let e={};for(let t of Xo){let s=document.getElementById(`agent-${t}-model`),i=document.getElementById(`agent-${t}-turns`);e[t]={model:s?.value||"sonnet",max_turns:parseInt(i?.value,10)||30}}return e}function V1(){let e={};for(let h of["implement_test","pr_changes","restart_planning"]){let d=document.getElementById(`loop-${h}`);e[h]=parseInt(d?.value,10)||0}let s=document.getElementById("plan-path-template")?.value?.trim()||"",i=document.getElementById("defaults-msize"),r=document.getElementById("defaults-mloops"),o={msize:parseInt(i?.value,10)||1,mloops:parseInt(r?.value,10)||1},n={plan_approval:document.getElementById("milestone-plan-approval")?.checked??!0};document.getElementById("milestone-pr-approval")?.checked===!0&&(n.pr_approval=!0);let c={enabled:document.getElementById("cb-enabled")?.checked??!0,max_consecutive_failures:parseInt(document.getElementById("cb-max-failures")?.value,10)||3},l={worktree_base_dir:document.getElementById("parallel-worktree-base-dir")?.value?.trim()||".worktrees",default_base_branch:document.getElementById("parallel-default-base-branch")?.value?.trim()||"main"};return{loops:e,plan_path_template:s,defaults:o,milestones:n,circuit_breaker:c,parallel:l}}function U1(){let e={};for(let t of Mh){let s=document.getElementById(`stage-${t}-enabled`),i=document.getElementById(`stage-${t}-agent`);e[t]={agent:i?.value||Yo[t].agent,enabled:s?.checked??!0}}return e}function q1(){let e=document.getElementById("preflight-enabled"),t=document.getElementById("preflight-script"),i=(document.getElementById("preflight-require")?.value||"").trim();return{enabled:e?.checked??!0,script:t?.value?.trim()||".claude/worca/scripts/preflight_checks.py",require:i?i.split(",").map(r=>r.trim()).filter(Boolean):[]}}function K1(){let e={};for(let r of um){let o=document.getElementById(`guard-${r.key}`);e[r.key]=o?.checked??!0}let t=document.getElementById("test-gate-strikes"),s=parseInt(t?.value,10)||2,i={};for(let r of Xo)i[r]=[...Go[r]?.tags||[]];return{guards:e,test_gate_strikes:s,subagent_dispatch:i}}function G1(e){return e>=1e9?{value:e/1e9,unit:"GB"}:{value:e/1e6,unit:"MB"}}function Y1(){let e=document.getElementById("global-disk-threshold-value"),t=document.getElementById("global-disk-threshold-unit"),s=parseFloat(e?.value)||2,r=(t?.value||"GB")==="GB"?1e9:1e6;return s*r}function X1(){let e=Y1(),t=document.getElementById("global-cleanup-policy"),s=document.getElementById("global-classifier-model"),i=document.getElementById("global-max-concurrent");return{worca:{ui:{worktree_disk_warning_bytes:e},parallel:{cleanup_policy:t?.value||"never",max_concurrent_pipelines:parseInt(i?.value,10)||10},circuit_breaker:{classifier_model:s?.value||"haiku"}}}}async function J1(e,t,s){fe="saving",ze="",t();try{let i=await fetch("/api/preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!i.ok)throw new Error(`HTTP ${i.status}`);let r=await i.json();if(r.ok&&s){let o=r.preferences?.worca??{};s({worktreeDiskWarningBytes:o.ui?.worktree_disk_warning_bytes??2e9,classifierModel:o.circuit_breaker?.classifier_model??"haiku",cleanupPolicy:o.parallel?.cleanup_policy??"never",maxConcurrentPipelines:o.parallel?.max_concurrent_pipelines??10})}fe="success",ze="Preferences saved successfully"}catch(i){fe="error",ze=`Failed to save: ${i.message}`}t(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",t())},3e3)}function Z1(){let e=document.querySelectorAll(".perm-input");return Array.from(e).map(t=>t.value.trim()).filter(t=>t.length>0)}function Q1(){let e={};for(let i of Ih){e[i]={};for(let r of Ha){let o=document.getElementById(`pricing-${i}-${r.key}`);e[i][r.key]=parseFloat(o?.value)||0}}let t=document.getElementById("pricing-server_tools-web_search_per_request"),s=document.getElementById("pricing-server_tools-web_fetch_per_request");return{models:e,server_tools:{web_search_per_request:parseFloat(t?.value)||0,web_fetch_per_request:parseFloat(s?.value)||0},currency:K?.worca?.pricing?.currency||"USD",last_updated:new Date().toISOString().slice(0,10)}}function Oh(){return K?.worca?.defaults||{msize:1,mloops:1}}function eS(e,t){let s=e.agents||{};return u`
934
934
  <div class="settings-tab-content">
935
935
  <div class="settings-cards">
936
936
  ${Xo.map(i=>{let r=s[i]||{};return u`
@@ -954,7 +954,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
954
954
  `})}
955
955
  </div>
956
956
  <div class="settings-tab-actions">
957
- <sl-button variant="primary" size="small" @click=${()=>{let i=W1();Jo({worca:{agents:i}},t)}}>
957
+ <sl-button variant="primary" size="small" @click=${()=>{let i=j1();Jo({worca:{agents:i}},t)}}>
958
958
  ${E(R(us,14))}
959
959
  Save
960
960
  </sl-button>
@@ -964,7 +964,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
964
964
  </sl-button>
965
965
  </div>
966
966
  </div>
967
- `}function eS(e,t){let s=e.loops||{},i=e.stages||Yo,r=e.milestones||{},o=e.circuit_breaker||{},n=e.parallel||{},a=i.preflight||{enabled:!0,script:".claude/worca/scripts/preflight_checks.py",require:[]};return u`
967
+ `}function tS(e,t){let s=e.loops||{},i=e.stages||Yo,r=e.milestones||{},o=e.circuit_breaker||{},n=e.parallel||{},a=i.preflight||{enabled:!0,script:".claude/worca/scripts/preflight_checks.py",require:[]};return u`
968
968
  <div class="settings-tab-content">
969
969
  <h3 class="settings-section-title">Preflight</h3>
970
970
  <div class="settings-grid">
@@ -997,7 +997,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
997
997
  <div class="settings-card-body">
998
998
  <div class="settings-field">
999
999
  <label class="settings-label">Agent</label>
1000
- <sl-select id="stage-${c}-agent" .value="${l.agent||M1[c]}" size="small" hoist>
1000
+ <sl-select id="stage-${c}-agent" .value="${l.agent||I1[c]}" size="small" hoist>
1001
1001
  ${Xo.map(d=>u`<sl-option value="${d}">${d}</sl-option>`)}
1002
1002
  </sl-select>
1003
1003
  </div>
@@ -1081,7 +1081,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1081
1081
  </div>
1082
1082
 
1083
1083
  <div class="settings-tab-actions">
1084
- <sl-button variant="primary" size="small" @click=${()=>{let{loops:c,plan_path_template:l,defaults:h,milestones:d,circuit_breaker:m,parallel:p}=j1(),f=V1();f.preflight=U1(),Jo({worca:{loops:c,stages:f,plan_path_template:l,defaults:h,milestones:d,circuit_breaker:m,parallel:p}},t)}}>
1084
+ <sl-button variant="primary" size="small" @click=${()=>{let{loops:c,plan_path_template:l,defaults:h,milestones:d,circuit_breaker:m,parallel:p}=V1(),f=U1();f.preflight=q1(),Jo({worca:{loops:c,stages:f,plan_path_template:l,defaults:h,milestones:d,circuit_breaker:m,parallel:p}},t)}}>
1085
1085
  ${E(R(us,14))}
1086
1086
  Save
1087
1087
  </sl-button>
@@ -1091,7 +1091,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1091
1091
  </sl-button>
1092
1092
  </div>
1093
1093
  </div>
1094
- `}function tS(e,t,s,i){let r=N1(e,t),o=pm||im,n=rm(r.input,o,r.tags,Ji),a=om(r.tags,s);function c(f){r.input=f.target.value,r.showSuggestions=!0,r.activeIndex=-1,i()}function l(){r.showSuggestions=!0,i()}function h(){setTimeout(()=>{r.showSuggestions=!1,i()},150)}function d(f){if(f.key==="Enter"){if(f.preventDefault(),r.activeIndex>=0&&n[r.activeIndex]){let _=n[r.activeIndex];if(!_.denied){let w=za(r.tags,_.name,Ji);r.tags=w.tags,r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}}else if(r.input.trim()){let _=za(r.tags,r.input,Ji);r.tags=_.tags,r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}}else f.key==="Backspace"&&!r.input&&r.tags.length>0?(r.tags=Ph(r.tags,r.tags[r.tags.length-1]),i()):f.key==="Escape"?(r.showSuggestions=!1,r.activeIndex=-1,i()):f.key==="ArrowDown"?(f.preventDefault(),r.activeIndex=Math.min(r.activeIndex+1,n.length-1),i()):f.key==="ArrowUp"&&(f.preventDefault(),r.activeIndex=Math.max(r.activeIndex-1,-1),i())}function m(f){if(f.denied)return;let _=za(r.tags,f.name,Ji);r.tags=_.tags,r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}function p(){r.tags=[...s],r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}return u`
1094
+ `}function sS(e,t,s,i){let r=F1(e,t),o=pm||im,n=rm(r.input,o,r.tags,Ji),a=om(r.tags,s);function c(f){r.input=f.target.value,r.showSuggestions=!0,r.activeIndex=-1,i()}function l(){r.showSuggestions=!0,i()}function h(){setTimeout(()=>{r.showSuggestions=!1,i()},150)}function d(f){if(f.key==="Enter"){if(f.preventDefault(),r.activeIndex>=0&&n[r.activeIndex]){let _=n[r.activeIndex];if(!_.denied){let w=za(r.tags,_.name,Ji);r.tags=w.tags,r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}}else if(r.input.trim()){let _=za(r.tags,r.input,Ji);r.tags=_.tags,r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}}else f.key==="Backspace"&&!r.input&&r.tags.length>0?(r.tags=Ph(r.tags,r.tags[r.tags.length-1]),i()):f.key==="Escape"?(r.showSuggestions=!1,r.activeIndex=-1,i()):f.key==="ArrowDown"?(f.preventDefault(),r.activeIndex=Math.min(r.activeIndex+1,n.length-1),i()):f.key==="ArrowUp"&&(f.preventDefault(),r.activeIndex=Math.max(r.activeIndex-1,-1),i())}function m(f){if(f.denied)return;let _=za(r.tags,f.name,Ji);r.tags=_.tags,r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}function p(){r.tags=[...s],r.input="",r.showSuggestions=!1,r.activeIndex=-1,i()}return u`
1095
1095
  <div class="settings-dispatch-row">
1096
1096
  <span class="settings-dispatch-agent">${e}</span>
1097
1097
  <div class="dispatch-tag-input-wrapper">
@@ -1128,7 +1128,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1128
1128
  @click=${p}
1129
1129
  >${E(R(Ii,14))}</sl-icon-button>`:u`<span class="dispatch-reset-placeholder"></span>`}
1130
1130
  </div>
1131
- `}function sS(e,t,s){let i=e.governance||gi,r=i.guards||gi.guards,o=i.subagent_dispatch||gi.subagent_dispatch,n=i._legacy_dispatch===!0;t.allow||(t.allow=[]);let a=t.allow;return u`
1131
+ `}function iS(e,t,s){let i=e.governance||gi,r=i.guards||gi.guards,o=i.subagent_dispatch||gi.subagent_dispatch,n=i._legacy_dispatch===!0;t.allow||(t.allow=[]);let a=t.allow;return u`
1132
1132
  <div class="settings-tab-content">
1133
1133
  <h3 class="settings-section-title">Guard Rules</h3>
1134
1134
  <div class="settings-switches">
@@ -1163,7 +1163,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1163
1163
  <strong>Denylist:</strong> <code>general-purpose</code> is always blocked and cannot be added to dispatch rules.
1164
1164
  </sl-alert>
1165
1165
  <div class="settings-dispatch-table">
1166
- ${Xo.map(c=>tS(c,o[c]||[],gi.subagent_dispatch[c]||[],s))}
1166
+ ${Xo.map(c=>sS(c,o[c]||[],gi.subagent_dispatch[c]||[],s))}
1167
1167
  </div>
1168
1168
 
1169
1169
  <h3 class="settings-section-title">Permissions</h3>
@@ -1182,7 +1182,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1182
1182
  </sl-button>
1183
1183
 
1184
1184
  <div class="settings-tab-actions">
1185
- <sl-button variant="primary" size="small" @click=${()=>{let c=q1(),l=J1();Jo({worca:{governance:c},permissions:{allow:l}},s)}}>
1185
+ <sl-button variant="primary" size="small" @click=${()=>{let c=K1(),l=Z1();Jo({worca:{governance:c},permissions:{allow:l}},s)}}>
1186
1186
  ${E(R(us,14))}
1187
1187
  Save
1188
1188
  </sl-button>
@@ -1192,18 +1192,18 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1192
1192
  </sl-button>
1193
1193
  </div>
1194
1194
  </div>
1195
- `}var mi=null,Ir=!1,Or=null;async function Fa(e,t=!1){Ir=!0,Or=null,e();try{let i=await fetch(t?"/api/versions?force=1":"/api/versions");if(!i.ok)throw new Error(`HTTP ${i.status}`);mi=await i.json()}catch(s){Or=s.message}finally{Ir=!1,e()}}function iS(e){if(!e)return"";let t=Date.now()-new Date(e).getTime(),s=Math.floor(t/1e3);if(s<60)return"just now";let i=Math.floor(s/60);return i<60?`${i}m ago`:`${Math.floor(i/60)}h ago`}function rS(e,t){navigator.clipboard.writeText(e).then(()=>{let s=t.querySelector(".version-copy-icon");s&&(s.textContent="\u2713",setTimeout(()=>{s.textContent=""},1500))})}function fi(e,t,s,i){if(t===void 0)return b;let r=u`${t||"\u2014"}`;return u`
1195
+ `}var mi=null,Ir=!1,Or=null;async function Fa(e,t=!1){Ir=!0,Or=null,e();try{let i=await fetch(t?"/api/versions?force=1":"/api/versions");if(!i.ok)throw new Error(`HTTP ${i.status}`);mi=await i.json()}catch(s){Or=s.message}finally{Ir=!1,e()}}function rS(e){if(!e)return"";let t=Date.now()-new Date(e).getTime(),s=Math.floor(t/1e3);if(s<60)return"just now";let i=Math.floor(s/60);return i<60?`${i}m ago`:`${Math.floor(i/60)}h ago`}function oS(e,t){navigator.clipboard.writeText(e).then(()=>{let s=t.querySelector(".version-copy-icon");s&&(s.textContent="\u2713",setTimeout(()=>{s.textContent=""},1500))})}function fi(e,t,s,i){if(t===void 0)return b;let r=u`${t||"\u2014"}`;return u`
1196
1196
  <div class="version-row">
1197
1197
  <span class="version-row-label">${e}</span>
1198
1198
  <span class="version-row-value">${t&&s?u`
1199
1199
  <sl-tooltip content="Copy: ${s}">
1200
- <button class="version-copy-btn" @click=${o=>rS(s,o.currentTarget)}>
1200
+ <button class="version-copy-btn" @click=${o=>oS(s,o.currentTarget)}>
1201
1201
  <span class="version-copy-icon">${E(R(He,12))}</span>
1202
1202
  </button>
1203
1203
  </sl-tooltip>
1204
1204
  `:b}${i?u`<sl-tooltip content="${i}">${r}</sl-tooltip>`:r}</span>
1205
1205
  </div>
1206
- `}function oS(e){if(!mi&&!Ir&&!Or&&Fa(e),Ir&&!mi)return u`
1206
+ `}function nS(e){if(!mi&&!Ir&&!Or&&Fa(e),Ir&&!mi)return u`
1207
1207
  <h3 class="settings-section-title">Worca Versions</h3>
1208
1208
  <div class="settings-card">
1209
1209
  <div class="settings-muted">Loading version info…</div>
@@ -1258,9 +1258,9 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1258
1258
  ${E(R(Be,14))}
1259
1259
  Refresh
1260
1260
  </sl-button>
1261
- <span class="version-refresh-hint">Updated ${iS(o)}</span>
1261
+ <span class="version-refresh-hint">Updated ${rS(o)}</span>
1262
1262
  </div>
1263
- `}function nS(e,{onThemeToggle:t,onSaveSourceRepo:s,onSaveGlobals:i,rerender:r,globals:o}){let n=e?.theme||"light",a=e?.source_repo||"",c=o||{},l=K1(c.worktreeDiskWarningBytes??2e9),h=c.cleanupPolicy||"never",d=c.classifierModel||"haiku",m=c.maxConcurrentPipelines??10;return u`
1263
+ `}function aS(e,{onThemeToggle:t,onSaveSourceRepo:s,onSaveGlobals:i,rerender:r,globals:o}){let n=e?.theme||"light",a=e?.source_repo||"",c=o||{},l=G1(c.worktreeDiskWarningBytes??2e9),h=c.cleanupPolicy||"never",d=c.classifierModel||"haiku",m=c.maxConcurrentPipelines??10;return u`
1264
1264
  <div class="settings-tab-content">
1265
1265
  <h3 class="settings-section-title">Appearance</h3>
1266
1266
  <div class="settings-switches">
@@ -1326,15 +1326,15 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1326
1326
  </div>
1327
1327
 
1328
1328
  <div class="settings-tab-actions">
1329
- <sl-button variant="primary" size="small" @click=${()=>{let p=Y1();X1(p,r,i)}}>
1329
+ <sl-button variant="primary" size="small" @click=${()=>{let p=X1();J1(p,r,i)}}>
1330
1330
  ${E(R(us,14))}
1331
1331
  Save Global Settings
1332
1332
  </sl-button>
1333
1333
  </div>
1334
1334
 
1335
- ${r?oS(r):b}
1335
+ ${r?nS(r):b}
1336
1336
  </div>
1337
- `}function aS(e,t){let s=e.pricing||{},i=s.models||{},r=s.server_tools||{};return u`
1337
+ `}function lS(e,t){let s=e.pricing||{},i=s.models||{},r=s.server_tools||{};return u`
1338
1338
  <div class="settings-tab-content">
1339
1339
  <h3 class="settings-section-title">Pricing</h3>
1340
1340
  <div class="pricing-table-wrap">
@@ -1415,7 +1415,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1415
1415
  </div>
1416
1416
 
1417
1417
  <div class="settings-tab-actions">
1418
- <sl-button variant="primary" size="small" @click=${()=>{let o=Z1();Jo({worca:{pricing:o}},t)}}>
1418
+ <sl-button variant="primary" size="small" @click=${()=>{let o=Q1();Jo({worca:{pricing:o}},t)}}>
1419
1419
  ${E(R(us,14))}
1420
1420
  Save
1421
1421
  </sl-button>
@@ -1425,7 +1425,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1425
1425
  </sl-button>
1426
1426
  </div>
1427
1427
  </div>
1428
- `}var lm={run_completed:{label:"Run Completed",desc:"When a pipeline run finishes successfully"},run_failed:{label:"Run Failed",desc:"When a pipeline run fails at any stage"},approval_needed:{label:"Approval Required",desc:"When a stage is waiting for plan or PR approval"},test_failures:{label:"Test Failures",desc:"When a test iteration ends with failures"},loop_limit_warning:{label:"Loop Limit Warning",desc:"When a stage approaches its configured loop limit"}};function lS(e,{rerender:t,onSaveNotifications:s,onRequestPermission:i}){let r=e?.notifications||{},o=typeof Notification<"u"?Notification.permission:"unsupported",n=o==="granted"&&(r.enabled??!0),a=r.sound??!1,c=r.events||{},l=o==="granted"?u`<sl-badge variant="success" pill>Granted</sl-badge>`:o==="denied"?u`<sl-badge variant="danger" pill>Blocked</sl-badge>`:o==="default"?u`<sl-badge variant="neutral" pill>Not Yet Asked</sl-badge>`:u`<sl-badge variant="neutral" pill>Not Supported</sl-badge>`,h=o!=="granted";return u`
1428
+ `}var lm={run_completed:{label:"Run Completed",desc:"When a pipeline run finishes successfully"},run_failed:{label:"Run Failed",desc:"When a pipeline run fails at any stage"},approval_needed:{label:"Approval Required",desc:"When a stage is waiting for plan or PR approval"},test_failures:{label:"Test Failures",desc:"When a test iteration ends with failures"},loop_limit_warning:{label:"Loop Limit Warning",desc:"When a stage approaches its configured loop limit"}};function cS(e,{rerender:t,onSaveNotifications:s,onRequestPermission:i}){let r=e?.notifications||{},o=typeof Notification<"u"?Notification.permission:"unsupported",n=o==="granted"&&(r.enabled??!0),a=r.sound??!1,c=r.events||{},l=o==="granted"?u`<sl-badge variant="success" pill>Granted</sl-badge>`:o==="denied"?u`<sl-badge variant="danger" pill>Blocked</sl-badge>`:o==="default"?u`<sl-badge variant="neutral" pill>Not Yet Asked</sl-badge>`:u`<sl-badge variant="neutral" pill>Not Supported</sl-badge>`,h=o!=="granted";return u`
1429
1429
  <div class="settings-tab-content">
1430
1430
  <h3 class="settings-section-title">Browser Notifications</h3>
1431
1431
  <div style="display: flex; align-items: center; gap: 12px; margin-bottom: 8px;">
@@ -1470,7 +1470,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1470
1470
  </sl-button>
1471
1471
  </div>
1472
1472
  </div>
1473
- `}var Na={};function cS(){return{enabled:document.getElementById("events-enabled")?.checked??!0,agent_telemetry:document.getElementById("events-agent-telemetry")?.checked??!1,hook_events:document.getElementById("events-hook-events")?.checked??!0,rate_limit_ms:parseInt(document.getElementById("events-rate-limit-ms")?.value,10)||1e3}}function hS(){let e={},t=parseFloat(document.getElementById("budget-max-cost")?.value);!Number.isNaN(t)&&t>0&&(e.max_cost_usd=t);let s=parseInt(document.getElementById("budget-warning-pct")?.value,10);return Number.isNaN(s)||(e.warning_pct=s),e}function dS(){return(K?.worca?.webhooks||[]).map((t,s)=>{let i=(document.getElementById(`webhook-${s}-events`)?.value||"").trim();return{url:document.getElementById(`webhook-${s}-url`)?.value?.trim()||"",secret:document.getElementById(`webhook-${s}-secret`)?.value||"",events:i?i.split(",").map(r=>r.trim()).filter(Boolean):[],timeout_ms:parseInt(document.getElementById(`webhook-${s}-timeout-ms`)?.value,10)||1e4,max_retries:parseInt(document.getElementById(`webhook-${s}-retries`)?.value,10)||3,rate_limit_ms:parseInt(document.getElementById(`webhook-${s}-rate-limit-ms`)?.value,10)||1e3,control:document.getElementById(`webhook-${s}-control`)?.checked??!1}})}function uS(e,t,s){let i=Na[t];return u`
1473
+ `}var Na={};function hS(){return{enabled:document.getElementById("events-enabled")?.checked??!0,agent_telemetry:document.getElementById("events-agent-telemetry")?.checked??!1,hook_events:document.getElementById("events-hook-events")?.checked??!0,rate_limit_ms:parseInt(document.getElementById("events-rate-limit-ms")?.value,10)||1e3}}function dS(){let e={},t=parseFloat(document.getElementById("budget-max-cost")?.value);!Number.isNaN(t)&&t>0&&(e.max_cost_usd=t);let s=parseInt(document.getElementById("budget-warning-pct")?.value,10);return Number.isNaN(s)||(e.warning_pct=s),e}function uS(){return(K?.worca?.webhooks||[]).map((t,s)=>{let i=(document.getElementById(`webhook-${s}-events`)?.value||"").trim();return{url:document.getElementById(`webhook-${s}-url`)?.value?.trim()||"",secret:document.getElementById(`webhook-${s}-secret`)?.value||"",events:i?i.split(",").map(r=>r.trim()).filter(Boolean):[],timeout_ms:parseInt(document.getElementById(`webhook-${s}-timeout-ms`)?.value,10)||1e4,max_retries:parseInt(document.getElementById(`webhook-${s}-retries`)?.value,10)||3,rate_limit_ms:parseInt(document.getElementById(`webhook-${s}-rate-limit-ms`)?.value,10)||1e3,control:document.getElementById(`webhook-${s}-control`)?.checked??!1}})}function pS(e,t,s){let i=Na[t];return u`
1474
1474
  <div class="settings-card webhook-card">
1475
1475
  <div class="settings-card-header">
1476
1476
  <span class="settings-card-title">Webhook ${t+1}</span>
@@ -1521,7 +1521,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1521
1521
  </div>
1522
1522
  </div>
1523
1523
  </div>
1524
- `}function pS(e,t){let s=e.events||{enabled:!0,agent_telemetry:!1,hook_events:!0,rate_limit_ms:1e3},i=e.budget||{},r=e.webhooks||[];return u`
1524
+ `}function fS(e,t){let s=e.events||{enabled:!0,agent_telemetry:!1,hook_events:!0,rate_limit_ms:1e3},i=e.budget||{},r=e.webhooks||[];return u`
1525
1525
  <div class="settings-tab-content">
1526
1526
  <h3 class="settings-section-title">Event System</h3>
1527
1527
  <div class="settings-switches">
@@ -1563,7 +1563,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1563
1563
  <h3 class="settings-section-title">Webhooks</h3>
1564
1564
  <div class="webhooks-list">
1565
1565
  ${r.length===0?u`<span class="settings-muted">No webhooks configured</span>`:b}
1566
- ${r.map((o,n)=>uS(o,n,t))}
1566
+ ${r.map((o,n)=>pS(o,n,t))}
1567
1567
  </div>
1568
1568
  <sl-button size="small" variant="text" @click=${()=>{K.worca.webhooks=[...K.worca.webhooks||[],{url:"",secret:"",events:[],timeout_ms:1e4,max_retries:3,rate_limit_ms:1e3,control:!1}],t()}}>
1569
1569
  ${E(R(ds,14))}
@@ -1571,7 +1571,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1571
1571
  </sl-button>
1572
1572
 
1573
1573
  <div class="settings-tab-actions">
1574
- <sl-button variant="primary" size="small" @click=${()=>{let o=cS(),n=hS(),a=dS();Jo({worca:{events:o,budget:n,webhooks:a}},t)}}>
1574
+ <sl-button variant="primary" size="small" @click=${()=>{let o=hS(),n=dS(),a=uS();Jo({worca:{events:o,budget:n,webhooks:a}},t)}}>
1575
1575
  ${E(R(us,14))}
1576
1576
  Save
1577
1577
  </sl-button>
@@ -1581,7 +1581,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1581
1581
  </sl-button>
1582
1582
  </div>
1583
1583
  </div>
1584
- `}async function fS(e){fe="saving",ze="",e();try{let t=await fetch(Va(Zi),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worca:{}})});if(!t.ok)throw new Error(`HTTP ${t.status}`);let s=await t.json();K={worca:s.worca,permissions:s.permissions},Wa=!1,ja=!0;let i=hm(s.autoMigrated);fe="success",ze=i>0?`${i} project setting${i===1?" was":"s were"} moved to global Preferences`:"Settings saved successfully"}catch(t){fe="error",ze=`Migration failed: ${t.message}`}e(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",e())},3e3)}function mS(e){return!Wa||ja?b:u`
1584
+ `}async function mS(e){fe="saving",ze="",e();try{let t=await fetch(Va(Zi),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worca:{}})});if(!t.ok)throw new Error(`HTTP ${t.status}`);let s=await t.json();K={worca:s.worca,permissions:s.permissions},Wa=!1,ja=!0;let i=hm(s.autoMigrated);fe="success",ze=i>0?`${i} project setting${i===1?" was":"s were"} moved to global Preferences`:"Settings saved successfully"}catch(t){fe="error",ze=`Migration failed: ${t.message}`}e(),fe==="success"&&setTimeout(()=>{fe==="success"&&(fe=null,ze="",e())},3e3)}function gS(e){return!Wa||ja?b:u`
1585
1585
  <sl-alert variant="warning" open class="migration-banner">
1586
1586
  <strong>Legacy project settings detected.</strong>
1587
1587
  Some settings in this project belong in global Preferences.
@@ -1590,7 +1590,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1590
1590
  variant="warning"
1591
1591
  outline
1592
1592
  style="margin-left: 8px;"
1593
- @click=${()=>fS(e)}
1593
+ @click=${()=>mS(e)}
1594
1594
  >Migrate now</sl-button>
1595
1595
  </sl-alert>
1596
1596
  `}function fm(e){return!fe||fe==="saving"?b:u`
@@ -1600,7 +1600,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1600
1600
  ${ze}
1601
1601
  </sl-alert>
1602
1602
  </div>
1603
- `}function gS(e,{onProjectAdd:t,onProjectRemove:s,onProjectsRefresh:i,rerender:r}){let o=e||[];!mi&&!Ir&&!Or&&Fa(r);let n=mi?.activeWorcaCc||null;function a(h){wt({label:"Remove Project",message:u`Are you sure you want to remove <strong>${h}</strong>? This only unregisters the project — no files are deleted.`,confirmLabel:"Remove",confirmVariant:"danger",onConfirm:()=>{fetch(`/api/projects/${h}`,{method:"DELETE"}).then(d=>d.json()).then(d=>{d.ok&&s?.(h)}).catch(()=>{})}},r)}function c(h){wt({label:"Update Worca",message:u`Update worca pipeline files in <strong>${h}</strong>?`,confirmLabel:"Update",confirmVariant:"primary",onConfirm:()=>{fetch(`/api/projects/${h}/worca-setup`,{method:"POST"}).then(d=>d.json()).then(d=>{d.ok&&setTimeout(()=>i?.(),3e3)}).catch(()=>{})}},r)}function l(){t?.({openDialog:!0})}return u`
1603
+ `}function _S(e,{onProjectAdd:t,onProjectRemove:s,onProjectsRefresh:i,rerender:r}){let o=e||[];!mi&&!Ir&&!Or&&Fa(r);let n=mi?.activeWorcaCc||null;function a(h){wt({label:"Remove Project",message:u`Are you sure you want to remove <strong>${h}</strong>? This only unregisters the project — no files are deleted.`,confirmLabel:"Remove",confirmVariant:"danger",onConfirm:()=>{fetch(`/api/projects/${h}`,{method:"DELETE"}).then(d=>d.json()).then(d=>{d.ok&&s?.(h)}).catch(()=>{})}},r)}function c(h){wt({label:"Update Worca",message:u`Update worca pipeline files in <strong>${h}</strong>?`,confirmLabel:"Update",confirmVariant:"primary",onConfirm:()=>{fetch(`/api/projects/${h}/worca-setup`,{method:"POST"}).then(d=>d.json()).then(d=>{d.ok&&setTimeout(()=>i?.(),3e3)}).catch(()=>{})}},r)}function l(){t?.({openDialog:!0})}return u`
1604
1604
  <div class="settings-card">
1605
1605
  <h3>Projects</h3>
1606
1606
  <div class="projects-list">
@@ -1664,15 +1664,15 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1664
1664
  Integrations
1665
1665
  </sl-tab>
1666
1666
 
1667
- <sl-tab-panel name="projects">${gS(c,{onProjectAdd:l,onProjectRemove:h,onProjectsRefresh:d,rerender:t})}</sl-tab-panel>
1668
- <sl-tab-panel name="notifications">${lS(e,{rerender:t,onSaveNotifications:r,onRequestPermission:o})}</sl-tab-panel>
1669
- <sl-tab-panel name="preferences">${nS(e,{onThemeToggle:s,onSaveSourceRepo:i,onSaveGlobals:a,rerender:t,globals:n})}</sl-tab-panel>
1667
+ <sl-tab-panel name="projects">${_S(c,{onProjectAdd:l,onProjectRemove:h,onProjectsRefresh:d,rerender:t})}</sl-tab-panel>
1668
+ <sl-tab-panel name="notifications">${cS(e,{rerender:t,onSaveNotifications:r,onRequestPermission:o})}</sl-tab-panel>
1669
+ <sl-tab-panel name="preferences">${aS(e,{onThemeToggle:s,onSaveSourceRepo:i,onSaveGlobals:a,rerender:t,globals:n})}</sl-tab-panel>
1670
1670
  <sl-tab-panel name="integrations">${am(m||{},{onStartEdit:p,onCancelEdit:f,onFieldChange:_,onEventToggle:w,onSave:k,onRemove:$,onDetect:y,onToggleEnabled:C})}</sl-tab-panel>
1671
1671
  </sl-tab-group>
1672
1672
  </div>
1673
1673
  `}function gm(e,{rerender:t,currentProjectId:s}={}){if(s!==Zi)return _i(s).then(()=>t()),u`<div class="empty-state">Loading settings\u2026</div>`;if(!K)return u`<div class="empty-state">Loading settings\u2026</div>`;let i=K.worca||{},r=K.permissions||{};return u`
1674
1674
  ${fm(t)}
1675
- ${mS(t)}
1675
+ ${gS(t)}
1676
1676
  ${uo()}
1677
1677
  <div class="settings-page">
1678
1678
  <sl-tab-group>
@@ -1697,14 +1697,14 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1697
1697
  Webhooks
1698
1698
  </sl-tab>
1699
1699
 
1700
- <sl-tab-panel name="agents">${Q1(i,t)}</sl-tab-panel>
1701
- <sl-tab-panel name="pipeline">${eS(i,t)}</sl-tab-panel>
1702
- <sl-tab-panel name="governance">${sS(i,r,t)}</sl-tab-panel>
1703
- <sl-tab-panel name="pricing">${aS(i,t)}</sl-tab-panel>
1704
- <sl-tab-panel name="webhooks">${pS(i,t)}</sl-tab-panel>
1700
+ <sl-tab-panel name="agents">${eS(i,t)}</sl-tab-panel>
1701
+ <sl-tab-panel name="pipeline">${tS(i,t)}</sl-tab-panel>
1702
+ <sl-tab-panel name="governance">${iS(i,r,t)}</sl-tab-panel>
1703
+ <sl-tab-panel name="pricing">${lS(i,t)}</sl-tab-panel>
1704
+ <sl-tab-panel name="webhooks">${fS(i,t)}</sl-tab-panel>
1705
1705
  </sl-tab-group>
1706
1706
  </div>
1707
- `}var Ss="none",os=null,vi="",er=null,zr="",Qo=!1,Nr="",Qi=null,Ua="",Vs=null,Fr="default",bi="",zh="",_m=(()=>{try{return localStorage.getItem("worca.worktree-banner-dismissed")==="1"}catch{return!1}})();function vm(e){return e==="source"?"GitHub Issue URL":e==="spec"?"Spec File Path":""}var Hr=null;function _S(e){if(Qi!==null&&Hr===e)return Promise.resolve(Qi);Hr=e;let t=e?`/api/projects/${e}/branches`:"/api/branches";return fetch(t).then(s=>s.json()).then(s=>(Qi=s.ok&&s.branches||[],Qi)).catch(()=>(Qi=[],[]))}function vS(e){if(er&&Hr===e)return Promise.resolve(er);let t=e?`/api/projects/${e}/plan-files`:"/api/plan-files";return fetch(t).then(s=>s.json()).then(s=>(s.ok&&(er=s.files),er||[])).catch(()=>[])}function bS(){if(!er)return[];if(!zr)return er;let e=zr.toLowerCase();return er.filter(t=>t.name.toLowerCase().includes(e)||t.path.toLowerCase().includes(e))}function yS(e){let t={};for(let s of e)t[s.dir]||(t[s.dir]=[]),t[s.dir].push(s);return t}function wS(e){if(Vs!==null&&Hr===e)return Promise.resolve(Vs);let t=e?`/api/projects/${e}/templates`:"/api/templates";return fetch(t).then(s=>s.json()).then(s=>(s.ok&&(Vs=s.templates),Vs||[])).catch(()=>(Vs=[],[]))}function SS(){let e={worca:[],project:[],user:[]};for(let t of Vs||[]){let s=t.tier;e[s]&&e[s].push(t)}return e}function bm(){return{submitStatus:os,isSubmitting:os==="submitting"}}async function ym({rerender:e,onStarted:t,projectId:s}){let i=document.getElementById("new-run-source-value"),r=document.getElementById("new-run-prompt"),o=document.getElementById("new-run-msize"),n=document.getElementById("new-run-mloops"),a=i?.value?.trim()||"",c=r?.value?.trim()||"",l=Ss!=="none"&&a.length>0,h=!!Nr,d=c.length>0;if(Ss!=="none"&&!a){os="error",vi=`Please enter a ${vm(Ss).toLowerCase()}.`,e();return}if(!l&&!h&&!d){os="error",vi="Please provide at least one of: a work source, a plan file, or a prompt.",e();return}let m=o&&parseInt(o.value,10)||1,p=n&&parseInt(n.value,10)||1;if(bi&&!/^[a-zA-Z0-9._/-]+$/.test(bi)){os="error",vi="PR base branch contains invalid characters.",e();return}os="submitting",vi="",e();try{let _={sourceType:Ss,msize:Math.max(1,Math.min(10,m)),mloops:Math.max(1,Math.min(10,p))};l&&(_.sourceValue=a),d&&(_.prompt=c),h&&(_.planFile=Nr),bi?_.branch=bi:Ua&&(_.branch=Ua),Fr&&Fr!=="default"&&(_.template=Fr);let w=s?`/api/projects/${s}/runs`:"/api/runs",k=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),$=await k.json();if(k.status===409&&$.code==="max_concurrent_exceeded"){os="error",vi=$.error||"Concurrent pipeline limit reached.",e();return}$.ok?(os=null,t()):(os="error",vi=$.error||"Failed to start pipeline",e())}catch(_){os="error",vi=_.message||"Network error",e()}}function Nh(e){let t=e?.maxConcurrentPipelines??10;return(e?.totalRunning??0)>=t}function wm(e,{rerender:t}){let s=e.currentProjectId||null,i=Nh(e);function r(S){Ss=S.target.value,t()}Hr!==s&&(Vs=null),(Qi===null||Hr!==s)&&_S(s).then(()=>t()),Vs===null&&wS(s).then(()=>t());function o(S){Fr=S.target.value,t()}function n(S){Ua=S.target.value,t()}function a(){vS(s).then(()=>{Qo=!0,t()})}function c(S){zr=S.target.value,Nr="",Qo=!0,t()}function l(){setTimeout(()=>{Qo=!1,t()},200)}function h(S){Nr=S.path,zr=S.path,Qo=!1,t()}function d(){Nr="",zr="",t()}function m(){_m=!0;try{localStorage.setItem("worca.worktree-banner-dismissed","1")}catch{}t()}let p=/^[a-zA-Z0-9._/-]+$/;function f(S){bi=S.target.value,zh=bi&&!p.test(bi)?"Invalid characters. Use letters, numbers, dots, hyphens, underscores, or slashes.":"",t()}let _=bS(),w=yS(_),C=!(Ss!=="none")&&!!!Nr?"Prompt (required)":"Additional Instructions (optional)";return u`
1707
+ `}var Ss="none",os=null,vi="",er=null,zr="",Qo=!1,Nr="",Qi=null,Ua="",Vs=null,Fr="default",bi="",zh="",_m=(()=>{try{return localStorage.getItem("worca.worktree-banner-dismissed")==="1"}catch{return!1}})();function vm(e){return e==="source"?"GitHub Issue URL":e==="spec"?"Spec File Path":""}var Hr=null;function vS(e){if(Qi!==null&&Hr===e)return Promise.resolve(Qi);Hr=e;let t=e?`/api/projects/${e}/branches`:"/api/branches";return fetch(t).then(s=>s.json()).then(s=>(Qi=s.ok&&s.branches||[],Qi)).catch(()=>(Qi=[],[]))}function bS(e){if(er&&Hr===e)return Promise.resolve(er);let t=e?`/api/projects/${e}/plan-files`:"/api/plan-files";return fetch(t).then(s=>s.json()).then(s=>(s.ok&&(er=s.files),er||[])).catch(()=>[])}function yS(){if(!er)return[];if(!zr)return er;let e=zr.toLowerCase();return er.filter(t=>t.name.toLowerCase().includes(e)||t.path.toLowerCase().includes(e))}function wS(e){let t={};for(let s of e)t[s.dir]||(t[s.dir]=[]),t[s.dir].push(s);return t}function SS(e){if(Vs!==null&&Hr===e)return Promise.resolve(Vs);let t=e?`/api/projects/${e}/templates`:"/api/templates";return fetch(t).then(s=>s.json()).then(s=>(s.ok&&(Vs=s.templates),Vs||[])).catch(()=>(Vs=[],[]))}function CS(){let e={worca:[],project:[],user:[]};for(let t of Vs||[]){let s=t.tier;e[s]&&e[s].push(t)}return e}function bm(){return{submitStatus:os,isSubmitting:os==="submitting"}}async function ym({rerender:e,onStarted:t,projectId:s}){let i=document.getElementById("new-run-source-value"),r=document.getElementById("new-run-prompt"),o=document.getElementById("new-run-msize"),n=document.getElementById("new-run-mloops"),a=i?.value?.trim()||"",c=r?.value?.trim()||"",l=Ss!=="none"&&a.length>0,h=!!Nr,d=c.length>0;if(Ss!=="none"&&!a){os="error",vi=`Please enter a ${vm(Ss).toLowerCase()}.`,e();return}if(!l&&!h&&!d){os="error",vi="Please provide at least one of: a work source, a plan file, or a prompt.",e();return}let m=o&&parseInt(o.value,10)||1,p=n&&parseInt(n.value,10)||1;if(bi&&!/^[a-zA-Z0-9._/-]+$/.test(bi)){os="error",vi="PR base branch contains invalid characters.",e();return}os="submitting",vi="",e();try{let _={sourceType:Ss,msize:Math.max(1,Math.min(10,m)),mloops:Math.max(1,Math.min(10,p))};l&&(_.sourceValue=a),d&&(_.prompt=c),h&&(_.planFile=Nr),bi?_.branch=bi:Ua&&(_.branch=Ua),Fr&&Fr!=="default"&&(_.template=Fr);let w=s?`/api/projects/${s}/runs`:"/api/runs",k=await fetch(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),$=await k.json();if(k.status===409&&$.code==="max_concurrent_exceeded"){os="error",vi=$.error||"Concurrent pipeline limit reached.",e();return}$.ok?(os=null,t()):(os="error",vi=$.error||"Failed to start pipeline",e())}catch(_){os="error",vi=_.message||"Network error",e()}}function Nh(e){let t=e?.maxConcurrentPipelines??10;return(e?.totalRunning??0)>=t}function wm(e,{rerender:t}){let s=e.currentProjectId||null,i=Nh(e);function r(S){Ss=S.target.value,t()}Hr!==s&&(Vs=null),(Qi===null||Hr!==s)&&vS(s).then(()=>t()),Vs===null&&SS(s).then(()=>t());function o(S){Fr=S.target.value,t()}function n(S){Ua=S.target.value,t()}function a(){bS(s).then(()=>{Qo=!0,t()})}function c(S){zr=S.target.value,Nr="",Qo=!0,t()}function l(){setTimeout(()=>{Qo=!1,t()},200)}function h(S){Nr=S.path,zr=S.path,Qo=!1,t()}function d(){Nr="",zr="",t()}function m(){_m=!0;try{localStorage.setItem("worca.worktree-banner-dismissed","1")}catch{}t()}let p=/^[a-zA-Z0-9._/-]+$/;function f(S){bi=S.target.value,zh=bi&&!p.test(bi)?"Invalid characters. Use letters, numbers, dots, hyphens, underscores, or slashes.":"",t()}let _=yS(),w=wS(_),C=!(Ss!=="none")&&!!!Nr?"Prompt (required)":"Additional Instructions (optional)";return u`
1708
1708
  <div class="new-run-page">
1709
1709
  ${_m?b:u`
1710
1710
  <sl-alert variant="primary" open closable @sl-after-hide=${m}>
@@ -1771,7 +1771,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1771
1771
  </div>
1772
1772
 
1773
1773
  <!-- Section 2: Pipeline -->
1774
- ${(()=>{let S=SS();return u`
1774
+ ${(()=>{let S=CS();return u`
1775
1775
  <div class="new-run-section">
1776
1776
  <h3 class="new-run-section-title">Pipeline</h3>
1777
1777
  <div class="settings-field">
@@ -1862,9 +1862,9 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1862
1862
  </div>
1863
1863
  </div>
1864
1864
  </div>
1865
- `}function Sm(e,t,s){return!s||s.length===0?null:e?.get(t)??s[s.length-1].number}function CS(e){return qn(Object.entries(e))}var xS={pending:Rs,running:Pe,in_progress:Pe,completed:Ls,failed:Ds,error:Ds,paused:St,interrupted:St,skipped:_r};function kS(e,t){return t?.[e]?.label?t[e].label:e.replace(/_/g," ").toUpperCase()}function Cm(e,t={},s=!0){if(!e||typeof e!="object")return u``;let i=CS(e);return i.length===0?u`<div class="empty-state">No stages</div>`:u`
1865
+ `}function Sm(e,t,s){return!s||s.length===0?null:e?.get(t)??s[s.length-1].number}function xS(e){return qn(Object.entries(e))}var kS={pending:Rs,running:Pe,in_progress:Pe,completed:Ls,failed:Ds,error:Ds,paused:St,interrupted:St,skipped:_r};function $S(e,t){return t?.[e]?.label?t[e].label:e.replace(/_/g," ").toUpperCase()}function Cm(e,t={},s=!0){if(!e||typeof e!="object")return u``;let i=xS(e);return i.length===0?u`<div class="empty-state">No stages</div>`:u`
1866
1866
  <div class="stage-timeline">
1867
- ${i.map(([r,o],n)=>{let a=yr(o.status||"pending",s),c=xS[a]||Rs,l=kS(r,t),h=a==="in_progress"||a==="running",d=o.iteration,m=h?"icon-spin":"";return u`
1867
+ ${i.map(([r,o],n)=>{let a=yr(o.status||"pending",s),c=kS[a]||Rs,l=$S(r,t),h=a==="in_progress"||a==="running",d=o.iteration,m=h?"icon-spin":"";return u`
1868
1868
  ${n>0?u`<div class="stage-connector ${i[n-1]?.[1]?.status==="completed"?"completed":""}"></div>`:""}
1869
1869
  <div class="stage-node ${si(a)} ${h?"pulse":""}">
1870
1870
  <div class="stage-icon">${E(R(c,22,m))}</div>
@@ -1873,7 +1873,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1873
1873
  </div>
1874
1874
  `})}
1875
1875
  </div>
1876
- `}function $S(e){return qn(Object.entries(e))}function ES(e){return e?e.startsWith("builtin:")?`worca:${e.slice(8)}`:e:null}function TS(e,t){if(!t||t<=0)return b;let s=e.reduce((h,d)=>h+(d.duration_api_ms||0),0),i=e.reduce((h,d)=>d.duration_session_ms!=null?h+d.duration_session_ms:h+(d.duration_ms||0),0),r=Math.max(0,i-s),o=Math.max(0,t-i);if(s<=0&&r<=0)return b;let n=Math.round(s/t*100),a=Math.round(r/t*100),c=Math.max(0,100-n-a),l=[{key:"thinking",pct:n,ms:s,label:"Thinking (Agent)",desc:"Time spent on model inference (API round-trips)",cls:"timing-bar-thinking"},{key:"tools",pct:a,ms:r,label:"Tools (Agent)",desc:"Time spent executing tools (bash, file I/O, subprocesses)",cls:"timing-bar-tools"},{key:"rest",pct:c,ms:o,label:"Rest of Pipeline",desc:"Orchestration, status writes, stage transitions, retry delays",cls:"timing-bar-rest"}].filter(h=>h.pct>0);return u`
1876
+ `}function ES(e){return qn(Object.entries(e))}function TS(e){return e?e.startsWith("builtin:")?`worca:${e.slice(8)}`:e:null}function AS(e,t){if(!t||t<=0)return b;let s=e.reduce((h,d)=>h+(d.duration_api_ms||0),0),i=e.reduce((h,d)=>d.duration_session_ms!=null?h+d.duration_session_ms:h+(d.duration_ms||0),0),r=Math.max(0,i-s),o=Math.max(0,t-i);if(s<=0&&r<=0)return b;let n=Math.round(s/t*100),a=Math.round(r/t*100),c=Math.max(0,100-n-a),l=[{key:"thinking",pct:n,ms:s,label:"Thinking (Agent)",desc:"Time spent on model inference (API round-trips)",cls:"timing-bar-thinking"},{key:"tools",pct:a,ms:r,label:"Tools (Agent)",desc:"Time spent executing tools (bash, file I/O, subprocesses)",cls:"timing-bar-tools"},{key:"rest",pct:c,ms:o,label:"Rest of Pipeline",desc:"Orchestration, status writes, stage transitions, retry delays",cls:"timing-bar-rest"}].filter(h=>h.pct>0);return u`
1877
1877
  <div class="pipeline-timing-bar-container">
1878
1878
  <div class="pipeline-timing-bar">
1879
1879
  ${l.map(h=>u`
@@ -1899,7 +1899,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1899
1899
  `)}
1900
1900
  </div>
1901
1901
  </div>
1902
- `}function AS(e){if(!e)return null;let t=null;for(let s of Object.values(e))s.completed_at&&(!t||s.completed_at>t)&&(t=s.completed_at);return t}function RS(e){return e==="completed"?"success":e==="error"?"danger":e==="in_progress"?"primary":e==="interrupted"?"warning":"neutral"}function DS(e){let t=e.status||"pending";return t==="completed"&&e.outcome==="success"?u`<span class="iter-status-icon success">${E(Rt("completed",12))}</span>`:t==="completed"?u`<span class="iter-status-icon">${E(Rt("completed",12))}</span>`:t==="error"?u`<span class="iter-status-icon failure">${E(Rt("error",12))}</span>`:t==="in_progress"?u`<span class="iter-status-icon in-progress">${E(Rt("in_progress",12))}</span>`:b}function xm(e){return e?u`<sl-badge variant="neutral" pill>${{initial:"Initial run",test_failure:"Test failure",review_changes:"Review changes",restart_planning:"Restart planning",plan_review_revise:"Plan revision",next_bead:"Next bead"}[e]||e.replace(/_/g," ")}</sl-badge>`:b}function LS(e){return e==="success"||e==="approve"?"success":e==="revise"||e==="request_changes"?"warning":e==="rejected"||e==="restart_planning"?"danger":"neutral"}function km(e){return e?u`<sl-badge variant="${LS(e)}" pill>${e.replace(/_/g," ")}</sl-badge>`:b}function $m(e){let t=e.classification;return t?u`
1902
+ `}function RS(e){if(!e)return null;let t=null;for(let s of Object.values(e))s.completed_at&&(!t||s.completed_at>t)&&(t=s.completed_at);return t}function DS(e){return e==="completed"?"success":e==="error"?"danger":e==="in_progress"?"primary":e==="interrupted"?"warning":"neutral"}function LS(e){let t=e.status||"pending";return t==="completed"&&e.outcome==="success"?u`<span class="iter-status-icon success">${E(Rt("completed",12))}</span>`:t==="completed"?u`<span class="iter-status-icon">${E(Rt("completed",12))}</span>`:t==="error"?u`<span class="iter-status-icon failure">${E(Rt("error",12))}</span>`:t==="in_progress"?u`<span class="iter-status-icon in-progress">${E(Rt("in_progress",12))}</span>`:b}function km(e){return e?u`<sl-badge variant="neutral" pill>${{initial:"Initial run",test_failure:"Test failure",review_changes:"Review changes",restart_planning:"Restart planning",plan_review_revise:"Plan revision",next_bead:"Next bead"}[e]||e.replace(/_/g," ")}</sl-badge>`:b}function PS(e){return e==="success"||e==="approve"?"success":e==="revise"||e==="request_changes"?"warning":e==="rejected"||e==="restart_planning"?"danger":"neutral"}function $m(e){return e?u`<sl-badge variant="${PS(e)}" pill>${e.replace(/_/g," ")}</sl-badge>`:b}function Em(e){let t=e.classification;return t?u`
1903
1903
  <div class="iteration-tags-row">
1904
1904
  <span class="meta-label">Fail Category:</span>
1905
1905
  <span class="meta-value">${t.category}</span>
@@ -1912,12 +1912,12 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1912
1912
  <span class="meta-value">yes</span>
1913
1913
  `:b}
1914
1914
  </div>
1915
- `:b}function Em(e){let t=e.dispatch_events;return!t||t.length===0?b:u`
1915
+ `:b}function Tm(e){let t=e.dispatch_events;return!t||t.length===0?b:u`
1916
1916
  <div class="iteration-tags-row">
1917
1917
  <span class="meta-label">Subagents:</span>
1918
1918
  ${t.map(s=>{let i=s.type==="pipeline.hook.dispatch_allowed",r=i?"success":"danger",o=Number.isInteger(s.count)&&s.count>1?s.count:0,n=o?` (\xD7${o})`:"",a=i?`${s.subagent_type} dispatched${n}`:`${s.subagent_type} blocked${n}`,c=s.reason||"";return u`<sl-badge variant="${r}" pill title="${c}">${a}</sl-badge>`})}
1919
1919
  </div>
1920
- `}function PS(e,t){let s=e.circuit_breaker;if(!s)return b;if(s.tripped)return u`
1920
+ `}function BS(e,t){let s=e.circuit_breaker;if(!s)return b;if(s.tripped)return u`
1921
1921
  <sl-alert class="circuit-breaker-banner" variant="danger" open>
1922
1922
  <strong>Circuit breaker tripped:</strong> ${s.tripped_reason||"Pipeline halted due to repeated errors."}
1923
1923
  </sl-alert>
@@ -1925,7 +1925,18 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1925
1925
  <sl-alert class="circuit-breaker-banner" variant="warning" open>
1926
1926
  <strong>Circuit breaker warning:</strong> ${String(i)}/${String(r)} consecutive failures.
1927
1927
  </sl-alert>
1928
- `}return b}function BS(e){return e==="pass"?"success":e==="warn"?"warning":e==="fail"?"danger":"neutral"}function MS(e,t){if(e.skipped||t.outcome==="skipped")return u`<div class="preflight-checks-view"><sl-badge variant="neutral" pill>Skipped</sl-badge></div>`;let i=t.output||{},r=i.checks||[],o=i.summary||"";return!r.length&&!o?b:u`
1928
+ `}return b}function MS(e){return e?.milestones?.pr_verified===!1&&e?.pipeline_status==="failed"?u`
1929
+ <sl-alert class="pr-verification-banner" variant="danger" open>
1930
+ <strong>PR verification failed:</strong> Guardian reported success but no new commit or PR was detected.
1931
+ </sl-alert>
1932
+ `:b}function xm(e){let t=e?.milestones?.pr_verified;return t==null?b:u`
1933
+ <div class="pr-verified-row">
1934
+ <span class="meta-label">PR Verification:</span>
1935
+ <sl-badge class="pr-verified-badge" variant="${t?"success":"danger"}" pill>
1936
+ ${t?"Verified":"Not Verified"}
1937
+ </sl-badge>
1938
+ </div>
1939
+ `}function IS(e){return e==="pass"?"success":e==="warn"?"warning":e==="fail"?"danger":"neutral"}function OS(e,t){if(e.skipped||t.outcome==="skipped")return u`<div class="preflight-checks-view"><sl-badge variant="neutral" pill>Skipped</sl-badge></div>`;let i=t.output||{},r=i.checks||[],o=i.summary||"";return!r.length&&!o?b:u`
1929
1940
  <div class="preflight-checks-view">
1930
1941
  ${o?u`<div class="preflight-summary">${o}</div>`:b}
1931
1942
  ${r.length>0?u`
@@ -1940,7 +1951,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1940
1951
  <tbody>
1941
1952
  ${r.map(n=>u`
1942
1953
  <tr>
1943
- <td><sl-badge variant="${BS(n.status)}" pill>${n.status}</sl-badge></td>
1954
+ <td><sl-badge variant="${IS(n.status)}" pill>${n.status}</sl-badge></td>
1944
1955
  <td class="preflight-check-name">${n.name}</td>
1945
1956
  <td class="preflight-check-message">${n.message||""}</td>
1946
1957
  </tr>
@@ -1949,14 +1960,14 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1949
1960
  </table>
1950
1961
  `:b}
1951
1962
  </div>
1952
- `}function Tm(e){return e.reduce((t,s)=>t+(s.cost_usd||0),0)}function IS(e,t,s,i,r){let o=t.iterations||[],n=Am(t);return{stage:e,status:t.status,agent:s||void 0,model:i||void 0,cost_usd:Tm(o),duration:n>0?ve(n):void 0,duration_ms:n>0?n:void 0,started_at:t.started_at||void 0,completed_at:t.completed_at||void 0,error:t.error||void 0,iterations:o.map(a=>({number:a.number,status:a.status,outcome:a.outcome||void 0,trigger:a.trigger||void 0,agent:a.agent||void 0,model:a.model||void 0,turns:a.turns||void 0,cost_usd:a.cost_usd||void 0,duration_ms:a.duration_ms||void 0,duration_session_ms:a.duration_session_ms||void 0,duration_api_ms:a.duration_api_ms||void 0,started_at:a.started_at||void 0,completed_at:a.completed_at||void 0,classification:a.classification||void 0,dispatch_events:a.dispatch_events?.length?a.dispatch_events:void 0})),prompts:r?{agent_instructions:r.agentInstructions||void 0,user_prompt:r.userPrompt||void 0}:void 0}}function Am(e){let t=e.iterations||[];if(t.length===0)return!e.started_at||!e.completed_at?0:rt(e.started_at,e.completed_at);let s=0;for(let i of t)i.started_at&&i.completed_at&&(s+=rt(i.started_at,i.completed_at));return s}function Fh(e,t,s=b){let i=e?ve(rt(e,t)):"";return u`
1963
+ `}function Am(e){return e.reduce((t,s)=>t+(s.cost_usd||0),0)}function zS(e,t,s,i,r){let o=t.iterations||[],n=Rm(t);return{stage:e,status:t.status,agent:s||void 0,model:i||void 0,cost_usd:Am(o),duration:n>0?ve(n):void 0,duration_ms:n>0?n:void 0,started_at:t.started_at||void 0,completed_at:t.completed_at||void 0,error:t.error||void 0,iterations:o.map(a=>({number:a.number,status:a.status,outcome:a.outcome||void 0,trigger:a.trigger||void 0,agent:a.agent||void 0,model:a.model||void 0,turns:a.turns||void 0,cost_usd:a.cost_usd||void 0,duration_ms:a.duration_ms||void 0,duration_session_ms:a.duration_session_ms||void 0,duration_api_ms:a.duration_api_ms||void 0,started_at:a.started_at||void 0,completed_at:a.completed_at||void 0,classification:a.classification||void 0,dispatch_events:a.dispatch_events?.length?a.dispatch_events:void 0})),prompts:r?{agent_instructions:r.agentInstructions||void 0,user_prompt:r.userPrompt||void 0}:void 0}}function Rm(e){let t=e.iterations||[];if(t.length===0)return!e.started_at||!e.completed_at?0:rt(e.started_at,e.completed_at);let s=0;for(let i of t)i.started_at&&i.completed_at&&(s+=rt(i.started_at,i.completed_at));return s}function Fh(e,t,s=b){let i=e?ve(rt(e,t)):"";return u`
1953
1964
  <div class="timing-strip">
1954
1965
  ${e?u`<span class="timing-strip-item"><span class="meta-label">Started:</span> <span class="meta-value">${Ct(e)}</span></span>`:b}
1955
1966
  ${t?u`<span class="timing-strip-item"><span class="meta-label">Finished:</span> <span class="meta-value">${Ct(t)}</span></span>`:b}
1956
1967
  ${i?u`<span class="timing-strip-item"><span class="meta-label">Duration:</span> <span class="meta-value">${i}</span></span>`:b}
1957
1968
  ${s}
1958
1969
  </div>
1959
- `}function OS(e,t,s,i){let r=e.agent||s||t,o=e.model||"",n=e.number??0,l=(i?.iterationPrompts||[]).find(m=>m.iteration===n)?.prompt||i?.userPrompt||null,h=l?{agentInstructions:i?.agentInstructions,userPrompt:l}:i,d=e.started_at?ve(rt(e.started_at,e.completed_at||null)):"";return u`
1970
+ `}function NS(e,t,s,i){let r=e.agent||s||t,o=e.model||"",n=e.number??0,l=(i?.iterationPrompts||[]).find(m=>m.iteration===n)?.prompt||i?.userPrompt||null,h=l?{agentInstructions:i?.agentInstructions,userPrompt:l}:i,d=e.started_at?ve(rt(e.started_at,e.completed_at||null)):"";return u`
1960
1971
  <div class="iteration-detail">
1961
1972
  ${Fh(e.started_at,e.completed_at)}
1962
1973
  <div class="stage-info-strip">
@@ -1969,15 +1980,15 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
1969
1980
  </div>
1970
1981
  ${e.trigger||e.outcome?u`
1971
1982
  <div class="iteration-tags-row">
1972
- ${e.trigger?u`<span class="meta-label">Iteration Trigger:</span> ${xm(e.trigger)}`:b}
1973
- ${e.outcome?u`<span class="meta-label">Iteration Outcome:</span> ${km(e.outcome)}`:b}
1983
+ ${e.trigger?u`<span class="meta-label">Iteration Trigger:</span> ${km(e.trigger)}`:b}
1984
+ ${e.outcome?u`<span class="meta-label">Iteration Outcome:</span> ${$m(e.outcome)}`:b}
1974
1985
  </div>
1975
1986
  `:b}
1976
- ${$m(e)}
1977
1987
  ${Em(e)}
1978
- ${Rm(t,h)}
1988
+ ${Tm(e)}
1989
+ ${Dm(t,h)}
1979
1990
  </div>
1980
- `}function Hh(e,t){navigator.clipboard.writeText(e).then(()=>{t.textContent="Copied!",setTimeout(()=>{t.textContent="Copy"},1500)})}function Rm(e,t){if(!t)return b;let{agentInstructions:s,userPrompt:i}=t;return!s&&!i?b:u`
1991
+ `}function Hh(e,t){navigator.clipboard.writeText(e).then(()=>{t.textContent="Copied!",setTimeout(()=>{t.textContent="Copy"},1500)})}function Dm(e,t){if(!t)return b;let{agentInstructions:s,userPrompt:i}=t;return!s&&!i?b:u`
1981
1992
  <sl-details class="agent-prompt-section" @sl-after-show=${is}>
1982
1993
  <div slot="summary" class="agent-prompt-header">
1983
1994
  <span class="stage-meta-icon">${E(R(fo,12))}</span>
@@ -2006,7 +2017,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2006
2017
  </div>
2007
2018
  `:b}
2008
2019
  </sl-details>
2009
- `}function zS(e){let{svg:t,nodes:s}=lu(e);return u`
2020
+ `}function FS(e){let{svg:t,nodes:s}=lu(e);return u`
2010
2021
  <div class="run-beads-graph">
2011
2022
  ${E(t)}
2012
2023
  ${s.map(({issue:i,x:r,y:o,w:n,h:a})=>u`
@@ -2016,7 +2027,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2016
2027
  </sl-tooltip>
2017
2028
  `)}
2018
2029
  </div>
2019
- `}function Dm(e,t={}){if(!(e?.milestones?.pr_approved===!1&&e?.pipeline_status==="paused"))return b;let{onApprove:s,onReject:i}=t;return u`
2030
+ `}function Lm(e,t={}){if(!(e?.milestones?.pr_approved===!1&&e?.pipeline_status==="paused"))return b;let{onApprove:s,onReject:i}=t;return u`
2020
2031
  <sl-card class="approval-panel" data-testid="pr-approval-panel">
2021
2032
  <div slot="header">
2022
2033
  <strong>PR creation paused — approval required</strong>
@@ -2027,7 +2038,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2027
2038
  <sl-button variant="danger" outline id="pr-reject-btn" @click=${()=>i?.(e.id)}>Reject</sl-button>
2028
2039
  </div>
2029
2040
  </sl-card>
2030
- `}function Lm(e){return e?e.length===0?u`
2041
+ `}function Pm(e){return e?e.length===0?u`
2031
2042
  <div class="run-beads-section">
2032
2043
  <sl-details class="run-beads-panel" @sl-after-show=${is}>
2033
2044
  <div slot="summary" class="run-beads-header">
@@ -2059,14 +2070,15 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2059
2070
  `)}
2060
2071
  </div>
2061
2072
  ${e.length>1?u`
2062
- ${zS(e)}
2073
+ ${FS(e)}
2063
2074
  `:""}
2064
2075
  </sl-details>
2065
2076
  </div>
2066
- `:b}function Pm(e,t={},s={}){if(!e){let p=u`<div class="empty-state">Select a run to view details</div>`;return{overview:p,stages:p}}let i=e.branch||e.work_request?.branch||"",r=ES(e.pipeline_template),o=e.pr_url||null,n=e.completed_at||(e.active?null:AS(e.stages)),a=e.stages||{},c=a;a.preflight||(c={preflight:{status:"skipped"},...c}),a.learn||(c={...c,learn:{status:"skipped"}});let l=t.stageUi||{},h=t.agents||{},d=u`
2077
+ `:b}function Bm(e,t={},s={}){if(!e){let p=u`<div class="empty-state">Select a run to view details</div>`;return{overview:p,stages:p}}let i=e.branch||e.work_request?.branch||"",r=TS(e.pipeline_template),o=e.pr_url||null,n=e.completed_at||(e.active?null:RS(e.stages)),a=e.stages||{},c=a;a.preflight||(c={preflight:{status:"skipped"},...c}),a.learn||(c={...c,learn:{status:"skipped"}});let l=t.stageUi||{},h=t.agents||{},d=u`
2067
2078
  <div class="run-detail-overview">
2068
2079
  ${Cm(c,l,e.active)}
2069
- ${PS(e,t)}
2080
+ ${BS(e,t)}
2081
+ ${MS(e)}
2070
2082
 
2071
2083
  <div class="run-info-section">
2072
2084
  ${i?u`
@@ -2097,13 +2109,13 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2097
2109
  ${_>0?u`<span class="pipeline-cost-item"><span class="meta-label">Total Turns:</span> <span class="meta-value">${_}</span></span>`:b}
2098
2110
  </div>
2099
2111
  `:b}
2100
- ${TS(p,w)}
2112
+ ${AS(p,w)}
2101
2113
  `})()}
2102
2114
  </div>
2103
2115
  </div>
2104
2116
  `,m=u`
2105
2117
  <div class="stage-panels">
2106
- ${$S(c).map(([p,f])=>{let _=l[p]?.label||p.replace(/_/g," ").toUpperCase(),w=yr(f.status||"pending",e.active),k=f.agent||h[p]?.agent||p,$=f.model||h[p]?.model||"",y=Am(f),C=y>0?ve(y):"",S=f.iterations||[],L=S.length>1,H=Tm(S);return u`
2118
+ ${ES(c).map(([p,f])=>{let _=l[p]?.label||p.replace(/_/g," ").toUpperCase(),w=yr(f.status||"pending",e.active),k=f.agent||h[p]?.agent||p,$=f.model||h[p]?.model||"",y=Rm(f),C=y>0?ve(y):"",S=f.iterations||[],L=S.length>1,H=Am(S);return u`
2107
2119
  <sl-details ?open=${w==="in_progress"} class="stage-panel"
2108
2120
  @sl-after-show=${F=>{if(is(F),!L)return;let W=F.target.querySelector("sl-tab-group");if(!W)return;let ie=Sm(s.stageIterationTab,p,S),j=`iter-${p}-${ie}`;requestAnimationFrame(()=>W.show(j))}}>
2109
2121
  <div slot="summary" class="stage-panel-header">
@@ -2141,12 +2153,12 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2141
2153
  </span>
2142
2154
  `:b}
2143
2155
  </span>
2144
- <sl-badge variant="${RS(w)}" pill>
2156
+ <sl-badge variant="${DS(w)}" pill>
2145
2157
  ${w.replace(/_/g," ")}
2146
2158
  </sl-badge>
2147
2159
  </div>
2148
2160
  ${(()=>{let F=w!=="pending"?s.promptCache?.[p]:null,W=u`
2149
- <button class="stage-copy-btn" title="Copy stage data as JSON" @click=${ie=>{let j=IS(p,f,k,$,F);Hh(JSON.stringify(j,null,2),ie.currentTarget)}}>
2161
+ <button class="stage-copy-btn" title="Copy stage data as JSON" @click=${ie=>{let j=zS(p,f,k,$,F);Hh(JSON.stringify(j,null,2),ie.currentTarget)}}>
2150
2162
  ${E(R(He,12))} Copy
2151
2163
  </button>
2152
2164
  `;if(L){let ie=y>0?ve(y):"";return u`
@@ -2159,15 +2171,16 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2159
2171
  ${j>0?u`<span class="stage-totals-item"><span class="meta-label">API Duration:</span> <span class="meta-value">${ve(j)}${T>0?` (${T}%)`:""}</span></span>`:b}
2160
2172
  ${ce>0?u`<span class="stage-totals-item"><span class="meta-label">Turns:</span> <span class="meta-value">${ce}</span></span>`:b}
2161
2173
  </div>`})()}
2174
+ ${p==="guardian"?xm(e):b}
2162
2175
  <sl-tab-group @sl-tab-show=${j=>{let ce=j.detail.name,T=parseInt(ce.split("-").pop(),10);Number.isNaN(T)||s.onStageTabChange?.(p,T)}}>
2163
2176
  ${S.map(j=>u`
2164
2177
  <sl-tab slot="nav" panel="iter-${p}-${j.number}">
2165
- Iter ${j.number} ${DS(j)}
2178
+ Iter ${j.number} ${LS(j)}
2166
2179
  </sl-tab>
2167
2180
  `)}
2168
2181
  ${S.map(j=>u`
2169
2182
  <sl-tab-panel name="iter-${p}-${j.number}">
2170
- ${OS(j,p,k,F)}
2183
+ ${NS(j,p,k,F)}
2171
2184
  </sl-tab-panel>
2172
2185
  `)}
2173
2186
  </sl-tab-group>
@@ -2186,16 +2199,17 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2186
2199
  </div>
2187
2200
  ${S.length===1&&(S[0].trigger||S[0].outcome)?u`
2188
2201
  <div class="iteration-tags-row">
2189
- ${S[0].trigger?u`<span class="meta-label">Iteration Trigger:</span> ${xm(S[0].trigger)}`:b}
2190
- ${S[0].outcome?u`<span class="meta-label">Iteration Outcome:</span> ${km(S[0].outcome)}`:b}
2202
+ ${S[0].trigger?u`<span class="meta-label">Iteration Trigger:</span> ${km(S[0].trigger)}`:b}
2203
+ ${S[0].outcome?u`<span class="meta-label">Iteration Outcome:</span> ${$m(S[0].outcome)}`:b}
2191
2204
  </div>
2192
2205
  `:b}
2193
2206
  ${f.task_progress?u`<div class="detail-row"><span class="detail-label">Progress:</span> ${f.task_progress}</div>`:b}
2194
2207
  ${f.error?u`<div class="detail-row detail-error"><span class="detail-label">Error:</span> ${f.error}</div>`:b}
2195
- ${S.length===1?$m(S[0]):b}
2196
2208
  ${S.length===1?Em(S[0]):b}
2197
- ${p==="preflight"&&S.length===1?MS(f,S[0]):b}
2198
- ${F?Rm(p,F):b}
2209
+ ${S.length===1?Tm(S[0]):b}
2210
+ ${p==="guardian"?xm(e):b}
2211
+ ${p==="preflight"&&S.length===1?OS(f,S[0]):b}
2212
+ ${F?Dm(p,F):b}
2199
2213
  </div>
2200
2214
  </div>
2201
2215
  `})()}
@@ -2210,12 +2224,12 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2210
2224
  </sl-details>
2211
2225
  `})}
2212
2226
  </div>
2213
- `;return{overview:d,stages:m}}var NS=["all","running","completed","failed","paused","error","archived"];function Bm(e,t,{onSelectRun:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:a,onUnarchive:c,statusFilter:l,onStatusFilter:h,archivedRuns:d=[],runsLoaded:m=!0}={}){let p=t==="active"?e.filter($=>$.active):e,f=t==="history"&&h,_={};if(f){_={all:p.length};for(let $ of p){let y=$.pipeline_status||"completed";_[y]=(_[y]||0)+1}_.archived=d.length}let w;if(f&&l==="archived"?w=ft([...d]):(w=p,f&&l&&l!=="all"&&(w=w.filter($=>($.pipeline_status||"completed")===l)),w=ft(w)),p.length===0&&!(l==="archived"&&d.length>0))return m?u`<div class="empty-state">
2227
+ `;return{overview:d,stages:m}}var HS=["all","running","completed","failed","paused","error","archived"];function Mm(e,t,{onSelectRun:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:a,onUnarchive:c,statusFilter:l,onStatusFilter:h,archivedRuns:d=[],runsLoaded:m=!0}={}){let p=t==="active"?e.filter($=>$.active):e,f=t==="history"&&h,_={};if(f){_={all:p.length};for(let $ of p){let y=$.pipeline_status||"completed";_[y]=(_[y]||0)+1}_.archived=d.length}let w;if(f&&l==="archived"?w=ft([...d]):(w=p,f&&l&&l!=="all"&&(w=w.filter($=>($.pipeline_status||"completed")===l)),w=ft(w)),p.length===0&&!(l==="archived"&&d.length>0))return m?u`<div class="empty-state">
2214
2228
  ${t==="active"?"No running pipelines":"No completed runs yet"}
2215
2229
  </div>`:u`<div class="empty-state">Loading runs…</div>`;let k=l==="archived";return u`
2216
2230
  ${f?u`
2217
2231
  <div class="filter-chips">
2218
- ${NS.filter($=>$==="all"||_[$]).map($=>u`
2232
+ ${HS.filter($=>$==="all"||_[$]).map($=>u`
2219
2233
  <button
2220
2234
  class="filter-chip ${(l||"all")===$?"active":""} filter-chip-${$}"
2221
2235
  @click=${()=>h($)}
@@ -2233,7 +2247,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2233
2247
  ${w.map($=>ss($,{onClick:s,onPause:i,onResume:r,onStop:o,onCancel:n,onArchive:k?void 0:a,onUnarchive:k?c:void 0}))}
2234
2248
  </div>
2235
2249
  `}
2236
- `}function FS(e,t,s){let i=Object.values(t),r=e?i.filter(c=>{let l=c.project||c._project;return l?l===e:!s||s===e}):i,o=!1,n=!1,a=!1;for(let c of r){let l=c.pipeline_status||(c.active?"running":"completed");l==="running"?o=!0:l==="failed"||l==="error"?n=!0:(l==="paused"||l==="approval_needed")&&(a=!0)}return o?"running":n?"error":a?"paused":"idle"}function HS(e){switch(e){case"running":return"project-status-running";case"error":return"project-status-error";case"paused":return"project-status-paused";default:return"project-status-idle"}}function Mm(e,t,s,{onNavigate:i,onProjectChange:r,onAddProject:o}){let{runs:n,preferences:a,projects:c,currentProjectId:l,worktrees:h=[],worktreeDiskWarningBytes:d=2e9,totalRunning:m=0,maxConcurrentPipelines:p=10}=e,f=m>=p,_=Object.values(n),w=l&&(c||[]).length>1?_.filter(j=>(j.project||j._project)===l):_,k=w.filter(j=>(j.pipeline_status||(j.active?"running":"completed"))==="running").length,$=w.length,C=(e.beads?.issues||[]).filter(j=>j.status==="ready"&&(j.blocked_by?.length??0)===0).length,S=h.length,L=d,F=h.reduce((j,ce)=>j+(ce.disk_bytes||0),0)>L,W=s==="open"?"connected":s==="reconnecting"?"reconnecting":"disconnected",ie=s==="open"?"Connected":s==="reconnecting"?"Reconnecting\u2026":"Disconnected";return u`
2250
+ `}function WS(e,t,s){let i=Object.values(t),r=e?i.filter(c=>{let l=c.project||c._project;return l?l===e:!s||s===e}):i,o=!1,n=!1,a=!1;for(let c of r){let l=c.pipeline_status||(c.active?"running":"completed");l==="running"?o=!0:l==="failed"||l==="error"?n=!0:(l==="paused"||l==="approval_needed")&&(a=!0)}return o?"running":n?"error":a?"paused":"idle"}function jS(e){switch(e){case"running":return"project-status-running";case"error":return"project-status-error";case"paused":return"project-status-paused";default:return"project-status-idle"}}function Im(e,t,s,{onNavigate:i,onProjectChange:r,onAddProject:o}){let{runs:n,preferences:a,projects:c,currentProjectId:l,worktrees:h=[],worktreeDiskWarningBytes:d=2e9,totalRunning:m=0,maxConcurrentPipelines:p=10}=e,f=m>=p,_=Object.values(n),w=l&&(c||[]).length>1?_.filter(j=>(j.project||j._project)===l):_,k=w.filter(j=>(j.pipeline_status||(j.active?"running":"completed"))==="running").length,$=w.length,C=(e.beads?.issues||[]).filter(j=>j.status==="ready"&&(j.blocked_by?.length??0)===0).length,S=h.length,L=d,F=h.reduce((j,ce)=>j+(ce.disk_bytes||0),0)>L,W=s==="open"?"connected":s==="reconnecting"?"reconnecting":"disconnected",ie=s==="open"?"Connected":s==="reconnecting"?"Reconnecting\u2026":"Disconnected";return u`
2237
2251
  <aside class="sidebar ${a.sidebarCollapsed?"collapsed":""}">
2238
2252
  <div class="sidebar-logo" @click=${()=>i("dashboard")} style="cursor:pointer">
2239
2253
  <span class="logo-text">WORCA</span>
@@ -2251,7 +2265,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2251
2265
  >
2252
2266
  <sl-option value="">All Projects</sl-option>
2253
2267
  <sl-divider></sl-divider>
2254
- ${c.map(j=>{let ce=FS(j.name,n,l),T=HS(ce);return u`
2268
+ ${c.map(j=>{let ce=WS(j.name,n,l),T=jS(ce);return u`
2255
2269
  <sl-option value=${j.name}>
2256
2270
  <span class="project-option-label">
2257
2271
  <span class="project-status-dot ${T}"></span>
@@ -2366,13 +2380,13 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2366
2380
  >${E(R(_o,18))}</button>
2367
2381
  </div>
2368
2382
  </aside>
2369
- `}var Im=null,Om=null,Wh=null;function WS(e,t){return e===Im&&t===Om||(Im=e,Om=t,Wh=[...Object.values(e),...Object.values(t||{})].filter(s=>s.stages&&Object.keys(s.stages).length>0).sort((s,i)=>(i.started_at||"").localeCompare(s.started_at||""))),Wh}function jS(e){let t=0;for(let s of e)for(let i of Object.values(s.stages||{}))for(let r of i.iterations||[])t+=r.cost_usd||0;return t}function VS(e){let t=0,s=0,i=0,r=0,o=0;for(let n of Object.values(e))for(let a of Object.values(n))for(let c of a)t+=c.inputTokens||0,s+=c.outputTokens||0,i+=c.cacheReadInputTokens||0,r+=c.cacheCreationInputTokens||0,o+=c.webSearchRequests||0;return{input:t,output:s,cacheRead:i,cacheWrite:r,webSearches:o}}function US(e){let t=0;for(let s of Object.values(e.stages||{}))for(let i of s.iterations||[])t+=i.cost_usd||0;return t}function qS(e){if(e.started_at){let t=e.completed_at||jh(e.stages);if(t)return rt(e.started_at,t)}return 0}function jh(e){if(!e)return null;let t=null;for(let s of Object.values(e))s.completed_at&&(!t||s.completed_at>t)&&(t=s.completed_at);return t}function Wr(e){return e==null||e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function tr(e){return e==null||e===0?"0":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function KS(e,t){let s=e?ve(rt(e,t||null)):"";return u`
2383
+ `}var Om=null,zm=null,Wh=null;function VS(e,t){return e===Om&&t===zm||(Om=e,zm=t,Wh=[...Object.values(e),...Object.values(t||{})].filter(s=>s.stages&&Object.keys(s.stages).length>0).sort((s,i)=>(i.started_at||"").localeCompare(s.started_at||""))),Wh}function US(e){let t=0;for(let s of e)for(let i of Object.values(s.stages||{}))for(let r of i.iterations||[])t+=r.cost_usd||0;return t}function qS(e){let t=0,s=0,i=0,r=0,o=0;for(let n of Object.values(e))for(let a of Object.values(n))for(let c of a)t+=c.inputTokens||0,s+=c.outputTokens||0,i+=c.cacheReadInputTokens||0,r+=c.cacheCreationInputTokens||0,o+=c.webSearchRequests||0;return{input:t,output:s,cacheRead:i,cacheWrite:r,webSearches:o}}function KS(e){let t=0;for(let s of Object.values(e.stages||{}))for(let i of s.iterations||[])t+=i.cost_usd||0;return t}function GS(e){if(e.started_at){let t=e.completed_at||jh(e.stages);if(t)return rt(e.started_at,t)}return 0}function jh(e){if(!e)return null;let t=null;for(let s of Object.values(e))s.completed_at&&(!t||s.completed_at>t)&&(t=s.completed_at);return t}function Wr(e){return e==null||e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function tr(e){return e==null||e===0?"0":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function YS(e,t){let s=e?ve(rt(e,t||null)):"";return u`
2370
2384
  <div class="timing-strip">
2371
2385
  ${e?u`<span class="timing-strip-item"><span class="meta-label">Started:</span> <span class="meta-value">${Ct(e)}</span></span>`:b}
2372
2386
  ${t?u`<span class="timing-strip-item"><span class="meta-label">Finished:</span> <span class="meta-value">${Ct(t)}</span></span>`:b}
2373
2387
  ${s?u`<span class="timing-strip-item"><span class="meta-label">Duration:</span> <span class="meta-value">${s}</span></span>`:b}
2374
2388
  </div>
2375
- `}function zm(e){let t=Object.keys(e||{});return Dt.filter(s=>t.includes(s)).concat(t.filter(s=>!Dt.includes(s)))}function GS(e,t){let s=jS(e),i=e.length>0?s/e.length:0,r=VS(t),o=r.input+r.output+r.cacheRead+r.cacheWrite;return u`
2389
+ `}function Nm(e){let t=Object.keys(e||{});return Dt.filter(s=>t.includes(s)).concat(t.filter(s=>!Dt.includes(s)))}function XS(e,t){let s=US(e),i=e.length>0?s/e.length:0,r=qS(t),o=r.input+r.output+r.cacheRead+r.cacheWrite;return u`
2376
2390
  <div class="costs-stats">
2377
2391
  <div class="stat-card stat-cost-total">
2378
2392
  <div class="stat-icon-ring">${E(R(Nt,20))}</div>
@@ -2412,7 +2426,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2412
2426
  </div>
2413
2427
  `:b}
2414
2428
  </div>
2415
- `}function YS(e){let s=zm(e).map(o=>{let n=0;for(let a of e[o]?.iterations||[])n+=a.cost_usd||0;return{name:o,cost:n}}).filter(o=>o.cost>0),i=s.reduce((o,n)=>o+n.cost,0);if(i===0)return b;let r={plan:"var(--accent)",coordinate:"var(--status-in-progress)",implement:"var(--status-completed)",test:"#8b5cf6",review:"#f59e0b",pr:"var(--muted)"};return u`
2429
+ `}function JS(e){let s=Nm(e).map(o=>{let n=0;for(let a of e[o]?.iterations||[])n+=a.cost_usd||0;return{name:o,cost:n}}).filter(o=>o.cost>0),i=s.reduce((o,n)=>o+n.cost,0);if(i===0)return b;let r={plan:"var(--accent)",coordinate:"var(--status-in-progress)",implement:"var(--status-completed)",test:"#8b5cf6",review:"#f59e0b",pr:"var(--muted)"};return u`
2416
2430
  <div class="cost-bar-container">
2417
2431
  <div class="cost-bar">
2418
2432
  ${s.map(o=>{let n=(o.cost/i*100).toFixed(1),a=r[o.name]||"var(--muted)";return u`<div class="cost-bar-segment" style="width:${n}%;background:${a}" title="${o.name}: ${Wr(o.cost)} (${n}%)"></div>`})}
@@ -2421,8 +2435,8 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2421
2435
  ${s.map(o=>{let n=r[o.name]||"var(--muted)";return u`<span class="cost-legend-item"><span class="cost-legend-dot" style="background:${n}"></span>${o.name} ${Wr(o.cost)}</span>`})}
2422
2436
  </div>
2423
2437
  </div>
2424
- `}function XS(e,t,s,{onToggleRun:i}){let r=US(e),o=qS(e),a=(e.work_request?.title||"Untitled").split(`
2425
- `)[0],c=a.length>60?`${a.slice(0,60)}\u2026`:a,l=e.completed_at||jh(e.stages),h=s===e.id,d=zm(e.stages),m=t[e.id]||{};return u`
2438
+ `}function ZS(e,t,s,{onToggleRun:i}){let r=KS(e),o=GS(e),a=(e.work_request?.title||"Untitled").split(`
2439
+ `)[0],c=a.length>60?`${a.slice(0,60)}\u2026`:a,l=e.completed_at||jh(e.stages),h=s===e.id,d=Nm(e.stages),m=t[e.id]||{};return u`
2426
2440
  <div class="cost-run-row ${h?"expanded":""}">
2427
2441
  <div class="cost-run-summary" @click=${()=>i(e.id)}>
2428
2442
  <span class="cost-run-title">${c}</span>
@@ -2435,8 +2449,8 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2435
2449
  </div>
2436
2450
  ${h?u`
2437
2451
  <div class="cost-run-detail">
2438
- ${KS(e.started_at,e.completed_at||jh(e.stages))}
2439
- ${YS(e.stages)}
2452
+ ${YS(e.started_at,e.completed_at||jh(e.stages))}
2453
+ ${JS(e.stages)}
2440
2454
  <table class="cost-table">
2441
2455
  <thead>
2442
2456
  <tr>
@@ -2475,22 +2489,22 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2475
2489
  </div>
2476
2490
  `:b}
2477
2491
  </div>
2478
- `}function Nm(e,{expandedRun:t,tokenData:s,onToggleRun:i}={}){let r=WS(e.runs,e.archivedRuns);return u`
2492
+ `}function Fm(e,{expandedRun:t,tokenData:s,onToggleRun:i}={}){let r=VS(e.runs,e.archivedRuns);return u`
2479
2493
  <div class="costs-dashboard">
2480
- ${GS(r,s||{})}
2494
+ ${XS(r,s||{})}
2481
2495
 
2482
2496
  <h3 class="costs-section-title">Cost by Run</h3>
2483
2497
  ${r.length>0?u`
2484
2498
  <div class="cost-run-list">
2485
- ${r.map(o=>XS(o,s||{},t,{onToggleRun:i||(()=>{})}))}
2499
+ ${r.map(o=>ZS(o,s||{},t,{onToggleRun:i||(()=>{})}))}
2486
2500
  </div>
2487
2501
  `:u`<div class="empty-state">No runs with cost data</div>`}
2488
2502
  </div>
2489
- `}function qa(e){if(!e)return"other";let s=e.replace(/^pipeline\./,"").split(".")[0];return["run","stage","agent","bead","git","test","review","circuit_breaker","cost","loop","hook","control"].includes(s)?s:"other"}function JS(e){return e?e.replace(/^pipeline\./,""):""}function Fm(e){return{run:"cat-run",stage:"cat-stage",agent:"cat-agent",cost:"cat-cost",circuit_breaker:"cat-danger",hook:"cat-danger",test:"cat-stage",review:"cat-stage",bead:"cat-run",git:"cat-run",loop:"cat-cost",control:"cat-danger"}[e]||"cat-neutral"}function ZS(e){if(!e)return"";let t=qa(e.event_type),s=e.payload||{};switch(t){case"run":return s.status||s.outcome||"";case"stage":return[s.stage,s.outcome,s.duration_s!=null?`${s.duration_s}s`:""].filter(Boolean).join(" \u2022 ");case"agent":return[s.tool_name,s.file||s.command].filter(Boolean).join(" \u2022 ").slice(0,80);case"bead":return[s.bead_id,s.title].filter(Boolean).join(" \u2022 ").slice(0,80);case"git":return[s.branch,s.sha?.slice(0,7),s.pr_url].filter(Boolean).join(" \u2022 ");case"test":return s.passed!=null||s.failed!=null?`pass:${s.passed??0} fail:${s.failed??0}`:s.outcome||"";case"review":return[s.verdict,s.issue_count!=null?`${s.issue_count} issues`:""].filter(Boolean).join(" \u2022 ");case"circuit_breaker":return[s.category,s.consecutive!=null?`${s.consecutive}x`:""].filter(Boolean).join(" \u2022 ");case"cost":return s.total_cost!=null?`$${Number(s.total_cost).toFixed(2)}`:s.budget_pct!=null?`${s.budget_pct}% of budget`:"";case"loop":return[s.loop_key,s.iteration!=null?`iter ${s.iteration}`:"",s.from&&s.to?`${s.from}\u2192${s.to}`:""].filter(Boolean).join(" \u2022 ");case"hook":return[s.tool_blocked,s.reason].filter(Boolean).join(": ").slice(0,80);case"control":return s.action||"";default:return""}}function QS(e){if(!e)return"";let t=new Date(e),s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${s}${i}${r}`}function eC(e){if(!e)return"";let t=new Date(e),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),r=String(t.getSeconds()).padStart(2,"0");return`${s}:${i}:${r}`}var Hm=["all","run","stage","agent","bead","cost","test","review","hook","other"];function jm(e,{selectedId:t,categoryFilter:s,runFilter:i,searchTerm:r,onSelectEvent:o,onCategoryFilter:n,onRunFilter:a,onSearch:c,onSetControl:l,onClear:h,onCopyJson:d,onDismissDetail:m}){let{events:p,controlAction:f}=e.webhookInbox,_={};for(let y of Hm)_[y]=0;for(let y of p){let C=qa(y.envelope?.event_type);_[C]=(_[C]||0)+1,_.all++}let w=[...new Set(p.map(y=>y.envelope?.run_id).filter(Boolean))],k=p;if(s&&s!=="all"&&(k=k.filter(y=>qa(y.envelope?.event_type)===s)),i&&(k=k.filter(y=>y.envelope?.run_id===i)),r){let y=r.toLowerCase();k=k.filter(C=>(C.envelope?.event_type||"").toLowerCase().includes(y)||JSON.stringify(C.envelope?.payload||{}).toLowerCase().includes(y))}let $=t?p.find(y=>y.id===t):null;return p.length===0?u`
2503
+ `}function qa(e){if(!e)return"other";let s=e.replace(/^pipeline\./,"").split(".")[0];return["run","stage","agent","bead","git","test","review","circuit_breaker","cost","loop","hook","control"].includes(s)?s:"other"}function QS(e){return e?e.replace(/^pipeline\./,""):""}function Hm(e){return{run:"cat-run",stage:"cat-stage",agent:"cat-agent",cost:"cat-cost",circuit_breaker:"cat-danger",hook:"cat-danger",test:"cat-stage",review:"cat-stage",bead:"cat-run",git:"cat-run",loop:"cat-cost",control:"cat-danger"}[e]||"cat-neutral"}function eC(e){if(!e)return"";let t=qa(e.event_type),s=e.payload||{};switch(t){case"run":return s.status||s.outcome||"";case"stage":return[s.stage,s.outcome,s.duration_s!=null?`${s.duration_s}s`:""].filter(Boolean).join(" \u2022 ");case"agent":return[s.tool_name,s.file||s.command].filter(Boolean).join(" \u2022 ").slice(0,80);case"bead":return[s.bead_id,s.title].filter(Boolean).join(" \u2022 ").slice(0,80);case"git":return[s.branch,s.sha?.slice(0,7),s.pr_url].filter(Boolean).join(" \u2022 ");case"test":return s.passed!=null||s.failed!=null?`pass:${s.passed??0} fail:${s.failed??0}`:s.outcome||"";case"review":return[s.verdict,s.issue_count!=null?`${s.issue_count} issues`:""].filter(Boolean).join(" \u2022 ");case"circuit_breaker":return[s.category,s.consecutive!=null?`${s.consecutive}x`:""].filter(Boolean).join(" \u2022 ");case"cost":return s.total_cost!=null?`$${Number(s.total_cost).toFixed(2)}`:s.budget_pct!=null?`${s.budget_pct}% of budget`:"";case"loop":return[s.loop_key,s.iteration!=null?`iter ${s.iteration}`:"",s.from&&s.to?`${s.from}\u2192${s.to}`:""].filter(Boolean).join(" \u2022 ");case"hook":return[s.tool_blocked,s.reason].filter(Boolean).join(": ").slice(0,80);case"control":return s.action||"";default:return""}}function tC(e){if(!e)return"";let t=new Date(e),s=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${s}${i}${r}`}function sC(e){if(!e)return"";let t=new Date(e),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),r=String(t.getSeconds()).padStart(2,"0");return`${s}:${i}:${r}`}var Wm=["all","run","stage","agent","bead","cost","test","review","hook","other"];function Vm(e,{selectedId:t,categoryFilter:s,runFilter:i,searchTerm:r,onSelectEvent:o,onCategoryFilter:n,onRunFilter:a,onSearch:c,onSetControl:l,onClear:h,onCopyJson:d,onDismissDetail:m}){let{events:p,controlAction:f}=e.webhookInbox,_={};for(let y of Wm)_[y]=0;for(let y of p){let C=qa(y.envelope?.event_type);_[C]=(_[C]||0)+1,_.all++}let w=[...new Set(p.map(y=>y.envelope?.run_id).filter(Boolean))],k=p;if(s&&s!=="all"&&(k=k.filter(y=>qa(y.envelope?.event_type)===s)),i&&(k=k.filter(y=>y.envelope?.run_id===i)),r){let y=r.toLowerCase();k=k.filter(C=>(C.envelope?.event_type||"").toLowerCase().includes(y)||JSON.stringify(C.envelope?.payload||{}).toLowerCase().includes(y))}let $=t?p.find(y=>y.id===t):null;return p.length===0?u`
2490
2504
  <div class="webhook-inbox">
2491
2505
  <div class="webhook-inbox-toolbar">
2492
2506
  <div class="webhook-inbox-control">
2493
- ${Wm(f,l)}
2507
+ ${jm(f,l)}
2494
2508
  </div>
2495
2509
  </div>
2496
2510
  <div class="webhook-inbox-empty">
@@ -2505,8 +2519,8 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2505
2519
  <div class="webhook-inbox">
2506
2520
  <div class="webhook-inbox-toolbar">
2507
2521
  <div class="webhook-inbox-category-chips">
2508
- ${Hm.map(y=>u`
2509
- <button class="webhook-inbox-category-chip ${s===y?"active":""} ${Fm(y)}"
2522
+ ${Wm.map(y=>u`
2523
+ <button class="webhook-inbox-category-chip ${s===y?"active":""} ${Hm(y)}"
2510
2524
  @click=${()=>n(y)}>
2511
2525
  ${y==="all"?"All":y}
2512
2526
  <span class="chip-count">${_[y]||0}</span>
@@ -2528,7 +2542,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2528
2542
  @input=${y=>c(y.target.value)} />
2529
2543
  </div>
2530
2544
  <div class="webhook-inbox-control">
2531
- ${Wm(f,l)}
2545
+ ${jm(f,l)}
2532
2546
  </div>
2533
2547
  <button class="webhook-inbox-clear-btn" @click=${h} title="Clear all events">
2534
2548
  ${E(R(At,14))}
@@ -2551,13 +2565,13 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2551
2565
  <div class="webhook-inbox-row ${t===y.id?"selected":""}"
2552
2566
  @click=${()=>o(y.id)}>
2553
2567
  <span class="wh-col-id">${y.id}</span>
2554
- <span class="wh-col-date">${QS(y.receivedAt)}</span>
2555
- <span class="wh-col-time">${eC(y.receivedAt)}</span>
2568
+ <span class="wh-col-date">${tC(y.receivedAt)}</span>
2569
+ <span class="wh-col-time">${sC(y.receivedAt)}</span>
2556
2570
  <span class="wh-col-type">
2557
- <span class="webhook-event-type ${Fm(C)}">${JS(y.envelope?.event_type)}</span>
2571
+ <span class="webhook-event-type ${Hm(C)}">${QS(y.envelope?.event_type)}</span>
2558
2572
  </span>
2559
2573
  <span class="wh-col-stage">${y.envelope?.payload?.stage||""}</span>
2560
- <span class="wh-col-summary webhook-inbox-summary">${ZS(y.envelope)}</span>
2574
+ <span class="wh-col-summary webhook-inbox-summary">${eC(y.envelope)}</span>
2561
2575
  <span class="wh-col-run" title="${y.envelope?.run_id||""}">${y.envelope?.run_id||""}</span>
2562
2576
  </div>
2563
2577
  `})}
@@ -2586,7 +2600,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2586
2600
  </div>
2587
2601
  `:""}
2588
2602
  </div>
2589
- `}function Wm(e,t){return u`
2603
+ `}function jm(e,t){return u`
2590
2604
  <div class="webhook-control-segment">
2591
2605
  ${["continue","pause","abort"].map(i=>u`
2592
2606
  <button class="webhook-control-btn ${e===i?"active":""} ${i==="abort"?"danger":""}"
@@ -2595,7 +2609,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2595
2609
  </button>
2596
2610
  `)}
2597
2611
  </div>
2598
- `}function yi(e){return!e||e<0?"0 B":e>=1e9?`${(e/1e9).toFixed(1)} GB`:e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${(e/1e3).toFixed(1)} KB`:`${e} B`}function tC(e){return ve((e||0)*1e3)}function Vh(e){return e.group_type==="fleet"&&e.fleet_id?`fleet:${e.fleet_id}`:e.group_type==="workspace"&&e.workspace_id?`workspace:${e.workspace_id}`:null}function sC(e,t){let s=t.toLowerCase();return(e.title||"").toLowerCase().includes(s)||(e.branch||"").toLowerCase().includes(s)||(Vh(e)||"").toLowerCase().includes(s)||(e.worktree_path||"").toLowerCase().includes(s)}var iC={running:"primary",completed:"success",failed:"danger",paused:"warning",cancelled:"neutral"};function rC(e){return iC[e]||"neutral"}function oC(e,t=2e9){let s=e.reduce((a,c)=>a+(c.disk_bytes||0),0),i=e.filter(a=>a.status==="completed").reduce((a,c)=>a+(c.disk_bytes||0),0),r=e.filter(a=>a.resumable),o=r.reduce((a,c)=>a+(c.disk_bytes||0),0);return s>t?u`
2612
+ `}function yi(e){return!e||e<0?"0 B":e>=1e9?`${(e/1e9).toFixed(1)} GB`:e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${(e/1e3).toFixed(1)} KB`:`${e} B`}function iC(e){return ve((e||0)*1e3)}function Vh(e){return e.group_type==="fleet"&&e.fleet_id?`fleet:${e.fleet_id}`:e.group_type==="workspace"&&e.workspace_id?`workspace:${e.workspace_id}`:null}function rC(e,t){let s=t.toLowerCase();return(e.title||"").toLowerCase().includes(s)||(e.branch||"").toLowerCase().includes(s)||(Vh(e)||"").toLowerCase().includes(s)||(e.worktree_path||"").toLowerCase().includes(s)}var oC={running:"primary",completed:"success",failed:"danger",paused:"warning",cancelled:"neutral"};function nC(e){return oC[e]||"neutral"}function aC(e,t=2e9){let s=e.reduce((a,c)=>a+(c.disk_bytes||0),0),i=e.filter(a=>a.status==="completed").reduce((a,c)=>a+(c.disk_bytes||0),0),r=e.filter(a=>a.resumable),o=r.reduce((a,c)=>a+(c.disk_bytes||0),0);return s>t?u`
2599
2613
  <sl-alert variant="warning" open class="worktrees-disk-alert">
2600
2614
  <strong>Worktree disk usage is high:</strong>
2601
2615
  ${yi(s)} across ${e.length} worktrees
@@ -2615,7 +2629,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2615
2629
  <span class="meta-value">${yi(o)}</span>
2616
2630
  `:b}
2617
2631
  </div>
2618
- `}function nC(e,{onSelectRun:t,onCleanup:s}={}){let i=e.status==="running",r=Vh(e),o=e.status||"unknown",n=t?()=>t(e.run_id):null;return u`
2632
+ `}function lC(e,{onSelectRun:t,onCleanup:s}={}){let i=e.status==="running",r=Vh(e),o=e.status||"unknown",n=t?()=>t(e.run_id):null;return u`
2619
2633
  <div
2620
2634
  class="run-card worktree-card ${si(o)}"
2621
2635
  @click=${n}
@@ -2626,7 +2640,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2626
2640
  </span>
2627
2641
  <span class="run-card-title">${e.title||e.run_id}</span>
2628
2642
  <sl-badge
2629
- variant="${rC(o)}"
2643
+ variant="${nC(o)}"
2630
2644
  pill
2631
2645
  class="status-badge-${o}"
2632
2646
  >
@@ -2644,7 +2658,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2644
2658
  </span>
2645
2659
  <span class="run-card-meta-item">
2646
2660
  <span class="meta-label">Age:</span>
2647
- <span class="meta-value">${tC(e.age_seconds)}</span>
2661
+ <span class="meta-value">${iC(e.age_seconds)}</span>
2648
2662
  </span>
2649
2663
  ${r?u`
2650
2664
  <span class="run-card-meta-item">
@@ -2671,7 +2685,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2671
2685
  </sl-button>
2672
2686
  </div>
2673
2687
  </div>
2674
- `}function aC(e,t,{onDialogClose:s,onDialogConfirm:i,onDialogCheckboxChange:r}={}){if(!e)return b;let o=e.resumable||!!e.group_type,n=!!e.group_type,a=o&&!t;return u`
2688
+ `}function cC(e,t,{onDialogClose:s,onDialogConfirm:i,onDialogCheckboxChange:r}={}){if(!e)return b;let o=e.resumable||!!e.group_type,n=!!e.group_type,a=o&&!t;return u`
2675
2689
  <sl-dialog
2676
2690
  label="Cleanup worktree"
2677
2691
  class="worktrees-dialog-cleanup"
@@ -2710,7 +2724,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2710
2724
  </sl-button>
2711
2725
  </div>
2712
2726
  </sl-dialog>
2713
- `}function lC(e,t,{onDialogClose:s,onDialogConfirm:i}={}){let r=e.filter(h=>h.status==="completed");if(r.length===0)return b;let o=r.reduce((h,d)=>h+(d.disk_bytes||0),0),n=r.filter(h=>!h.group_type),a={},c={};for(let h of r)h.group_type==="fleet"&&h.fleet_id?(a[h.fleet_id]||(a[h.fleet_id]=[]),a[h.fleet_id].push(h)):h.group_type==="workspace"&&h.workspace_id&&(c[h.workspace_id]||(c[h.workspace_id]=[]),c[h.workspace_id].push(h));let l=[n.length>0?`${n.length} standalone`:null,...Object.entries(a).map(([h,d])=>`${d.length} from fleet ${h}`),...Object.entries(c).map(([h,d])=>`${d.length} from workspace ${h}`)].filter(Boolean);return u`
2727
+ `}function hC(e,t,{onDialogClose:s,onDialogConfirm:i}={}){let r=e.filter(h=>h.status==="completed");if(r.length===0)return b;let o=r.reduce((h,d)=>h+(d.disk_bytes||0),0),n=r.filter(h=>!h.group_type),a={},c={};for(let h of r)h.group_type==="fleet"&&h.fleet_id?(a[h.fleet_id]||(a[h.fleet_id]=[]),a[h.fleet_id].push(h)):h.group_type==="workspace"&&h.workspace_id&&(c[h.workspace_id]||(c[h.workspace_id]=[]),c[h.workspace_id].push(h));let l=[n.length>0?`${n.length} standalone`:null,...Object.entries(a).map(([h,d])=>`${d.length} from fleet ${h}`),...Object.entries(c).map(([h,d])=>`${d.length} from workspace ${h}`)].filter(Boolean);return u`
2714
2728
  <sl-dialog
2715
2729
  label="Cleanup all completed worktrees"
2716
2730
  class="worktrees-dialog-bulk"
@@ -2737,15 +2751,15 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2737
2751
  </sl-button>
2738
2752
  </div>
2739
2753
  </sl-dialog>
2740
- `}function Vm(e,{diskWarningBytes:t,filter:s="",onFilter:i,onSelectRun:r,onCleanup:o,onBulkCleanup:n,dialogItem:a=null,dialogBulk:c=!1,dialogCheckbox:l=!1,onDialogClose:h,onDialogConfirm:d,onDialogCheckboxChange:m}={}){if(!e||e.length===0)return u`
2754
+ `}function Um(e,{diskWarningBytes:t,filter:s="",onFilter:i,onSelectRun:r,onCleanup:o,onBulkCleanup:n,dialogItem:a=null,dialogBulk:c=!1,dialogCheckbox:l=!1,onDialogClose:h,onDialogConfirm:d,onDialogCheckboxChange:m}={}){if(!e||e.length===0)return u`
2741
2755
  <div class="worktrees-view">
2742
2756
  <div class="empty-state">
2743
2757
  No worktrees yet. Start a run to create one.
2744
2758
  </div>
2745
2759
  </div>
2746
- `;let p=ft(s?e.filter(_=>sC(_,s)):e),f=e.filter(_=>_.status==="completed").length;return u`
2760
+ `;let p=ft(s?e.filter(_=>rC(_,s)):e),f=e.filter(_=>_.status==="completed").length;return u`
2747
2761
  <div class="worktrees-view">
2748
- ${oC(e,t)}
2762
+ ${aC(e,t)}
2749
2763
  <div class="worktrees-toolbar">
2750
2764
  <sl-input
2751
2765
  size="small"
@@ -2770,13 +2784,13 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2770
2784
  </div>
2771
2785
  ${p.length===0?u`<div class="empty-state">No worktrees match the filter.</div>`:u`
2772
2786
  <div class="run-list worktrees-list">
2773
- ${p.map(_=>nC(_,{onSelectRun:r,onCleanup:o}))}
2787
+ ${p.map(_=>lC(_,{onSelectRun:r,onCleanup:o}))}
2774
2788
  </div>
2775
2789
  `}
2776
- ${lC(e,c,{onDialogClose:h,onDialogConfirm:d})}
2777
- ${aC(a,l,{onDialogClose:h,onDialogConfirm:d,onDialogCheckboxChange:m})}
2790
+ ${hC(e,c,{onDialogClose:h,onDialogConfirm:d})}
2791
+ ${cC(a,l,{onDialogClose:h,onDialogConfirm:d,onDialogCheckboxChange:m})}
2778
2792
  </div>
2779
- `}var Um=["subscribe-run","unsubscribe-run","subscribe-log","unsubscribe-log","list-runs","get-agent-prompt","get-preferences","set-preferences","stop-run","resume-run","list-beads-issues","start-beads-issue","list-beads-by-run","list-beads-counts","list-beads-refs","list-beads-unlinked","get-webhook-inbox","set-webhook-control","clear-webhook-inbox","hello","hello-ack","run-snapshot","run-update","runs-list","log-line","log-bulk","preferences","run-started","run-stopped","stage-restarted","beads-update","webhook-inbox-event","webhook-control-changed","webhook-inbox-cleared"];function Uh(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function qm(e,t,s=Uh()){return{id:s,type:e,payload:t}}function Km(e={}){let t={initialMs:e.backoff?.initialMs??1e3,maxMs:e.backoff?.maxMs??3e4,factor:e.backoff?.factor??2,jitterRatio:e.backoff?.jitterRatio??.2},s=()=>e.url&&e.url.length>0?e.url:typeof location<"u"?(location.protocol==="https:"?"wss://":"ws://")+location.host+"/ws":"ws://localhost/ws",i=null,r="closed",o=0,n=null,a=!0,c=new Map,l=[],h=new Map,d=new Set;function m(y){for(let C of Array.from(d))try{C(y)}catch{}}function p(){if(!a||n)return;r="reconnecting",m(r);let y=Math.min(t.maxMs,t.initialMs*t.factor**o),C=t.jitterRatio*y,S=Math.max(0,Math.round(y+(Math.random()*2-1)*C));n=setTimeout(()=>{n=null,$()},S)}function f(y){try{i?.send(JSON.stringify(y))}catch{}}function _(){for(r="open",m(r),o=0;l.length;){let y=l.shift();y&&f(y)}}function w(y){let C;try{C=JSON.parse(String(y.data))}catch{return}if(!C||typeof C.id!="string"||typeof C.type!="string")return;if(c.has(C.id)){let L=c.get(C.id);c.delete(C.id),C.ok?L?.resolve(C.payload):L?.reject(C.error||new Error("ws error"));return}let S=h.get(C.type);if(S&&S.size>0)for(let L of Array.from(S))try{L(C.payload,C)}catch{}}function k(){r="closed",m(r);for(let[y,C]of c.entries())C.reject(new Error("ws disconnected")),c.delete(y);o+=1,p()}function $(){if(!a)return;let y=s();try{i=new WebSocket(y),r="connecting",m(r),i.addEventListener("open",_),i.addEventListener("message",w),i.addEventListener("error",()=>{}),i.addEventListener("close",k)}catch{p()}}return $(),{sendRaw(y){f(y)},send(y,C){if(!Um.includes(y))return Promise.reject(new Error(`unknown message type: ${y}`));let S=Uh(),L=qm(y,C,S);return new Promise((H,F)=>{c.set(S,{resolve:H,reject:F,type:y}),i&&i.readyState===i.OPEN?f(L):l.push(L)})},on(y,C){h.has(y)||h.set(y,new Set);let S=h.get(y);return S?.add(C),()=>{S?.delete(C)}},onConnection(y){return d.add(y),()=>{d.delete(y)}},close(){a=!1,n&&(clearTimeout(n),n=null);try{i?.close()}catch{}},getState(){return r}}}var Ka=globalThis,Ga=Ka.ShadowRoot&&(Ka.ShadyCSS===void 0||Ka.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qh=Symbol(),Gm=new WeakMap,en=class{constructor(t,s,i){if(this._$cssResult$=!0,i!==qh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=s}get styleSheet(){let t=this.o,s=this.t;if(Ga&&t===void 0){let i=s!==void 0&&s.length===1;i&&(t=Gm.get(s)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Gm.set(s,t))}return t}toString(){return this.cssText}},Ym=e=>new en(typeof e=="string"?e:e+"",void 0,qh),Y=(e,...t)=>{let s=e.length===1?e[0]:t.reduce((i,r,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[o+1],e[0]);return new en(s,e,qh)},Xm=(e,t)=>{if(Ga)e.adoptedStyleSheets=t.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(let s of t){let i=document.createElement("style"),r=Ka.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=s.cssText,e.appendChild(i)}},Kh=Ga?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let s="";for(let i of t.cssRules)s+=i.cssText;return Ym(s)})(e):e;var{is:cC,defineProperty:hC,getOwnPropertyDescriptor:dC,getOwnPropertyNames:uC,getOwnPropertySymbols:pC,getPrototypeOf:fC}=Object,wi=globalThis,Jm=wi.trustedTypes,mC=Jm?Jm.emptyScript:"",gC=wi.reactiveElementPolyfillSupport,tn=(e,t)=>e,Si={toAttribute(e,t){switch(t){case Boolean:e=e?mC:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=e!==null;break;case Number:s=e===null?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch{s=null}}return s}},Ya=(e,t)=>!cC(e,t),Zm={attribute:!0,type:String,converter:Si,reflect:!1,useDefault:!1,hasChanged:Ya};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),wi.litPropertyMetadata??(wi.litPropertyMetadata=new WeakMap);var Us=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=Zm){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(t,i,s);r!==void 0&&hC(this.prototype,t,r)}}static getPropertyDescriptor(t,s,i){let{get:r,set:o}=dC(this.prototype,t)??{get(){return this[s]},set(n){this[s]=n}};return{get:r,set(n){let a=r?.call(this);o?.call(this,n),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Zm}static _$Ei(){if(this.hasOwnProperty(tn("elementProperties")))return;let t=fC(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(tn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(tn("properties"))){let s=this.properties,i=[...uC(s),...pC(s)];for(let r of i)this.createProperty(r,s[r])}let t=this[Symbol.metadata];if(t!==null){let s=litPropertyMetadata.get(t);if(s!==void 0)for(let[i,r]of s)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[s,i]of this.elementProperties){let r=this._$Eu(s,i);r!==void 0&&this._$Eh.set(r,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let s=[];if(Array.isArray(t)){let i=new Set(t.flat(1/0).reverse());for(let r of i)s.unshift(Kh(r))}else t!==void 0&&s.push(Kh(t));return s}static _$Eu(t,s){let i=s.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,s=this.constructor.elementProperties;for(let i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Xm(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$ET(t,s){let i=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,i);if(r!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:Si).toAttribute(s,i.type);this._$Em=t,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,s){let i=this.constructor,r=i._$Eh.get(t);if(r!==void 0&&this._$Em!==r){let o=i.getPropertyOptions(r),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Si;this._$Em=r;let a=n.fromAttribute(s,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(t,s,i,r=!1,o){if(t!==void 0){let n=this.constructor;if(r===!1&&(o=this[t]),i??(i=n.getPropertyOptions(t)),!((i.hasChanged??Ya)(o,s)||i.useDefault&&i.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,s,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,s,{useDefault:i,reflect:r,wrapped:o},n){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,n??s??this[t]),o!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),r===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,o]of i){let{wrapped:n}=o,a=this[r];n!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let t=!1,s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(s)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach(s=>s.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(s=>this._$ET(s,this[s]))),this._$EM()}updated(t){}firstUpdated(t){}};Us.elementStyles=[],Us.shadowRootOptions={mode:"open"},Us[tn("elementProperties")]=new Map,Us[tn("finalized")]=new Map,gC?.({ReactiveElement:Us}),(wi.reactiveElementVersions??(wi.reactiveElementVersions=[])).push("2.1.2");var sn=globalThis,Ci=class extends Us{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var s;let t=super.createRenderRoot();return(s=this.renderOptions).renderBefore??(s.renderBefore=t.firstChild),t}update(t){let s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Fn(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ct}};Ci._$litElement$=!0,Ci.finalized=!0,sn.litElementHydrateSupport?.({LitElement:Ci});var _C=sn.litElementPolyfillSupport;_C?.({LitElement:Ci});(sn.litElementVersions??(sn.litElementVersions=[])).push("4.2.2");var Qm=Y`
2793
+ `}var qm=["subscribe-run","unsubscribe-run","subscribe-log","unsubscribe-log","list-runs","get-agent-prompt","get-preferences","set-preferences","stop-run","resume-run","list-beads-issues","start-beads-issue","list-beads-by-run","list-beads-counts","list-beads-refs","list-beads-unlinked","get-webhook-inbox","set-webhook-control","clear-webhook-inbox","hello","hello-ack","run-snapshot","run-update","runs-list","log-line","log-bulk","preferences","run-started","run-stopped","stage-restarted","beads-update","webhook-inbox-event","webhook-control-changed","webhook-inbox-cleared"];function Uh(){let e=Date.now().toString(36),t=Math.random().toString(36).slice(2,8);return`${e}-${t}`}function Km(e,t,s=Uh()){return{id:s,type:e,payload:t}}function Gm(e={}){let t={initialMs:e.backoff?.initialMs??1e3,maxMs:e.backoff?.maxMs??3e4,factor:e.backoff?.factor??2,jitterRatio:e.backoff?.jitterRatio??.2},s=()=>e.url&&e.url.length>0?e.url:typeof location<"u"?(location.protocol==="https:"?"wss://":"ws://")+location.host+"/ws":"ws://localhost/ws",i=null,r="closed",o=0,n=null,a=!0,c=new Map,l=[],h=new Map,d=new Set;function m(y){for(let C of Array.from(d))try{C(y)}catch{}}function p(){if(!a||n)return;r="reconnecting",m(r);let y=Math.min(t.maxMs,t.initialMs*t.factor**o),C=t.jitterRatio*y,S=Math.max(0,Math.round(y+(Math.random()*2-1)*C));n=setTimeout(()=>{n=null,$()},S)}function f(y){try{i?.send(JSON.stringify(y))}catch{}}function _(){for(r="open",m(r),o=0;l.length;){let y=l.shift();y&&f(y)}}function w(y){let C;try{C=JSON.parse(String(y.data))}catch{return}if(!C||typeof C.id!="string"||typeof C.type!="string")return;if(c.has(C.id)){let L=c.get(C.id);c.delete(C.id),C.ok?L?.resolve(C.payload):L?.reject(C.error||new Error("ws error"));return}let S=h.get(C.type);if(S&&S.size>0)for(let L of Array.from(S))try{L(C.payload,C)}catch{}}function k(){r="closed",m(r);for(let[y,C]of c.entries())C.reject(new Error("ws disconnected")),c.delete(y);o+=1,p()}function $(){if(!a)return;let y=s();try{i=new WebSocket(y),r="connecting",m(r),i.addEventListener("open",_),i.addEventListener("message",w),i.addEventListener("error",()=>{}),i.addEventListener("close",k)}catch{p()}}return $(),{sendRaw(y){f(y)},send(y,C){if(!qm.includes(y))return Promise.reject(new Error(`unknown message type: ${y}`));let S=Uh(),L=Km(y,C,S);return new Promise((H,F)=>{c.set(S,{resolve:H,reject:F,type:y}),i&&i.readyState===i.OPEN?f(L):l.push(L)})},on(y,C){h.has(y)||h.set(y,new Set);let S=h.get(y);return S?.add(C),()=>{S?.delete(C)}},onConnection(y){return d.add(y),()=>{d.delete(y)}},close(){a=!1,n&&(clearTimeout(n),n=null);try{i?.close()}catch{}},getState(){return r}}}var Ka=globalThis,Ga=Ka.ShadowRoot&&(Ka.ShadyCSS===void 0||Ka.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qh=Symbol(),Ym=new WeakMap,en=class{constructor(t,s,i){if(this._$cssResult$=!0,i!==qh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=s}get styleSheet(){let t=this.o,s=this.t;if(Ga&&t===void 0){let i=s!==void 0&&s.length===1;i&&(t=Ym.get(s)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ym.set(s,t))}return t}toString(){return this.cssText}},Xm=e=>new en(typeof e=="string"?e:e+"",void 0,qh),Y=(e,...t)=>{let s=e.length===1?e[0]:t.reduce((i,r,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[o+1],e[0]);return new en(s,e,qh)},Jm=(e,t)=>{if(Ga)e.adoptedStyleSheets=t.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(let s of t){let i=document.createElement("style"),r=Ka.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=s.cssText,e.appendChild(i)}},Kh=Ga?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let s="";for(let i of t.cssRules)s+=i.cssText;return Xm(s)})(e):e;var{is:dC,defineProperty:uC,getOwnPropertyDescriptor:pC,getOwnPropertyNames:fC,getOwnPropertySymbols:mC,getPrototypeOf:gC}=Object,wi=globalThis,Zm=wi.trustedTypes,_C=Zm?Zm.emptyScript:"",vC=wi.reactiveElementPolyfillSupport,tn=(e,t)=>e,Si={toAttribute(e,t){switch(t){case Boolean:e=e?_C:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let s=e;switch(t){case Boolean:s=e!==null;break;case Number:s=e===null?null:Number(e);break;case Object:case Array:try{s=JSON.parse(e)}catch{s=null}}return s}},Ya=(e,t)=>!dC(e,t),Qm={attribute:!0,type:String,converter:Si,reflect:!1,useDefault:!1,hasChanged:Ya};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),wi.litPropertyMetadata??(wi.litPropertyMetadata=new WeakMap);var Us=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=Qm){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(t,s),!s.noAccessor){let i=Symbol(),r=this.getPropertyDescriptor(t,i,s);r!==void 0&&uC(this.prototype,t,r)}}static getPropertyDescriptor(t,s,i){let{get:r,set:o}=pC(this.prototype,t)??{get(){return this[s]},set(n){this[s]=n}};return{get:r,set(n){let a=r?.call(this);o?.call(this,n),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Qm}static _$Ei(){if(this.hasOwnProperty(tn("elementProperties")))return;let t=gC(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(tn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(tn("properties"))){let s=this.properties,i=[...fC(s),...mC(s)];for(let r of i)this.createProperty(r,s[r])}let t=this[Symbol.metadata];if(t!==null){let s=litPropertyMetadata.get(t);if(s!==void 0)for(let[i,r]of s)this.elementProperties.set(i,r)}this._$Eh=new Map;for(let[s,i]of this.elementProperties){let r=this._$Eu(s,i);r!==void 0&&this._$Eh.set(r,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let s=[];if(Array.isArray(t)){let i=new Set(t.flat(1/0).reverse());for(let r of i)s.unshift(Kh(r))}else t!==void 0&&s.push(Kh(t));return s}static _$Eu(t,s){let i=s.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,s=this.constructor.elementProperties;for(let i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Jm(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$ET(t,s){let i=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,i);if(r!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:Si).toAttribute(s,i.type);this._$Em=t,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,s){let i=this.constructor,r=i._$Eh.get(t);if(r!==void 0&&this._$Em!==r){let o=i.getPropertyOptions(r),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Si;this._$Em=r;let a=n.fromAttribute(s,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(t,s,i,r=!1,o){if(t!==void 0){let n=this.constructor;if(r===!1&&(o=this[t]),i??(i=n.getPropertyOptions(t)),!((i.hasChanged??Ya)(o,s)||i.useDefault&&i.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,s,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,s,{useDefault:i,reflect:r,wrapped:o},n){i&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,n??s??this[t]),o!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),r===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[r,o]of i){let{wrapped:n}=o,a=this[r];n!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let t=!1,s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(s)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach(s=>s.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(s=>this._$ET(s,this[s]))),this._$EM()}updated(t){}firstUpdated(t){}};Us.elementStyles=[],Us.shadowRootOptions={mode:"open"},Us[tn("elementProperties")]=new Map,Us[tn("finalized")]=new Map,vC?.({ReactiveElement:Us}),(wi.reactiveElementVersions??(wi.reactiveElementVersions=[])).push("2.1.2");var sn=globalThis,Ci=class extends Us{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var s;let t=super.createRenderRoot();return(s=this.renderOptions).renderBefore??(s.renderBefore=t.firstChild),t}update(t){let s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Fn(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ct}};Ci._$litElement$=!0,Ci.finalized=!0,sn.litElementHydrateSupport?.({LitElement:Ci});var bC=sn.litElementPolyfillSupport;bC?.({LitElement:Ci});(sn.litElementVersions??(sn.litElementVersions=[])).push("4.2.2");var eg=Y`
2780
2794
  :host {
2781
2795
  display: block;
2782
2796
  }
@@ -2858,7 +2872,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2858
2872
  display: block;
2859
2873
  padding: var(--sl-spacing-medium);
2860
2874
  }
2861
- `;var sg=Object.defineProperty,vC=Object.defineProperties,bC=Object.getOwnPropertyDescriptor,yC=Object.getOwnPropertyDescriptors,eg=Object.getOwnPropertySymbols,wC=Object.prototype.hasOwnProperty,SC=Object.prototype.propertyIsEnumerable,Gh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yh=e=>{throw TypeError(e)},tg=(e,t,s)=>t in e?sg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ut=(e,t)=>{for(var s in t||(t={}))wC.call(t,s)&&tg(e,s,t[s]);if(eg)for(var s of eg(t))SC.call(t,s)&&tg(e,s,t[s]);return e},qs=(e,t)=>vC(e,yC(t)),g=(e,t,s,i)=>{for(var r=i>1?void 0:i?bC(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&sg(t,s,r),r},ig=(e,t,s)=>t.has(e)||Yh("Cannot "+s),rg=(e,t,s)=>(ig(e,t,"read from private field"),s?s.call(e):t.get(e)),og=(e,t,s)=>t.has(e)?Yh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ng=(e,t,s,i)=>(ig(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),CC=function(e,t){this[0]=e,this[1]=t},ag=e=>{var t=e[Gh("asyncIterator")],s=!1,i,r={};return t==null?(t=e[Gh("iterator")](),i=o=>r[o]=n=>t[o](n)):(t=t.call(e),i=o=>r[o]=n=>{if(s){if(s=!1,o==="throw")throw n;return n}return s=!0,{done:!1,value:new CC(new Promise(a=>{var c=t[o](n);c instanceof Object||Yh("Object expected"),a(c)}),1)}}),r[Gh("iterator")]=()=>r,i("next"),"throw"in t?i("throw"):r.throw=o=>{throw o},"return"in t&&i("return"),r};var cg=new Map,xC=new WeakMap;function kC(e){return e??{keyframes:[],options:{duration:0}}}function lg(e,t){return t.toLowerCase()==="rtl"?{keyframes:e.rtlKeyframes||e.keyframes,options:e.options}:e}function Ge(e,t){cg.set(e,kC(t))}function Ye(e,t,s){let i=xC.get(e);if(i?.[t])return lg(i[t],s.dir);let r=cg.get(t);return r?lg(r,s.dir):{keyframes:[],options:{duration:0}}}function vt(e,t){return new Promise(s=>{function i(r){r.target===e&&(e.removeEventListener(t,i),s())}e.addEventListener(t,i)})}function Xe(e,t,s){return new Promise(i=>{if(s?.duration===1/0)throw new Error("Promise-based animations must be finite.");let r=e.animate(t,qs(ut({},s),{duration:$C()?0:s.duration}));r.addEventListener("cancel",i,{once:!0}),r.addEventListener("finish",i,{once:!0})})}function Xh(e){return e=e.toString().toLowerCase(),e.indexOf("ms")>-1?parseFloat(e):e.indexOf("s")>-1?parseFloat(e)*1e3:parseFloat(e)}function $C(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function at(e){return Promise.all(e.getAnimations().map(t=>new Promise(s=>{t.cancel(),requestAnimationFrame(s)})))}function Jh(e,t){return e.map(s=>qs(ut({},s),{height:s.height==="auto"?`${t}px`:s.height}))}var Zh=new Set,jr=new Map,sr,Qh="ltr",ed="en",hg=typeof MutationObserver<"u"&&typeof document<"u"&&typeof document.documentElement<"u";if(hg){let e=new MutationObserver(dg);Qh=document.documentElement.dir||"ltr",ed=document.documentElement.lang||navigator.language,e.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","lang"]})}function rn(...e){e.map(t=>{let s=t.$code.toLowerCase();jr.has(s)?jr.set(s,Object.assign(Object.assign({},jr.get(s)),t)):jr.set(s,t),sr||(sr=t)}),dg()}function dg(){hg&&(Qh=document.documentElement.dir||"ltr",ed=document.documentElement.lang||navigator.language),[...Zh.keys()].map(e=>{typeof e.requestUpdate=="function"&&e.requestUpdate()})}var Xa=class{constructor(t){this.host=t,this.host.addController(this)}hostConnected(){Zh.add(this.host)}hostDisconnected(){Zh.delete(this.host)}dir(){return`${this.host.dir||Qh}`.toLowerCase()}lang(){return`${this.host.lang||ed}`.toLowerCase()}getTranslationData(t){var s,i;let r=new Intl.Locale(t.replace(/_/g,"-")),o=r?.language.toLowerCase(),n=(i=(s=r?.region)===null||s===void 0?void 0:s.toLowerCase())!==null&&i!==void 0?i:"",a=jr.get(`${o}-${n}`),c=jr.get(o);return{locale:r,language:o,region:n,primary:a,secondary:c}}exists(t,s){var i;let{primary:r,secondary:o}=this.getTranslationData((i=s.lang)!==null&&i!==void 0?i:this.lang());return s=Object.assign({includeFallback:!1},s),!!(r&&r[t]||o&&o[t]||s.includeFallback&&sr&&sr[t])}term(t,...s){let{primary:i,secondary:r}=this.getTranslationData(this.lang()),o;if(i&&i[t])o=i[t];else if(r&&r[t])o=r[t];else if(sr&&sr[t])o=sr[t];else return console.error(`No translation found for: ${String(t)}`),String(t);return typeof o=="function"?o(...s):o}date(t,s){return t=new Date(t),new Intl.DateTimeFormat(this.lang(),s).format(t)}number(t,s){return t=Number(t),isNaN(t)?"":new Intl.NumberFormat(this.lang(),s).format(t)}relativeTime(t,s,i){return new Intl.RelativeTimeFormat(this.lang(),i).format(t,s)}};var ug={$code:"en",$name:"English",$dir:"ltr",carousel:"Carousel",clearEntry:"Clear entry",close:"Close",copied:"Copied",copy:"Copy",currentValue:"Current value",error:"Error",goToSlide:(e,t)=>`Go to slide ${e} of ${t}`,hidePassword:"Hide password",loading:"Loading",nextSlide:"Next slide",numOptionsSelected:e=>e===0?"No options selected":e===1?"1 option selected":`${e} options selected`,previousSlide:"Previous slide",progress:"Progress",remove:"Remove",resize:"Resize",scrollToEnd:"Scroll to end",scrollToStart:"Scroll to start",selectAColorFromTheScreen:"Select a color from the screen",showPassword:"Show password",slideNum:e=>`Slide ${e}`,toggleColorFormat:"Toggle color format"};rn(ug);var pg=ug;var be=class extends Xa{};rn(pg);var td="";function fg(e){td=e}function mg(e=""){if(!td){let t=[...document.getElementsByTagName("script")],s=t.find(i=>i.hasAttribute("data-shoelace"));if(s)fg(s.getAttribute("data-shoelace"));else{let i=t.find(o=>/shoelace(\.min)?\.js($|\?)/.test(o.src)||/shoelace-autoloader(\.min)?\.js($|\?)/.test(o.src)),r="";i&&(r=i.getAttribute("src")),fg(r.split("/").slice(0,-1).join("/"))}}return td.replace(/\/$/,"")+(e?`/${e.replace(/^\//,"")}`:"")}var EC={name:"default",resolver:e=>mg(`assets/icons/${e}.svg`)},gg=EC;var _g={caret:`
2875
+ `;var ig=Object.defineProperty,yC=Object.defineProperties,wC=Object.getOwnPropertyDescriptor,SC=Object.getOwnPropertyDescriptors,tg=Object.getOwnPropertySymbols,CC=Object.prototype.hasOwnProperty,xC=Object.prototype.propertyIsEnumerable,Gh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Yh=e=>{throw TypeError(e)},sg=(e,t,s)=>t in e?ig(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ut=(e,t)=>{for(var s in t||(t={}))CC.call(t,s)&&sg(e,s,t[s]);if(tg)for(var s of tg(t))xC.call(t,s)&&sg(e,s,t[s]);return e},qs=(e,t)=>yC(e,SC(t)),g=(e,t,s,i)=>{for(var r=i>1?void 0:i?wC(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(i?n(t,s,r):n(r))||r);return i&&r&&ig(t,s,r),r},rg=(e,t,s)=>t.has(e)||Yh("Cannot "+s),og=(e,t,s)=>(rg(e,t,"read from private field"),s?s.call(e):t.get(e)),ng=(e,t,s)=>t.has(e)?Yh("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ag=(e,t,s,i)=>(rg(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),kC=function(e,t){this[0]=e,this[1]=t},lg=e=>{var t=e[Gh("asyncIterator")],s=!1,i,r={};return t==null?(t=e[Gh("iterator")](),i=o=>r[o]=n=>t[o](n)):(t=t.call(e),i=o=>r[o]=n=>{if(s){if(s=!1,o==="throw")throw n;return n}return s=!0,{done:!1,value:new kC(new Promise(a=>{var c=t[o](n);c instanceof Object||Yh("Object expected"),a(c)}),1)}}),r[Gh("iterator")]=()=>r,i("next"),"throw"in t?i("throw"):r.throw=o=>{throw o},"return"in t&&i("return"),r};var hg=new Map,$C=new WeakMap;function EC(e){return e??{keyframes:[],options:{duration:0}}}function cg(e,t){return t.toLowerCase()==="rtl"?{keyframes:e.rtlKeyframes||e.keyframes,options:e.options}:e}function Ge(e,t){hg.set(e,EC(t))}function Ye(e,t,s){let i=$C.get(e);if(i?.[t])return cg(i[t],s.dir);let r=hg.get(t);return r?cg(r,s.dir):{keyframes:[],options:{duration:0}}}function vt(e,t){return new Promise(s=>{function i(r){r.target===e&&(e.removeEventListener(t,i),s())}e.addEventListener(t,i)})}function Xe(e,t,s){return new Promise(i=>{if(s?.duration===1/0)throw new Error("Promise-based animations must be finite.");let r=e.animate(t,qs(ut({},s),{duration:TC()?0:s.duration}));r.addEventListener("cancel",i,{once:!0}),r.addEventListener("finish",i,{once:!0})})}function Xh(e){return e=e.toString().toLowerCase(),e.indexOf("ms")>-1?parseFloat(e):e.indexOf("s")>-1?parseFloat(e)*1e3:parseFloat(e)}function TC(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function at(e){return Promise.all(e.getAnimations().map(t=>new Promise(s=>{t.cancel(),requestAnimationFrame(s)})))}function Jh(e,t){return e.map(s=>qs(ut({},s),{height:s.height==="auto"?`${t}px`:s.height}))}var Zh=new Set,jr=new Map,sr,Qh="ltr",ed="en",dg=typeof MutationObserver<"u"&&typeof document<"u"&&typeof document.documentElement<"u";if(dg){let e=new MutationObserver(ug);Qh=document.documentElement.dir||"ltr",ed=document.documentElement.lang||navigator.language,e.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","lang"]})}function rn(...e){e.map(t=>{let s=t.$code.toLowerCase();jr.has(s)?jr.set(s,Object.assign(Object.assign({},jr.get(s)),t)):jr.set(s,t),sr||(sr=t)}),ug()}function ug(){dg&&(Qh=document.documentElement.dir||"ltr",ed=document.documentElement.lang||navigator.language),[...Zh.keys()].map(e=>{typeof e.requestUpdate=="function"&&e.requestUpdate()})}var Xa=class{constructor(t){this.host=t,this.host.addController(this)}hostConnected(){Zh.add(this.host)}hostDisconnected(){Zh.delete(this.host)}dir(){return`${this.host.dir||Qh}`.toLowerCase()}lang(){return`${this.host.lang||ed}`.toLowerCase()}getTranslationData(t){var s,i;let r=new Intl.Locale(t.replace(/_/g,"-")),o=r?.language.toLowerCase(),n=(i=(s=r?.region)===null||s===void 0?void 0:s.toLowerCase())!==null&&i!==void 0?i:"",a=jr.get(`${o}-${n}`),c=jr.get(o);return{locale:r,language:o,region:n,primary:a,secondary:c}}exists(t,s){var i;let{primary:r,secondary:o}=this.getTranslationData((i=s.lang)!==null&&i!==void 0?i:this.lang());return s=Object.assign({includeFallback:!1},s),!!(r&&r[t]||o&&o[t]||s.includeFallback&&sr&&sr[t])}term(t,...s){let{primary:i,secondary:r}=this.getTranslationData(this.lang()),o;if(i&&i[t])o=i[t];else if(r&&r[t])o=r[t];else if(sr&&sr[t])o=sr[t];else return console.error(`No translation found for: ${String(t)}`),String(t);return typeof o=="function"?o(...s):o}date(t,s){return t=new Date(t),new Intl.DateTimeFormat(this.lang(),s).format(t)}number(t,s){return t=Number(t),isNaN(t)?"":new Intl.NumberFormat(this.lang(),s).format(t)}relativeTime(t,s,i){return new Intl.RelativeTimeFormat(this.lang(),i).format(t,s)}};var pg={$code:"en",$name:"English",$dir:"ltr",carousel:"Carousel",clearEntry:"Clear entry",close:"Close",copied:"Copied",copy:"Copy",currentValue:"Current value",error:"Error",goToSlide:(e,t)=>`Go to slide ${e} of ${t}`,hidePassword:"Hide password",loading:"Loading",nextSlide:"Next slide",numOptionsSelected:e=>e===0?"No options selected":e===1?"1 option selected":`${e} options selected`,previousSlide:"Previous slide",progress:"Progress",remove:"Remove",resize:"Resize",scrollToEnd:"Scroll to end",scrollToStart:"Scroll to start",selectAColorFromTheScreen:"Select a color from the screen",showPassword:"Show password",slideNum:e=>`Slide ${e}`,toggleColorFormat:"Toggle color format"};rn(pg);var fg=pg;var be=class extends Xa{};rn(fg);var td="";function mg(e){td=e}function gg(e=""){if(!td){let t=[...document.getElementsByTagName("script")],s=t.find(i=>i.hasAttribute("data-shoelace"));if(s)mg(s.getAttribute("data-shoelace"));else{let i=t.find(o=>/shoelace(\.min)?\.js($|\?)/.test(o.src)||/shoelace-autoloader(\.min)?\.js($|\?)/.test(o.src)),r="";i&&(r=i.getAttribute("src")),mg(r.split("/").slice(0,-1).join("/"))}}return td.replace(/\/$/,"")+(e?`/${e.replace(/^\//,"")}`:"")}var AC={name:"default",resolver:e=>gg(`assets/icons/${e}.svg`)},_g=AC;var vg={caret:`
2862
2876
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2863
2877
  <polyline points="6 9 12 15 18 9"></polyline>
2864
2878
  </svg>
@@ -2950,7 +2964,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2950
2964
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-circle-fill" viewBox="0 0 16 16">
2951
2965
  <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"></path>
2952
2966
  </svg>
2953
- `},TC={name:"system",resolver:e=>e in _g?`data:image/svg+xml,${encodeURIComponent(_g[e])}`:""},vg=TC;var AC=[gg,vg],sd=[];function bg(e){sd.push(e)}function yg(e){sd=sd.filter(t=>t!==e)}function id(e){return AC.find(t=>t.name===e)}var wg=Y`
2967
+ `},RC={name:"system",resolver:e=>e in vg?`data:image/svg+xml,${encodeURIComponent(vg[e])}`:""},bg=RC;var DC=[_g,bg],sd=[];function yg(e){sd.push(e)}function wg(e){sd=sd.filter(t=>t!==e)}function id(e){return DC.find(t=>t.name===e)}var Sg=Y`
2954
2968
  :host {
2955
2969
  display: inline-block;
2956
2970
  width: 1em;
@@ -2977,9 +2991,9 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
2977
2991
  [hidden] {
2978
2992
  display: none !important;
2979
2993
  }
2980
- `;var RC={attribute:!0,type:String,converter:Si,reflect:!1,hasChanged:Ya},DC=(e=RC,t,s)=>{let{kind:i,metadata:r}=s,o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),i==="accessor"){let{name:n}=s;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(i==="setter"){let{name:n}=s;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function v(e){return(t,s)=>typeof s=="object"?DC(e,t,s):((i,r,o)=>{let n=r.hasOwnProperty(o);return r.constructor.createProperty(o,i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,s)}function oe(e){return v({...e,state:!0,attribute:!1})}function Sg(e){return(t,s)=>{let i=typeof t=="function"?t:t[s];Object.assign(i,e)}}var ir=(e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,s),s);function Z(e,t){return(s,i,r)=>{let o=n=>n.renderRoot?.querySelector(e)??null;if(t){let{get:n,set:a}=typeof i=="object"?s:r??(()=>{let c=Symbol();return{get(){return this[c]},set(l){this[c]=l}}})();return ir(s,i,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return ir(s,i,{get(){return o(this)}})}}var Ja,X=class extends Ci{constructor(){super(),og(this,Ja,!1),this.initialReflectedProperties=new Map,Object.entries(this.constructor.dependencies).forEach(([e,t])=>{this.constructor.define(e,t)})}emit(e,t){let s=new CustomEvent(e,ut({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}static define(e,t=this,s={}){let i=customElements.get(e);if(!i){try{customElements.define(e,t,s)}catch{customElements.define(e,class extends t{},s)}return}let r=" (unknown version)",o=r;"version"in t&&t.version&&(r=" v"+t.version),"version"in i&&i.version&&(o=" v"+i.version),!(r&&o&&r===o)&&console.warn(`Attempted to register <${e}>${r}, but <${e}>${o} has already been registered.`)}attributeChangedCallback(e,t,s){rg(this,Ja)||(this.constructor.elementProperties.forEach((i,r)=>{i.reflect&&this[r]!=null&&this.initialReflectedProperties.set(r,this[r])}),ng(this,Ja,!0)),super.attributeChangedCallback(e,t,s)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((t,s)=>{e.has(s)&&this[s]==null&&(this[s]=t)})}};Ja=new WeakMap;X.version="2.20.1";X.dependencies={};g([v()],X.prototype,"dir",2);g([v()],X.prototype,"lang",2);var{I:zL}=Yd;var Cg=(e,t)=>t===void 0?e?._$litType$!==void 0:e?._$litType$===t;var xg=e=>e.strings===void 0;var LC={},kg=(e,t=LC)=>e._$AH=t;var on=Symbol(),Za=Symbol(),rd,od=new Map,Ce=class extends X{constructor(){super(...arguments),this.initialRender=!1,this.svg=null,this.label="",this.library="default"}async resolveIcon(e,t){var s;let i;if(t?.spriteSheet)return this.svg=u`<svg part="svg">
2994
+ `;var LC={attribute:!0,type:String,converter:Si,reflect:!1,hasChanged:Ya},PC=(e=LC,t,s)=>{let{kind:i,metadata:r}=s,o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),i==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(s.name,e),i==="accessor"){let{name:n}=s;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(i==="setter"){let{name:n}=s;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,e,!0,a)}}throw Error("Unsupported decorator location: "+i)};function v(e){return(t,s)=>typeof s=="object"?PC(e,t,s):((i,r,o)=>{let n=r.hasOwnProperty(o);return r.constructor.createProperty(o,i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,s)}function oe(e){return v({...e,state:!0,attribute:!1})}function Cg(e){return(t,s)=>{let i=typeof t=="function"?t:t[s];Object.assign(i,e)}}var ir=(e,t,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,s),s);function Z(e,t){return(s,i,r)=>{let o=n=>n.renderRoot?.querySelector(e)??null;if(t){let{get:n,set:a}=typeof i=="object"?s:r??(()=>{let c=Symbol();return{get(){return this[c]},set(l){this[c]=l}}})();return ir(s,i,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return ir(s,i,{get(){return o(this)}})}}var Ja,X=class extends Ci{constructor(){super(),ng(this,Ja,!1),this.initialReflectedProperties=new Map,Object.entries(this.constructor.dependencies).forEach(([e,t])=>{this.constructor.define(e,t)})}emit(e,t){let s=new CustomEvent(e,ut({bubbles:!0,cancelable:!1,composed:!0,detail:{}},t));return this.dispatchEvent(s),s}static define(e,t=this,s={}){let i=customElements.get(e);if(!i){try{customElements.define(e,t,s)}catch{customElements.define(e,class extends t{},s)}return}let r=" (unknown version)",o=r;"version"in t&&t.version&&(r=" v"+t.version),"version"in i&&i.version&&(o=" v"+i.version),!(r&&o&&r===o)&&console.warn(`Attempted to register <${e}>${r}, but <${e}>${o} has already been registered.`)}attributeChangedCallback(e,t,s){og(this,Ja)||(this.constructor.elementProperties.forEach((i,r)=>{i.reflect&&this[r]!=null&&this.initialReflectedProperties.set(r,this[r])}),ag(this,Ja,!0)),super.attributeChangedCallback(e,t,s)}willUpdate(e){super.willUpdate(e),this.initialReflectedProperties.forEach((t,s)=>{e.has(s)&&this[s]==null&&(this[s]=t)})}};Ja=new WeakMap;X.version="2.20.1";X.dependencies={};g([v()],X.prototype,"dir",2);g([v()],X.prototype,"lang",2);var{I:FL}=Yd;var xg=(e,t)=>t===void 0?e?._$litType$!==void 0:e?._$litType$===t;var kg=e=>e.strings===void 0;var BC={},$g=(e,t=BC)=>e._$AH=t;var on=Symbol(),Za=Symbol(),rd,od=new Map,Ce=class extends X{constructor(){super(...arguments),this.initialRender=!1,this.svg=null,this.label="",this.library="default"}async resolveIcon(e,t){var s;let i;if(t?.spriteSheet)return this.svg=u`<svg part="svg">
2981
2995
  <use part="use" href="${e}"></use>
2982
- </svg>`,this.svg;try{if(i=await fetch(e,{mode:"cors"}),!i.ok)return i.status===410?on:Za}catch{return Za}try{let r=document.createElement("div");r.innerHTML=await i.text();let o=r.firstElementChild;if(((s=o?.tagName)==null?void 0:s.toLowerCase())!=="svg")return on;rd||(rd=new DOMParser);let a=rd.parseFromString(o.outerHTML,"text/html").body.querySelector("svg");return a?(a.part.add("svg"),document.adoptNode(a)):on}catch{return on}}connectedCallback(){super.connectedCallback(),bg(this)}firstUpdated(){this.initialRender=!0,this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),yg(this)}getIconSource(){let e=id(this.library);return this.name&&e?{url:e.resolver(this.name),fromLibrary:!0}:{url:this.src,fromLibrary:!1}}handleLabelChange(){typeof this.label=="string"&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var e;let{url:t,fromLibrary:s}=this.getIconSource(),i=s?id(this.library):void 0;if(!t){this.svg=null;return}let r=od.get(t);if(r||(r=this.resolveIcon(t,i),od.set(t,r)),!this.initialRender)return;let o=await r;if(o===Za&&od.delete(t),t===this.getIconSource().url){if(Cg(o)){if(this.svg=o,i){await this.updateComplete;let n=this.shadowRoot.querySelector("[part='svg']");typeof i.mutator=="function"&&n&&i.mutator(n)}return}switch(o){case Za:case on:this.svg=null,this.emit("sl-error");break;default:this.svg=o.cloneNode(!0),(e=i?.mutator)==null||e.call(i,this.svg),this.emit("sl-load")}}}render(){return this.svg}};Ce.styles=[Q,wg];g([oe()],Ce.prototype,"svg",2);g([v({reflect:!0})],Ce.prototype,"name",2);g([v()],Ce.prototype,"src",2);g([v()],Ce.prototype,"label",2);g([v({reflect:!0})],Ce.prototype,"library",2);g([G("label")],Ce.prototype,"handleLabelChange",1);g([G(["name","src","library"])],Ce.prototype,"setIcon",1);var ee=mr(class extends Qs{constructor(e){if(super(e),e.type!==ts.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(let i in t)t[i]&&!this.nt?.has(i)&&this.st.add(i);return this.render(t)}let s=e.element.classList;for(let i of this.st)i in t||(s.remove(i),this.st.delete(i));for(let i in t){let r=!!t[i];r===this.st.has(i)||this.nt?.has(i)||(r?(s.add(i),this.st.add(i)):(s.remove(i),this.st.delete(i)))}return ct}});var Gt=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.open=!1,this.disabled=!1}firstUpdated(){this.body.style.height=this.open?"auto":"0",this.open&&(this.details.open=!0),this.detailsObserver=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName==="open"&&(this.details.open?this.show():this.hide())}),this.detailsObserver.observe(this.details,{attributes:!0})}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.detailsObserver)==null||e.disconnect()}handleSummaryClick(e){e.preventDefault(),this.disabled||(this.open?this.hide():this.show(),this.header.focus())}handleSummaryKeyDown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.open?this.hide():this.show()),(e.key==="ArrowUp"||e.key==="ArrowLeft")&&(e.preventDefault(),this.hide()),(e.key==="ArrowDown"||e.key==="ArrowRight")&&(e.preventDefault(),this.show())}async handleOpenChange(){if(this.open){if(this.details.open=!0,this.emit("sl-show",{cancelable:!0}).defaultPrevented){this.open=!1,this.details.open=!1;return}await at(this.body);let{keyframes:t,options:s}=Ye(this,"details.show",{dir:this.localize.dir()});await Xe(this.body,Jh(t,this.body.scrollHeight),s),this.body.style.height="auto",this.emit("sl-after-show")}else{if(this.emit("sl-hide",{cancelable:!0}).defaultPrevented){this.details.open=!0,this.open=!0;return}await at(this.body);let{keyframes:t,options:s}=Ye(this,"details.hide",{dir:this.localize.dir()});await Xe(this.body,Jh(t,this.body.scrollHeight),s),this.body.style.height="auto",this.details.open=!1,this.emit("sl-after-hide")}}async show(){if(!(this.open||this.disabled))return this.open=!0,vt(this,"sl-after-show")}async hide(){if(!(!this.open||this.disabled))return this.open=!1,vt(this,"sl-after-hide")}render(){let e=this.localize.dir()==="rtl";return u`
2996
+ </svg>`,this.svg;try{if(i=await fetch(e,{mode:"cors"}),!i.ok)return i.status===410?on:Za}catch{return Za}try{let r=document.createElement("div");r.innerHTML=await i.text();let o=r.firstElementChild;if(((s=o?.tagName)==null?void 0:s.toLowerCase())!=="svg")return on;rd||(rd=new DOMParser);let a=rd.parseFromString(o.outerHTML,"text/html").body.querySelector("svg");return a?(a.part.add("svg"),document.adoptNode(a)):on}catch{return on}}connectedCallback(){super.connectedCallback(),yg(this)}firstUpdated(){this.initialRender=!0,this.setIcon()}disconnectedCallback(){super.disconnectedCallback(),wg(this)}getIconSource(){let e=id(this.library);return this.name&&e?{url:e.resolver(this.name),fromLibrary:!0}:{url:this.src,fromLibrary:!1}}handleLabelChange(){typeof this.label=="string"&&this.label.length>0?(this.setAttribute("role","img"),this.setAttribute("aria-label",this.label),this.removeAttribute("aria-hidden")):(this.removeAttribute("role"),this.removeAttribute("aria-label"),this.setAttribute("aria-hidden","true"))}async setIcon(){var e;let{url:t,fromLibrary:s}=this.getIconSource(),i=s?id(this.library):void 0;if(!t){this.svg=null;return}let r=od.get(t);if(r||(r=this.resolveIcon(t,i),od.set(t,r)),!this.initialRender)return;let o=await r;if(o===Za&&od.delete(t),t===this.getIconSource().url){if(xg(o)){if(this.svg=o,i){await this.updateComplete;let n=this.shadowRoot.querySelector("[part='svg']");typeof i.mutator=="function"&&n&&i.mutator(n)}return}switch(o){case Za:case on:this.svg=null,this.emit("sl-error");break;default:this.svg=o.cloneNode(!0),(e=i?.mutator)==null||e.call(i,this.svg),this.emit("sl-load")}}}render(){return this.svg}};Ce.styles=[Q,Sg];g([oe()],Ce.prototype,"svg",2);g([v({reflect:!0})],Ce.prototype,"name",2);g([v()],Ce.prototype,"src",2);g([v()],Ce.prototype,"label",2);g([v({reflect:!0})],Ce.prototype,"library",2);g([G("label")],Ce.prototype,"handleLabelChange",1);g([G(["name","src","library"])],Ce.prototype,"setIcon",1);var ee=mr(class extends Qs{constructor(e){if(super(e),e.type!==ts.ATTRIBUTE||e.name!=="class"||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return" "+Object.keys(e).filter(t=>e[t]).join(" ")+" "}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(" ").split(/\s/).filter(i=>i!=="")));for(let i in t)t[i]&&!this.nt?.has(i)&&this.st.add(i);return this.render(t)}let s=e.element.classList;for(let i of this.st)i in t||(s.remove(i),this.st.delete(i));for(let i in t){let r=!!t[i];r===this.st.has(i)||this.nt?.has(i)||(r?(s.add(i),this.st.add(i)):(s.remove(i),this.st.delete(i)))}return ct}});var Gt=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.open=!1,this.disabled=!1}firstUpdated(){this.body.style.height=this.open?"auto":"0",this.open&&(this.details.open=!0),this.detailsObserver=new MutationObserver(e=>{for(let t of e)t.type==="attributes"&&t.attributeName==="open"&&(this.details.open?this.show():this.hide())}),this.detailsObserver.observe(this.details,{attributes:!0})}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.detailsObserver)==null||e.disconnect()}handleSummaryClick(e){e.preventDefault(),this.disabled||(this.open?this.hide():this.show(),this.header.focus())}handleSummaryKeyDown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.open?this.hide():this.show()),(e.key==="ArrowUp"||e.key==="ArrowLeft")&&(e.preventDefault(),this.hide()),(e.key==="ArrowDown"||e.key==="ArrowRight")&&(e.preventDefault(),this.show())}async handleOpenChange(){if(this.open){if(this.details.open=!0,this.emit("sl-show",{cancelable:!0}).defaultPrevented){this.open=!1,this.details.open=!1;return}await at(this.body);let{keyframes:t,options:s}=Ye(this,"details.show",{dir:this.localize.dir()});await Xe(this.body,Jh(t,this.body.scrollHeight),s),this.body.style.height="auto",this.emit("sl-after-show")}else{if(this.emit("sl-hide",{cancelable:!0}).defaultPrevented){this.details.open=!0,this.open=!0;return}await at(this.body);let{keyframes:t,options:s}=Ye(this,"details.hide",{dir:this.localize.dir()});await Xe(this.body,Jh(t,this.body.scrollHeight),s),this.body.style.height="auto",this.details.open=!1,this.emit("sl-after-hide")}}async show(){if(!(this.open||this.disabled))return this.open=!0,vt(this,"sl-after-show")}async hide(){if(!(!this.open||this.disabled))return this.open=!1,vt(this,"sl-after-hide")}render(){let e=this.localize.dir()==="rtl";return u`
2983
2997
  <details
2984
2998
  part="base"
2985
2999
  class=${ee({details:!0,"details--open":this.open,"details--disabled":this.disabled,"details--rtl":e})}
@@ -3012,7 +3026,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3012
3026
  <slot part="content" id="content" class="details__content"></slot>
3013
3027
  </div>
3014
3028
  </details>
3015
- `}};Gt.styles=[Q,Qm];Gt.dependencies={"sl-icon":Ce};g([Z(".details")],Gt.prototype,"details",2);g([Z(".details__header")],Gt.prototype,"header",2);g([Z(".details__body")],Gt.prototype,"body",2);g([Z(".details__expand-icon-slot")],Gt.prototype,"expandIconSlot",2);g([v({type:Boolean,reflect:!0})],Gt.prototype,"open",2);g([v()],Gt.prototype,"summary",2);g([v({type:Boolean,reflect:!0})],Gt.prototype,"disabled",2);g([G("open",{waitUntilFirstUpdate:!0})],Gt.prototype,"handleOpenChange",1);Ge("details.show",{keyframes:[{height:"0",opacity:"0"},{height:"auto",opacity:"1"}],options:{duration:250,easing:"linear"}});Ge("details.hide",{keyframes:[{height:"auto",opacity:"1"},{height:"0",opacity:"0"}],options:{duration:250,easing:"linear"}});Gt.define("sl-details");var $g=Y`
3029
+ `}};Gt.styles=[Q,eg];Gt.dependencies={"sl-icon":Ce};g([Z(".details")],Gt.prototype,"details",2);g([Z(".details__header")],Gt.prototype,"header",2);g([Z(".details__body")],Gt.prototype,"body",2);g([Z(".details__expand-icon-slot")],Gt.prototype,"expandIconSlot",2);g([v({type:Boolean,reflect:!0})],Gt.prototype,"open",2);g([v()],Gt.prototype,"summary",2);g([v({type:Boolean,reflect:!0})],Gt.prototype,"disabled",2);g([G("open",{waitUntilFirstUpdate:!0})],Gt.prototype,"handleOpenChange",1);Ge("details.show",{keyframes:[{height:"0",opacity:"0"},{height:"auto",opacity:"1"}],options:{duration:250,easing:"linear"}});Ge("details.hide",{keyframes:[{height:"auto",opacity:"1"},{height:"0",opacity:"0"}],options:{duration:250,easing:"linear"}});Gt.define("sl-details");var Eg=Y`
3016
3030
  :host {
3017
3031
  display: inline-block;
3018
3032
  }
@@ -3125,7 +3139,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3125
3139
  .tag--pill {
3126
3140
  border-radius: var(--sl-border-radius-pill);
3127
3141
  }
3128
- `;var Eg=Y`
3142
+ `;var Tg=Y`
3129
3143
  :host {
3130
3144
  display: inline-block;
3131
3145
  color: var(--sl-color-neutral-600);
@@ -3172,8 +3186,8 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3172
3186
  .icon-button__icon {
3173
3187
  pointer-events: none;
3174
3188
  }
3175
- `;var Ag=Symbol.for(""),PC=e=>{if(e?.r===Ag)return e?._$litStatic$};var Vr=(e,...t)=>({_$litStatic$:t.reduce((s,i,r)=>s+(o=>{if(o._$litStatic$!==void 0)return o._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${o}. Use 'unsafeStatic' to pass non-literal values, but
3176
- take care to ensure page security.`)})(i)+e[r+1],e[0]),r:Ag}),Tg=new Map,nd=e=>(t,...s)=>{let i=s.length,r,o,n=[],a=[],c,l=0,h=!1;for(;l<i;){for(c=t[l];l<i&&(o=s[l],(r=PC(o))!==void 0);)c+=r+t[++l],h=!0;l!==i&&a.push(o),n.push(c),l++}if(l===i&&n.push(t[i]),h){let d=n.join("$$lit$$");(t=Tg.get(d))===void 0&&(n.raw=n,Tg.set(d,t=n)),s=a}return e(t,...s)},Ur=nd(u),K5=nd(Ud),G5=nd(qd);var J=e=>e??b;var Te=class extends X{constructor(){super(...arguments),this.hasFocus=!1,this.label="",this.disabled=!1}handleBlur(){this.hasFocus=!1,this.emit("sl-blur")}handleFocus(){this.hasFocus=!0,this.emit("sl-focus")}handleClick(e){this.disabled&&(e.preventDefault(),e.stopPropagation())}click(){this.button.click()}focus(e){this.button.focus(e)}blur(){this.button.blur()}render(){let e=!!this.href,t=e?Vr`a`:Vr`button`;return Ur`
3189
+ `;var Rg=Symbol.for(""),MC=e=>{if(e?.r===Rg)return e?._$litStatic$};var Vr=(e,...t)=>({_$litStatic$:t.reduce((s,i,r)=>s+(o=>{if(o._$litStatic$!==void 0)return o._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${o}. Use 'unsafeStatic' to pass non-literal values, but
3190
+ take care to ensure page security.`)})(i)+e[r+1],e[0]),r:Rg}),Ag=new Map,nd=e=>(t,...s)=>{let i=s.length,r,o,n=[],a=[],c,l=0,h=!1;for(;l<i;){for(c=t[l];l<i&&(o=s[l],(r=MC(o))!==void 0);)c+=r+t[++l],h=!0;l!==i&&a.push(o),n.push(c),l++}if(l===i&&n.push(t[i]),h){let d=n.join("$$lit$$");(t=Ag.get(d))===void 0&&(n.raw=n,Ag.set(d,t=n)),s=a}return e(t,...s)},Ur=nd(u),YP=nd(Ud),XP=nd(qd);var J=e=>e??b;var Te=class extends X{constructor(){super(...arguments),this.hasFocus=!1,this.label="",this.disabled=!1}handleBlur(){this.hasFocus=!1,this.emit("sl-blur")}handleFocus(){this.hasFocus=!0,this.emit("sl-focus")}handleClick(e){this.disabled&&(e.preventDefault(),e.stopPropagation())}click(){this.button.click()}focus(e){this.button.focus(e)}blur(){this.button.blur()}render(){let e=!!this.href,t=e?Vr`a`:Vr`button`;return Ur`
3177
3191
  <${t}
3178
3192
  part="base"
3179
3193
  class=${ee({"icon-button":!0,"icon-button--disabled":!e&&this.disabled,"icon-button--focused":this.hasFocus})}
@@ -3199,7 +3213,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3199
3213
  aria-hidden="true"
3200
3214
  ></sl-icon>
3201
3215
  </${t}>
3202
- `}};Te.styles=[Q,Eg];Te.dependencies={"sl-icon":Ce};g([Z(".icon-button")],Te.prototype,"button",2);g([oe()],Te.prototype,"hasFocus",2);g([v()],Te.prototype,"name",2);g([v()],Te.prototype,"library",2);g([v()],Te.prototype,"src",2);g([v()],Te.prototype,"href",2);g([v()],Te.prototype,"target",2);g([v()],Te.prototype,"download",2);g([v()],Te.prototype,"label",2);g([v({type:Boolean,reflect:!0})],Te.prototype,"disabled",2);var xi=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.variant="neutral",this.size="medium",this.pill=!1,this.removable=!1}handleRemoveClick(){this.emit("sl-remove")}render(){return u`
3216
+ `}};Te.styles=[Q,Tg];Te.dependencies={"sl-icon":Ce};g([Z(".icon-button")],Te.prototype,"button",2);g([oe()],Te.prototype,"hasFocus",2);g([v()],Te.prototype,"name",2);g([v()],Te.prototype,"library",2);g([v()],Te.prototype,"src",2);g([v()],Te.prototype,"href",2);g([v()],Te.prototype,"target",2);g([v()],Te.prototype,"download",2);g([v()],Te.prototype,"label",2);g([v({type:Boolean,reflect:!0})],Te.prototype,"disabled",2);var xi=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.variant="neutral",this.size="medium",this.pill=!1,this.removable=!1}handleRemoveClick(){this.emit("sl-remove")}render(){return u`
3203
3217
  <span
3204
3218
  part="base"
3205
3219
  class=${ee({tag:!0,"tag--primary":this.variant==="primary","tag--success":this.variant==="success","tag--neutral":this.variant==="neutral","tag--warning":this.variant==="warning","tag--danger":this.variant==="danger","tag--text":this.variant==="text","tag--small":this.size==="small","tag--medium":this.size==="medium","tag--large":this.size==="large","tag--pill":this.pill,"tag--removable":this.removable})}
@@ -3219,7 +3233,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3219
3233
  ></sl-icon-button>
3220
3234
  `:""}
3221
3235
  </span>
3222
- `}};xi.styles=[Q,$g];xi.dependencies={"sl-icon-button":Te};g([v({reflect:!0})],xi.prototype,"variant",2);g([v({reflect:!0})],xi.prototype,"size",2);g([v({type:Boolean,reflect:!0})],xi.prototype,"pill",2);g([v({type:Boolean})],xi.prototype,"removable",2);var Rg=Y`
3236
+ `}};xi.styles=[Q,Eg];xi.dependencies={"sl-icon-button":Te};g([v({reflect:!0})],xi.prototype,"variant",2);g([v({reflect:!0})],xi.prototype,"size",2);g([v({type:Boolean,reflect:!0})],xi.prototype,"pill",2);g([v({type:Boolean})],xi.prototype,"removable",2);var Dg=Y`
3223
3237
  :host {
3224
3238
  display: block;
3225
3239
  }
@@ -3561,7 +3575,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3561
3575
  padding-block: var(--sl-spacing-2x-small);
3562
3576
  padding-inline: var(--sl-spacing-x-large);
3563
3577
  }
3564
- `;function BC(e,t){return{top:Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top),left:Math.round(e.getBoundingClientRect().left-t.getBoundingClientRect().left)}}var ad=new Set;function MC(){let e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}function IC(){let e=Number(getComputedStyle(document.body).paddingRight.replace(/px/,""));return isNaN(e)||!e?0:e}function ld(e){if(ad.add(e),!document.documentElement.classList.contains("sl-scroll-lock")){let t=MC()+IC(),s=getComputedStyle(document.documentElement).scrollbarGutter;(!s||s==="auto")&&(s="stable"),t<2&&(s=""),document.documentElement.style.setProperty("--sl-scroll-lock-gutter",s),document.documentElement.classList.add("sl-scroll-lock"),document.documentElement.style.setProperty("--sl-scroll-lock-size",`${t}px`)}}function cd(e){ad.delete(e),ad.size===0&&(document.documentElement.classList.remove("sl-scroll-lock"),document.documentElement.style.removeProperty("--sl-scroll-lock-size"))}function nn(e,t,s="vertical",i="smooth"){let r=BC(e,t),o=r.top+t.scrollTop,n=r.left+t.scrollLeft,a=t.scrollLeft,c=t.scrollLeft+t.offsetWidth,l=t.scrollTop,h=t.scrollTop+t.offsetHeight;(s==="horizontal"||s==="both")&&(n<a?t.scrollTo({left:n,behavior:i}):n+e.clientWidth>c&&t.scrollTo({left:n-t.offsetWidth+e.clientWidth,behavior:i})),(s==="vertical"||s==="both")&&(o<l?t.scrollTo({top:o,behavior:i}):o+e.clientHeight>h&&t.scrollTo({top:o-t.offsetHeight+e.clientHeight,behavior:i}))}var Yt=Y`
3578
+ `;function IC(e,t){return{top:Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top),left:Math.round(e.getBoundingClientRect().left-t.getBoundingClientRect().left)}}var ad=new Set;function OC(){let e=document.documentElement.clientWidth;return Math.abs(window.innerWidth-e)}function zC(){let e=Number(getComputedStyle(document.body).paddingRight.replace(/px/,""));return isNaN(e)||!e?0:e}function ld(e){if(ad.add(e),!document.documentElement.classList.contains("sl-scroll-lock")){let t=OC()+zC(),s=getComputedStyle(document.documentElement).scrollbarGutter;(!s||s==="auto")&&(s="stable"),t<2&&(s=""),document.documentElement.style.setProperty("--sl-scroll-lock-gutter",s),document.documentElement.classList.add("sl-scroll-lock"),document.documentElement.style.setProperty("--sl-scroll-lock-size",`${t}px`)}}function cd(e){ad.delete(e),ad.size===0&&(document.documentElement.classList.remove("sl-scroll-lock"),document.documentElement.style.removeProperty("--sl-scroll-lock-size"))}function nn(e,t,s="vertical",i="smooth"){let r=IC(e,t),o=r.top+t.scrollTop,n=r.left+t.scrollLeft,a=t.scrollLeft,c=t.scrollLeft+t.offsetWidth,l=t.scrollTop,h=t.scrollTop+t.offsetHeight;(s==="horizontal"||s==="both")&&(n<a?t.scrollTo({left:n,behavior:i}):n+e.clientWidth>c&&t.scrollTo({left:n-t.offsetWidth+e.clientWidth,behavior:i})),(s==="vertical"||s==="both")&&(o<l?t.scrollTo({top:o,behavior:i}):o+e.clientHeight>h&&t.scrollTo({top:o-t.offsetHeight+e.clientHeight,behavior:i}))}var Yt=Y`
3565
3579
  .form-control .form-control__label {
3566
3580
  display: none;
3567
3581
  }
@@ -3617,7 +3631,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3617
3631
  .form-control--has-help-text.form-control--radio-group .form-control__help-text {
3618
3632
  margin-top: var(--sl-spacing-2x-small);
3619
3633
  }
3620
- `;var Dg=Y`
3634
+ `;var Lg=Y`
3621
3635
  :host {
3622
3636
  --arrow-color: var(--sl-color-neutral-1000);
3623
3637
  --arrow-size: 6px;
@@ -3675,7 +3689,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3675
3689
  var(--hover-bridge-bottom-left-x, 0) var(--hover-bridge-bottom-left-y, 0)
3676
3690
  );
3677
3691
  }
3678
- `;var Cs=Math.min,bt=Math.max,ln=Math.round,cn=Math.floor,ns=e=>({x:e,y:e}),OC={left:"right",right:"left",bottom:"top",top:"bottom"};function el(e,t,s){return bt(e,Cs(t,s))}function rr(e,t){return typeof e=="function"?e(t):e}function Ks(e){return e.split("-")[0]}function or(e){return e.split("-")[1]}function hd(e){return e==="x"?"y":"x"}function tl(e){return e==="y"?"height":"width"}function xs(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function sl(e){return hd(xs(e))}function Bg(e,t,s){s===void 0&&(s=!1);let i=or(e),r=sl(e),o=tl(r),n=r==="x"?i===(s?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(n=an(n)),[n,an(n)]}function Mg(e){let t=an(e);return[Qa(e),t,Qa(t)]}function Qa(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var Lg=["left","right"],Pg=["right","left"],zC=["top","bottom"],NC=["bottom","top"];function FC(e,t,s){switch(e){case"top":case"bottom":return s?t?Pg:Lg:t?Lg:Pg;case"left":case"right":return t?zC:NC;default:return[]}}function Ig(e,t,s,i){let r=or(e),o=FC(Ks(e),s==="start",i);return r&&(o=o.map(n=>n+"-"+r),t&&(o=o.concat(o.map(Qa)))),o}function an(e){let t=Ks(e);return OC[t]+e.slice(t.length)}function HC(e){return{top:0,right:0,bottom:0,left:0,...e}}function dd(e){return typeof e!="number"?HC(e):{top:e,right:e,bottom:e,left:e}}function nr(e){let{x:t,y:s,width:i,height:r}=e;return{width:i,height:r,top:s,left:t,right:t+i,bottom:s+r,x:t,y:s}}function Og(e,t,s){let{reference:i,floating:r}=e,o=xs(t),n=sl(t),a=tl(n),c=Ks(t),l=o==="y",h=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,m=i[a]/2-r[a]/2,p;switch(c){case"top":p={x:h,y:i.y-r.height};break;case"bottom":p={x:h,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:d};break;case"left":p={x:i.x-r.width,y:d};break;default:p={x:i.x,y:i.y}}switch(or(t)){case"start":p[n]-=m*(s&&l?-1:1);break;case"end":p[n]+=m*(s&&l?-1:1);break}return p}async function zg(e,t){var s;t===void 0&&(t={});let{x:i,y:r,platform:o,rects:n,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:d="floating",altBoundary:m=!1,padding:p=0}=rr(t,e),f=dd(p),w=a[m?d==="floating"?"reference":"floating":d],k=nr(await o.getClippingRect({element:(s=await(o.isElement==null?void 0:o.isElement(w)))==null||s?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:h,strategy:c})),$=d==="floating"?{x:i,y:r,width:n.floating.width,height:n.floating.height}:n.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),C=await(o.isElement==null?void 0:o.isElement(y))?await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1}:{x:1,y:1},S=nr(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:$,offsetParent:y,strategy:c}):$);return{top:(k.top-S.top+f.top)/C.y,bottom:(S.bottom-k.bottom+f.bottom)/C.y,left:(k.left-S.left+f.left)/C.x,right:(S.right-k.right+f.right)/C.x}}var WC=50,Ng=async(e,t,s)=>{let{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:n}=s,a=n.detectOverflow?n:{...n,detectOverflow:zg},c=await(n.isRTL==null?void 0:n.isRTL(t)),l=await n.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:d}=Og(l,i,c),m=i,p=0,f={};for(let _=0;_<o.length;_++){let w=o[_];if(!w)continue;let{name:k,fn:$}=w,{x:y,y:C,data:S,reset:L}=await $({x:h,y:d,initialPlacement:i,placement:m,strategy:r,middlewareData:f,rects:l,platform:a,elements:{reference:e,floating:t}});h=y??h,d=C??d,f[k]={...f[k],...S},L&&p<WC&&(p++,typeof L=="object"&&(L.placement&&(m=L.placement),L.rects&&(l=L.rects===!0?await n.getElementRects({reference:e,floating:t,strategy:r}):L.rects),{x:h,y:d}=Og(l,m,c)),_=-1)}return{x:h,y:d,placement:m,strategy:r,middlewareData:f}},Fg=e=>({name:"arrow",options:e,async fn(t){let{x:s,y:i,placement:r,rects:o,platform:n,elements:a,middlewareData:c}=t,{element:l,padding:h=0}=rr(e,t)||{};if(l==null)return{};let d=dd(h),m={x:s,y:i},p=sl(r),f=tl(p),_=await n.getDimensions(l),w=p==="y",k=w?"top":"left",$=w?"bottom":"right",y=w?"clientHeight":"clientWidth",C=o.reference[f]+o.reference[p]-m[p]-o.floating[f],S=m[p]-o.reference[p],L=await(n.getOffsetParent==null?void 0:n.getOffsetParent(l)),H=L?L[y]:0;(!H||!await(n.isElement==null?void 0:n.isElement(L)))&&(H=a.floating[y]||o.floating[f]);let F=C/2-S/2,W=H/2-_[f]/2-1,ie=Cs(d[k],W),j=Cs(d[$],W),ce=ie,T=H-_[f]-j,x=H/2-_[f]/2+F,D=el(ce,x,T),A=!c.arrow&&or(r)!=null&&x!==D&&o.reference[f]/2-(x<ce?ie:j)-_[f]/2<0,B=A?x<ce?x-ce:x-T:0;return{[p]:m[p]+B,data:{[p]:D,centerOffset:x-D-B,...A&&{alignmentOffset:B}},reset:A}}});var Hg=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,i;let{placement:r,middlewareData:o,rects:n,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:h=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:_=!0,...w}=rr(e,t);if((s=o.arrow)!=null&&s.alignmentOffset)return{};let k=Ks(r),$=xs(a),y=Ks(a)===a,C=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=m||(y||!_?[an(a)]:Mg(a)),L=f!=="none";!m&&L&&S.push(...Ig(a,_,f,C));let H=[a,...S],F=await c.detectOverflow(t,w),W=[],ie=((i=o.flip)==null?void 0:i.overflows)||[];if(h&&W.push(F[k]),d){let x=Bg(r,n,C);W.push(F[x[0]],F[x[1]])}if(ie=[...ie,{placement:r,overflows:W}],!W.every(x=>x<=0)){var j,ce;let x=(((j=o.flip)==null?void 0:j.index)||0)+1,D=H[x];if(D&&(!(d==="alignment"?$!==xs(D):!1)||ie.every(P=>xs(P.placement)===$?P.overflows[0]>0:!0)))return{data:{index:x,overflows:ie},reset:{placement:D}};let A=(ce=ie.filter(B=>B.overflows[0]<=0).sort((B,P)=>B.overflows[1]-P.overflows[1])[0])==null?void 0:ce.placement;if(!A)switch(p){case"bestFit":{var T;let B=(T=ie.filter(P=>{if(L){let V=xs(P.placement);return V===$||V==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(V=>V>0).reduce((V,se)=>V+se,0)]).sort((P,V)=>P[1]-V[1])[0])==null?void 0:T[0];B&&(A=B);break}case"initialPlacement":A=a;break}if(r!==A)return{reset:{placement:A}}}return{}}}};var jC=new Set(["left","top"]);async function VC(e,t){let{placement:s,platform:i,elements:r}=e,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),n=Ks(s),a=or(s),c=xs(s)==="y",l=jC.has(n)?-1:1,h=o&&c?-1:1,d=rr(t,e),{mainAxis:m,crossAxis:p,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(p=a==="end"?f*-1:f),c?{x:p*h,y:m*l}:{x:m*l,y:p*h}}var Wg=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,i;let{x:r,y:o,placement:n,middlewareData:a}=t,c=await VC(t,e);return n===((s=a.offset)==null?void 0:s.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:n}}}}},jg=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:s,y:i,placement:r,platform:o}=t,{mainAxis:n=!0,crossAxis:a=!1,limiter:c={fn:k=>{let{x:$,y}=k;return{x:$,y}}},...l}=rr(e,t),h={x:s,y:i},d=await o.detectOverflow(t,l),m=xs(Ks(r)),p=hd(m),f=h[p],_=h[m];if(n){let k=p==="y"?"top":"left",$=p==="y"?"bottom":"right",y=f+d[k],C=f-d[$];f=el(y,f,C)}if(a){let k=m==="y"?"top":"left",$=m==="y"?"bottom":"right",y=_+d[k],C=_-d[$];_=el(y,_,C)}let w=c.fn({...t,[p]:f,[m]:_});return{...w,data:{x:w.x-s,y:w.y-i,enabled:{[p]:n,[m]:a}}}}}};var Vg=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var s,i;let{placement:r,rects:o,platform:n,elements:a}=t,{apply:c=()=>{},...l}=rr(e,t),h=await n.detectOverflow(t,l),d=Ks(r),m=or(r),p=xs(r)==="y",{width:f,height:_}=o.floating,w,k;d==="top"||d==="bottom"?(w=d,k=m===(await(n.isRTL==null?void 0:n.isRTL(a.floating))?"start":"end")?"left":"right"):(k=d,w=m==="end"?"top":"bottom");let $=_-h.top-h.bottom,y=f-h.left-h.right,C=Cs(_-h[w],$),S=Cs(f-h[k],y),L=!t.middlewareData.shift,H=C,F=S;if((s=t.middlewareData.shift)!=null&&s.enabled.x&&(F=y),(i=t.middlewareData.shift)!=null&&i.enabled.y&&(H=$),L&&!m){let ie=bt(h.left,0),j=bt(h.right,0),ce=bt(h.top,0),T=bt(h.bottom,0);p?F=f-2*(ie!==0||j!==0?ie+j:bt(h.left,h.right)):H=_-2*(ce!==0||T!==0?ce+T:bt(h.top,h.bottom))}await c({...t,availableWidth:F,availableHeight:H});let W=await n.getDimensions(a.floating);return f!==W.width||_!==W.height?{reset:{rects:!0}}:{}}}};function il(){return typeof window<"u"}function lr(e){return qg(e)?(e.nodeName||"").toLowerCase():"#document"}function $t(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function as(e){var t;return(t=(qg(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function qg(e){return il()?e instanceof Node||e instanceof $t(e).Node:!1}function Xt(e){return il()?e instanceof Element||e instanceof $t(e).Element:!1}function ks(e){return il()?e instanceof HTMLElement||e instanceof $t(e).HTMLElement:!1}function Ug(e){return!il()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $t(e).ShadowRoot}function Kr(e){let{overflow:t,overflowX:s,overflowY:i,display:r}=Jt(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+s)&&r!=="inline"&&r!=="contents"}function Kg(e){return/^(table|td|th)$/.test(lr(e))}function hn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var UC=/transform|translate|scale|rotate|perspective|filter/,qC=/paint|layout|strict|content/,ar=e=>!!e&&e!=="none",ud;function Gr(e){let t=Xt(e)?Jt(e):e;return ar(t.transform)||ar(t.translate)||ar(t.scale)||ar(t.rotate)||ar(t.perspective)||!rl()&&(ar(t.backdropFilter)||ar(t.filter))||UC.test(t.willChange||"")||qC.test(t.contain||"")}function Gg(e){let t=Gs(e);for(;ks(t)&&!cr(t);){if(Gr(t))return t;if(hn(t))return null;t=Gs(t)}return null}function rl(){return ud==null&&(ud=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ud}function cr(e){return/^(html|body|#document)$/.test(lr(e))}function Jt(e){return $t(e).getComputedStyle(e)}function dn(e){return Xt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gs(e){if(lr(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Ug(e)&&e.host||as(e);return Ug(t)?t.host:t}function Yg(e){let t=Gs(e);return cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:ks(t)&&Kr(t)?t:Yg(t)}function qr(e,t,s){var i;t===void 0&&(t=[]),s===void 0&&(s=!0);let r=Yg(e),o=r===((i=e.ownerDocument)==null?void 0:i.body),n=$t(r);if(o){let a=ol(n);return t.concat(n,n.visualViewport||[],Kr(r)?r:[],a&&s?qr(a):[])}else return t.concat(r,qr(r,[],s))}function ol(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qg(e){let t=Jt(e),s=parseFloat(t.width)||0,i=parseFloat(t.height)||0,r=ks(e),o=r?e.offsetWidth:s,n=r?e.offsetHeight:i,a=ln(s)!==o||ln(i)!==n;return a&&(s=o,i=n),{width:s,height:i,$:a}}function fd(e){return Xt(e)?e:e.contextElement}function Yr(e){let t=fd(e);if(!ks(t))return ns(1);let s=t.getBoundingClientRect(),{width:i,height:r,$:o}=Qg(t),n=(o?ln(s.width):s.width)/i,a=(o?ln(s.height):s.height)/r;return(!n||!Number.isFinite(n))&&(n=1),(!a||!Number.isFinite(a))&&(a=1),{x:n,y:a}}var KC=ns(0);function e_(e){let t=$t(e);return!rl()||!t.visualViewport?KC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function GC(e,t,s){return t===void 0&&(t=!1),!s||t&&s!==$t(e)?!1:t}function hr(e,t,s,i){t===void 0&&(t=!1),s===void 0&&(s=!1);let r=e.getBoundingClientRect(),o=fd(e),n=ns(1);t&&(i?Xt(i)&&(n=Yr(i)):n=Yr(e));let a=GC(o,s,i)?e_(o):ns(0),c=(r.left+a.x)/n.x,l=(r.top+a.y)/n.y,h=r.width/n.x,d=r.height/n.y;if(o){let m=$t(o),p=i&&Xt(i)?$t(i):i,f=m,_=ol(f);for(;_&&i&&p!==f;){let w=Yr(_),k=_.getBoundingClientRect(),$=Jt(_),y=k.left+(_.clientLeft+parseFloat($.paddingLeft))*w.x,C=k.top+(_.clientTop+parseFloat($.paddingTop))*w.y;c*=w.x,l*=w.y,h*=w.x,d*=w.y,c+=y,l+=C,f=$t(_),_=ol(f)}}return nr({width:h,height:d,x:c,y:l})}function nl(e,t){let s=dn(e).scrollLeft;return t?t.left+s:hr(as(e)).left+s}function t_(e,t){let s=e.getBoundingClientRect(),i=s.left+t.scrollLeft-nl(e,s),r=s.top+t.scrollTop;return{x:i,y:r}}function YC(e){let{elements:t,rect:s,offsetParent:i,strategy:r}=e,o=r==="fixed",n=as(i),a=t?hn(t.floating):!1;if(i===n||a&&o)return s;let c={scrollLeft:0,scrollTop:0},l=ns(1),h=ns(0),d=ks(i);if((d||!d&&!o)&&((lr(i)!=="body"||Kr(n))&&(c=dn(i)),d)){let p=hr(i);l=Yr(i),h.x=p.x+i.clientLeft,h.y=p.y+i.clientTop}let m=n&&!d&&!o?t_(n,c):ns(0);return{width:s.width*l.x,height:s.height*l.y,x:s.x*l.x-c.scrollLeft*l.x+h.x+m.x,y:s.y*l.y-c.scrollTop*l.y+h.y+m.y}}function XC(e){return Array.from(e.getClientRects())}function JC(e){let t=as(e),s=dn(e),i=e.ownerDocument.body,r=bt(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=bt(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),n=-s.scrollLeft+nl(e),a=-s.scrollTop;return Jt(i).direction==="rtl"&&(n+=bt(t.clientWidth,i.clientWidth)-r),{width:r,height:o,x:n,y:a}}var Xg=25;function ZC(e,t){let s=$t(e),i=as(e),r=s.visualViewport,o=i.clientWidth,n=i.clientHeight,a=0,c=0;if(r){o=r.width,n=r.height;let h=rl();(!h||h&&t==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}let l=nl(i);if(l<=0){let h=i.ownerDocument,d=h.body,m=getComputedStyle(d),p=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-p);f<=Xg&&(o-=f)}else l<=Xg&&(o+=l);return{width:o,height:n,x:a,y:c}}function QC(e,t){let s=hr(e,!0,t==="fixed"),i=s.top+e.clientTop,r=s.left+e.clientLeft,o=ks(e)?Yr(e):ns(1),n=e.clientWidth*o.x,a=e.clientHeight*o.y,c=r*o.x,l=i*o.y;return{width:n,height:a,x:c,y:l}}function Jg(e,t,s){let i;if(t==="viewport")i=ZC(e,s);else if(t==="document")i=JC(as(e));else if(Xt(t))i=QC(t,s);else{let r=e_(e);i={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return nr(i)}function s_(e,t){let s=Gs(e);return s===t||!Xt(s)||cr(s)?!1:Jt(s).position==="fixed"||s_(s,t)}function ex(e,t){let s=t.get(e);if(s)return s;let i=qr(e,[],!1).filter(a=>Xt(a)&&lr(a)!=="body"),r=null,o=Jt(e).position==="fixed",n=o?Gs(e):e;for(;Xt(n)&&!cr(n);){let a=Jt(n),c=Gr(n);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Kr(n)&&!c&&s_(e,n))?i=i.filter(h=>h!==n):r=a,n=Gs(n)}return t.set(e,i),i}function tx(e){let{element:t,boundary:s,rootBoundary:i,strategy:r}=e,n=[...s==="clippingAncestors"?hn(t)?[]:ex(t,this._c):[].concat(s),i],a=Jg(t,n[0],r),c=a.top,l=a.right,h=a.bottom,d=a.left;for(let m=1;m<n.length;m++){let p=Jg(t,n[m],r);c=bt(p.top,c),l=Cs(p.right,l),h=Cs(p.bottom,h),d=bt(p.left,d)}return{width:l-d,height:h-c,x:d,y:c}}function sx(e){let{width:t,height:s}=Qg(e);return{width:t,height:s}}function ix(e,t,s){let i=ks(t),r=as(t),o=s==="fixed",n=hr(e,!0,o,t),a={scrollLeft:0,scrollTop:0},c=ns(0);function l(){c.x=nl(r)}if(i||!i&&!o)if((lr(t)!=="body"||Kr(r))&&(a=dn(t)),i){let p=hr(t,!0,o,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else r&&l();o&&!i&&r&&l();let h=r&&!i&&!o?t_(r,a):ns(0),d=n.left+a.scrollLeft-c.x-h.x,m=n.top+a.scrollTop-c.y-h.y;return{x:d,y:m,width:n.width,height:n.height}}function pd(e){return Jt(e).position==="static"}function Zg(e,t){if(!ks(e)||Jt(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return as(e)===s&&(s=s.ownerDocument.body),s}function i_(e,t){let s=$t(e);if(hn(e))return s;if(!ks(e)){let r=Gs(e);for(;r&&!cr(r);){if(Xt(r)&&!pd(r))return r;r=Gs(r)}return s}let i=Zg(e,t);for(;i&&Kg(i)&&pd(i);)i=Zg(i,t);return i&&cr(i)&&pd(i)&&!Gr(i)?s:i||Gg(e)||s}var rx=async function(e){let t=this.getOffsetParent||i_,s=this.getDimensions,i=await s(e.floating);return{reference:ix(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ox(e){return Jt(e).direction==="rtl"}var un={convertOffsetParentRelativeRectToViewportRelativeRect:YC,getDocumentElement:as,getClippingRect:tx,getOffsetParent:i_,getElementRects:rx,getClientRects:XC,getDimensions:sx,getScale:Yr,isElement:Xt,isRTL:ox};function r_(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nx(e,t){let s=null,i,r=as(e);function o(){var a;clearTimeout(i),(a=s)==null||a.disconnect(),s=null}function n(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:h,top:d,width:m,height:p}=l;if(a||t(),!m||!p)return;let f=cn(d),_=cn(r.clientWidth-(h+m)),w=cn(r.clientHeight-(d+p)),k=cn(h),y={rootMargin:-f+"px "+-_+"px "+-w+"px "+-k+"px",threshold:bt(0,Cs(1,c))||1},C=!0;function S(L){let H=L[0].intersectionRatio;if(H!==c){if(!C)return n();H?n(!1,H):i=setTimeout(()=>{n(!1,1e-7)},1e3)}H===1&&!r_(l,e.getBoundingClientRect())&&n(),C=!1}try{s=new IntersectionObserver(S,{...y,root:r.ownerDocument})}catch{s=new IntersectionObserver(S,y)}s.observe(e)}return n(!0),o}function o_(e,t,s,i){i===void 0&&(i={});let{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,l=fd(e),h=r||o?[...l?qr(l):[],...t?qr(t):[]]:[];h.forEach(k=>{r&&k.addEventListener("scroll",s,{passive:!0}),o&&k.addEventListener("resize",s)});let d=l&&a?nx(l,s):null,m=-1,p=null;n&&(p=new ResizeObserver(k=>{let[$]=k;$&&$.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),s()}),l&&!c&&p.observe(l),t&&p.observe(t));let f,_=c?hr(e):null;c&&w();function w(){let k=hr(e);_&&!r_(_,k)&&s(),_=k,f=requestAnimationFrame(w)}return s(),()=>{var k;h.forEach($=>{r&&$.removeEventListener("scroll",s),o&&$.removeEventListener("resize",s)}),d?.(),(k=p)==null||k.disconnect(),p=null,c&&cancelAnimationFrame(f)}}var n_=Wg;var a_=jg,l_=Hg,md=Vg;var c_=Fg;var h_=(e,t,s)=>{let i=new Map,r={platform:un,...s},o={...r.platform,_c:i};return Ng(e,t,{...r,platform:o})};function d_(e){return ax(e)}function gd(e){return e.assignedSlot?e.assignedSlot:e.parentNode instanceof ShadowRoot?e.parentNode.host:e.parentNode}function ax(e){for(let t=e;t;t=gd(t))if(t instanceof Element&&getComputedStyle(t).display==="none")return null;for(let t=gd(e);t;t=gd(t)){if(!(t instanceof Element))continue;let s=getComputedStyle(t);if(s.display!=="contents"&&(s.position!=="static"||Gr(s)||t.tagName==="BODY"))return t}return null}function lx(e){return e!==null&&typeof e=="object"&&"getBoundingClientRect"in e&&("contextElement"in e?e.contextElement instanceof Element:!0)}var me=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.active=!1,this.placement="top",this.strategy="absolute",this.distance=0,this.skidding=0,this.arrow=!1,this.arrowPlacement="anchor",this.arrowPadding=10,this.flip=!1,this.flipFallbackPlacements="",this.flipFallbackStrategy="best-fit",this.flipPadding=0,this.shift=!1,this.shiftPadding=0,this.autoSizePadding=0,this.hoverBridge=!1,this.updateHoverBridge=()=>{if(this.hoverBridge&&this.anchorEl){let e=this.anchorEl.getBoundingClientRect(),t=this.popup.getBoundingClientRect(),s=this.placement.includes("top")||this.placement.includes("bottom"),i=0,r=0,o=0,n=0,a=0,c=0,l=0,h=0;s?e.top<t.top?(i=e.left,r=e.bottom,o=e.right,n=e.bottom,a=t.left,c=t.top,l=t.right,h=t.top):(i=t.left,r=t.bottom,o=t.right,n=t.bottom,a=e.left,c=e.top,l=e.right,h=e.top):e.left<t.left?(i=e.right,r=e.top,o=t.left,n=t.top,a=e.right,c=e.bottom,l=t.left,h=t.bottom):(i=t.right,r=t.top,o=e.left,n=e.top,a=t.right,c=t.bottom,l=e.left,h=e.bottom),this.style.setProperty("--hover-bridge-top-left-x",`${i}px`),this.style.setProperty("--hover-bridge-top-left-y",`${r}px`),this.style.setProperty("--hover-bridge-top-right-x",`${o}px`),this.style.setProperty("--hover-bridge-top-right-y",`${n}px`),this.style.setProperty("--hover-bridge-bottom-left-x",`${a}px`),this.style.setProperty("--hover-bridge-bottom-left-y",`${c}px`),this.style.setProperty("--hover-bridge-bottom-right-x",`${l}px`),this.style.setProperty("--hover-bridge-bottom-right-y",`${h}px`)}}}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start()}disconnectedCallback(){super.disconnectedCallback(),this.stop()}async updated(e){super.updated(e),e.has("active")&&(this.active?this.start():this.stop()),e.has("anchor")&&this.handleAnchorChange(),this.active&&(await this.updateComplete,this.reposition())}async handleAnchorChange(){if(await this.stop(),this.anchor&&typeof this.anchor=="string"){let e=this.getRootNode();this.anchorEl=e.getElementById(this.anchor)}else this.anchor instanceof Element||lx(this.anchor)?this.anchorEl=this.anchor:this.anchorEl=this.querySelector('[slot="anchor"]');this.anchorEl instanceof HTMLSlotElement&&(this.anchorEl=this.anchorEl.assignedElements({flatten:!0})[0]),this.anchorEl&&this.active&&this.start()}start(){!this.anchorEl||!this.active||(this.cleanup=o_(this.anchorEl,this.popup,()=>{this.reposition()}))}async stop(){return new Promise(e=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame(()=>e())):e()})}reposition(){if(!this.active||!this.anchorEl)return;let e=[n_({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?e.push(md({apply:({rects:s})=>{let i=this.sync==="width"||this.sync==="both",r=this.sync==="height"||this.sync==="both";this.popup.style.width=i?`${s.reference.width}px`:"",this.popup.style.height=r?`${s.reference.height}px`:""}})):(this.popup.style.width="",this.popup.style.height=""),this.flip&&e.push(l_({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:this.flipFallbackStrategy==="best-fit"?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&e.push(a_({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?e.push(md({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:s,availableHeight:i})=>{this.autoSize==="vertical"||this.autoSize==="both"?this.style.setProperty("--auto-size-available-height",`${i}px`):this.style.removeProperty("--auto-size-available-height"),this.autoSize==="horizontal"||this.autoSize==="both"?this.style.setProperty("--auto-size-available-width",`${s}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&e.push(c_({element:this.arrowEl,padding:this.arrowPadding}));let t=this.strategy==="absolute"?s=>un.getOffsetParent(s,d_):un.getOffsetParent;h_(this.anchorEl,this.popup,{placement:this.placement,middleware:e,strategy:this.strategy,platform:qs(ut({},un),{getOffsetParent:t})}).then(({x:s,y:i,middlewareData:r,placement:o})=>{let n=this.localize.dir()==="rtl",a={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]];if(this.setAttribute("data-current-placement",o),Object.assign(this.popup.style,{left:`${s}px`,top:`${i}px`}),this.arrow){let c=r.arrow.x,l=r.arrow.y,h="",d="",m="",p="";if(this.arrowPlacement==="start"){let f=typeof c=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";h=typeof l=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",d=n?f:"",p=n?"":f}else if(this.arrowPlacement==="end"){let f=typeof c=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";d=n?"":f,p=n?f:"",m=typeof l=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else this.arrowPlacement==="center"?(p=typeof c=="number"?"calc(50% - var(--arrow-size-diagonal))":"",h=typeof l=="number"?"calc(50% - var(--arrow-size-diagonal))":""):(p=typeof c=="number"?`${c}px`:"",h=typeof l=="number"?`${l}px`:"");Object.assign(this.arrowEl.style,{top:h,right:d,bottom:m,left:p,[a]:"calc(var(--arrow-size-diagonal) * -1)"})}}),requestAnimationFrame(()=>this.updateHoverBridge()),this.emit("sl-reposition")}render(){return u`
3692
+ `;var Cs=Math.min,bt=Math.max,ln=Math.round,cn=Math.floor,ns=e=>({x:e,y:e}),NC={left:"right",right:"left",bottom:"top",top:"bottom"};function el(e,t,s){return bt(e,Cs(t,s))}function rr(e,t){return typeof e=="function"?e(t):e}function Ks(e){return e.split("-")[0]}function or(e){return e.split("-")[1]}function hd(e){return e==="x"?"y":"x"}function tl(e){return e==="y"?"height":"width"}function xs(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function sl(e){return hd(xs(e))}function Mg(e,t,s){s===void 0&&(s=!1);let i=or(e),r=sl(e),o=tl(r),n=r==="x"?i===(s?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(n=an(n)),[n,an(n)]}function Ig(e){let t=an(e);return[Qa(e),t,Qa(t)]}function Qa(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var Pg=["left","right"],Bg=["right","left"],FC=["top","bottom"],HC=["bottom","top"];function WC(e,t,s){switch(e){case"top":case"bottom":return s?t?Bg:Pg:t?Pg:Bg;case"left":case"right":return t?FC:HC;default:return[]}}function Og(e,t,s,i){let r=or(e),o=WC(Ks(e),s==="start",i);return r&&(o=o.map(n=>n+"-"+r),t&&(o=o.concat(o.map(Qa)))),o}function an(e){let t=Ks(e);return NC[t]+e.slice(t.length)}function jC(e){return{top:0,right:0,bottom:0,left:0,...e}}function dd(e){return typeof e!="number"?jC(e):{top:e,right:e,bottom:e,left:e}}function nr(e){let{x:t,y:s,width:i,height:r}=e;return{width:i,height:r,top:s,left:t,right:t+i,bottom:s+r,x:t,y:s}}function zg(e,t,s){let{reference:i,floating:r}=e,o=xs(t),n=sl(t),a=tl(n),c=Ks(t),l=o==="y",h=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,m=i[a]/2-r[a]/2,p;switch(c){case"top":p={x:h,y:i.y-r.height};break;case"bottom":p={x:h,y:i.y+i.height};break;case"right":p={x:i.x+i.width,y:d};break;case"left":p={x:i.x-r.width,y:d};break;default:p={x:i.x,y:i.y}}switch(or(t)){case"start":p[n]-=m*(s&&l?-1:1);break;case"end":p[n]+=m*(s&&l?-1:1);break}return p}async function Ng(e,t){var s;t===void 0&&(t={});let{x:i,y:r,platform:o,rects:n,elements:a,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:d="floating",altBoundary:m=!1,padding:p=0}=rr(t,e),f=dd(p),w=a[m?d==="floating"?"reference":"floating":d],k=nr(await o.getClippingRect({element:(s=await(o.isElement==null?void 0:o.isElement(w)))==null||s?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:l,rootBoundary:h,strategy:c})),$=d==="floating"?{x:i,y:r,width:n.floating.width,height:n.floating.height}:n.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),C=await(o.isElement==null?void 0:o.isElement(y))?await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1}:{x:1,y:1},S=nr(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:$,offsetParent:y,strategy:c}):$);return{top:(k.top-S.top+f.top)/C.y,bottom:(S.bottom-k.bottom+f.bottom)/C.y,left:(k.left-S.left+f.left)/C.x,right:(S.right-k.right+f.right)/C.x}}var VC=50,Fg=async(e,t,s)=>{let{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:n}=s,a=n.detectOverflow?n:{...n,detectOverflow:Ng},c=await(n.isRTL==null?void 0:n.isRTL(t)),l=await n.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:d}=zg(l,i,c),m=i,p=0,f={};for(let _=0;_<o.length;_++){let w=o[_];if(!w)continue;let{name:k,fn:$}=w,{x:y,y:C,data:S,reset:L}=await $({x:h,y:d,initialPlacement:i,placement:m,strategy:r,middlewareData:f,rects:l,platform:a,elements:{reference:e,floating:t}});h=y??h,d=C??d,f[k]={...f[k],...S},L&&p<VC&&(p++,typeof L=="object"&&(L.placement&&(m=L.placement),L.rects&&(l=L.rects===!0?await n.getElementRects({reference:e,floating:t,strategy:r}):L.rects),{x:h,y:d}=zg(l,m,c)),_=-1)}return{x:h,y:d,placement:m,strategy:r,middlewareData:f}},Hg=e=>({name:"arrow",options:e,async fn(t){let{x:s,y:i,placement:r,rects:o,platform:n,elements:a,middlewareData:c}=t,{element:l,padding:h=0}=rr(e,t)||{};if(l==null)return{};let d=dd(h),m={x:s,y:i},p=sl(r),f=tl(p),_=await n.getDimensions(l),w=p==="y",k=w?"top":"left",$=w?"bottom":"right",y=w?"clientHeight":"clientWidth",C=o.reference[f]+o.reference[p]-m[p]-o.floating[f],S=m[p]-o.reference[p],L=await(n.getOffsetParent==null?void 0:n.getOffsetParent(l)),H=L?L[y]:0;(!H||!await(n.isElement==null?void 0:n.isElement(L)))&&(H=a.floating[y]||o.floating[f]);let F=C/2-S/2,W=H/2-_[f]/2-1,ie=Cs(d[k],W),j=Cs(d[$],W),ce=ie,T=H-_[f]-j,x=H/2-_[f]/2+F,D=el(ce,x,T),A=!c.arrow&&or(r)!=null&&x!==D&&o.reference[f]/2-(x<ce?ie:j)-_[f]/2<0,B=A?x<ce?x-ce:x-T:0;return{[p]:m[p]+B,data:{[p]:D,centerOffset:x-D-B,...A&&{alignmentOffset:B}},reset:A}}});var Wg=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var s,i;let{placement:r,middlewareData:o,rects:n,initialPlacement:a,platform:c,elements:l}=t,{mainAxis:h=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:_=!0,...w}=rr(e,t);if((s=o.arrow)!=null&&s.alignmentOffset)return{};let k=Ks(r),$=xs(a),y=Ks(a)===a,C=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=m||(y||!_?[an(a)]:Ig(a)),L=f!=="none";!m&&L&&S.push(...Og(a,_,f,C));let H=[a,...S],F=await c.detectOverflow(t,w),W=[],ie=((i=o.flip)==null?void 0:i.overflows)||[];if(h&&W.push(F[k]),d){let x=Mg(r,n,C);W.push(F[x[0]],F[x[1]])}if(ie=[...ie,{placement:r,overflows:W}],!W.every(x=>x<=0)){var j,ce;let x=(((j=o.flip)==null?void 0:j.index)||0)+1,D=H[x];if(D&&(!(d==="alignment"?$!==xs(D):!1)||ie.every(P=>xs(P.placement)===$?P.overflows[0]>0:!0)))return{data:{index:x,overflows:ie},reset:{placement:D}};let A=(ce=ie.filter(B=>B.overflows[0]<=0).sort((B,P)=>B.overflows[1]-P.overflows[1])[0])==null?void 0:ce.placement;if(!A)switch(p){case"bestFit":{var T;let B=(T=ie.filter(P=>{if(L){let V=xs(P.placement);return V===$||V==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(V=>V>0).reduce((V,se)=>V+se,0)]).sort((P,V)=>P[1]-V[1])[0])==null?void 0:T[0];B&&(A=B);break}case"initialPlacement":A=a;break}if(r!==A)return{reset:{placement:A}}}return{}}}};var UC=new Set(["left","top"]);async function qC(e,t){let{placement:s,platform:i,elements:r}=e,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),n=Ks(s),a=or(s),c=xs(s)==="y",l=UC.has(n)?-1:1,h=o&&c?-1:1,d=rr(t,e),{mainAxis:m,crossAxis:p,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(p=a==="end"?f*-1:f),c?{x:p*h,y:m*l}:{x:m*l,y:p*h}}var jg=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,i;let{x:r,y:o,placement:n,middlewareData:a}=t,c=await qC(t,e);return n===((s=a.offset)==null?void 0:s.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:n}}}}},Vg=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:s,y:i,placement:r,platform:o}=t,{mainAxis:n=!0,crossAxis:a=!1,limiter:c={fn:k=>{let{x:$,y}=k;return{x:$,y}}},...l}=rr(e,t),h={x:s,y:i},d=await o.detectOverflow(t,l),m=xs(Ks(r)),p=hd(m),f=h[p],_=h[m];if(n){let k=p==="y"?"top":"left",$=p==="y"?"bottom":"right",y=f+d[k],C=f-d[$];f=el(y,f,C)}if(a){let k=m==="y"?"top":"left",$=m==="y"?"bottom":"right",y=_+d[k],C=_-d[$];_=el(y,_,C)}let w=c.fn({...t,[p]:f,[m]:_});return{...w,data:{x:w.x-s,y:w.y-i,enabled:{[p]:n,[m]:a}}}}}};var Ug=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var s,i;let{placement:r,rects:o,platform:n,elements:a}=t,{apply:c=()=>{},...l}=rr(e,t),h=await n.detectOverflow(t,l),d=Ks(r),m=or(r),p=xs(r)==="y",{width:f,height:_}=o.floating,w,k;d==="top"||d==="bottom"?(w=d,k=m===(await(n.isRTL==null?void 0:n.isRTL(a.floating))?"start":"end")?"left":"right"):(k=d,w=m==="end"?"top":"bottom");let $=_-h.top-h.bottom,y=f-h.left-h.right,C=Cs(_-h[w],$),S=Cs(f-h[k],y),L=!t.middlewareData.shift,H=C,F=S;if((s=t.middlewareData.shift)!=null&&s.enabled.x&&(F=y),(i=t.middlewareData.shift)!=null&&i.enabled.y&&(H=$),L&&!m){let ie=bt(h.left,0),j=bt(h.right,0),ce=bt(h.top,0),T=bt(h.bottom,0);p?F=f-2*(ie!==0||j!==0?ie+j:bt(h.left,h.right)):H=_-2*(ce!==0||T!==0?ce+T:bt(h.top,h.bottom))}await c({...t,availableWidth:F,availableHeight:H});let W=await n.getDimensions(a.floating);return f!==W.width||_!==W.height?{reset:{rects:!0}}:{}}}};function il(){return typeof window<"u"}function lr(e){return Kg(e)?(e.nodeName||"").toLowerCase():"#document"}function $t(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function as(e){var t;return(t=(Kg(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Kg(e){return il()?e instanceof Node||e instanceof $t(e).Node:!1}function Xt(e){return il()?e instanceof Element||e instanceof $t(e).Element:!1}function ks(e){return il()?e instanceof HTMLElement||e instanceof $t(e).HTMLElement:!1}function qg(e){return!il()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $t(e).ShadowRoot}function Kr(e){let{overflow:t,overflowX:s,overflowY:i,display:r}=Jt(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+s)&&r!=="inline"&&r!=="contents"}function Gg(e){return/^(table|td|th)$/.test(lr(e))}function hn(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var KC=/transform|translate|scale|rotate|perspective|filter/,GC=/paint|layout|strict|content/,ar=e=>!!e&&e!=="none",ud;function Gr(e){let t=Xt(e)?Jt(e):e;return ar(t.transform)||ar(t.translate)||ar(t.scale)||ar(t.rotate)||ar(t.perspective)||!rl()&&(ar(t.backdropFilter)||ar(t.filter))||KC.test(t.willChange||"")||GC.test(t.contain||"")}function Yg(e){let t=Gs(e);for(;ks(t)&&!cr(t);){if(Gr(t))return t;if(hn(t))return null;t=Gs(t)}return null}function rl(){return ud==null&&(ud=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ud}function cr(e){return/^(html|body|#document)$/.test(lr(e))}function Jt(e){return $t(e).getComputedStyle(e)}function dn(e){return Xt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gs(e){if(lr(e)==="html")return e;let t=e.assignedSlot||e.parentNode||qg(e)&&e.host||as(e);return qg(t)?t.host:t}function Xg(e){let t=Gs(e);return cr(t)?e.ownerDocument?e.ownerDocument.body:e.body:ks(t)&&Kr(t)?t:Xg(t)}function qr(e,t,s){var i;t===void 0&&(t=[]),s===void 0&&(s=!0);let r=Xg(e),o=r===((i=e.ownerDocument)==null?void 0:i.body),n=$t(r);if(o){let a=ol(n);return t.concat(n,n.visualViewport||[],Kr(r)?r:[],a&&s?qr(a):[])}else return t.concat(r,qr(r,[],s))}function ol(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function e_(e){let t=Jt(e),s=parseFloat(t.width)||0,i=parseFloat(t.height)||0,r=ks(e),o=r?e.offsetWidth:s,n=r?e.offsetHeight:i,a=ln(s)!==o||ln(i)!==n;return a&&(s=o,i=n),{width:s,height:i,$:a}}function fd(e){return Xt(e)?e:e.contextElement}function Yr(e){let t=fd(e);if(!ks(t))return ns(1);let s=t.getBoundingClientRect(),{width:i,height:r,$:o}=e_(t),n=(o?ln(s.width):s.width)/i,a=(o?ln(s.height):s.height)/r;return(!n||!Number.isFinite(n))&&(n=1),(!a||!Number.isFinite(a))&&(a=1),{x:n,y:a}}var YC=ns(0);function t_(e){let t=$t(e);return!rl()||!t.visualViewport?YC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function XC(e,t,s){return t===void 0&&(t=!1),!s||t&&s!==$t(e)?!1:t}function hr(e,t,s,i){t===void 0&&(t=!1),s===void 0&&(s=!1);let r=e.getBoundingClientRect(),o=fd(e),n=ns(1);t&&(i?Xt(i)&&(n=Yr(i)):n=Yr(e));let a=XC(o,s,i)?t_(o):ns(0),c=(r.left+a.x)/n.x,l=(r.top+a.y)/n.y,h=r.width/n.x,d=r.height/n.y;if(o){let m=$t(o),p=i&&Xt(i)?$t(i):i,f=m,_=ol(f);for(;_&&i&&p!==f;){let w=Yr(_),k=_.getBoundingClientRect(),$=Jt(_),y=k.left+(_.clientLeft+parseFloat($.paddingLeft))*w.x,C=k.top+(_.clientTop+parseFloat($.paddingTop))*w.y;c*=w.x,l*=w.y,h*=w.x,d*=w.y,c+=y,l+=C,f=$t(_),_=ol(f)}}return nr({width:h,height:d,x:c,y:l})}function nl(e,t){let s=dn(e).scrollLeft;return t?t.left+s:hr(as(e)).left+s}function s_(e,t){let s=e.getBoundingClientRect(),i=s.left+t.scrollLeft-nl(e,s),r=s.top+t.scrollTop;return{x:i,y:r}}function JC(e){let{elements:t,rect:s,offsetParent:i,strategy:r}=e,o=r==="fixed",n=as(i),a=t?hn(t.floating):!1;if(i===n||a&&o)return s;let c={scrollLeft:0,scrollTop:0},l=ns(1),h=ns(0),d=ks(i);if((d||!d&&!o)&&((lr(i)!=="body"||Kr(n))&&(c=dn(i)),d)){let p=hr(i);l=Yr(i),h.x=p.x+i.clientLeft,h.y=p.y+i.clientTop}let m=n&&!d&&!o?s_(n,c):ns(0);return{width:s.width*l.x,height:s.height*l.y,x:s.x*l.x-c.scrollLeft*l.x+h.x+m.x,y:s.y*l.y-c.scrollTop*l.y+h.y+m.y}}function ZC(e){return Array.from(e.getClientRects())}function QC(e){let t=as(e),s=dn(e),i=e.ownerDocument.body,r=bt(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=bt(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight),n=-s.scrollLeft+nl(e),a=-s.scrollTop;return Jt(i).direction==="rtl"&&(n+=bt(t.clientWidth,i.clientWidth)-r),{width:r,height:o,x:n,y:a}}var Jg=25;function ex(e,t){let s=$t(e),i=as(e),r=s.visualViewport,o=i.clientWidth,n=i.clientHeight,a=0,c=0;if(r){o=r.width,n=r.height;let h=rl();(!h||h&&t==="fixed")&&(a=r.offsetLeft,c=r.offsetTop)}let l=nl(i);if(l<=0){let h=i.ownerDocument,d=h.body,m=getComputedStyle(d),p=h.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-p);f<=Jg&&(o-=f)}else l<=Jg&&(o+=l);return{width:o,height:n,x:a,y:c}}function tx(e,t){let s=hr(e,!0,t==="fixed"),i=s.top+e.clientTop,r=s.left+e.clientLeft,o=ks(e)?Yr(e):ns(1),n=e.clientWidth*o.x,a=e.clientHeight*o.y,c=r*o.x,l=i*o.y;return{width:n,height:a,x:c,y:l}}function Zg(e,t,s){let i;if(t==="viewport")i=ex(e,s);else if(t==="document")i=QC(as(e));else if(Xt(t))i=tx(t,s);else{let r=t_(e);i={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return nr(i)}function i_(e,t){let s=Gs(e);return s===t||!Xt(s)||cr(s)?!1:Jt(s).position==="fixed"||i_(s,t)}function sx(e,t){let s=t.get(e);if(s)return s;let i=qr(e,[],!1).filter(a=>Xt(a)&&lr(a)!=="body"),r=null,o=Jt(e).position==="fixed",n=o?Gs(e):e;for(;Xt(n)&&!cr(n);){let a=Jt(n),c=Gr(n);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||Kr(n)&&!c&&i_(e,n))?i=i.filter(h=>h!==n):r=a,n=Gs(n)}return t.set(e,i),i}function ix(e){let{element:t,boundary:s,rootBoundary:i,strategy:r}=e,n=[...s==="clippingAncestors"?hn(t)?[]:sx(t,this._c):[].concat(s),i],a=Zg(t,n[0],r),c=a.top,l=a.right,h=a.bottom,d=a.left;for(let m=1;m<n.length;m++){let p=Zg(t,n[m],r);c=bt(p.top,c),l=Cs(p.right,l),h=Cs(p.bottom,h),d=bt(p.left,d)}return{width:l-d,height:h-c,x:d,y:c}}function rx(e){let{width:t,height:s}=e_(e);return{width:t,height:s}}function ox(e,t,s){let i=ks(t),r=as(t),o=s==="fixed",n=hr(e,!0,o,t),a={scrollLeft:0,scrollTop:0},c=ns(0);function l(){c.x=nl(r)}if(i||!i&&!o)if((lr(t)!=="body"||Kr(r))&&(a=dn(t)),i){let p=hr(t,!0,o,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else r&&l();o&&!i&&r&&l();let h=r&&!i&&!o?s_(r,a):ns(0),d=n.left+a.scrollLeft-c.x-h.x,m=n.top+a.scrollTop-c.y-h.y;return{x:d,y:m,width:n.width,height:n.height}}function pd(e){return Jt(e).position==="static"}function Qg(e,t){if(!ks(e)||Jt(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return as(e)===s&&(s=s.ownerDocument.body),s}function r_(e,t){let s=$t(e);if(hn(e))return s;if(!ks(e)){let r=Gs(e);for(;r&&!cr(r);){if(Xt(r)&&!pd(r))return r;r=Gs(r)}return s}let i=Qg(e,t);for(;i&&Gg(i)&&pd(i);)i=Qg(i,t);return i&&cr(i)&&pd(i)&&!Gr(i)?s:i||Yg(e)||s}var nx=async function(e){let t=this.getOffsetParent||r_,s=this.getDimensions,i=await s(e.floating);return{reference:ox(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ax(e){return Jt(e).direction==="rtl"}var un={convertOffsetParentRelativeRectToViewportRelativeRect:JC,getDocumentElement:as,getClippingRect:ix,getOffsetParent:r_,getElementRects:nx,getClientRects:ZC,getDimensions:rx,getScale:Yr,isElement:Xt,isRTL:ax};function o_(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function lx(e,t){let s=null,i,r=as(e);function o(){var a;clearTimeout(i),(a=s)==null||a.disconnect(),s=null}function n(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:h,top:d,width:m,height:p}=l;if(a||t(),!m||!p)return;let f=cn(d),_=cn(r.clientWidth-(h+m)),w=cn(r.clientHeight-(d+p)),k=cn(h),y={rootMargin:-f+"px "+-_+"px "+-w+"px "+-k+"px",threshold:bt(0,Cs(1,c))||1},C=!0;function S(L){let H=L[0].intersectionRatio;if(H!==c){if(!C)return n();H?n(!1,H):i=setTimeout(()=>{n(!1,1e-7)},1e3)}H===1&&!o_(l,e.getBoundingClientRect())&&n(),C=!1}try{s=new IntersectionObserver(S,{...y,root:r.ownerDocument})}catch{s=new IntersectionObserver(S,y)}s.observe(e)}return n(!0),o}function n_(e,t,s,i){i===void 0&&(i={});let{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,l=fd(e),h=r||o?[...l?qr(l):[],...t?qr(t):[]]:[];h.forEach(k=>{r&&k.addEventListener("scroll",s,{passive:!0}),o&&k.addEventListener("resize",s)});let d=l&&a?lx(l,s):null,m=-1,p=null;n&&(p=new ResizeObserver(k=>{let[$]=k;$&&$.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),s()}),l&&!c&&p.observe(l),t&&p.observe(t));let f,_=c?hr(e):null;c&&w();function w(){let k=hr(e);_&&!o_(_,k)&&s(),_=k,f=requestAnimationFrame(w)}return s(),()=>{var k;h.forEach($=>{r&&$.removeEventListener("scroll",s),o&&$.removeEventListener("resize",s)}),d?.(),(k=p)==null||k.disconnect(),p=null,c&&cancelAnimationFrame(f)}}var a_=jg;var l_=Vg,c_=Wg,md=Ug;var h_=Hg;var d_=(e,t,s)=>{let i=new Map,r={platform:un,...s},o={...r.platform,_c:i};return Fg(e,t,{...r,platform:o})};function u_(e){return cx(e)}function gd(e){return e.assignedSlot?e.assignedSlot:e.parentNode instanceof ShadowRoot?e.parentNode.host:e.parentNode}function cx(e){for(let t=e;t;t=gd(t))if(t instanceof Element&&getComputedStyle(t).display==="none")return null;for(let t=gd(e);t;t=gd(t)){if(!(t instanceof Element))continue;let s=getComputedStyle(t);if(s.display!=="contents"&&(s.position!=="static"||Gr(s)||t.tagName==="BODY"))return t}return null}function hx(e){return e!==null&&typeof e=="object"&&"getBoundingClientRect"in e&&("contextElement"in e?e.contextElement instanceof Element:!0)}var me=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.active=!1,this.placement="top",this.strategy="absolute",this.distance=0,this.skidding=0,this.arrow=!1,this.arrowPlacement="anchor",this.arrowPadding=10,this.flip=!1,this.flipFallbackPlacements="",this.flipFallbackStrategy="best-fit",this.flipPadding=0,this.shift=!1,this.shiftPadding=0,this.autoSizePadding=0,this.hoverBridge=!1,this.updateHoverBridge=()=>{if(this.hoverBridge&&this.anchorEl){let e=this.anchorEl.getBoundingClientRect(),t=this.popup.getBoundingClientRect(),s=this.placement.includes("top")||this.placement.includes("bottom"),i=0,r=0,o=0,n=0,a=0,c=0,l=0,h=0;s?e.top<t.top?(i=e.left,r=e.bottom,o=e.right,n=e.bottom,a=t.left,c=t.top,l=t.right,h=t.top):(i=t.left,r=t.bottom,o=t.right,n=t.bottom,a=e.left,c=e.top,l=e.right,h=e.top):e.left<t.left?(i=e.right,r=e.top,o=t.left,n=t.top,a=e.right,c=e.bottom,l=t.left,h=t.bottom):(i=t.right,r=t.top,o=e.left,n=e.top,a=t.right,c=t.bottom,l=e.left,h=e.bottom),this.style.setProperty("--hover-bridge-top-left-x",`${i}px`),this.style.setProperty("--hover-bridge-top-left-y",`${r}px`),this.style.setProperty("--hover-bridge-top-right-x",`${o}px`),this.style.setProperty("--hover-bridge-top-right-y",`${n}px`),this.style.setProperty("--hover-bridge-bottom-left-x",`${a}px`),this.style.setProperty("--hover-bridge-bottom-left-y",`${c}px`),this.style.setProperty("--hover-bridge-bottom-right-x",`${l}px`),this.style.setProperty("--hover-bridge-bottom-right-y",`${h}px`)}}}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.start()}disconnectedCallback(){super.disconnectedCallback(),this.stop()}async updated(e){super.updated(e),e.has("active")&&(this.active?this.start():this.stop()),e.has("anchor")&&this.handleAnchorChange(),this.active&&(await this.updateComplete,this.reposition())}async handleAnchorChange(){if(await this.stop(),this.anchor&&typeof this.anchor=="string"){let e=this.getRootNode();this.anchorEl=e.getElementById(this.anchor)}else this.anchor instanceof Element||hx(this.anchor)?this.anchorEl=this.anchor:this.anchorEl=this.querySelector('[slot="anchor"]');this.anchorEl instanceof HTMLSlotElement&&(this.anchorEl=this.anchorEl.assignedElements({flatten:!0})[0]),this.anchorEl&&this.active&&this.start()}start(){!this.anchorEl||!this.active||(this.cleanup=n_(this.anchorEl,this.popup,()=>{this.reposition()}))}async stop(){return new Promise(e=>{this.cleanup?(this.cleanup(),this.cleanup=void 0,this.removeAttribute("data-current-placement"),this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height"),requestAnimationFrame(()=>e())):e()})}reposition(){if(!this.active||!this.anchorEl)return;let e=[a_({mainAxis:this.distance,crossAxis:this.skidding})];this.sync?e.push(md({apply:({rects:s})=>{let i=this.sync==="width"||this.sync==="both",r=this.sync==="height"||this.sync==="both";this.popup.style.width=i?`${s.reference.width}px`:"",this.popup.style.height=r?`${s.reference.height}px`:""}})):(this.popup.style.width="",this.popup.style.height=""),this.flip&&e.push(c_({boundary:this.flipBoundary,fallbackPlacements:this.flipFallbackPlacements,fallbackStrategy:this.flipFallbackStrategy==="best-fit"?"bestFit":"initialPlacement",padding:this.flipPadding})),this.shift&&e.push(l_({boundary:this.shiftBoundary,padding:this.shiftPadding})),this.autoSize?e.push(md({boundary:this.autoSizeBoundary,padding:this.autoSizePadding,apply:({availableWidth:s,availableHeight:i})=>{this.autoSize==="vertical"||this.autoSize==="both"?this.style.setProperty("--auto-size-available-height",`${i}px`):this.style.removeProperty("--auto-size-available-height"),this.autoSize==="horizontal"||this.autoSize==="both"?this.style.setProperty("--auto-size-available-width",`${s}px`):this.style.removeProperty("--auto-size-available-width")}})):(this.style.removeProperty("--auto-size-available-width"),this.style.removeProperty("--auto-size-available-height")),this.arrow&&e.push(h_({element:this.arrowEl,padding:this.arrowPadding}));let t=this.strategy==="absolute"?s=>un.getOffsetParent(s,u_):un.getOffsetParent;d_(this.anchorEl,this.popup,{placement:this.placement,middleware:e,strategy:this.strategy,platform:qs(ut({},un),{getOffsetParent:t})}).then(({x:s,y:i,middlewareData:r,placement:o})=>{let n=this.localize.dir()==="rtl",a={top:"bottom",right:"left",bottom:"top",left:"right"}[o.split("-")[0]];if(this.setAttribute("data-current-placement",o),Object.assign(this.popup.style,{left:`${s}px`,top:`${i}px`}),this.arrow){let c=r.arrow.x,l=r.arrow.y,h="",d="",m="",p="";if(this.arrowPlacement==="start"){let f=typeof c=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";h=typeof l=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"",d=n?f:"",p=n?"":f}else if(this.arrowPlacement==="end"){let f=typeof c=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:"";d=n?"":f,p=n?f:"",m=typeof l=="number"?`calc(${this.arrowPadding}px - var(--arrow-padding-offset))`:""}else this.arrowPlacement==="center"?(p=typeof c=="number"?"calc(50% - var(--arrow-size-diagonal))":"",h=typeof l=="number"?"calc(50% - var(--arrow-size-diagonal))":""):(p=typeof c=="number"?`${c}px`:"",h=typeof l=="number"?`${l}px`:"");Object.assign(this.arrowEl.style,{top:h,right:d,bottom:m,left:p,[a]:"calc(var(--arrow-size-diagonal) * -1)"})}}),requestAnimationFrame(()=>this.updateHoverBridge()),this.emit("sl-reposition")}render(){return u`
3679
3693
  <slot name="anchor" @slotchange=${this.handleAnchorChange}></slot>
3680
3694
 
3681
3695
  <span
@@ -3690,7 +3704,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3690
3704
  <slot></slot>
3691
3705
  ${this.arrow?u`<div part="arrow" class="popup__arrow" role="presentation"></div>`:""}
3692
3706
  </div>
3693
- `}};me.styles=[Q,Dg];g([Z(".popup")],me.prototype,"popup",2);g([Z(".popup__arrow")],me.prototype,"arrowEl",2);g([v()],me.prototype,"anchor",2);g([v({type:Boolean,reflect:!0})],me.prototype,"active",2);g([v({reflect:!0})],me.prototype,"placement",2);g([v({reflect:!0})],me.prototype,"strategy",2);g([v({type:Number})],me.prototype,"distance",2);g([v({type:Number})],me.prototype,"skidding",2);g([v({type:Boolean})],me.prototype,"arrow",2);g([v({attribute:"arrow-placement"})],me.prototype,"arrowPlacement",2);g([v({attribute:"arrow-padding",type:Number})],me.prototype,"arrowPadding",2);g([v({type:Boolean})],me.prototype,"flip",2);g([v({attribute:"flip-fallback-placements",converter:{fromAttribute:e=>e.split(" ").map(t=>t.trim()).filter(t=>t!==""),toAttribute:e=>e.join(" ")}})],me.prototype,"flipFallbackPlacements",2);g([v({attribute:"flip-fallback-strategy"})],me.prototype,"flipFallbackStrategy",2);g([v({type:Object})],me.prototype,"flipBoundary",2);g([v({attribute:"flip-padding",type:Number})],me.prototype,"flipPadding",2);g([v({type:Boolean})],me.prototype,"shift",2);g([v({type:Object})],me.prototype,"shiftBoundary",2);g([v({attribute:"shift-padding",type:Number})],me.prototype,"shiftPadding",2);g([v({attribute:"auto-size"})],me.prototype,"autoSize",2);g([v()],me.prototype,"sync",2);g([v({type:Object})],me.prototype,"autoSizeBoundary",2);g([v({attribute:"auto-size-padding",type:Number})],me.prototype,"autoSizePadding",2);g([v({attribute:"hover-bridge",type:Boolean})],me.prototype,"hoverBridge",2);var pn=new WeakMap,fn=new WeakMap,mn=new WeakMap,_d=new WeakSet,al=new WeakMap,Et=class{constructor(e,t){this.handleFormData=s=>{let i=this.options.disabled(this.host),r=this.options.name(this.host),o=this.options.value(this.host),n=this.host.tagName.toLowerCase()==="sl-button";this.host.isConnected&&!i&&!n&&typeof r=="string"&&r.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(a=>{s.formData.append(r,a.toString())}):s.formData.append(r,o.toString()))},this.handleFormSubmit=s=>{var i;let r=this.options.disabled(this.host),o=this.options.reportValidity;this.form&&!this.form.noValidate&&((i=pn.get(this.form))==null||i.forEach(n=>{this.setUserInteracted(n,!0)})),this.form&&!this.form.noValidate&&!r&&!o(this.host)&&(s.preventDefault(),s.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),al.set(this.host,[])},this.handleInteraction=s=>{let i=al.get(this.host);i.includes(s.type)||i.push(s.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){let s=this.form.querySelectorAll("*");for(let i of s)if(typeof i.checkValidity=="function"&&!i.checkValidity())return!1}return!0},this.reportFormValidity=()=>{if(this.form&&!this.form.noValidate){let s=this.form.querySelectorAll("*");for(let i of s)if(typeof i.reportValidity=="function"&&!i.reportValidity())return!1}return!0},(this.host=e).addController(this),this.options=ut({form:s=>{let i=s.form;if(i){let o=s.getRootNode().querySelector(`#${i}`);if(o)return o}return s.closest("form")},name:s=>s.name,value:s=>s.value,defaultValue:s=>s.defaultValue,disabled:s=>{var i;return(i=s.disabled)!=null?i:!1},reportValidity:s=>typeof s.reportValidity=="function"?s.reportValidity():!0,checkValidity:s=>typeof s.checkValidity=="function"?s.checkValidity():!0,setValue:(s,i)=>s.value=i,assumeInteractionOn:["sl-input"]},t)}hostConnected(){let e=this.options.form(this.host);e&&this.attachForm(e),al.set(this.host,[]),this.options.assumeInteractionOn.forEach(t=>{this.host.addEventListener(t,this.handleInteraction)})}hostDisconnected(){this.detachForm(),al.delete(this.host),this.options.assumeInteractionOn.forEach(e=>{this.host.removeEventListener(e,this.handleInteraction)})}hostUpdated(){let e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(e){e?(this.form=e,pn.has(this.form)?pn.get(this.form).add(this.host):pn.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),fn.has(this.form)||(fn.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),mn.has(this.form)||(mn.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;let e=pn.get(this.form);e&&(e.delete(this.host),e.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),fn.has(this.form)&&(this.form.reportValidity=fn.get(this.form),fn.delete(this.form)),mn.has(this.form)&&(this.form.checkValidity=mn.get(this.form),mn.delete(this.form)),this.form=void 0))}setUserInteracted(e,t){t?_d.add(e):_d.delete(e),e.requestUpdate()}doAction(e,t){if(this.form){let s=document.createElement("button");s.type=e,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",t&&(s.name=t.name,s.value=t.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach(i=>{t.hasAttribute(i)&&s.setAttribute(i,t.getAttribute(i))})),this.form.append(s),s.click(),s.remove()}}getForm(){var e;return(e=this.form)!=null?e:null}reset(e){this.doAction("reset",e)}submit(e){this.doAction("submit",e)}setValidity(e){let t=this.host,s=!!_d.has(t),i=!!t.required;t.toggleAttribute("data-required",i),t.toggleAttribute("data-optional",!i),t.toggleAttribute("data-invalid",!e),t.toggleAttribute("data-valid",e),t.toggleAttribute("data-user-invalid",!e&&s),t.toggleAttribute("data-user-valid",e&&s)}updateValidity(){let e=this.host;this.setValidity(e.validity.valid)}emitInvalidEvent(e){let t=new CustomEvent("sl-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});e||t.preventDefault(),this.host.dispatchEvent(t)||e?.preventDefault()}},Xr=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),u_=Object.freeze(qs(ut({},Xr),{valid:!1,valueMissing:!0})),p_=Object.freeze(qs(ut({},Xr),{valid:!1,customError:!0}));var Je=class{constructor(e,...t){this.slotNames=[],this.handleSlotChange=s=>{let i=s.target;(this.slotNames.includes("[default]")&&!i.name||i.name&&this.slotNames.includes(i.name))&&this.host.requestUpdate()},(this.host=e).addController(this),this.slotNames=t}hasDefaultSlot(){return[...this.host.childNodes].some(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent.trim()!=="")return!0;if(e.nodeType===e.ELEMENT_NODE){let t=e;if(t.tagName.toLowerCase()==="sl-visually-hidden")return!1;if(!t.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(e){return this.host.querySelector(`:scope > [slot="${e}"]`)!==null}test(e){return e==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}};var le=class extends X{constructor(){super(...arguments),this.formControlController=new Et(this,{assumeInteractionOn:["sl-blur","sl-input"]}),this.hasSlotController=new Je(this,"help-text","label"),this.localize=new be(this),this.typeToSelectString="",this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.valueHasChanged=!1,this.name="",this._value="",this.defaultValue="",this.size="medium",this.placeholder="",this.multiple=!1,this.maxOptionsVisible=3,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.helpText="",this.form="",this.required=!1,this.getTag=e=>u`
3707
+ `}};me.styles=[Q,Lg];g([Z(".popup")],me.prototype,"popup",2);g([Z(".popup__arrow")],me.prototype,"arrowEl",2);g([v()],me.prototype,"anchor",2);g([v({type:Boolean,reflect:!0})],me.prototype,"active",2);g([v({reflect:!0})],me.prototype,"placement",2);g([v({reflect:!0})],me.prototype,"strategy",2);g([v({type:Number})],me.prototype,"distance",2);g([v({type:Number})],me.prototype,"skidding",2);g([v({type:Boolean})],me.prototype,"arrow",2);g([v({attribute:"arrow-placement"})],me.prototype,"arrowPlacement",2);g([v({attribute:"arrow-padding",type:Number})],me.prototype,"arrowPadding",2);g([v({type:Boolean})],me.prototype,"flip",2);g([v({attribute:"flip-fallback-placements",converter:{fromAttribute:e=>e.split(" ").map(t=>t.trim()).filter(t=>t!==""),toAttribute:e=>e.join(" ")}})],me.prototype,"flipFallbackPlacements",2);g([v({attribute:"flip-fallback-strategy"})],me.prototype,"flipFallbackStrategy",2);g([v({type:Object})],me.prototype,"flipBoundary",2);g([v({attribute:"flip-padding",type:Number})],me.prototype,"flipPadding",2);g([v({type:Boolean})],me.prototype,"shift",2);g([v({type:Object})],me.prototype,"shiftBoundary",2);g([v({attribute:"shift-padding",type:Number})],me.prototype,"shiftPadding",2);g([v({attribute:"auto-size"})],me.prototype,"autoSize",2);g([v()],me.prototype,"sync",2);g([v({type:Object})],me.prototype,"autoSizeBoundary",2);g([v({attribute:"auto-size-padding",type:Number})],me.prototype,"autoSizePadding",2);g([v({attribute:"hover-bridge",type:Boolean})],me.prototype,"hoverBridge",2);var pn=new WeakMap,fn=new WeakMap,mn=new WeakMap,_d=new WeakSet,al=new WeakMap,Et=class{constructor(e,t){this.handleFormData=s=>{let i=this.options.disabled(this.host),r=this.options.name(this.host),o=this.options.value(this.host),n=this.host.tagName.toLowerCase()==="sl-button";this.host.isConnected&&!i&&!n&&typeof r=="string"&&r.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(a=>{s.formData.append(r,a.toString())}):s.formData.append(r,o.toString()))},this.handleFormSubmit=s=>{var i;let r=this.options.disabled(this.host),o=this.options.reportValidity;this.form&&!this.form.noValidate&&((i=pn.get(this.form))==null||i.forEach(n=>{this.setUserInteracted(n,!0)})),this.form&&!this.form.noValidate&&!r&&!o(this.host)&&(s.preventDefault(),s.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),al.set(this.host,[])},this.handleInteraction=s=>{let i=al.get(this.host);i.includes(s.type)||i.push(s.type),i.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){let s=this.form.querySelectorAll("*");for(let i of s)if(typeof i.checkValidity=="function"&&!i.checkValidity())return!1}return!0},this.reportFormValidity=()=>{if(this.form&&!this.form.noValidate){let s=this.form.querySelectorAll("*");for(let i of s)if(typeof i.reportValidity=="function"&&!i.reportValidity())return!1}return!0},(this.host=e).addController(this),this.options=ut({form:s=>{let i=s.form;if(i){let o=s.getRootNode().querySelector(`#${i}`);if(o)return o}return s.closest("form")},name:s=>s.name,value:s=>s.value,defaultValue:s=>s.defaultValue,disabled:s=>{var i;return(i=s.disabled)!=null?i:!1},reportValidity:s=>typeof s.reportValidity=="function"?s.reportValidity():!0,checkValidity:s=>typeof s.checkValidity=="function"?s.checkValidity():!0,setValue:(s,i)=>s.value=i,assumeInteractionOn:["sl-input"]},t)}hostConnected(){let e=this.options.form(this.host);e&&this.attachForm(e),al.set(this.host,[]),this.options.assumeInteractionOn.forEach(t=>{this.host.addEventListener(t,this.handleInteraction)})}hostDisconnected(){this.detachForm(),al.delete(this.host),this.options.assumeInteractionOn.forEach(e=>{this.host.removeEventListener(e,this.handleInteraction)})}hostUpdated(){let e=this.options.form(this.host);e||this.detachForm(),e&&this.form!==e&&(this.detachForm(),this.attachForm(e)),this.host.hasUpdated&&this.setValidity(this.host.validity.valid)}attachForm(e){e?(this.form=e,pn.has(this.form)?pn.get(this.form).add(this.host):pn.set(this.form,new Set([this.host])),this.form.addEventListener("formdata",this.handleFormData),this.form.addEventListener("submit",this.handleFormSubmit),this.form.addEventListener("reset",this.handleFormReset),fn.has(this.form)||(fn.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),mn.has(this.form)||(mn.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;let e=pn.get(this.form);e&&(e.delete(this.host),e.size<=0&&(this.form.removeEventListener("formdata",this.handleFormData),this.form.removeEventListener("submit",this.handleFormSubmit),this.form.removeEventListener("reset",this.handleFormReset),fn.has(this.form)&&(this.form.reportValidity=fn.get(this.form),fn.delete(this.form)),mn.has(this.form)&&(this.form.checkValidity=mn.get(this.form),mn.delete(this.form)),this.form=void 0))}setUserInteracted(e,t){t?_d.add(e):_d.delete(e),e.requestUpdate()}doAction(e,t){if(this.form){let s=document.createElement("button");s.type=e,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",t&&(s.name=t.name,s.value=t.value,["formaction","formenctype","formmethod","formnovalidate","formtarget"].forEach(i=>{t.hasAttribute(i)&&s.setAttribute(i,t.getAttribute(i))})),this.form.append(s),s.click(),s.remove()}}getForm(){var e;return(e=this.form)!=null?e:null}reset(e){this.doAction("reset",e)}submit(e){this.doAction("submit",e)}setValidity(e){let t=this.host,s=!!_d.has(t),i=!!t.required;t.toggleAttribute("data-required",i),t.toggleAttribute("data-optional",!i),t.toggleAttribute("data-invalid",!e),t.toggleAttribute("data-valid",e),t.toggleAttribute("data-user-invalid",!e&&s),t.toggleAttribute("data-user-valid",e&&s)}updateValidity(){let e=this.host;this.setValidity(e.validity.valid)}emitInvalidEvent(e){let t=new CustomEvent("sl-invalid",{bubbles:!1,composed:!1,cancelable:!0,detail:{}});e||t.preventDefault(),this.host.dispatchEvent(t)||e?.preventDefault()}},Xr=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),p_=Object.freeze(qs(ut({},Xr),{valid:!1,valueMissing:!0})),f_=Object.freeze(qs(ut({},Xr),{valid:!1,customError:!0}));var Je=class{constructor(e,...t){this.slotNames=[],this.handleSlotChange=s=>{let i=s.target;(this.slotNames.includes("[default]")&&!i.name||i.name&&this.slotNames.includes(i.name))&&this.host.requestUpdate()},(this.host=e).addController(this),this.slotNames=t}hasDefaultSlot(){return[...this.host.childNodes].some(e=>{if(e.nodeType===e.TEXT_NODE&&e.textContent.trim()!=="")return!0;if(e.nodeType===e.ELEMENT_NODE){let t=e;if(t.tagName.toLowerCase()==="sl-visually-hidden")return!1;if(!t.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(e){return this.host.querySelector(`:scope > [slot="${e}"]`)!==null}test(e){return e==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(e)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}};var le=class extends X{constructor(){super(...arguments),this.formControlController=new Et(this,{assumeInteractionOn:["sl-blur","sl-input"]}),this.hasSlotController=new Je(this,"help-text","label"),this.localize=new be(this),this.typeToSelectString="",this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.valueHasChanged=!1,this.name="",this._value="",this.defaultValue="",this.size="medium",this.placeholder="",this.multiple=!1,this.maxOptionsVisible=3,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.helpText="",this.form="",this.required=!1,this.getTag=e=>u`
3694
3708
  <sl-tag
3695
3709
  part="tag"
3696
3710
  exportparts="
@@ -3829,7 +3843,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3829
3843
  <slot name="help-text">${this.helpText}</slot>
3830
3844
  </div>
3831
3845
  </div>
3832
- `}};le.styles=[Q,Yt,Rg];le.dependencies={"sl-icon":Ce,"sl-popup":me,"sl-tag":xi};g([Z(".select")],le.prototype,"popup",2);g([Z(".select__combobox")],le.prototype,"combobox",2);g([Z(".select__display-input")],le.prototype,"displayInput",2);g([Z(".select__value-input")],le.prototype,"valueInput",2);g([Z(".select__listbox")],le.prototype,"listbox",2);g([oe()],le.prototype,"hasFocus",2);g([oe()],le.prototype,"displayLabel",2);g([oe()],le.prototype,"currentOption",2);g([oe()],le.prototype,"selectedOptions",2);g([oe()],le.prototype,"valueHasChanged",2);g([v()],le.prototype,"name",2);g([oe()],le.prototype,"value",1);g([v({attribute:"value"})],le.prototype,"defaultValue",2);g([v({reflect:!0})],le.prototype,"size",2);g([v()],le.prototype,"placeholder",2);g([v({type:Boolean,reflect:!0})],le.prototype,"multiple",2);g([v({attribute:"max-options-visible",type:Number})],le.prototype,"maxOptionsVisible",2);g([v({type:Boolean,reflect:!0})],le.prototype,"disabled",2);g([v({type:Boolean})],le.prototype,"clearable",2);g([v({type:Boolean,reflect:!0})],le.prototype,"open",2);g([v({type:Boolean})],le.prototype,"hoist",2);g([v({type:Boolean,reflect:!0})],le.prototype,"filled",2);g([v({type:Boolean,reflect:!0})],le.prototype,"pill",2);g([v()],le.prototype,"label",2);g([v({reflect:!0})],le.prototype,"placement",2);g([v({attribute:"help-text"})],le.prototype,"helpText",2);g([v({reflect:!0})],le.prototype,"form",2);g([v({type:Boolean,reflect:!0})],le.prototype,"required",2);g([v()],le.prototype,"getTag",2);g([G("disabled",{waitUntilFirstUpdate:!0})],le.prototype,"handleDisabledChange",1);g([G(["defaultValue","value"],{waitUntilFirstUpdate:!0})],le.prototype,"handleValueChange",1);g([G("open",{waitUntilFirstUpdate:!0})],le.prototype,"handleOpenChange",1);Ge("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}});Ge("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});le.define("sl-select");var f_=Y`
3846
+ `}};le.styles=[Q,Yt,Dg];le.dependencies={"sl-icon":Ce,"sl-popup":me,"sl-tag":xi};g([Z(".select")],le.prototype,"popup",2);g([Z(".select__combobox")],le.prototype,"combobox",2);g([Z(".select__display-input")],le.prototype,"displayInput",2);g([Z(".select__value-input")],le.prototype,"valueInput",2);g([Z(".select__listbox")],le.prototype,"listbox",2);g([oe()],le.prototype,"hasFocus",2);g([oe()],le.prototype,"displayLabel",2);g([oe()],le.prototype,"currentOption",2);g([oe()],le.prototype,"selectedOptions",2);g([oe()],le.prototype,"valueHasChanged",2);g([v()],le.prototype,"name",2);g([oe()],le.prototype,"value",1);g([v({attribute:"value"})],le.prototype,"defaultValue",2);g([v({reflect:!0})],le.prototype,"size",2);g([v()],le.prototype,"placeholder",2);g([v({type:Boolean,reflect:!0})],le.prototype,"multiple",2);g([v({attribute:"max-options-visible",type:Number})],le.prototype,"maxOptionsVisible",2);g([v({type:Boolean,reflect:!0})],le.prototype,"disabled",2);g([v({type:Boolean})],le.prototype,"clearable",2);g([v({type:Boolean,reflect:!0})],le.prototype,"open",2);g([v({type:Boolean})],le.prototype,"hoist",2);g([v({type:Boolean,reflect:!0})],le.prototype,"filled",2);g([v({type:Boolean,reflect:!0})],le.prototype,"pill",2);g([v()],le.prototype,"label",2);g([v({reflect:!0})],le.prototype,"placement",2);g([v({attribute:"help-text"})],le.prototype,"helpText",2);g([v({reflect:!0})],le.prototype,"form",2);g([v({type:Boolean,reflect:!0})],le.prototype,"required",2);g([v()],le.prototype,"getTag",2);g([G("disabled",{waitUntilFirstUpdate:!0})],le.prototype,"handleDisabledChange",1);g([G(["defaultValue","value"],{waitUntilFirstUpdate:!0})],le.prototype,"handleValueChange",1);g([G("open",{waitUntilFirstUpdate:!0})],le.prototype,"handleOpenChange",1);Ge("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}});Ge("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});le.define("sl-select");var m_=Y`
3833
3847
  :host {
3834
3848
  display: block;
3835
3849
  user-select: none;
@@ -3925,7 +3939,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
3925
3939
  <slot part="label" class="option__label" @slotchange=${this.handleDefaultSlotChange}></slot>
3926
3940
  <slot part="suffix" name="suffix" class="option__suffix"></slot>
3927
3941
  </div>
3928
- `}};Ot.styles=[Q,f_];Ot.dependencies={"sl-icon":Ce};g([Z(".option__label")],Ot.prototype,"defaultSlot",2);g([oe()],Ot.prototype,"current",2);g([oe()],Ot.prototype,"selected",2);g([oe()],Ot.prototype,"hasHover",2);g([v({reflect:!0})],Ot.prototype,"value",2);g([v({type:Boolean,reflect:!0})],Ot.prototype,"disabled",2);g([G("disabled")],Ot.prototype,"handleDisabledChange",1);g([G("selected")],Ot.prototype,"handleSelectedChange",1);g([G("value")],Ot.prototype,"handleValueChange",1);Ot.define("sl-option");var m_=Y`
3942
+ `}};Ot.styles=[Q,m_];Ot.dependencies={"sl-icon":Ce};g([Z(".option__label")],Ot.prototype,"defaultSlot",2);g([oe()],Ot.prototype,"current",2);g([oe()],Ot.prototype,"selected",2);g([oe()],Ot.prototype,"hasHover",2);g([v({reflect:!0})],Ot.prototype,"value",2);g([v({type:Boolean,reflect:!0})],Ot.prototype,"disabled",2);g([G("disabled")],Ot.prototype,"handleDisabledChange",1);g([G("selected")],Ot.prototype,"handleSelectedChange",1);g([G("value")],Ot.prototype,"handleValueChange",1);Ot.define("sl-option");var g_=Y`
3929
3943
  :host {
3930
3944
  display: block;
3931
3945
  }
@@ -4211,7 +4225,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
4211
4225
  .input--no-spin-buttons input[type='number'] {
4212
4226
  -moz-appearance: textfield;
4213
4227
  }
4214
- `;var ki=(e="value")=>(t,s)=>{let i=t.constructor,r=i.prototype.attributeChangedCallback;i.prototype.attributeChangedCallback=function(o,n,a){var c;let l=i.getPropertyOptions(e),h=typeof l.attribute=="string"?l.attribute:e;if(o===h){let d=l.converter||Si,p=(typeof d=="function"?d:(c=d?.fromAttribute)!=null?c:Si.fromAttribute)(a,l.type);this[e]!==p&&(this[s]=p)}r.call(this,o,n,a)}};var Ys=mr(class extends Qs{constructor(e){if(super(e),e.type!==ts.PROPERTY&&e.type!==ts.ATTRIBUTE&&e.type!==ts.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!xg(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===ct||t===b)return t;let s=e.element,i=e.name;if(e.type===ts.PROPERTY){if(t===s[i])return ct}else if(e.type===ts.BOOLEAN_ATTRIBUTE){if(!!t===s.hasAttribute(i))return ct}else if(e.type===ts.ATTRIBUTE&&s.getAttribute(i)===t+"")return ct;return kg(e),t}});var ne=class extends X{constructor(){super(...arguments),this.formControlController=new Et(this,{assumeInteractionOn:["sl-blur","sl-input"]}),this.hasSlotController=new Je(this,"help-text","label"),this.localize=new be(this),this.hasFocus=!1,this.title="",this.__numberInput=Object.assign(document.createElement("input"),{type:"number"}),this.__dateInput=Object.assign(document.createElement("input"),{type:"date"}),this.type="text",this.name="",this.value="",this.defaultValue="",this.size="medium",this.filled=!1,this.pill=!1,this.label="",this.helpText="",this.clearable=!1,this.disabled=!1,this.placeholder="",this.readonly=!1,this.passwordToggle=!1,this.passwordVisible=!1,this.noSpinButtons=!1,this.form="",this.required=!1,this.spellcheck=!0}get valueAsDate(){var e;return this.__dateInput.type=this.type,this.__dateInput.value=this.value,((e=this.input)==null?void 0:e.valueAsDate)||this.__dateInput.valueAsDate}set valueAsDate(e){this.__dateInput.type=this.type,this.__dateInput.valueAsDate=e,this.value=this.__dateInput.value}get valueAsNumber(){var e;return this.__numberInput.value=this.value,((e=this.input)==null?void 0:e.valueAsNumber)||this.__numberInput.valueAsNumber}set valueAsNumber(e){this.__numberInput.valueAsNumber=e,this.value=this.__numberInput.value}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleBlur(){this.hasFocus=!1,this.emit("sl-blur")}handleChange(){this.value=this.input.value,this.emit("sl-change")}handleClearClick(e){e.preventDefault(),this.value!==""&&(this.value="",this.emit("sl-clear"),this.emit("sl-input"),this.emit("sl-change")),this.input.focus()}handleFocus(){this.hasFocus=!0,this.emit("sl-focus")}handleInput(){this.value=this.input.value,this.formControlController.updateValidity(),this.emit("sl-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleKeyDown(e){let t=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey;e.key==="Enter"&&!t&&setTimeout(()=>{!e.defaultPrevented&&!e.isComposing&&this.formControlController.submit()})}handlePasswordToggle(){this.passwordVisible=!this.passwordVisible}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleStepChange(){this.input.step=String(this.step),this.formControlController.updateValidity()}async handleValueChange(){await this.updateComplete,this.formControlController.updateValidity()}focus(e){this.input.focus(e)}blur(){this.input.blur()}select(){this.input.select()}setSelectionRange(e,t,s="none"){this.input.setSelectionRange(e,t,s)}setRangeText(e,t,s,i="preserve"){let r=t??this.input.selectionStart,o=s??this.input.selectionEnd;this.input.setRangeText(e,r,o,i),this.value!==this.input.value&&(this.value=this.input.value)}showPicker(){"showPicker"in HTMLInputElement.prototype&&this.input.showPicker()}stepUp(){this.input.stepUp(),this.value!==this.input.value&&(this.value=this.input.value)}stepDown(){this.input.stepDown(),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){let e=this.hasSlotController.test("label"),t=this.hasSlotController.test("help-text"),s=this.label?!0:!!e,i=this.helpText?!0:!!t,o=this.clearable&&!this.disabled&&!this.readonly&&(typeof this.value=="number"||this.value.length>0);return u`
4228
+ `;var ki=(e="value")=>(t,s)=>{let i=t.constructor,r=i.prototype.attributeChangedCallback;i.prototype.attributeChangedCallback=function(o,n,a){var c;let l=i.getPropertyOptions(e),h=typeof l.attribute=="string"?l.attribute:e;if(o===h){let d=l.converter||Si,p=(typeof d=="function"?d:(c=d?.fromAttribute)!=null?c:Si.fromAttribute)(a,l.type);this[e]!==p&&(this[s]=p)}r.call(this,o,n,a)}};var Ys=mr(class extends Qs{constructor(e){if(super(e),e.type!==ts.PROPERTY&&e.type!==ts.ATTRIBUTE&&e.type!==ts.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!kg(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===ct||t===b)return t;let s=e.element,i=e.name;if(e.type===ts.PROPERTY){if(t===s[i])return ct}else if(e.type===ts.BOOLEAN_ATTRIBUTE){if(!!t===s.hasAttribute(i))return ct}else if(e.type===ts.ATTRIBUTE&&s.getAttribute(i)===t+"")return ct;return $g(e),t}});var ne=class extends X{constructor(){super(...arguments),this.formControlController=new Et(this,{assumeInteractionOn:["sl-blur","sl-input"]}),this.hasSlotController=new Je(this,"help-text","label"),this.localize=new be(this),this.hasFocus=!1,this.title="",this.__numberInput=Object.assign(document.createElement("input"),{type:"number"}),this.__dateInput=Object.assign(document.createElement("input"),{type:"date"}),this.type="text",this.name="",this.value="",this.defaultValue="",this.size="medium",this.filled=!1,this.pill=!1,this.label="",this.helpText="",this.clearable=!1,this.disabled=!1,this.placeholder="",this.readonly=!1,this.passwordToggle=!1,this.passwordVisible=!1,this.noSpinButtons=!1,this.form="",this.required=!1,this.spellcheck=!0}get valueAsDate(){var e;return this.__dateInput.type=this.type,this.__dateInput.value=this.value,((e=this.input)==null?void 0:e.valueAsDate)||this.__dateInput.valueAsDate}set valueAsDate(e){this.__dateInput.type=this.type,this.__dateInput.valueAsDate=e,this.value=this.__dateInput.value}get valueAsNumber(){var e;return this.__numberInput.value=this.value,((e=this.input)==null?void 0:e.valueAsNumber)||this.__numberInput.valueAsNumber}set valueAsNumber(e){this.__numberInput.valueAsNumber=e,this.value=this.__numberInput.value}get validity(){return this.input.validity}get validationMessage(){return this.input.validationMessage}firstUpdated(){this.formControlController.updateValidity()}handleBlur(){this.hasFocus=!1,this.emit("sl-blur")}handleChange(){this.value=this.input.value,this.emit("sl-change")}handleClearClick(e){e.preventDefault(),this.value!==""&&(this.value="",this.emit("sl-clear"),this.emit("sl-input"),this.emit("sl-change")),this.input.focus()}handleFocus(){this.hasFocus=!0,this.emit("sl-focus")}handleInput(){this.value=this.input.value,this.formControlController.updateValidity(),this.emit("sl-input")}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleKeyDown(e){let t=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey;e.key==="Enter"&&!t&&setTimeout(()=>{!e.defaultPrevented&&!e.isComposing&&this.formControlController.submit()})}handlePasswordToggle(){this.passwordVisible=!this.passwordVisible}handleDisabledChange(){this.formControlController.setValidity(this.disabled)}handleStepChange(){this.input.step=String(this.step),this.formControlController.updateValidity()}async handleValueChange(){await this.updateComplete,this.formControlController.updateValidity()}focus(e){this.input.focus(e)}blur(){this.input.blur()}select(){this.input.select()}setSelectionRange(e,t,s="none"){this.input.setSelectionRange(e,t,s)}setRangeText(e,t,s,i="preserve"){let r=t??this.input.selectionStart,o=s??this.input.selectionEnd;this.input.setRangeText(e,r,o,i),this.value!==this.input.value&&(this.value=this.input.value)}showPicker(){"showPicker"in HTMLInputElement.prototype&&this.input.showPicker()}stepUp(){this.input.stepUp(),this.value!==this.input.value&&(this.value=this.input.value)}stepDown(){this.input.stepDown(),this.value!==this.input.value&&(this.value=this.input.value)}checkValidity(){return this.input.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.input.reportValidity()}setCustomValidity(e){this.input.setCustomValidity(e),this.formControlController.updateValidity()}render(){let e=this.hasSlotController.test("label"),t=this.hasSlotController.test("help-text"),s=this.label?!0:!!e,i=this.helpText?!0:!!t,o=this.clearable&&!this.disabled&&!this.readonly&&(typeof this.value=="number"||this.value.length>0);return u`
4215
4229
  <div
4216
4230
  part="form-control"
4217
4231
  class=${ee({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--has-label":s,"form-control--has-help-text":i})}
@@ -4318,7 +4332,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
4318
4332
  <slot name="help-text">${this.helpText}</slot>
4319
4333
  </div>
4320
4334
  </div>
4321
- `}};ne.styles=[Q,Yt,m_];ne.dependencies={"sl-icon":Ce};g([Z(".input__control")],ne.prototype,"input",2);g([oe()],ne.prototype,"hasFocus",2);g([v()],ne.prototype,"title",2);g([v({reflect:!0})],ne.prototype,"type",2);g([v()],ne.prototype,"name",2);g([v()],ne.prototype,"value",2);g([ki()],ne.prototype,"defaultValue",2);g([v({reflect:!0})],ne.prototype,"size",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"filled",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"pill",2);g([v()],ne.prototype,"label",2);g([v({attribute:"help-text"})],ne.prototype,"helpText",2);g([v({type:Boolean})],ne.prototype,"clearable",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"disabled",2);g([v()],ne.prototype,"placeholder",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"readonly",2);g([v({attribute:"password-toggle",type:Boolean})],ne.prototype,"passwordToggle",2);g([v({attribute:"password-visible",type:Boolean})],ne.prototype,"passwordVisible",2);g([v({attribute:"no-spin-buttons",type:Boolean})],ne.prototype,"noSpinButtons",2);g([v({reflect:!0})],ne.prototype,"form",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"required",2);g([v()],ne.prototype,"pattern",2);g([v({type:Number})],ne.prototype,"minlength",2);g([v({type:Number})],ne.prototype,"maxlength",2);g([v()],ne.prototype,"min",2);g([v()],ne.prototype,"max",2);g([v()],ne.prototype,"step",2);g([v()],ne.prototype,"autocapitalize",2);g([v()],ne.prototype,"autocorrect",2);g([v()],ne.prototype,"autocomplete",2);g([v({type:Boolean})],ne.prototype,"autofocus",2);g([v()],ne.prototype,"enterkeyhint",2);g([v({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],ne.prototype,"spellcheck",2);g([v()],ne.prototype,"inputmode",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ne.prototype,"handleDisabledChange",1);g([G("step",{waitUntilFirstUpdate:!0})],ne.prototype,"handleStepChange",1);g([G("value",{waitUntilFirstUpdate:!0})],ne.prototype,"handleValueChange",1);ne.define("sl-input");var g_=Y`
4335
+ `}};ne.styles=[Q,Yt,g_];ne.dependencies={"sl-icon":Ce};g([Z(".input__control")],ne.prototype,"input",2);g([oe()],ne.prototype,"hasFocus",2);g([v()],ne.prototype,"title",2);g([v({reflect:!0})],ne.prototype,"type",2);g([v()],ne.prototype,"name",2);g([v()],ne.prototype,"value",2);g([ki()],ne.prototype,"defaultValue",2);g([v({reflect:!0})],ne.prototype,"size",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"filled",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"pill",2);g([v()],ne.prototype,"label",2);g([v({attribute:"help-text"})],ne.prototype,"helpText",2);g([v({type:Boolean})],ne.prototype,"clearable",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"disabled",2);g([v()],ne.prototype,"placeholder",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"readonly",2);g([v({attribute:"password-toggle",type:Boolean})],ne.prototype,"passwordToggle",2);g([v({attribute:"password-visible",type:Boolean})],ne.prototype,"passwordVisible",2);g([v({attribute:"no-spin-buttons",type:Boolean})],ne.prototype,"noSpinButtons",2);g([v({reflect:!0})],ne.prototype,"form",2);g([v({type:Boolean,reflect:!0})],ne.prototype,"required",2);g([v()],ne.prototype,"pattern",2);g([v({type:Number})],ne.prototype,"minlength",2);g([v({type:Number})],ne.prototype,"maxlength",2);g([v()],ne.prototype,"min",2);g([v()],ne.prototype,"max",2);g([v()],ne.prototype,"step",2);g([v()],ne.prototype,"autocapitalize",2);g([v()],ne.prototype,"autocorrect",2);g([v()],ne.prototype,"autocomplete",2);g([v({type:Boolean})],ne.prototype,"autofocus",2);g([v()],ne.prototype,"enterkeyhint",2);g([v({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],ne.prototype,"spellcheck",2);g([v()],ne.prototype,"inputmode",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ne.prototype,"handleDisabledChange",1);g([G("step",{waitUntilFirstUpdate:!0})],ne.prototype,"handleStepChange",1);g([G("value",{waitUntilFirstUpdate:!0})],ne.prototype,"handleValueChange",1);ne.define("sl-input");var __=Y`
4322
4336
  :host {
4323
4337
  --track-width: 2px;
4324
4338
  --track-color: rgb(128 128 128 / 25%);
@@ -4380,7 +4394,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
4380
4394
  <circle class="spinner__track"></circle>
4381
4395
  <circle class="spinner__indicator"></circle>
4382
4396
  </svg>
4383
- `}};gn.styles=[Q,g_];var __=Y`
4397
+ `}};gn.styles=[Q,__];var v_=Y`
4384
4398
  :host {
4385
4399
  display: inline-block;
4386
4400
  position: relative;
@@ -5000,7 +5014,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5000
5014
  ${this.caret?Ur` <sl-icon part="caret" class="button__caret" library="system" name="caret"></sl-icon> `:""}
5001
5015
  ${this.loading?Ur`<sl-spinner part="spinner"></sl-spinner>`:""}
5002
5016
  </${t}>
5003
- `}};ue.styles=[Q,__];ue.dependencies={"sl-icon":Ce,"sl-spinner":gn};g([Z(".button")],ue.prototype,"button",2);g([oe()],ue.prototype,"hasFocus",2);g([oe()],ue.prototype,"invalid",2);g([v()],ue.prototype,"title",2);g([v({reflect:!0})],ue.prototype,"variant",2);g([v({reflect:!0})],ue.prototype,"size",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"caret",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"loading",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"outline",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"pill",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"circle",2);g([v()],ue.prototype,"type",2);g([v()],ue.prototype,"name",2);g([v()],ue.prototype,"value",2);g([v()],ue.prototype,"href",2);g([v()],ue.prototype,"target",2);g([v()],ue.prototype,"rel",2);g([v()],ue.prototype,"download",2);g([v()],ue.prototype,"form",2);g([v({attribute:"formaction"})],ue.prototype,"formAction",2);g([v({attribute:"formenctype"})],ue.prototype,"formEnctype",2);g([v({attribute:"formmethod"})],ue.prototype,"formMethod",2);g([v({attribute:"formnovalidate",type:Boolean})],ue.prototype,"formNoValidate",2);g([v({attribute:"formtarget"})],ue.prototype,"formTarget",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ue.prototype,"handleDisabledChange",1);ue.define("sl-button");var v_=Y`
5017
+ `}};ue.styles=[Q,v_];ue.dependencies={"sl-icon":Ce,"sl-spinner":gn};g([Z(".button")],ue.prototype,"button",2);g([oe()],ue.prototype,"hasFocus",2);g([oe()],ue.prototype,"invalid",2);g([v()],ue.prototype,"title",2);g([v({reflect:!0})],ue.prototype,"variant",2);g([v({reflect:!0})],ue.prototype,"size",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"caret",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"loading",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"outline",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"pill",2);g([v({type:Boolean,reflect:!0})],ue.prototype,"circle",2);g([v()],ue.prototype,"type",2);g([v()],ue.prototype,"name",2);g([v()],ue.prototype,"value",2);g([v()],ue.prototype,"href",2);g([v()],ue.prototype,"target",2);g([v()],ue.prototype,"rel",2);g([v()],ue.prototype,"download",2);g([v()],ue.prototype,"form",2);g([v({attribute:"formaction"})],ue.prototype,"formAction",2);g([v({attribute:"formenctype"})],ue.prototype,"formEnctype",2);g([v({attribute:"formmethod"})],ue.prototype,"formMethod",2);g([v({attribute:"formnovalidate",type:Boolean})],ue.prototype,"formNoValidate",2);g([v({attribute:"formtarget"})],ue.prototype,"formTarget",2);g([G("disabled",{waitUntilFirstUpdate:!0})],ue.prototype,"handleDisabledChange",1);ue.define("sl-button");var b_=Y`
5004
5018
  :host {
5005
5019
  display: inline-flex;
5006
5020
  }
@@ -5097,7 +5111,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5097
5111
  >
5098
5112
  <slot></slot>
5099
5113
  </span>
5100
- `}};Jr.styles=[Q,v_];g([v({reflect:!0})],Jr.prototype,"variant",2);g([v({type:Boolean,reflect:!0})],Jr.prototype,"pill",2);g([v({type:Boolean,reflect:!0})],Jr.prototype,"pulse",2);Jr.define("sl-badge");var b_=Y`
5114
+ `}};Jr.styles=[Q,b_];g([v({reflect:!0})],Jr.prototype,"variant",2);g([v({type:Boolean,reflect:!0})],Jr.prototype,"pill",2);g([v({type:Boolean,reflect:!0})],Jr.prototype,"pulse",2);Jr.define("sl-badge");var y_=Y`
5101
5115
  :host {
5102
5116
  --color: var(--sl-panel-border-color);
5103
5117
  --width: var(--sl-panel-border-width);
@@ -5116,7 +5130,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5116
5130
  border-left: solid var(--width) var(--color);
5117
5131
  margin: 0 var(--spacing);
5118
5132
  }
5119
- `;var _n=class extends X{constructor(){super(...arguments),this.vertical=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","separator")}handleVerticalChange(){this.setAttribute("aria-orientation",this.vertical?"vertical":"horizontal")}};_n.styles=[Q,b_];g([v({type:Boolean,reflect:!0})],_n.prototype,"vertical",2);g([G("vertical")],_n.prototype,"handleVerticalChange",1);_n.define("sl-divider");var y_=Y`
5133
+ `;var _n=class extends X{constructor(){super(...arguments),this.vertical=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","separator")}handleVerticalChange(){this.setAttribute("aria-orientation",this.vertical?"vertical":"horizontal")}};_n.styles=[Q,y_];g([v({type:Boolean,reflect:!0})],_n.prototype,"vertical",2);g([G("vertical")],_n.prototype,"handleVerticalChange",1);_n.define("sl-divider");var w_=Y`
5120
5134
  :host {
5121
5135
  --max-width: 20rem;
5122
5136
  --hide-delay: 0ms;
@@ -5193,7 +5207,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5193
5207
  <slot name="content">${this.content}</slot>
5194
5208
  </div>
5195
5209
  </sl-popup>
5196
- `}};Ze.styles=[Q,y_];Ze.dependencies={"sl-popup":me};g([Z("slot:not([name])")],Ze.prototype,"defaultSlot",2);g([Z(".tooltip__body")],Ze.prototype,"body",2);g([Z("sl-popup")],Ze.prototype,"popup",2);g([v()],Ze.prototype,"content",2);g([v()],Ze.prototype,"placement",2);g([v({type:Boolean,reflect:!0})],Ze.prototype,"disabled",2);g([v({type:Number})],Ze.prototype,"distance",2);g([v({type:Boolean,reflect:!0})],Ze.prototype,"open",2);g([v({type:Number})],Ze.prototype,"skidding",2);g([v()],Ze.prototype,"trigger",2);g([v({type:Boolean})],Ze.prototype,"hoist",2);g([G("open",{waitUntilFirstUpdate:!0})],Ze.prototype,"handleOpenChange",1);g([G(["content","distance","hoist","placement","skidding"])],Ze.prototype,"handleOptionsChange",1);g([G("disabled")],Ze.prototype,"handleDisabledChange",1);Ge("tooltip.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:150,easing:"ease"}});Ge("tooltip.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:150,easing:"ease"}});Ze.define("sl-tooltip");function*ll(e=document.activeElement){e!=null&&(yield e,"shadowRoot"in e&&e.shadowRoot&&e.shadowRoot.mode!=="closed"&&(yield*ag(ll(e.shadowRoot.activeElement))))}function S_(){return[...ll()].pop()}var w_=new WeakMap;function C_(e){let t=w_.get(e);return t||(t=window.getComputedStyle(e,null),w_.set(e,t)),t}function cx(e){if(typeof e.checkVisibility=="function")return e.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0});let t=C_(e);return t.visibility!=="hidden"&&t.display!=="none"}function hx(e){let t=C_(e),{overflowY:s,overflowX:i}=t;return s==="scroll"||i==="scroll"?!0:s!=="auto"||i!=="auto"?!1:e.scrollHeight>e.clientHeight&&s==="auto"||e.scrollWidth>e.clientWidth&&i==="auto"}function dx(e){let t=e.tagName.toLowerCase(),s=Number(e.getAttribute("tabindex"));if(e.hasAttribute("tabindex")&&(isNaN(s)||s<=-1)||e.hasAttribute("disabled")||e.closest("[inert]"))return!1;if(t==="input"&&e.getAttribute("type")==="radio"){let o=e.getRootNode(),n=`input[type='radio'][name="${e.getAttribute("name")}"]`,a=o.querySelector(`${n}:checked`);return a?a===e:o.querySelector(n)===e}return cx(e)?(t==="audio"||t==="video")&&e.hasAttribute("controls")||e.hasAttribute("tabindex")||e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"||["button","input","select","textarea","a","audio","video","summary","iframe"].includes(t)?!0:hx(e):!1}function ux(e,t){var s;return((s=e.getRootNode({composed:!0}))==null?void 0:s.host)!==t}function vd(e){let t=new WeakMap,s=[];function i(r){if(r instanceof Element){if(r.hasAttribute("inert")||r.closest("[inert]")||t.has(r))return;t.set(r,!0),!s.includes(r)&&dx(r)&&s.push(r),r instanceof HTMLSlotElement&&ux(r,e)&&r.assignedElements({flatten:!0}).forEach(o=>{i(o)}),r.shadowRoot!==null&&r.shadowRoot.mode==="open"&&i(r.shadowRoot)}for(let o of r.children)i(o)}return i(e),s.sort((r,o)=>{let n=Number(r.getAttribute("tabindex"))||0;return(Number(o.getAttribute("tabindex"))||0)-n})}var vn=[],x_=class{constructor(e){this.tabDirection="forward",this.handleFocusIn=()=>{this.isActive()&&this.checkFocus()},this.handleKeyDown=t=>{var s;if(t.key!=="Tab"||this.isExternalActivated||!this.isActive())return;let i=S_();if(this.previousFocus=i,this.previousFocus&&this.possiblyHasTabbableChildren(this.previousFocus))return;t.shiftKey?this.tabDirection="backward":this.tabDirection="forward";let r=vd(this.element),o=r.findIndex(a=>a===i);this.previousFocus=this.currentFocus;let n=this.tabDirection==="forward"?1:-1;for(;;){o+n>=r.length?o=0:o+n<0?o=r.length-1:o+=n,this.previousFocus=this.currentFocus;let a=r[o];if(this.tabDirection==="backward"&&this.previousFocus&&this.possiblyHasTabbableChildren(this.previousFocus)||a&&this.possiblyHasTabbableChildren(a))return;t.preventDefault(),this.currentFocus=a,(s=this.currentFocus)==null||s.focus({preventScroll:!1});let c=[...ll()];if(c.includes(this.currentFocus)||!c.includes(this.previousFocus))break}setTimeout(()=>this.checkFocus())},this.handleKeyUp=()=>{this.tabDirection="forward"},this.element=e,this.elementsWithTabbableControls=["iframe"]}activate(){vn.push(this.element),document.addEventListener("focusin",this.handleFocusIn),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}deactivate(){vn=vn.filter(e=>e!==this.element),this.currentFocus=null,document.removeEventListener("focusin",this.handleFocusIn),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}isActive(){return vn[vn.length-1]===this.element}activateExternal(){this.isExternalActivated=!0}deactivateExternal(){this.isExternalActivated=!1}checkFocus(){if(this.isActive()&&!this.isExternalActivated){let e=vd(this.element);if(!this.element.matches(":focus-within")){let t=e[0],s=e[e.length-1],i=this.tabDirection==="forward"?t:s;typeof i?.focus=="function"&&(this.currentFocus=i,i.focus({preventScroll:!1}))}}}possiblyHasTabbableChildren(e){return this.elementsWithTabbableControls.includes(e.tagName.toLowerCase())||e.hasAttribute("controls")}};var k_=Y`
5210
+ `}};Ze.styles=[Q,w_];Ze.dependencies={"sl-popup":me};g([Z("slot:not([name])")],Ze.prototype,"defaultSlot",2);g([Z(".tooltip__body")],Ze.prototype,"body",2);g([Z("sl-popup")],Ze.prototype,"popup",2);g([v()],Ze.prototype,"content",2);g([v()],Ze.prototype,"placement",2);g([v({type:Boolean,reflect:!0})],Ze.prototype,"disabled",2);g([v({type:Number})],Ze.prototype,"distance",2);g([v({type:Boolean,reflect:!0})],Ze.prototype,"open",2);g([v({type:Number})],Ze.prototype,"skidding",2);g([v()],Ze.prototype,"trigger",2);g([v({type:Boolean})],Ze.prototype,"hoist",2);g([G("open",{waitUntilFirstUpdate:!0})],Ze.prototype,"handleOpenChange",1);g([G(["content","distance","hoist","placement","skidding"])],Ze.prototype,"handleOptionsChange",1);g([G("disabled")],Ze.prototype,"handleDisabledChange",1);Ge("tooltip.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:150,easing:"ease"}});Ge("tooltip.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:150,easing:"ease"}});Ze.define("sl-tooltip");function*ll(e=document.activeElement){e!=null&&(yield e,"shadowRoot"in e&&e.shadowRoot&&e.shadowRoot.mode!=="closed"&&(yield*lg(ll(e.shadowRoot.activeElement))))}function C_(){return[...ll()].pop()}var S_=new WeakMap;function x_(e){let t=S_.get(e);return t||(t=window.getComputedStyle(e,null),S_.set(e,t)),t}function dx(e){if(typeof e.checkVisibility=="function")return e.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0});let t=x_(e);return t.visibility!=="hidden"&&t.display!=="none"}function ux(e){let t=x_(e),{overflowY:s,overflowX:i}=t;return s==="scroll"||i==="scroll"?!0:s!=="auto"||i!=="auto"?!1:e.scrollHeight>e.clientHeight&&s==="auto"||e.scrollWidth>e.clientWidth&&i==="auto"}function px(e){let t=e.tagName.toLowerCase(),s=Number(e.getAttribute("tabindex"));if(e.hasAttribute("tabindex")&&(isNaN(s)||s<=-1)||e.hasAttribute("disabled")||e.closest("[inert]"))return!1;if(t==="input"&&e.getAttribute("type")==="radio"){let o=e.getRootNode(),n=`input[type='radio'][name="${e.getAttribute("name")}"]`,a=o.querySelector(`${n}:checked`);return a?a===e:o.querySelector(n)===e}return dx(e)?(t==="audio"||t==="video")&&e.hasAttribute("controls")||e.hasAttribute("tabindex")||e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")!=="false"||["button","input","select","textarea","a","audio","video","summary","iframe"].includes(t)?!0:ux(e):!1}function fx(e,t){var s;return((s=e.getRootNode({composed:!0}))==null?void 0:s.host)!==t}function vd(e){let t=new WeakMap,s=[];function i(r){if(r instanceof Element){if(r.hasAttribute("inert")||r.closest("[inert]")||t.has(r))return;t.set(r,!0),!s.includes(r)&&px(r)&&s.push(r),r instanceof HTMLSlotElement&&fx(r,e)&&r.assignedElements({flatten:!0}).forEach(o=>{i(o)}),r.shadowRoot!==null&&r.shadowRoot.mode==="open"&&i(r.shadowRoot)}for(let o of r.children)i(o)}return i(e),s.sort((r,o)=>{let n=Number(r.getAttribute("tabindex"))||0;return(Number(o.getAttribute("tabindex"))||0)-n})}var vn=[],k_=class{constructor(e){this.tabDirection="forward",this.handleFocusIn=()=>{this.isActive()&&this.checkFocus()},this.handleKeyDown=t=>{var s;if(t.key!=="Tab"||this.isExternalActivated||!this.isActive())return;let i=C_();if(this.previousFocus=i,this.previousFocus&&this.possiblyHasTabbableChildren(this.previousFocus))return;t.shiftKey?this.tabDirection="backward":this.tabDirection="forward";let r=vd(this.element),o=r.findIndex(a=>a===i);this.previousFocus=this.currentFocus;let n=this.tabDirection==="forward"?1:-1;for(;;){o+n>=r.length?o=0:o+n<0?o=r.length-1:o+=n,this.previousFocus=this.currentFocus;let a=r[o];if(this.tabDirection==="backward"&&this.previousFocus&&this.possiblyHasTabbableChildren(this.previousFocus)||a&&this.possiblyHasTabbableChildren(a))return;t.preventDefault(),this.currentFocus=a,(s=this.currentFocus)==null||s.focus({preventScroll:!1});let c=[...ll()];if(c.includes(this.currentFocus)||!c.includes(this.previousFocus))break}setTimeout(()=>this.checkFocus())},this.handleKeyUp=()=>{this.tabDirection="forward"},this.element=e,this.elementsWithTabbableControls=["iframe"]}activate(){vn.push(this.element),document.addEventListener("focusin",this.handleFocusIn),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}deactivate(){vn=vn.filter(e=>e!==this.element),this.currentFocus=null,document.removeEventListener("focusin",this.handleFocusIn),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)}isActive(){return vn[vn.length-1]===this.element}activateExternal(){this.isExternalActivated=!0}deactivateExternal(){this.isExternalActivated=!1}checkFocus(){if(this.isActive()&&!this.isExternalActivated){let e=vd(this.element);if(!this.element.matches(":focus-within")){let t=e[0],s=e[e.length-1],i=this.tabDirection==="forward"?t:s;typeof i?.focus=="function"&&(this.currentFocus=i,i.focus({preventScroll:!1}))}}}possiblyHasTabbableChildren(e){return this.elementsWithTabbableControls.includes(e.tagName.toLowerCase())||e.hasAttribute("controls")}};var $_=Y`
5197
5211
  :host {
5198
5212
  --width: 31rem;
5199
5213
  --header-spacing: var(--sl-spacing-large);
@@ -5310,7 +5324,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5310
5324
  border: solid 1px var(--sl-color-neutral-0);
5311
5325
  }
5312
5326
  }
5313
- `;var cl=e=>{var t;let{activeElement:s}=document;s&&e.contains(s)&&((t=document.activeElement)==null||t.blur())};var ls=class extends X{constructor(){super(...arguments),this.hasSlotController=new Je(this,"footer"),this.localize=new be(this),this.modal=new x_(this),this.open=!1,this.label="",this.noHeader=!1,this.handleDocumentKeyDown=e=>{e.key==="Escape"&&this.modal.isActive()&&this.open&&(e.stopPropagation(),this.requestClose("keyboard"))}}firstUpdated(){this.dialog.hidden=!this.open,this.open&&(this.addOpenListeners(),this.modal.activate(),ld(this))}disconnectedCallback(){super.disconnectedCallback(),this.modal.deactivate(),cd(this),this.removeOpenListeners()}requestClose(e){if(this.emit("sl-request-close",{cancelable:!0,detail:{source:e}}).defaultPrevented){let s=Ye(this,"dialog.denyClose",{dir:this.localize.dir()});Xe(this.panel,s.keyframes,s.options);return}this.hide()}addOpenListeners(){var e;"CloseWatcher"in window?((e=this.closeWatcher)==null||e.destroy(),this.closeWatcher=new CloseWatcher,this.closeWatcher.onclose=()=>this.requestClose("keyboard")):document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){var e;(e=this.closeWatcher)==null||e.destroy(),document.removeEventListener("keydown",this.handleDocumentKeyDown)}async handleOpenChange(){if(this.open){this.emit("sl-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.modal.activate(),ld(this);let e=this.querySelector("[autofocus]");e&&e.removeAttribute("autofocus"),await Promise.all([at(this.dialog),at(this.overlay)]),this.dialog.hidden=!1,requestAnimationFrame(()=>{this.emit("sl-initial-focus",{cancelable:!0}).defaultPrevented||(e?e.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),e&&e.setAttribute("autofocus","")});let t=Ye(this,"dialog.show",{dir:this.localize.dir()}),s=Ye(this,"dialog.overlay.show",{dir:this.localize.dir()});await Promise.all([Xe(this.panel,t.keyframes,t.options),Xe(this.overlay,s.keyframes,s.options)]),this.emit("sl-after-show")}else{cl(this),this.emit("sl-hide"),this.removeOpenListeners(),this.modal.deactivate(),await Promise.all([at(this.dialog),at(this.overlay)]);let e=Ye(this,"dialog.hide",{dir:this.localize.dir()}),t=Ye(this,"dialog.overlay.hide",{dir:this.localize.dir()});await Promise.all([Xe(this.overlay,t.keyframes,t.options).then(()=>{this.overlay.hidden=!0}),Xe(this.panel,e.keyframes,e.options).then(()=>{this.panel.hidden=!0})]),this.dialog.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1,cd(this);let s=this.originalTrigger;typeof s?.focus=="function"&&setTimeout(()=>s.focus()),this.emit("sl-after-hide")}}async show(){if(!this.open)return this.open=!0,vt(this,"sl-after-show")}async hide(){if(this.open)return this.open=!1,vt(this,"sl-after-hide")}render(){return u`
5327
+ `;var cl=e=>{var t;let{activeElement:s}=document;s&&e.contains(s)&&((t=document.activeElement)==null||t.blur())};var ls=class extends X{constructor(){super(...arguments),this.hasSlotController=new Je(this,"footer"),this.localize=new be(this),this.modal=new k_(this),this.open=!1,this.label="",this.noHeader=!1,this.handleDocumentKeyDown=e=>{e.key==="Escape"&&this.modal.isActive()&&this.open&&(e.stopPropagation(),this.requestClose("keyboard"))}}firstUpdated(){this.dialog.hidden=!this.open,this.open&&(this.addOpenListeners(),this.modal.activate(),ld(this))}disconnectedCallback(){super.disconnectedCallback(),this.modal.deactivate(),cd(this),this.removeOpenListeners()}requestClose(e){if(this.emit("sl-request-close",{cancelable:!0,detail:{source:e}}).defaultPrevented){let s=Ye(this,"dialog.denyClose",{dir:this.localize.dir()});Xe(this.panel,s.keyframes,s.options);return}this.hide()}addOpenListeners(){var e;"CloseWatcher"in window?((e=this.closeWatcher)==null||e.destroy(),this.closeWatcher=new CloseWatcher,this.closeWatcher.onclose=()=>this.requestClose("keyboard")):document.addEventListener("keydown",this.handleDocumentKeyDown)}removeOpenListeners(){var e;(e=this.closeWatcher)==null||e.destroy(),document.removeEventListener("keydown",this.handleDocumentKeyDown)}async handleOpenChange(){if(this.open){this.emit("sl-show"),this.addOpenListeners(),this.originalTrigger=document.activeElement,this.modal.activate(),ld(this);let e=this.querySelector("[autofocus]");e&&e.removeAttribute("autofocus"),await Promise.all([at(this.dialog),at(this.overlay)]),this.dialog.hidden=!1,requestAnimationFrame(()=>{this.emit("sl-initial-focus",{cancelable:!0}).defaultPrevented||(e?e.focus({preventScroll:!0}):this.panel.focus({preventScroll:!0})),e&&e.setAttribute("autofocus","")});let t=Ye(this,"dialog.show",{dir:this.localize.dir()}),s=Ye(this,"dialog.overlay.show",{dir:this.localize.dir()});await Promise.all([Xe(this.panel,t.keyframes,t.options),Xe(this.overlay,s.keyframes,s.options)]),this.emit("sl-after-show")}else{cl(this),this.emit("sl-hide"),this.removeOpenListeners(),this.modal.deactivate(),await Promise.all([at(this.dialog),at(this.overlay)]);let e=Ye(this,"dialog.hide",{dir:this.localize.dir()}),t=Ye(this,"dialog.overlay.hide",{dir:this.localize.dir()});await Promise.all([Xe(this.overlay,t.keyframes,t.options).then(()=>{this.overlay.hidden=!0}),Xe(this.panel,e.keyframes,e.options).then(()=>{this.panel.hidden=!0})]),this.dialog.hidden=!0,this.overlay.hidden=!1,this.panel.hidden=!1,cd(this);let s=this.originalTrigger;typeof s?.focus=="function"&&setTimeout(()=>s.focus()),this.emit("sl-after-hide")}}async show(){if(!this.open)return this.open=!0,vt(this,"sl-after-show")}async hide(){if(this.open)return this.open=!1,vt(this,"sl-after-hide")}render(){return u`
5314
5328
  <div
5315
5329
  part="base"
5316
5330
  class=${ee({dialog:!0,"dialog--open":this.open,"dialog--has-footer":this.hasSlotController.test("footer")})}
@@ -5354,7 +5368,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5354
5368
  </footer>
5355
5369
  </div>
5356
5370
  </div>
5357
- `}};ls.styles=[Q,k_];ls.dependencies={"sl-icon-button":Te};g([Z(".dialog")],ls.prototype,"dialog",2);g([Z(".dialog__panel")],ls.prototype,"panel",2);g([Z(".dialog__overlay")],ls.prototype,"overlay",2);g([v({type:Boolean,reflect:!0})],ls.prototype,"open",2);g([v({reflect:!0})],ls.prototype,"label",2);g([v({attribute:"no-header",type:Boolean,reflect:!0})],ls.prototype,"noHeader",2);g([G("open",{waitUntilFirstUpdate:!0})],ls.prototype,"handleOpenChange",1);Ge("dialog.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}});Ge("dialog.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});Ge("dialog.denyClose",{keyframes:[{scale:1},{scale:1.02},{scale:1}],options:{duration:250}});Ge("dialog.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}});Ge("dialog.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});ls.define("sl-dialog");var $_=Y`
5371
+ `}};ls.styles=[Q,$_];ls.dependencies={"sl-icon-button":Te};g([Z(".dialog")],ls.prototype,"dialog",2);g([Z(".dialog__panel")],ls.prototype,"panel",2);g([Z(".dialog__overlay")],ls.prototype,"overlay",2);g([v({type:Boolean,reflect:!0})],ls.prototype,"open",2);g([v({reflect:!0})],ls.prototype,"label",2);g([v({attribute:"no-header",type:Boolean,reflect:!0})],ls.prototype,"noHeader",2);g([G("open",{waitUntilFirstUpdate:!0})],ls.prototype,"handleOpenChange",1);Ge("dialog.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}});Ge("dialog.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});Ge("dialog.denyClose",{keyframes:[{scale:1},{scale:1.02},{scale:1}],options:{duration:250}});Ge("dialog.overlay.show",{keyframes:[{opacity:0},{opacity:1}],options:{duration:250}});Ge("dialog.overlay.hide",{keyframes:[{opacity:1},{opacity:0}],options:{duration:250}});ls.define("sl-dialog");var E_=Y`
5358
5372
  :host {
5359
5373
  --indicator-color: var(--sl-color-primary-600);
5360
5374
  --track-color: var(--sl-color-neutral-200);
@@ -5588,11 +5602,11 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5588
5602
  .tab-group--end ::slotted(sl-tab-panel) {
5589
5603
  --padding: 0 var(--sl-spacing-medium);
5590
5604
  }
5591
- `;var E_=Y`
5605
+ `;var T_=Y`
5592
5606
  :host {
5593
5607
  display: contents;
5594
5608
  }
5595
- `;var bn=class extends X{constructor(){super(...arguments),this.observedElements=[],this.disabled=!1}connectedCallback(){super.connectedCallback(),this.resizeObserver=new ResizeObserver(e=>{this.emit("sl-resize",{detail:{entries:e}})}),this.disabled||this.startObserver()}disconnectedCallback(){super.disconnectedCallback(),this.stopObserver()}handleSlotChange(){this.disabled||this.startObserver()}startObserver(){let e=this.shadowRoot.querySelector("slot");if(e!==null){let t=e.assignedElements({flatten:!0});this.observedElements.forEach(s=>this.resizeObserver.unobserve(s)),this.observedElements=[],t.forEach(s=>{this.resizeObserver.observe(s),this.observedElements.push(s)})}}stopObserver(){this.resizeObserver.disconnect()}handleDisabledChange(){this.disabled?this.stopObserver():this.startObserver()}render(){return u` <slot @slotchange=${this.handleSlotChange}></slot> `}};bn.styles=[Q,E_];g([v({type:Boolean,reflect:!0})],bn.prototype,"disabled",2);g([G("disabled",{waitUntilFirstUpdate:!0})],bn.prototype,"handleDisabledChange",1);var Qe=class extends X{constructor(){super(...arguments),this.tabs=[],this.focusableTabs=[],this.panels=[],this.localize=new be(this),this.hasScrollControls=!1,this.shouldHideScrollStartButton=!1,this.shouldHideScrollEndButton=!1,this.placement="top",this.activation="auto",this.noScrollControls=!1,this.fixedScrollControls=!1,this.scrollOffset=1}connectedCallback(){let e=Promise.all([customElements.whenDefined("sl-tab"),customElements.whenDefined("sl-tab-panel")]);super.connectedCallback(),this.resizeObserver=new ResizeObserver(()=>{this.repositionIndicator(),this.updateScrollControls()}),this.mutationObserver=new MutationObserver(t=>{let s=t.filter(({target:i})=>{if(i===this)return!0;if(i.closest("sl-tab-group")!==this)return!1;let r=i.tagName.toLowerCase();return r==="sl-tab"||r==="sl-tab-panel"});if(s.length!==0){if(s.some(i=>!["aria-labelledby","aria-controls"].includes(i.attributeName))&&setTimeout(()=>this.setAriaLabels()),s.some(i=>i.attributeName==="disabled"))this.syncTabsAndPanels();else if(s.some(i=>i.attributeName==="active")){let r=s.filter(o=>o.attributeName==="active"&&o.target.tagName.toLowerCase()==="sl-tab").map(o=>o.target).find(o=>o.active);r&&this.setActiveTab(r)}}}),this.updateComplete.then(()=>{this.syncTabsAndPanels(),this.mutationObserver.observe(this,{attributes:!0,attributeFilter:["active","disabled","name","panel"],childList:!0,subtree:!0}),this.resizeObserver.observe(this.nav),e.then(()=>{new IntersectionObserver((s,i)=>{var r;s[0].intersectionRatio>0&&(this.setAriaLabels(),this.setActiveTab((r=this.getActiveTab())!=null?r:this.tabs[0],{emitEvents:!1}),i.unobserve(s[0].target))}).observe(this.tabGroup)})})}disconnectedCallback(){var e,t;super.disconnectedCallback(),(e=this.mutationObserver)==null||e.disconnect(),this.nav&&((t=this.resizeObserver)==null||t.unobserve(this.nav))}getAllTabs(){return this.shadowRoot.querySelector('slot[name="nav"]').assignedElements()}getAllPanels(){return[...this.body.assignedElements()].filter(e=>e.tagName.toLowerCase()==="sl-tab-panel")}getActiveTab(){return this.tabs.find(e=>e.active)}handleClick(e){let s=e.target.closest("sl-tab");s?.closest("sl-tab-group")===this&&s!==null&&this.setActiveTab(s,{scrollBehavior:"smooth"})}handleKeyDown(e){let s=e.target.closest("sl-tab");if(s?.closest("sl-tab-group")===this&&(["Enter"," "].includes(e.key)&&s!==null&&(this.setActiveTab(s,{scrollBehavior:"smooth"}),e.preventDefault()),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key))){let r=this.tabs.find(a=>a.matches(":focus")),o=this.localize.dir()==="rtl",n=null;if(r?.tagName.toLowerCase()==="sl-tab"){if(e.key==="Home")n=this.focusableTabs[0];else if(e.key==="End")n=this.focusableTabs[this.focusableTabs.length-1];else if(["top","bottom"].includes(this.placement)&&e.key===(o?"ArrowRight":"ArrowLeft")||["start","end"].includes(this.placement)&&e.key==="ArrowUp"){let a=this.tabs.findIndex(c=>c===r);n=this.findNextFocusableTab(a,"backward")}else if(["top","bottom"].includes(this.placement)&&e.key===(o?"ArrowLeft":"ArrowRight")||["start","end"].includes(this.placement)&&e.key==="ArrowDown"){let a=this.tabs.findIndex(c=>c===r);n=this.findNextFocusableTab(a,"forward")}if(!n)return;n.tabIndex=0,n.focus({preventScroll:!0}),this.activation==="auto"?this.setActiveTab(n,{scrollBehavior:"smooth"}):this.tabs.forEach(a=>{a.tabIndex=a===n?0:-1}),["top","bottom"].includes(this.placement)&&nn(n,this.nav,"horizontal"),e.preventDefault()}}}handleScrollToStart(){this.nav.scroll({left:this.localize.dir()==="rtl"?this.nav.scrollLeft+this.nav.clientWidth:this.nav.scrollLeft-this.nav.clientWidth,behavior:"smooth"})}handleScrollToEnd(){this.nav.scroll({left:this.localize.dir()==="rtl"?this.nav.scrollLeft-this.nav.clientWidth:this.nav.scrollLeft+this.nav.clientWidth,behavior:"smooth"})}setActiveTab(e,t){if(t=ut({emitEvents:!0,scrollBehavior:"auto"},t),e!==this.activeTab&&!e.disabled){let s=this.activeTab;this.activeTab=e,this.tabs.forEach(i=>{i.active=i===this.activeTab,i.tabIndex=i===this.activeTab?0:-1}),this.panels.forEach(i=>{var r;return i.active=i.name===((r=this.activeTab)==null?void 0:r.panel)}),this.syncIndicator(),["top","bottom"].includes(this.placement)&&nn(this.activeTab,this.nav,"horizontal",t.scrollBehavior),t.emitEvents&&(s&&this.emit("sl-tab-hide",{detail:{name:s.panel}}),this.emit("sl-tab-show",{detail:{name:this.activeTab.panel}}))}}setAriaLabels(){this.tabs.forEach(e=>{let t=this.panels.find(s=>s.name===e.panel);t&&(e.setAttribute("aria-controls",t.getAttribute("id")),t.setAttribute("aria-labelledby",e.getAttribute("id")))})}repositionIndicator(){let e=this.getActiveTab();if(!e)return;let t=e.clientWidth,s=e.clientHeight,i=this.localize.dir()==="rtl",r=this.getAllTabs(),n=r.slice(0,r.indexOf(e)).reduce((a,c)=>({left:a.left+c.clientWidth,top:a.top+c.clientHeight}),{left:0,top:0});switch(this.placement){case"top":case"bottom":this.indicator.style.width=`${t}px`,this.indicator.style.height="auto",this.indicator.style.translate=i?`${-1*n.left}px`:`${n.left}px`;break;case"start":case"end":this.indicator.style.width="auto",this.indicator.style.height=`${s}px`,this.indicator.style.translate=`0 ${n.top}px`;break}}syncTabsAndPanels(){this.tabs=this.getAllTabs(),this.focusableTabs=this.tabs.filter(e=>!e.disabled),this.panels=this.getAllPanels(),this.syncIndicator(),this.updateComplete.then(()=>this.updateScrollControls())}findNextFocusableTab(e,t){let s=null,i=t==="forward"?1:-1,r=e+i;for(;e<this.tabs.length;){if(s=this.tabs[r]||null,s===null){t==="forward"?s=this.focusableTabs[0]:s=this.focusableTabs[this.focusableTabs.length-1];break}if(!s.disabled)break;r+=i}return s}updateScrollButtons(){this.hasScrollControls&&!this.fixedScrollControls&&(this.shouldHideScrollStartButton=this.scrollFromStart()<=this.scrollOffset,this.shouldHideScrollEndButton=this.isScrolledToEnd())}isScrolledToEnd(){return this.scrollFromStart()+this.nav.clientWidth>=this.nav.scrollWidth-this.scrollOffset}scrollFromStart(){return this.localize.dir()==="rtl"?-this.nav.scrollLeft:this.nav.scrollLeft}updateScrollControls(){this.noScrollControls?this.hasScrollControls=!1:this.hasScrollControls=["top","bottom"].includes(this.placement)&&this.nav.scrollWidth>this.nav.clientWidth+1,this.updateScrollButtons()}syncIndicator(){this.getActiveTab()?(this.indicator.style.display="block",this.repositionIndicator()):this.indicator.style.display="none"}show(e){let t=this.tabs.find(s=>s.panel===e);t&&this.setActiveTab(t,{scrollBehavior:"smooth"})}render(){let e=this.localize.dir()==="rtl";return u`
5609
+ `;var bn=class extends X{constructor(){super(...arguments),this.observedElements=[],this.disabled=!1}connectedCallback(){super.connectedCallback(),this.resizeObserver=new ResizeObserver(e=>{this.emit("sl-resize",{detail:{entries:e}})}),this.disabled||this.startObserver()}disconnectedCallback(){super.disconnectedCallback(),this.stopObserver()}handleSlotChange(){this.disabled||this.startObserver()}startObserver(){let e=this.shadowRoot.querySelector("slot");if(e!==null){let t=e.assignedElements({flatten:!0});this.observedElements.forEach(s=>this.resizeObserver.unobserve(s)),this.observedElements=[],t.forEach(s=>{this.resizeObserver.observe(s),this.observedElements.push(s)})}}stopObserver(){this.resizeObserver.disconnect()}handleDisabledChange(){this.disabled?this.stopObserver():this.startObserver()}render(){return u` <slot @slotchange=${this.handleSlotChange}></slot> `}};bn.styles=[Q,T_];g([v({type:Boolean,reflect:!0})],bn.prototype,"disabled",2);g([G("disabled",{waitUntilFirstUpdate:!0})],bn.prototype,"handleDisabledChange",1);var Qe=class extends X{constructor(){super(...arguments),this.tabs=[],this.focusableTabs=[],this.panels=[],this.localize=new be(this),this.hasScrollControls=!1,this.shouldHideScrollStartButton=!1,this.shouldHideScrollEndButton=!1,this.placement="top",this.activation="auto",this.noScrollControls=!1,this.fixedScrollControls=!1,this.scrollOffset=1}connectedCallback(){let e=Promise.all([customElements.whenDefined("sl-tab"),customElements.whenDefined("sl-tab-panel")]);super.connectedCallback(),this.resizeObserver=new ResizeObserver(()=>{this.repositionIndicator(),this.updateScrollControls()}),this.mutationObserver=new MutationObserver(t=>{let s=t.filter(({target:i})=>{if(i===this)return!0;if(i.closest("sl-tab-group")!==this)return!1;let r=i.tagName.toLowerCase();return r==="sl-tab"||r==="sl-tab-panel"});if(s.length!==0){if(s.some(i=>!["aria-labelledby","aria-controls"].includes(i.attributeName))&&setTimeout(()=>this.setAriaLabels()),s.some(i=>i.attributeName==="disabled"))this.syncTabsAndPanels();else if(s.some(i=>i.attributeName==="active")){let r=s.filter(o=>o.attributeName==="active"&&o.target.tagName.toLowerCase()==="sl-tab").map(o=>o.target).find(o=>o.active);r&&this.setActiveTab(r)}}}),this.updateComplete.then(()=>{this.syncTabsAndPanels(),this.mutationObserver.observe(this,{attributes:!0,attributeFilter:["active","disabled","name","panel"],childList:!0,subtree:!0}),this.resizeObserver.observe(this.nav),e.then(()=>{new IntersectionObserver((s,i)=>{var r;s[0].intersectionRatio>0&&(this.setAriaLabels(),this.setActiveTab((r=this.getActiveTab())!=null?r:this.tabs[0],{emitEvents:!1}),i.unobserve(s[0].target))}).observe(this.tabGroup)})})}disconnectedCallback(){var e,t;super.disconnectedCallback(),(e=this.mutationObserver)==null||e.disconnect(),this.nav&&((t=this.resizeObserver)==null||t.unobserve(this.nav))}getAllTabs(){return this.shadowRoot.querySelector('slot[name="nav"]').assignedElements()}getAllPanels(){return[...this.body.assignedElements()].filter(e=>e.tagName.toLowerCase()==="sl-tab-panel")}getActiveTab(){return this.tabs.find(e=>e.active)}handleClick(e){let s=e.target.closest("sl-tab");s?.closest("sl-tab-group")===this&&s!==null&&this.setActiveTab(s,{scrollBehavior:"smooth"})}handleKeyDown(e){let s=e.target.closest("sl-tab");if(s?.closest("sl-tab-group")===this&&(["Enter"," "].includes(e.key)&&s!==null&&(this.setActiveTab(s,{scrollBehavior:"smooth"}),e.preventDefault()),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key))){let r=this.tabs.find(a=>a.matches(":focus")),o=this.localize.dir()==="rtl",n=null;if(r?.tagName.toLowerCase()==="sl-tab"){if(e.key==="Home")n=this.focusableTabs[0];else if(e.key==="End")n=this.focusableTabs[this.focusableTabs.length-1];else if(["top","bottom"].includes(this.placement)&&e.key===(o?"ArrowRight":"ArrowLeft")||["start","end"].includes(this.placement)&&e.key==="ArrowUp"){let a=this.tabs.findIndex(c=>c===r);n=this.findNextFocusableTab(a,"backward")}else if(["top","bottom"].includes(this.placement)&&e.key===(o?"ArrowLeft":"ArrowRight")||["start","end"].includes(this.placement)&&e.key==="ArrowDown"){let a=this.tabs.findIndex(c=>c===r);n=this.findNextFocusableTab(a,"forward")}if(!n)return;n.tabIndex=0,n.focus({preventScroll:!0}),this.activation==="auto"?this.setActiveTab(n,{scrollBehavior:"smooth"}):this.tabs.forEach(a=>{a.tabIndex=a===n?0:-1}),["top","bottom"].includes(this.placement)&&nn(n,this.nav,"horizontal"),e.preventDefault()}}}handleScrollToStart(){this.nav.scroll({left:this.localize.dir()==="rtl"?this.nav.scrollLeft+this.nav.clientWidth:this.nav.scrollLeft-this.nav.clientWidth,behavior:"smooth"})}handleScrollToEnd(){this.nav.scroll({left:this.localize.dir()==="rtl"?this.nav.scrollLeft-this.nav.clientWidth:this.nav.scrollLeft+this.nav.clientWidth,behavior:"smooth"})}setActiveTab(e,t){if(t=ut({emitEvents:!0,scrollBehavior:"auto"},t),e!==this.activeTab&&!e.disabled){let s=this.activeTab;this.activeTab=e,this.tabs.forEach(i=>{i.active=i===this.activeTab,i.tabIndex=i===this.activeTab?0:-1}),this.panels.forEach(i=>{var r;return i.active=i.name===((r=this.activeTab)==null?void 0:r.panel)}),this.syncIndicator(),["top","bottom"].includes(this.placement)&&nn(this.activeTab,this.nav,"horizontal",t.scrollBehavior),t.emitEvents&&(s&&this.emit("sl-tab-hide",{detail:{name:s.panel}}),this.emit("sl-tab-show",{detail:{name:this.activeTab.panel}}))}}setAriaLabels(){this.tabs.forEach(e=>{let t=this.panels.find(s=>s.name===e.panel);t&&(e.setAttribute("aria-controls",t.getAttribute("id")),t.setAttribute("aria-labelledby",e.getAttribute("id")))})}repositionIndicator(){let e=this.getActiveTab();if(!e)return;let t=e.clientWidth,s=e.clientHeight,i=this.localize.dir()==="rtl",r=this.getAllTabs(),n=r.slice(0,r.indexOf(e)).reduce((a,c)=>({left:a.left+c.clientWidth,top:a.top+c.clientHeight}),{left:0,top:0});switch(this.placement){case"top":case"bottom":this.indicator.style.width=`${t}px`,this.indicator.style.height="auto",this.indicator.style.translate=i?`${-1*n.left}px`:`${n.left}px`;break;case"start":case"end":this.indicator.style.width="auto",this.indicator.style.height=`${s}px`,this.indicator.style.translate=`0 ${n.top}px`;break}}syncTabsAndPanels(){this.tabs=this.getAllTabs(),this.focusableTabs=this.tabs.filter(e=>!e.disabled),this.panels=this.getAllPanels(),this.syncIndicator(),this.updateComplete.then(()=>this.updateScrollControls())}findNextFocusableTab(e,t){let s=null,i=t==="forward"?1:-1,r=e+i;for(;e<this.tabs.length;){if(s=this.tabs[r]||null,s===null){t==="forward"?s=this.focusableTabs[0]:s=this.focusableTabs[this.focusableTabs.length-1];break}if(!s.disabled)break;r+=i}return s}updateScrollButtons(){this.hasScrollControls&&!this.fixedScrollControls&&(this.shouldHideScrollStartButton=this.scrollFromStart()<=this.scrollOffset,this.shouldHideScrollEndButton=this.isScrolledToEnd())}isScrolledToEnd(){return this.scrollFromStart()+this.nav.clientWidth>=this.nav.scrollWidth-this.scrollOffset}scrollFromStart(){return this.localize.dir()==="rtl"?-this.nav.scrollLeft:this.nav.scrollLeft}updateScrollControls(){this.noScrollControls?this.hasScrollControls=!1:this.hasScrollControls=["top","bottom"].includes(this.placement)&&this.nav.scrollWidth>this.nav.clientWidth+1,this.updateScrollButtons()}syncIndicator(){this.getActiveTab()?(this.indicator.style.display="block",this.repositionIndicator()):this.indicator.style.display="none"}show(e){let t=this.tabs.find(s=>s.panel===e);t&&this.setActiveTab(t,{scrollBehavior:"smooth"})}render(){let e=this.localize.dir()==="rtl";return u`
5596
5610
  <div
5597
5611
  part="base"
5598
5612
  class=${ee({"tab-group":!0,"tab-group--top":this.placement==="top","tab-group--bottom":this.placement==="bottom","tab-group--start":this.placement==="start","tab-group--end":this.placement==="end","tab-group--rtl":this.localize.dir()==="rtl","tab-group--has-scroll-controls":this.hasScrollControls})}
@@ -5640,7 +5654,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5640
5654
 
5641
5655
  <slot part="body" class="tab-group__body" @slotchange=${this.syncTabsAndPanels}></slot>
5642
5656
  </div>
5643
- `}};Qe.styles=[Q,$_];Qe.dependencies={"sl-icon-button":Te,"sl-resize-observer":bn};g([Z(".tab-group")],Qe.prototype,"tabGroup",2);g([Z(".tab-group__body")],Qe.prototype,"body",2);g([Z(".tab-group__nav")],Qe.prototype,"nav",2);g([Z(".tab-group__indicator")],Qe.prototype,"indicator",2);g([oe()],Qe.prototype,"hasScrollControls",2);g([oe()],Qe.prototype,"shouldHideScrollStartButton",2);g([oe()],Qe.prototype,"shouldHideScrollEndButton",2);g([v()],Qe.prototype,"placement",2);g([v()],Qe.prototype,"activation",2);g([v({attribute:"no-scroll-controls",type:Boolean})],Qe.prototype,"noScrollControls",2);g([v({attribute:"fixed-scroll-controls",type:Boolean})],Qe.prototype,"fixedScrollControls",2);g([Sg({passive:!0})],Qe.prototype,"updateScrollButtons",1);g([G("noScrollControls",{waitUntilFirstUpdate:!0})],Qe.prototype,"updateScrollControls",1);g([G("placement",{waitUntilFirstUpdate:!0})],Qe.prototype,"syncIndicator",1);Qe.define("sl-tab-group");var px=(e,t)=>{let s=0;return function(...i){window.clearTimeout(s),s=window.setTimeout(()=>{e.call(this,...i)},t)}},T_=(e,t,s)=>{let i=e[t];e[t]=function(...r){i.call(this,...r),s.call(this,i,...r)}};(()=>{if(typeof window>"u")return;if(!("onscrollend"in window)){let t=new Set,s=new WeakMap,i=o=>{for(let n of o.changedTouches)t.add(n.identifier)},r=o=>{for(let n of o.changedTouches)t.delete(n.identifier)};document.addEventListener("touchstart",i,!0),document.addEventListener("touchend",r,!0),document.addEventListener("touchcancel",r,!0),T_(EventTarget.prototype,"addEventListener",function(o,n){if(n!=="scrollend")return;let a=px(()=>{t.size?a():this.dispatchEvent(new Event("scrollend"))},100);o.call(this,"scroll",a,{passive:!0}),s.set(this,a)}),T_(EventTarget.prototype,"removeEventListener",function(o,n){if(n!=="scrollend")return;let a=s.get(this);a&&o.call(this,"scroll",a,{passive:!0})})}})();var A_=Y`
5657
+ `}};Qe.styles=[Q,E_];Qe.dependencies={"sl-icon-button":Te,"sl-resize-observer":bn};g([Z(".tab-group")],Qe.prototype,"tabGroup",2);g([Z(".tab-group__body")],Qe.prototype,"body",2);g([Z(".tab-group__nav")],Qe.prototype,"nav",2);g([Z(".tab-group__indicator")],Qe.prototype,"indicator",2);g([oe()],Qe.prototype,"hasScrollControls",2);g([oe()],Qe.prototype,"shouldHideScrollStartButton",2);g([oe()],Qe.prototype,"shouldHideScrollEndButton",2);g([v()],Qe.prototype,"placement",2);g([v()],Qe.prototype,"activation",2);g([v({attribute:"no-scroll-controls",type:Boolean})],Qe.prototype,"noScrollControls",2);g([v({attribute:"fixed-scroll-controls",type:Boolean})],Qe.prototype,"fixedScrollControls",2);g([Cg({passive:!0})],Qe.prototype,"updateScrollButtons",1);g([G("noScrollControls",{waitUntilFirstUpdate:!0})],Qe.prototype,"updateScrollControls",1);g([G("placement",{waitUntilFirstUpdate:!0})],Qe.prototype,"syncIndicator",1);Qe.define("sl-tab-group");var mx=(e,t)=>{let s=0;return function(...i){window.clearTimeout(s),s=window.setTimeout(()=>{e.call(this,...i)},t)}},A_=(e,t,s)=>{let i=e[t];e[t]=function(...r){i.call(this,...r),s.call(this,i,...r)}};(()=>{if(typeof window>"u")return;if(!("onscrollend"in window)){let t=new Set,s=new WeakMap,i=o=>{for(let n of o.changedTouches)t.add(n.identifier)},r=o=>{for(let n of o.changedTouches)t.delete(n.identifier)};document.addEventListener("touchstart",i,!0),document.addEventListener("touchend",r,!0),document.addEventListener("touchcancel",r,!0),A_(EventTarget.prototype,"addEventListener",function(o,n){if(n!=="scrollend")return;let a=mx(()=>{t.size?a():this.dispatchEvent(new Event("scrollend"))},100);o.call(this,"scroll",a,{passive:!0}),s.set(this,a)}),A_(EventTarget.prototype,"removeEventListener",function(o,n){if(n!=="scrollend")return;let a=s.get(this);a&&o.call(this,"scroll",a,{passive:!0})})}})();var R_=Y`
5644
5658
  :host {
5645
5659
  display: inline-block;
5646
5660
  }
@@ -5705,7 +5719,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5705
5719
  outline-offset: -3px;
5706
5720
  }
5707
5721
  }
5708
- `;var fx=0,Zt=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.attrId=++fx,this.componentId=`sl-tab-${this.attrId}`,this.panel="",this.active=!1,this.closable=!1,this.disabled=!1,this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tab")}handleCloseClick(e){e.stopPropagation(),this.emit("sl-close")}handleActiveChange(){this.setAttribute("aria-selected",this.active?"true":"false")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.disabled&&!this.active?this.tabIndex=-1:this.tabIndex=0}render(){return this.id=this.id.length>0?this.id:this.componentId,u`
5722
+ `;var gx=0,Zt=class extends X{constructor(){super(...arguments),this.localize=new be(this),this.attrId=++gx,this.componentId=`sl-tab-${this.attrId}`,this.panel="",this.active=!1,this.closable=!1,this.disabled=!1,this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("role","tab")}handleCloseClick(e){e.stopPropagation(),this.emit("sl-close")}handleActiveChange(){this.setAttribute("aria-selected",this.active?"true":"false")}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false"),this.disabled&&!this.active?this.tabIndex=-1:this.tabIndex=0}render(){return this.id=this.id.length>0?this.id:this.componentId,u`
5709
5723
  <div
5710
5724
  part="base"
5711
5725
  class=${ee({tab:!0,"tab--active":this.active,"tab--closable":this.closable,"tab--disabled":this.disabled})}
@@ -5724,7 +5738,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5724
5738
  ></sl-icon-button>
5725
5739
  `:""}
5726
5740
  </div>
5727
- `}};Zt.styles=[Q,A_];Zt.dependencies={"sl-icon-button":Te};g([Z(".tab")],Zt.prototype,"tab",2);g([v({reflect:!0})],Zt.prototype,"panel",2);g([v({type:Boolean,reflect:!0})],Zt.prototype,"active",2);g([v({type:Boolean,reflect:!0})],Zt.prototype,"closable",2);g([v({type:Boolean,reflect:!0})],Zt.prototype,"disabled",2);g([v({type:Number,reflect:!0})],Zt.prototype,"tabIndex",2);g([G("active")],Zt.prototype,"handleActiveChange",1);g([G("disabled")],Zt.prototype,"handleDisabledChange",1);Zt.define("sl-tab");var R_=Y`
5741
+ `}};Zt.styles=[Q,R_];Zt.dependencies={"sl-icon-button":Te};g([Z(".tab")],Zt.prototype,"tab",2);g([v({reflect:!0})],Zt.prototype,"panel",2);g([v({type:Boolean,reflect:!0})],Zt.prototype,"active",2);g([v({type:Boolean,reflect:!0})],Zt.prototype,"closable",2);g([v({type:Boolean,reflect:!0})],Zt.prototype,"disabled",2);g([v({type:Number,reflect:!0})],Zt.prototype,"tabIndex",2);g([G("active")],Zt.prototype,"handleActiveChange",1);g([G("disabled")],Zt.prototype,"handleDisabledChange",1);Zt.define("sl-tab");var D_=Y`
5728
5742
  :host {
5729
5743
  --padding: 0;
5730
5744
 
@@ -5739,12 +5753,12 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5739
5753
  display: block;
5740
5754
  padding: var(--padding);
5741
5755
  }
5742
- `;var mx=0,Zr=class extends X{constructor(){super(...arguments),this.attrId=++mx,this.componentId=`sl-tab-panel-${this.attrId}`,this.name="",this.active=!1}connectedCallback(){super.connectedCallback(),this.id=this.id.length>0?this.id:this.componentId,this.setAttribute("role","tabpanel")}handleActiveChange(){this.setAttribute("aria-hidden",this.active?"false":"true")}render(){return u`
5756
+ `;var _x=0,Zr=class extends X{constructor(){super(...arguments),this.attrId=++_x,this.componentId=`sl-tab-panel-${this.attrId}`,this.name="",this.active=!1}connectedCallback(){super.connectedCallback(),this.id=this.id.length>0?this.id:this.componentId,this.setAttribute("role","tabpanel")}handleActiveChange(){this.setAttribute("aria-hidden",this.active?"false":"true")}render(){return u`
5743
5757
  <slot
5744
5758
  part="base"
5745
5759
  class=${ee({"tab-panel":!0,"tab-panel--active":this.active})}
5746
5760
  ></slot>
5747
- `}};Zr.styles=[Q,R_];g([v({reflect:!0})],Zr.prototype,"name",2);g([v({type:Boolean,reflect:!0})],Zr.prototype,"active",2);g([G("active")],Zr.prototype,"handleActiveChange",1);Zr.define("sl-tab-panel");var D_=Y`
5761
+ `}};Zr.styles=[Q,D_];g([v({reflect:!0})],Zr.prototype,"name",2);g([v({type:Boolean,reflect:!0})],Zr.prototype,"active",2);g([G("active")],Zr.prototype,"handleActiveChange",1);Zr.define("sl-tab-panel");var L_=Y`
5748
5762
  :host {
5749
5763
  display: inline-block;
5750
5764
  }
@@ -5955,7 +5969,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
5955
5969
  <slot name="help-text">${this.helpText}</slot>
5956
5970
  </div>
5957
5971
  </div>
5958
- `}};lt.styles=[Q,Yt,D_];g([Z('input[type="checkbox"]')],lt.prototype,"input",2);g([oe()],lt.prototype,"hasFocus",2);g([v()],lt.prototype,"title",2);g([v()],lt.prototype,"name",2);g([v()],lt.prototype,"value",2);g([v({reflect:!0})],lt.prototype,"size",2);g([v({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],lt.prototype,"checked",2);g([ki("checked")],lt.prototype,"defaultChecked",2);g([v({reflect:!0})],lt.prototype,"form",2);g([v({type:Boolean,reflect:!0})],lt.prototype,"required",2);g([v({attribute:"help-text"})],lt.prototype,"helpText",2);g([G("checked",{waitUntilFirstUpdate:!0})],lt.prototype,"handleCheckedChange",1);g([G("disabled",{waitUntilFirstUpdate:!0})],lt.prototype,"handleDisabledChange",1);lt.define("sl-switch");var L_=Y`
5972
+ `}};lt.styles=[Q,Yt,L_];g([Z('input[type="checkbox"]')],lt.prototype,"input",2);g([oe()],lt.prototype,"hasFocus",2);g([v()],lt.prototype,"title",2);g([v()],lt.prototype,"name",2);g([v()],lt.prototype,"value",2);g([v({reflect:!0})],lt.prototype,"size",2);g([v({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],lt.prototype,"checked",2);g([ki("checked")],lt.prototype,"defaultChecked",2);g([v({reflect:!0})],lt.prototype,"form",2);g([v({type:Boolean,reflect:!0})],lt.prototype,"required",2);g([v({attribute:"help-text"})],lt.prototype,"helpText",2);g([G("checked",{waitUntilFirstUpdate:!0})],lt.prototype,"handleCheckedChange",1);g([G("disabled",{waitUntilFirstUpdate:!0})],lt.prototype,"handleDisabledChange",1);lt.define("sl-switch");var P_=Y`
5959
5973
  :host {
5960
5974
  display: contents;
5961
5975
 
@@ -6134,7 +6148,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6134
6148
  </div>
6135
6149
  `:""}
6136
6150
  </div>
6137
- `}};zt.styles=[Q,L_];zt.dependencies={"sl-icon-button":Te};g([Z('[part~="base"]')],zt.prototype,"base",2);g([Z(".alert__countdown-elapsed")],zt.prototype,"countdownElement",2);g([v({type:Boolean,reflect:!0})],zt.prototype,"open",2);g([v({type:Boolean,reflect:!0})],zt.prototype,"closable",2);g([v({reflect:!0})],zt.prototype,"variant",2);g([v({type:Number})],zt.prototype,"duration",2);g([v({type:String,reflect:!0})],zt.prototype,"countdown",2);g([oe()],zt.prototype,"remainingTime",2);g([G("open",{waitUntilFirstUpdate:!0})],zt.prototype,"handleOpenChange",1);g([G("duration")],zt.prototype,"handleDurationChange",1);var P_=zt;Ge("alert.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}});Ge("alert.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});P_.define("sl-alert");var B_=Y`
6151
+ `}};zt.styles=[Q,P_];zt.dependencies={"sl-icon-button":Te};g([Z('[part~="base"]')],zt.prototype,"base",2);g([Z(".alert__countdown-elapsed")],zt.prototype,"countdownElement",2);g([v({type:Boolean,reflect:!0})],zt.prototype,"open",2);g([v({type:Boolean,reflect:!0})],zt.prototype,"closable",2);g([v({reflect:!0})],zt.prototype,"variant",2);g([v({type:Number})],zt.prototype,"duration",2);g([v({type:String,reflect:!0})],zt.prototype,"countdown",2);g([oe()],zt.prototype,"remainingTime",2);g([G("open",{waitUntilFirstUpdate:!0})],zt.prototype,"handleOpenChange",1);g([G("duration")],zt.prototype,"handleDurationChange",1);var B_=zt;Ge("alert.show",{keyframes:[{opacity:0,scale:.8},{opacity:1,scale:1}],options:{duration:250,easing:"ease"}});Ge("alert.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.8}],options:{duration:250,easing:"ease"}});B_.define("sl-alert");var M_=Y`
6138
6152
  :host {
6139
6153
  display: block;
6140
6154
  }
@@ -6369,7 +6383,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6369
6383
  <slot name="help-text">${this.helpText}</slot>
6370
6384
  </div>
6371
6385
  </div>
6372
- `}};he.styles=[Q,Yt,B_];g([Z(".textarea__control")],he.prototype,"input",2);g([Z(".textarea__size-adjuster")],he.prototype,"sizeAdjuster",2);g([oe()],he.prototype,"hasFocus",2);g([v()],he.prototype,"title",2);g([v()],he.prototype,"name",2);g([v()],he.prototype,"value",2);g([v({reflect:!0})],he.prototype,"size",2);g([v({type:Boolean,reflect:!0})],he.prototype,"filled",2);g([v()],he.prototype,"label",2);g([v({attribute:"help-text"})],he.prototype,"helpText",2);g([v()],he.prototype,"placeholder",2);g([v({type:Number})],he.prototype,"rows",2);g([v()],he.prototype,"resize",2);g([v({type:Boolean,reflect:!0})],he.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],he.prototype,"readonly",2);g([v({reflect:!0})],he.prototype,"form",2);g([v({type:Boolean,reflect:!0})],he.prototype,"required",2);g([v({type:Number})],he.prototype,"minlength",2);g([v({type:Number})],he.prototype,"maxlength",2);g([v()],he.prototype,"autocapitalize",2);g([v()],he.prototype,"autocorrect",2);g([v()],he.prototype,"autocomplete",2);g([v({type:Boolean})],he.prototype,"autofocus",2);g([v()],he.prototype,"enterkeyhint",2);g([v({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],he.prototype,"spellcheck",2);g([v()],he.prototype,"inputmode",2);g([ki()],he.prototype,"defaultValue",2);g([G("disabled",{waitUntilFirstUpdate:!0})],he.prototype,"handleDisabledChange",1);g([G("rows",{waitUntilFirstUpdate:!0})],he.prototype,"handleRowsChange",1);g([G("value",{waitUntilFirstUpdate:!0})],he.prototype,"handleValueChange",1);he.define("sl-textarea");var M_=Y`
6386
+ `}};he.styles=[Q,Yt,M_];g([Z(".textarea__control")],he.prototype,"input",2);g([Z(".textarea__size-adjuster")],he.prototype,"sizeAdjuster",2);g([oe()],he.prototype,"hasFocus",2);g([v()],he.prototype,"title",2);g([v()],he.prototype,"name",2);g([v()],he.prototype,"value",2);g([v({reflect:!0})],he.prototype,"size",2);g([v({type:Boolean,reflect:!0})],he.prototype,"filled",2);g([v()],he.prototype,"label",2);g([v({attribute:"help-text"})],he.prototype,"helpText",2);g([v()],he.prototype,"placeholder",2);g([v({type:Number})],he.prototype,"rows",2);g([v()],he.prototype,"resize",2);g([v({type:Boolean,reflect:!0})],he.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],he.prototype,"readonly",2);g([v({reflect:!0})],he.prototype,"form",2);g([v({type:Boolean,reflect:!0})],he.prototype,"required",2);g([v({type:Number})],he.prototype,"minlength",2);g([v({type:Number})],he.prototype,"maxlength",2);g([v()],he.prototype,"autocapitalize",2);g([v()],he.prototype,"autocorrect",2);g([v()],he.prototype,"autocomplete",2);g([v({type:Boolean})],he.prototype,"autofocus",2);g([v()],he.prototype,"enterkeyhint",2);g([v({type:Boolean,converter:{fromAttribute:e=>!(!e||e==="false"),toAttribute:e=>e?"true":"false"}})],he.prototype,"spellcheck",2);g([v()],he.prototype,"inputmode",2);g([ki()],he.prototype,"defaultValue",2);g([G("disabled",{waitUntilFirstUpdate:!0})],he.prototype,"handleDisabledChange",1);g([G("rows",{waitUntilFirstUpdate:!0})],he.prototype,"handleRowsChange",1);g([G("value",{waitUntilFirstUpdate:!0})],he.prototype,"handleValueChange",1);he.define("sl-textarea");var I_=Y`
6373
6387
  :host {
6374
6388
  display: block;
6375
6389
  }
@@ -6401,7 +6415,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6401
6415
  white-space: nowrap;
6402
6416
  border: 0;
6403
6417
  }
6404
- `;var I_=Y`
6418
+ `;var O_=Y`
6405
6419
  :host {
6406
6420
  display: inline-block;
6407
6421
  }
@@ -6423,7 +6437,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6423
6437
  >
6424
6438
  <slot @slotchange=${this.handleSlotChange}></slot>
6425
6439
  </div>
6426
- `}};Qr.styles=[Q,I_];g([Z("slot")],Qr.prototype,"defaultSlot",2);g([oe()],Qr.prototype,"disableRole",2);g([v()],Qr.prototype,"label",2);function yn(e){var t;let s="sl-button, sl-radio-button";return(t=e.closest(s))!=null?t:e.querySelector(s)}var et=class extends X{constructor(){super(...arguments),this.formControlController=new Et(this),this.hasSlotController=new Je(this,"help-text","label"),this.customValidityMessage="",this.hasButtonGroup=!1,this.errorMessage="",this.defaultValue="",this.label="",this.helpText="",this.name="option",this.value="",this.size="medium",this.form="",this.required=!1}get validity(){let e=this.required&&!this.value;return this.customValidityMessage!==""?p_:e?u_:Xr}get validationMessage(){let e=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:e?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}firstUpdated(){this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("sl-radio, sl-radio-button")]}handleRadioClick(e){let t=e.target.closest("sl-radio, sl-radio-button"),s=this.getAllRadios(),i=this.value;!t||t.disabled||(this.value=t.value,s.forEach(r=>r.checked=r===t),this.value!==i&&(this.emit("sl-change"),this.emit("sl-input")))}handleKeyDown(e){var t;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(e.key))return;let s=this.getAllRadios().filter(a=>!a.disabled),i=(t=s.find(a=>a.checked))!=null?t:s[0],r=e.key===" "?0:["ArrowUp","ArrowLeft"].includes(e.key)?-1:1,o=this.value,n=s.indexOf(i)+r;n<0&&(n=s.length-1),n>s.length-1&&(n=0),this.getAllRadios().forEach(a=>{a.checked=!1,this.hasButtonGroup||a.setAttribute("tabindex","-1")}),this.value=s[n].value,s[n].checked=!0,this.hasButtonGroup?s[n].shadowRoot.querySelector("button").focus():(s[n].setAttribute("tabindex","0"),s[n].focus()),this.value!==o&&(this.emit("sl-change"),this.emit("sl-input")),e.preventDefault()}handleLabelClick(){this.focus()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}async syncRadioElements(){var e,t;let s=this.getAllRadios();if(await Promise.all(s.map(async i=>{await i.updateComplete,i.checked=i.value===this.value,i.size=this.size})),this.hasButtonGroup=s.some(i=>i.tagName.toLowerCase()==="sl-radio-button"),s.length>0&&!s.some(i=>i.checked))if(this.hasButtonGroup){let i=(e=s[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else s[0].setAttribute("tabindex","0");if(this.hasButtonGroup){let i=(t=this.shadowRoot)==null?void 0:t.querySelector("sl-button-group");i&&(i.disableRole=!0)}}syncRadios(){if(customElements.get("sl-radio")&&customElements.get("sl-radio-button")){this.syncRadioElements();return}customElements.get("sl-radio")?this.syncRadioElements():customElements.whenDefined("sl-radio").then(()=>this.syncRadios()),customElements.get("sl-radio-button")?this.syncRadioElements():customElements.whenDefined("sl-radio-button").then(()=>this.syncRadios())}updateCheckedRadio(){this.getAllRadios().forEach(t=>t.checked=t.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleSizeChange(){this.syncRadios()}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}checkValidity(){let e=this.required&&!this.value,t=this.customValidityMessage!=="";return e||t?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){let e=this.validity.valid;return this.errorMessage=this.customValidityMessage||e?"":this.validationInput.validationMessage,this.formControlController.setValidity(e),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),e||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),e}setCustomValidity(e=""){this.customValidityMessage=e,this.errorMessage=e,this.validationInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){let t=this.getAllRadios(),s=t.find(o=>o.checked),i=t.find(o=>!o.disabled),r=s||i;r&&r.focus(e)}render(){let e=this.hasSlotController.test("label"),t=this.hasSlotController.test("help-text"),s=this.label?!0:!!e,i=this.helpText?!0:!!t,r=u`
6440
+ `}};Qr.styles=[Q,O_];g([Z("slot")],Qr.prototype,"defaultSlot",2);g([oe()],Qr.prototype,"disableRole",2);g([v()],Qr.prototype,"label",2);function yn(e){var t;let s="sl-button, sl-radio-button";return(t=e.closest(s))!=null?t:e.querySelector(s)}var et=class extends X{constructor(){super(...arguments),this.formControlController=new Et(this),this.hasSlotController=new Je(this,"help-text","label"),this.customValidityMessage="",this.hasButtonGroup=!1,this.errorMessage="",this.defaultValue="",this.label="",this.helpText="",this.name="option",this.value="",this.size="medium",this.form="",this.required=!1}get validity(){let e=this.required&&!this.value;return this.customValidityMessage!==""?f_:e?p_:Xr}get validationMessage(){let e=this.required&&!this.value;return this.customValidityMessage!==""?this.customValidityMessage:e?this.validationInput.validationMessage:""}connectedCallback(){super.connectedCallback(),this.defaultValue=this.value}firstUpdated(){this.formControlController.updateValidity()}getAllRadios(){return[...this.querySelectorAll("sl-radio, sl-radio-button")]}handleRadioClick(e){let t=e.target.closest("sl-radio, sl-radio-button"),s=this.getAllRadios(),i=this.value;!t||t.disabled||(this.value=t.value,s.forEach(r=>r.checked=r===t),this.value!==i&&(this.emit("sl-change"),this.emit("sl-input")))}handleKeyDown(e){var t;if(!["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"," "].includes(e.key))return;let s=this.getAllRadios().filter(a=>!a.disabled),i=(t=s.find(a=>a.checked))!=null?t:s[0],r=e.key===" "?0:["ArrowUp","ArrowLeft"].includes(e.key)?-1:1,o=this.value,n=s.indexOf(i)+r;n<0&&(n=s.length-1),n>s.length-1&&(n=0),this.getAllRadios().forEach(a=>{a.checked=!1,this.hasButtonGroup||a.setAttribute("tabindex","-1")}),this.value=s[n].value,s[n].checked=!0,this.hasButtonGroup?s[n].shadowRoot.querySelector("button").focus():(s[n].setAttribute("tabindex","0"),s[n].focus()),this.value!==o&&(this.emit("sl-change"),this.emit("sl-input")),e.preventDefault()}handleLabelClick(){this.focus()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}async syncRadioElements(){var e,t;let s=this.getAllRadios();if(await Promise.all(s.map(async i=>{await i.updateComplete,i.checked=i.value===this.value,i.size=this.size})),this.hasButtonGroup=s.some(i=>i.tagName.toLowerCase()==="sl-radio-button"),s.length>0&&!s.some(i=>i.checked))if(this.hasButtonGroup){let i=(e=s[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else s[0].setAttribute("tabindex","0");if(this.hasButtonGroup){let i=(t=this.shadowRoot)==null?void 0:t.querySelector("sl-button-group");i&&(i.disableRole=!0)}}syncRadios(){if(customElements.get("sl-radio")&&customElements.get("sl-radio-button")){this.syncRadioElements();return}customElements.get("sl-radio")?this.syncRadioElements():customElements.whenDefined("sl-radio").then(()=>this.syncRadios()),customElements.get("sl-radio-button")?this.syncRadioElements():customElements.whenDefined("sl-radio-button").then(()=>this.syncRadios())}updateCheckedRadio(){this.getAllRadios().forEach(t=>t.checked=t.value===this.value),this.formControlController.setValidity(this.validity.valid)}handleSizeChange(){this.syncRadios()}handleValueChange(){this.hasUpdated&&this.updateCheckedRadio()}checkValidity(){let e=this.required&&!this.value,t=this.customValidityMessage!=="";return e||t?(this.formControlController.emitInvalidEvent(),!1):!0}getForm(){return this.formControlController.getForm()}reportValidity(){let e=this.validity.valid;return this.errorMessage=this.customValidityMessage||e?"":this.validationInput.validationMessage,this.formControlController.setValidity(e),this.validationInput.hidden=!0,clearTimeout(this.validationTimeout),e||(this.validationInput.hidden=!1,this.validationInput.reportValidity(),this.validationTimeout=setTimeout(()=>this.validationInput.hidden=!0,1e4)),e}setCustomValidity(e=""){this.customValidityMessage=e,this.errorMessage=e,this.validationInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){let t=this.getAllRadios(),s=t.find(o=>o.checked),i=t.find(o=>!o.disabled),r=s||i;r&&r.focus(e)}render(){let e=this.hasSlotController.test("label"),t=this.hasSlotController.test("help-text"),s=this.label?!0:!!e,i=this.helpText?!0:!!t,r=u`
6427
6441
  <slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>
6428
6442
  `;return u`
6429
6443
  <fieldset
@@ -6475,7 +6489,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6475
6489
  <slot name="help-text">${this.helpText}</slot>
6476
6490
  </div>
6477
6491
  </fieldset>
6478
- `}};et.styles=[Q,Yt,M_];et.dependencies={"sl-button-group":Qr};g([Z("slot:not([name])")],et.prototype,"defaultSlot",2);g([Z(".radio-group__validation-input")],et.prototype,"validationInput",2);g([oe()],et.prototype,"hasButtonGroup",2);g([oe()],et.prototype,"errorMessage",2);g([oe()],et.prototype,"defaultValue",2);g([v()],et.prototype,"label",2);g([v({attribute:"help-text"})],et.prototype,"helpText",2);g([v()],et.prototype,"name",2);g([v({reflect:!0})],et.prototype,"value",2);g([v({reflect:!0})],et.prototype,"size",2);g([v({reflect:!0})],et.prototype,"form",2);g([v({type:Boolean,reflect:!0})],et.prototype,"required",2);g([G("size",{waitUntilFirstUpdate:!0})],et.prototype,"handleSizeChange",1);g([G("value")],et.prototype,"handleValueChange",1);et.define("sl-radio-group");var O_=Y`
6492
+ `}};et.styles=[Q,Yt,I_];et.dependencies={"sl-button-group":Qr};g([Z("slot:not([name])")],et.prototype,"defaultSlot",2);g([Z(".radio-group__validation-input")],et.prototype,"validationInput",2);g([oe()],et.prototype,"hasButtonGroup",2);g([oe()],et.prototype,"errorMessage",2);g([oe()],et.prototype,"defaultValue",2);g([v()],et.prototype,"label",2);g([v({attribute:"help-text"})],et.prototype,"helpText",2);g([v()],et.prototype,"name",2);g([v({reflect:!0})],et.prototype,"value",2);g([v({reflect:!0})],et.prototype,"size",2);g([v({reflect:!0})],et.prototype,"form",2);g([v({type:Boolean,reflect:!0})],et.prototype,"required",2);g([G("size",{waitUntilFirstUpdate:!0})],et.prototype,"handleSizeChange",1);g([G("value")],et.prototype,"handleValueChange",1);et.define("sl-radio-group");var z_=Y`
6479
6493
  :host {
6480
6494
  display: block;
6481
6495
  }
@@ -6598,7 +6612,7 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6598
6612
 
6599
6613
  <slot part="label" class="radio__label"></slot>
6600
6614
  </span>
6601
- `}};cs.styles=[Q,O_];cs.dependencies={"sl-icon":Ce};g([oe()],cs.prototype,"checked",2);g([oe()],cs.prototype,"hasFocus",2);g([v()],cs.prototype,"value",2);g([v({reflect:!0})],cs.prototype,"size",2);g([v({type:Boolean,reflect:!0})],cs.prototype,"disabled",2);g([G("checked")],cs.prototype,"handleCheckedChange",1);g([G("disabled",{waitUntilFirstUpdate:!0})],cs.prototype,"handleDisabledChange",1);cs.define("sl-radio");var z_=Y`
6615
+ `}};cs.styles=[Q,z_];cs.dependencies={"sl-icon":Ce};g([oe()],cs.prototype,"checked",2);g([oe()],cs.prototype,"hasFocus",2);g([v()],cs.prototype,"value",2);g([v({reflect:!0})],cs.prototype,"size",2);g([v({type:Boolean,reflect:!0})],cs.prototype,"disabled",2);g([G("checked")],cs.prototype,"handleCheckedChange",1);g([G("disabled",{waitUntilFirstUpdate:!0})],cs.prototype,"handleDisabledChange",1);cs.define("sl-radio");var N_=Y`
6602
6616
  :host {
6603
6617
  display: inline-block;
6604
6618
  }
@@ -6774,9 +6788,9 @@ ${ph}${"\u2500".repeat(40)} Iteration ${e} ${"\u2500".repeat(40)}${Ea}
6774
6788
  <slot name="help-text">${this.helpText}</slot>
6775
6789
  </div>
6776
6790
  </div>
6777
- `}};Ne.styles=[Q,Yt,z_];Ne.dependencies={"sl-icon":Ce};g([Z('input[type="checkbox"]')],Ne.prototype,"input",2);g([oe()],Ne.prototype,"hasFocus",2);g([v()],Ne.prototype,"title",2);g([v()],Ne.prototype,"name",2);g([v()],Ne.prototype,"value",2);g([v({reflect:!0})],Ne.prototype,"size",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"checked",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"indeterminate",2);g([ki("checked")],Ne.prototype,"defaultChecked",2);g([v({reflect:!0})],Ne.prototype,"form",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"required",2);g([v({attribute:"help-text"})],Ne.prototype,"helpText",2);g([G("disabled",{waitUntilFirstUpdate:!0})],Ne.prototype,"handleDisabledChange",1);g([G(["checked","indeterminate"],{waitUntilFirstUpdate:!0})],Ne.prototype,"handleStateChange",1);Ne.define("sl-checkbox");gn.define("sl-spinner");var O=Zd();function Qt(e){let t=O.getState().currentProjectId;return t?`/api/projects/${t}${e}`:`/api${e}`}var q=Km(),Rn=Jd({store:O,ws:q,getSettings:()=>Xs}),I=Al(location.hash),V_=q.getState(),yd=!0,Xs={},Fe=null,hs=null,Ei=null,$n=null,wd="",Dn=null,Ln=!1,to=!1,Tt="*",fl="",$i=null,$s={},wn=new Set,xd="all",kd="all",Cn=null,En=null,$d=new Map,Ed={},Td=[],xn=!1,_l=new Map,Ad={},ml=null,vl=!1,Tn=null,gl=null,ur=null,eo={},gx=["pipeline.run.started","pipeline.run.completed","pipeline.run.failed","pipeline.run.interrupted","pipeline.run.paused","pipeline.run.cancelled","pipeline.run.resumed","pipeline.run.resumed_from_pause","pipeline.git.pr_created","pipeline.circuit_breaker.tripped","pipeline.cost.budget_warning"];function bl(){Promise.all([fetch("/api/integrations/status").then(e=>e.json()),fetch("/api/integrations/config").then(e=>e.json())]).then(([e,t])=>{Tn=e,gl=t,z()}).catch(()=>{Tn={enabled:!1},gl={},z()})}var hl=null;function U_(){q_(),hl=setInterval(()=>{fetch("/api/integrations/status").then(e=>e.json()).then(e=>{Tn=e,z()}).catch(()=>{})},1e4)}function q_(){hl&&(clearInterval(hl),hl=null)}function so(e){if(!eo[e]){let t=gl?.[e];eo[e]={token:t?.bot_token||t?.webhook_url||"",chatId:String(t?.chat_id||t?.channel_id||""),events:t?.events?[...t.events]:[...gx],saving:!1,error:null,saved:!1}}return eo[e]}function _x(e){ur=e,delete eo[e],so(e),z()}function vx(){ur&&delete eo[ur],ur=null,z()}function bx(e,t,s){let i=so(e);i[t]=s,i.saved=!1,i.error=null,z()}function yx(e,t){let s=so(e),i=s.events.indexOf(t);i>=0?s.events.splice(i,1):s.events.push(t),s.saved=!1,z()}function wx(e){let t=so(e);t.saving=!0,t.error=null,t.saved=!1,z(),fetch("/api/integrations/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({adapter:e,token:t.token,chatId:t.chatId,events:t.events})}).then(s=>s.ok?s.json():s.json().then(i=>Promise.reject(new Error(i.error||"Save failed")))).then(()=>{t.saving=!1,t.saved=!0,ur=null,bl()}).catch(s=>{t.saving=!1,t.error=s.message,z()})}function Sx(e){fetch(`/api/integrations/config/${e}`,{method:"DELETE"}).then(t=>t.json()).then(()=>{delete eo[e],ur=null,bl()}).catch(()=>z())}function Cx(e,t){fetch(`/api/integrations/config/${e}/enabled`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})}).then(s=>s.json()).then(()=>bl()).catch(()=>z())}function xx(e){if(e!=="telegram")return;let t=so(e);t.detecting=!0,t.detectHint=null,z(),fetch("/api/integrations/telegram/detect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t.token})}).then(s=>s.json()).then(s=>{if(t.detecting=!1,!s.ok)t.detectHint=s.error||"Detection failed";else if(s.chats.length===0){let i=s.botUsername?`@${s.botUsername}`:"the bot";t.detectHint=`No chats found. Send /start to ${i} in Telegram, then click Detect again.`}else t.chatId=String(s.chats[0].id),t.detectHint=`Found: ${s.chats[0].title} (${s.chats[0].id})`;z()}).catch(()=>{t.detecting=!1,t.detectHint="Detection failed \u2014 check server logs.",z()})}var pr=null,Rd="all",Dd=null,Ld="",dl="all";function kx(){Xs={},Fe=null,hs=null,Ei=null,$n=null,Tt="*",fl="",$i=null;for(let e of Object.keys($s))delete $s[e];wn.clear(),xd="all",kd="all",Cn=null,En=null,$d.clear(),Ed={},Td=[],xn=!1,_l.clear(),Ad={},ml=null,vl=!1,pr=null,Rd="all",Dd=null,Ld="",dl="all"}function $x(e,t){_l.set(e,t)}function yl(e){e&&q.send("list-beads-by-run",{runId:e}).then(t=>{$d.set(e,t.issues||[]),z()}).catch(()=>{})}function Ex(e,t){if(!(!e||!t)){$s[e]||($s[e]={});for(let[s,i]of Object.entries(t)){if(i.status==="pending")continue;let r=`${e}:${s}`;$s[e][s]||wn.has(r)||(wn.add(r),q.send("get-agent-prompt",{runId:e,stage:s}).then(o=>{$s[e][s]=o,wn.delete(r),z()}).catch(()=>{wn.delete(r)}))}}}function N_(e){if(!e||!e.stages)return null;for(let[t,s]of Object.entries(e.stages))if(s.status==="in_progress")return t;return null}function K_(e,t){let s=N_(e),i=N_(t);i&&s!==i&&(Tt="*",$i=null,Mr(),O.clearLog(),q.send("unsubscribe-log").catch(()=>{}),q.send("subscribe-log",{stage:null,runId:t.id}).catch(()=>{}))}q.on("runs-list",(e,t)=>{if((O.getState().projects||[]).length>1){let i={...O.getState().runs},r=new Set((e.runs||[]).map(c=>c.id)),o=t?.project||null;if(o)for(let[c,l]of Object.entries(i))l._project===o&&!r.has(c)&&delete i[c];let n={...O.getState().archivedRuns};if(o)for(let[c,l]of Object.entries(n))l._project===o&&!r.has(c)&&delete n[c];let a=Date.now();for(let c of e.runs||[])if(o&&(c._project=o),c.archived){if(Wn(c,a))continue;n[c.id]=c,delete i[c.id]}else i[c.id]=c,delete n[c.id];e.settings&&(Xs=e.settings),O.setState({runs:i,archivedRuns:n,runsLoaded:!0});return}e.settings&&(Xs=e.settings),O.setRunsBulk(e.runs||[])});q.on("runs-list",()=>{An();let e=O.getState().runs,t=0;for(let s of Object.values(e)){let i=s.pipeline_status||(s.active?"running":"completed");(i==="running"||i==="paused")&&t++}O.setState({totalRunning:t})});q.on("run-snapshot",e=>{if(e?.id){let t=O.getRunById(e.id)??null;if(e.archived===!0||O.getState().archivedRuns[e.id]||Rn.handleRunUpdate(e.id,e,t),t&&$s[e.id])for(let[i,r]of Object.entries(e.stages||{})){let o=t.stages?.[i],n=o?.iterations?.length||0;((r.iterations?.length||0)>n||r.prompt&&r.prompt!==o?.prompt)&&delete $s[e.id][i]}O.setRun(e.id,e),I.runId===e.id&&(K_(t,e),Ta(e)),Fe&&(Fe=null,z())}});q.on("run-update",e=>{if(e?.id){let t=O.getRunById(e.id)??null;e.archived===!0||O.getState().archivedRuns[e.id]||Rn.handleRunUpdate(e.id,e,t),O.setRun(e.id,e),I.runId===e.id&&(K_(t,e),Ta(e),yl(e.id)),Fe&&(Fe=null,z())}});q.on("log-line",e=>{e&&(O.appendLog(e),e.iteration&&e.iteration>1&&e._iterStart&&yf(e.iteration),fh(e))});q.on("log-bulk",e=>{if(e&&Array.isArray(e.lines))for(let t of e.lines){let s={stage:e.stage,iteration:e.iteration,line:t,timestamp:new Date().toISOString()};O.appendLog(s),Tt!=="*"&&Zf(s),fh(s)}});q.on("preferences",e=>{e&&(O.setState({preferences:e}),bo(e.theme||"light"))});q.on("beads-update",(e,t)=>{let s=O.getState().currentProjectId;t?.project&&s&&t.project!==s||e&&(O.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}}),I.runId&&I.section!=="beads"&&yl(I.runId),Pd(),I.section==="beads"&&I.runId&&Bd(I.runId))});function G_(){return q.send("list-runs").then(e=>{e.settings&&(Xs=e.settings),O.setRunsBulk(e.runs||[])})}q.on("run-started",()=>{Fe=null,z()});q.on("run-archived",e=>{if(e?.runId){let t=O.getState().runs[e.runId]??O.getState().archivedRuns[e.runId];t?O.setRun(e.runId,{...t,archived:!0,archived_at:e.archived_at||new Date().toISOString()}):G_().catch(()=>{})}});q.on("run-unarchived",e=>{if(e?.runId){let t=O.getState().runs[e.runId]??O.getState().archivedRuns[e.runId];if(t){let{archived:s,archived_at:i,...r}=t;O.setRun(e.runId,r)}else G_().catch(()=>{})}});q.on("run-stopped",()=>{Fe=null,z()});q.on("run-cancelled",e=>{if(e?.runId){let t=O.getRunById(e.runId);t&&O.setRun(e.runId,{...t,pipeline_status:"cancelled",active:!1})}});q.on("stage-restarted",()=>{});q.on("learn-started",e=>{e?.runId&&e.runId===I.runId&&q.send("subscribe-run",{runId:e.runId}).catch(()=>{})});q.on("webhook-inbox-event",e=>{if(e){let t=O.getState().currentProjectId;if(!e.projectId||!t||e.projectId===t){let s=O.getState().webhookInbox;O.setState({webhookInbox:{...s,events:[...s.events,e]}})}}});q.on("webhook-control-changed",e=>{if(e){let t=O.getState().webhookInbox;O.setState({webhookInbox:{...t,controlAction:e.action}})}});q.on("webhook-inbox-cleared",()=>{let e=O.getState().webhookInbox;O.setState({webhookInbox:{...e,events:[]}}),pr=null});function Tx(e){if(!(e?.capabilities||[]).includes("multi-project")){q.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:null}}),F_();return}fetch("/api/projects").then(i=>i.json()).then(i=>{let r=i.projects||[];O.setState({projects:r});let o=I.projectId||(r.length===1?r[0].name:null);O.setState({currentProjectId:o}),q.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:o}}),F_()}).catch(()=>{})}function Y_(){let e=O.getState().projects||[];Promise.all(e.map(t=>fetch(`/api/projects/${t.name}/runs`).then(s=>s.json()).then(s=>({runs:(s.runs||[]).map(i=>({...i,project:i.project||t.name})),settings:s.settings||null,projectName:t.name})).catch(()=>({runs:[],settings:null,projectName:t.name})))).then(t=>{let s={},i={},r=Date.now();for(let{runs:o,settings:n}of t){n&&(Xs=n);for(let a of o)if(a.archived){if(Wn(a,r))continue;i[a.id]=a}else s[a.id]=a}O.setState({runs:s,archivedRuns:i,runsLoaded:!0}),z()})}function An(){let e=O.getState().projects||[],t=O.getState().currentProjectId,s=t?[t]:e.length>1?e.map(r=>r.name):[];if(s.length===0){O.setState({worktrees:[]});return}let i=s.map(r=>fetch(`/api/projects/${r}/worktrees`).then(o=>o.json()).then(o=>(o.worktrees||[]).map(n=>({...n,project:r}))).catch(()=>[]));Promise.all(i).then(r=>{O.setState({worktrees:r.flat()})})}function F_(){(O.getState().projects||[]).length>1?Y_():q.send("list-runs").then(e=>{e.settings&&(Xs=e.settings),O.setRunsBulk(e.runs||[])}).catch(()=>{}),q.send("list-beads-issues").then(e=>{O.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}})}).catch(()=>{}),q.send("get-webhook-inbox").then(e=>{O.setState({webhookInbox:{events:e.events||[],controlAction:e.controlAction||"continue"}})}).catch(()=>{}),Pd(),Md(),An(),I.runId&&(I.section!=="beads"&&(q.send("subscribe-run",{runId:I.runId}).catch(()=>{}),q.send("subscribe-log",{stage:Tt==="*"?null:Tt,runId:I.runId}).catch(()=>{})),yl(I.runId),I.section==="beads"&&Bd(I.runId))}q.on("hello",Tx);q.on("projects-updated",e=>{e?.projects&&O.setState({projects:e.projects})});function Ax(e){q.send("unsubscribe-run").catch(()=>{}),q.send("unsubscribe-log").catch(()=>{}),q.send("unsubscribe-events").catch(()=>{}),O.clearLog(),O.setState({currentProjectId:e,runs:{},archivedRuns:{},logLines:[],activeRunId:null,runsLoaded:!1,worktrees:[]}),wd="",Dn=null,Ln=!1,to=!1,kx(),q.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:e}}),(O.getState().projects||[]).length>1?Y_():q.send("list-runs").then(t=>{t.settings&&(Xs=t.settings),O.setRunsBulk(t.runs||[])}).catch(()=>{}),q.send("list-beads-issues").then(t=>{O.setState({beads:{issues:t.issues||[],dbExists:t.dbExists??!1,dbPath:t.dbPath||null,loading:!1}})}).catch(()=>{}),O.setState({webhookInbox:{events:[],controlAction:O.getState().webhookInbox?.controlAction||"continue"}}),q.send("get-webhook-inbox").then(t=>{O.setState({webhookInbox:{events:t.events||[],controlAction:t.controlAction||"continue"}})}).catch(()=>{}),Pd(),Md(),An()}q.onConnection(e=>{V_=e,e==="open"&&q.send("get-preferences").then(t=>{O.setState({preferences:t}),bo(t.theme||"light")}).catch(()=>{}),z()});Xd(e=>{let t=I.runId,s=I.projectId;I=e,e.projectId!==s&&Ax(e.projectId),t&&t!==I.runId&&(_l.clear(),q.send("unsubscribe-run").catch(()=>{}),q.send("unsubscribe-log").catch(()=>{}),O.clearLog(),Mr(),mh()),I.runId&&I.runId!==t&&(I.section==="beads"?Bd(I.runId):(Tt="*",$i=null,q.send("subscribe-run",{runId:I.runId}).catch(()=>{}),q.send("subscribe-log",{stage:null,runId:I.runId}).catch(()=>{}),yl(I.runId))),I.section==="settings"?(_i(null).then(()=>z()),U_()):q_(),I.section==="project-settings"&&_i(O.getState().currentProjectId||null).then(()=>z()),I.section==="costs"&&(vl=!1,X_()),!I.runId&&t&&(Qf(),wf()),z()});function Rx(e){st(e,null,I.projectId)}function Sn(e){st(I.section,e,I.projectId)}function Dx(e){e?st(I.section,null,e):st("dashboard",null,null)}function Lx(){let t=O.getState().preferences.theme==="dark"?"light":"dark";q.send("set-preferences",{theme:t}).catch(()=>{}),O.setState({preferences:{theme:t}}),bo(t)}function Px(e){q.send("set-preferences",{notifications:e}).catch(()=>{}),O.setState({preferences:{notifications:e}})}function Bx(e){q.send("set-preferences",{source_repo:e}).catch(()=>{}),O.setState({preferences:{source_repo:e}})}function Mx(e){if(Tt=e,e!=="*"){let i=O.getRunById(I.runId)?.stages?.[e]?.iterations?.length||0;$i=i>0?i:null}else $i=null;Mr(),O.clearLog(),q.send("unsubscribe-log").catch(()=>{}),q.send("subscribe-log",{stage:e==="*"?null:e,runId:I.runId,iteration:$i}).catch(()=>{}),z()}function Ix(e){$i=e,Mr(),O.clearLog(),q.send("unsubscribe-log").catch(()=>{}),q.send("subscribe-log",{stage:Tt==="*"?null:Tt,runId:I.runId,iteration:e}).catch(()=>{}),z()}function Ox(e){fl=e,em(e)}function zx(){yd=!yd,z()}function _e(e){Ei=e,z(),requestAnimationFrame(()=>{let t=document.getElementById("action-error-dialog");t&&t.show()})}function Nx(){Ei=null,z()}function Fx(){wt({label:"Stop Pipeline?",message:"Are you sure? The current stage will be interrupted and marked as error.",confirmLabel:"Stop",confirmVariant:"danger",onConfirm:Hx},z)}async function Hx(){Fe="stopping",Ei=null,z();try{let t=Object.values(O.getState().runs).find(r=>r.active)?.id||"current",i=await(await fetch(Qt(`/runs/${t}/stop`),{method:"POST"})).json();i.ok||(Fe=null,_e(i.error||"Failed to stop pipeline"))}catch(e){Fe=null,_e(e?.message||"Failed to stop pipeline")}}function Wx(){Fe="resuming",Ei=null,z(),q.send("resume-run",{runId:I.runId}).then(()=>{Fe=null,z()}).catch(e=>{Fe=null,_e(e?.message||"Failed to resume pipeline")})}async function jx(){let t=Object.values(O.getState().runs).find(s=>s.active)?.id||"current";Fe="pausing",Ei=null,z();try{let i=await(await fetch(Qt(`/runs/${t}/pause`),{method:"POST"})).json();i.ok||(Fe=null,_e(i.error||"Failed to pause pipeline"))}catch(s){Fe=null,_e(s?.message||"Failed to pause pipeline")}}async function Sd(e){hs={action:"pause",runId:e},z();try{let s=await(await fetch(Qt(`/runs/${e}/pause`),{method:"POST"})).json();s.ok||_e(s.error||"Failed to pause run")}catch(t){_e(t?.message||"Failed to pause run")}finally{hs=null,z()}}async function ul(e){hs={action:"resume",runId:e},z();try{await q.send("resume-run",{runId:e})}catch(t){_e(t?.message||"Failed to resume run")}finally{hs=null,z()}}function pl(e){wt({label:"Stop Pipeline?",message:"Are you sure? The current stage will be interrupted and marked as error.",confirmLabel:"Stop",confirmVariant:"danger",onConfirm:async()=>{hs={action:"stop",runId:e},z();try{let t=await fetch(Qt(`/runs/${e}/stop`),{method:"POST"}),s=await t.json();t.status===409&&s.code==="no_running_process"?_e("Process is no longer running. Use Cancel to force the run into cancelled state."):s.ok||_e(s.error||"Failed to stop run")}catch(t){_e(t?.message||"Failed to stop run")}finally{hs=null,z()}}},z)}function kn(e){wt({label:"Cancel Pipeline?",message:"This will permanently cancel the run. Any running process will be terminated and the pipeline cannot be resumed.",confirmLabel:"Cancel Run",confirmVariant:"danger",onConfirm:async()=>{hs={action:"cancel",runId:e},z();try{let s=await(await fetch(Qt(`/runs/${e}/cancel`),{method:"POST"})).json();s.ok||_e(s.error||"Failed to cancel run")}catch(t){_e(t?.message||"Failed to cancel run")}finally{hs=null,z()}}},z)}async function Vx(e){try{let t=await fetch(Qt(`/runs/${e}/control`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"approve",source:"ui-pr-approval"})});if(t.status===404){_e("This run has already finished. Refreshing...");return}if(t.status===409){_e("This run is no longer awaiting approval.");return}t.ok||_e("Could not deliver decision; try again.")}catch{_e("Could not deliver decision; try again.")}}async function Ux(e){try{let t=await fetch(Qt(`/runs/${e}/control`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reject",source:"ui-pr-approval"})});if(t.status===404){_e("This run has already finished. Refreshing...");return}if(t.status===409){_e("This run is no longer awaiting approval.");return}t.ok||_e("Could not deliver decision; try again.")}catch{_e("Could not deliver decision; try again.")}}var{archiveRun:bd,unarchiveRun:qx}=Qd({showConfirm:wt,showActionError:_e,projectUrl:Qt,store:O,rerender:z});function Kx(e){Dn=e,Ln=!1,to=!1,z()}function Gx(){Dn=null,Ln=!0,to=!1,z()}function Cd(){Dn=null,Ln=!1,to=!1,z()}async function H_(e,t){let s=Qt(`/worktrees/${encodeURIComponent(e)}${t?"?force=1":""}`),i=await fetch(s,{method:"DELETE"}),r=null;try{r=await i.json()}catch{}if(!i.ok||!r?.ok)throw new Error(r?.error||`Cleanup failed (HTTP ${i.status})`)}async function Yx(e,t){if(e===null){let s=(O.getState().worktrees||[]).filter(r=>r.status==="completed");Cd();let i=[];for(let r of s)try{await H_(r.run_id,!1)}catch(o){i.push(`${r.title||r.run_id}: ${o.message}`)}An(),i.length>0&&_e(`Cleanup completed with ${i.length} failure(s):
6791
+ `}};Ne.styles=[Q,Yt,N_];Ne.dependencies={"sl-icon":Ce};g([Z('input[type="checkbox"]')],Ne.prototype,"input",2);g([oe()],Ne.prototype,"hasFocus",2);g([v()],Ne.prototype,"title",2);g([v()],Ne.prototype,"name",2);g([v()],Ne.prototype,"value",2);g([v({reflect:!0})],Ne.prototype,"size",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"disabled",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"checked",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"indeterminate",2);g([ki("checked")],Ne.prototype,"defaultChecked",2);g([v({reflect:!0})],Ne.prototype,"form",2);g([v({type:Boolean,reflect:!0})],Ne.prototype,"required",2);g([v({attribute:"help-text"})],Ne.prototype,"helpText",2);g([G("disabled",{waitUntilFirstUpdate:!0})],Ne.prototype,"handleDisabledChange",1);g([G(["checked","indeterminate"],{waitUntilFirstUpdate:!0})],Ne.prototype,"handleStateChange",1);Ne.define("sl-checkbox");gn.define("sl-spinner");var O=Zd();function Qt(e){let t=O.getState().currentProjectId;return t?`/api/projects/${t}${e}`:`/api${e}`}var q=Gm(),Rn=Jd({store:O,ws:q,getSettings:()=>Xs}),I=Al(location.hash),U_=q.getState(),yd=!0,Xs={},Fe=null,hs=null,Ei=null,$n=null,wd="",Dn=null,Ln=!1,to=!1,Tt="*",fl="",$i=null,$s={},wn=new Set,xd="all",kd="all",Cn=null,En=null,$d=new Map,Ed={},Td=[],xn=!1,_l=new Map,Ad={},ml=null,vl=!1,Tn=null,gl=null,ur=null,eo={},vx=["pipeline.run.started","pipeline.run.completed","pipeline.run.failed","pipeline.run.interrupted","pipeline.run.paused","pipeline.run.cancelled","pipeline.run.resumed","pipeline.run.resumed_from_pause","pipeline.git.pr_created","pipeline.circuit_breaker.tripped","pipeline.cost.budget_warning"];function bl(){Promise.all([fetch("/api/integrations/status").then(e=>e.json()),fetch("/api/integrations/config").then(e=>e.json())]).then(([e,t])=>{Tn=e,gl=t,z()}).catch(()=>{Tn={enabled:!1},gl={},z()})}var hl=null;function q_(){K_(),hl=setInterval(()=>{fetch("/api/integrations/status").then(e=>e.json()).then(e=>{Tn=e,z()}).catch(()=>{})},1e4)}function K_(){hl&&(clearInterval(hl),hl=null)}function so(e){if(!eo[e]){let t=gl?.[e];eo[e]={token:t?.bot_token||t?.webhook_url||"",chatId:String(t?.chat_id||t?.channel_id||""),events:t?.events?[...t.events]:[...vx],saving:!1,error:null,saved:!1}}return eo[e]}function bx(e){ur=e,delete eo[e],so(e),z()}function yx(){ur&&delete eo[ur],ur=null,z()}function wx(e,t,s){let i=so(e);i[t]=s,i.saved=!1,i.error=null,z()}function Sx(e,t){let s=so(e),i=s.events.indexOf(t);i>=0?s.events.splice(i,1):s.events.push(t),s.saved=!1,z()}function Cx(e){let t=so(e);t.saving=!0,t.error=null,t.saved=!1,z(),fetch("/api/integrations/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({adapter:e,token:t.token,chatId:t.chatId,events:t.events})}).then(s=>s.ok?s.json():s.json().then(i=>Promise.reject(new Error(i.error||"Save failed")))).then(()=>{t.saving=!1,t.saved=!0,ur=null,bl()}).catch(s=>{t.saving=!1,t.error=s.message,z()})}function xx(e){fetch(`/api/integrations/config/${e}`,{method:"DELETE"}).then(t=>t.json()).then(()=>{delete eo[e],ur=null,bl()}).catch(()=>z())}function kx(e,t){fetch(`/api/integrations/config/${e}/enabled`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:t})}).then(s=>s.json()).then(()=>bl()).catch(()=>z())}function $x(e){if(e!=="telegram")return;let t=so(e);t.detecting=!0,t.detectHint=null,z(),fetch("/api/integrations/telegram/detect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t.token})}).then(s=>s.json()).then(s=>{if(t.detecting=!1,!s.ok)t.detectHint=s.error||"Detection failed";else if(s.chats.length===0){let i=s.botUsername?`@${s.botUsername}`:"the bot";t.detectHint=`No chats found. Send /start to ${i} in Telegram, then click Detect again.`}else t.chatId=String(s.chats[0].id),t.detectHint=`Found: ${s.chats[0].title} (${s.chats[0].id})`;z()}).catch(()=>{t.detecting=!1,t.detectHint="Detection failed \u2014 check server logs.",z()})}var pr=null,Rd="all",Dd=null,Ld="",dl="all";function Ex(){Xs={},Fe=null,hs=null,Ei=null,$n=null,Tt="*",fl="",$i=null;for(let e of Object.keys($s))delete $s[e];wn.clear(),xd="all",kd="all",Cn=null,En=null,$d.clear(),Ed={},Td=[],xn=!1,_l.clear(),Ad={},ml=null,vl=!1,pr=null,Rd="all",Dd=null,Ld="",dl="all"}function Tx(e,t){_l.set(e,t)}function yl(e){e&&q.send("list-beads-by-run",{runId:e}).then(t=>{$d.set(e,t.issues||[]),z()}).catch(()=>{})}function Ax(e,t){if(!(!e||!t)){$s[e]||($s[e]={});for(let[s,i]of Object.entries(t)){if(i.status==="pending")continue;let r=`${e}:${s}`;$s[e][s]||wn.has(r)||(wn.add(r),q.send("get-agent-prompt",{runId:e,stage:s}).then(o=>{$s[e][s]=o,wn.delete(r),z()}).catch(()=>{wn.delete(r)}))}}}function F_(e){if(!e||!e.stages)return null;for(let[t,s]of Object.entries(e.stages))if(s.status==="in_progress")return t;return null}function G_(e,t){let s=F_(e),i=F_(t);i&&s!==i&&(Tt="*",$i=null,Mr(),O.clearLog(),q.send("unsubscribe-log").catch(()=>{}),q.send("subscribe-log",{stage:null,runId:t.id}).catch(()=>{}))}q.on("runs-list",(e,t)=>{if((O.getState().projects||[]).length>1){let i={...O.getState().runs},r=new Set((e.runs||[]).map(c=>c.id)),o=t?.project||null;if(o)for(let[c,l]of Object.entries(i))l._project===o&&!r.has(c)&&delete i[c];let n={...O.getState().archivedRuns};if(o)for(let[c,l]of Object.entries(n))l._project===o&&!r.has(c)&&delete n[c];let a=Date.now();for(let c of e.runs||[])if(o&&(c._project=o),c.archived){if(Wn(c,a))continue;n[c.id]=c,delete i[c.id]}else i[c.id]=c,delete n[c.id];e.settings&&(Xs=e.settings),O.setState({runs:i,archivedRuns:n,runsLoaded:!0});return}e.settings&&(Xs=e.settings),O.setRunsBulk(e.runs||[])});q.on("runs-list",()=>{An();let e=O.getState().runs,t=0;for(let s of Object.values(e)){let i=s.pipeline_status||(s.active?"running":"completed");(i==="running"||i==="paused")&&t++}O.setState({totalRunning:t})});q.on("run-snapshot",e=>{if(e?.id){let t=O.getRunById(e.id)??null;if(e.archived===!0||O.getState().archivedRuns[e.id]||Rn.handleRunUpdate(e.id,e,t),t&&$s[e.id])for(let[i,r]of Object.entries(e.stages||{})){let o=t.stages?.[i],n=o?.iterations?.length||0;((r.iterations?.length||0)>n||r.prompt&&r.prompt!==o?.prompt)&&delete $s[e.id][i]}O.setRun(e.id,e),I.runId===e.id&&(G_(t,e),Ta(e)),Fe&&(Fe=null,z())}});q.on("run-update",e=>{if(e?.id){let t=O.getRunById(e.id)??null;e.archived===!0||O.getState().archivedRuns[e.id]||Rn.handleRunUpdate(e.id,e,t),O.setRun(e.id,e),I.runId===e.id&&(G_(t,e),Ta(e),yl(e.id)),Fe&&(Fe=null,z())}});q.on("log-line",e=>{e&&(O.appendLog(e),e.iteration&&e.iteration>1&&e._iterStart&&yf(e.iteration),fh(e))});q.on("log-bulk",e=>{if(e&&Array.isArray(e.lines))for(let t of e.lines){let s={stage:e.stage,iteration:e.iteration,line:t,timestamp:new Date().toISOString()};O.appendLog(s),Tt!=="*"&&Zf(s),fh(s)}});q.on("preferences",e=>{e&&(O.setState({preferences:e}),bo(e.theme||"light"))});q.on("beads-update",(e,t)=>{let s=O.getState().currentProjectId;t?.project&&s&&t.project!==s||e&&(O.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}}),I.runId&&I.section!=="beads"&&yl(I.runId),Pd(),I.section==="beads"&&I.runId&&Bd(I.runId))});function Y_(){return q.send("list-runs").then(e=>{e.settings&&(Xs=e.settings),O.setRunsBulk(e.runs||[])})}q.on("run-started",()=>{Fe=null,z()});q.on("run-archived",e=>{if(e?.runId){let t=O.getState().runs[e.runId]??O.getState().archivedRuns[e.runId];t?O.setRun(e.runId,{...t,archived:!0,archived_at:e.archived_at||new Date().toISOString()}):Y_().catch(()=>{})}});q.on("run-unarchived",e=>{if(e?.runId){let t=O.getState().runs[e.runId]??O.getState().archivedRuns[e.runId];if(t){let{archived:s,archived_at:i,...r}=t;O.setRun(e.runId,r)}else Y_().catch(()=>{})}});q.on("run-stopped",()=>{Fe=null,z()});q.on("run-cancelled",e=>{if(e?.runId){let t=O.getRunById(e.runId);t&&O.setRun(e.runId,{...t,pipeline_status:"cancelled",active:!1})}});q.on("stage-restarted",()=>{});q.on("learn-started",e=>{e?.runId&&e.runId===I.runId&&q.send("subscribe-run",{runId:e.runId}).catch(()=>{})});q.on("webhook-inbox-event",e=>{if(e){let t=O.getState().currentProjectId;if(!e.projectId||!t||e.projectId===t){let s=O.getState().webhookInbox;O.setState({webhookInbox:{...s,events:[...s.events,e]}})}}});q.on("webhook-control-changed",e=>{if(e){let t=O.getState().webhookInbox;O.setState({webhookInbox:{...t,controlAction:e.action}})}});q.on("webhook-inbox-cleared",()=>{let e=O.getState().webhookInbox;O.setState({webhookInbox:{...e,events:[]}}),pr=null});function Rx(e){if(!(e?.capabilities||[]).includes("multi-project")){q.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:null}}),H_();return}fetch("/api/projects").then(i=>i.json()).then(i=>{let r=i.projects||[];O.setState({projects:r});let o=I.projectId||(r.length===1?r[0].name:null);O.setState({currentProjectId:o}),q.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:o}}),H_()}).catch(()=>{})}function X_(){let e=O.getState().projects||[];Promise.all(e.map(t=>fetch(`/api/projects/${t.name}/runs`).then(s=>s.json()).then(s=>({runs:(s.runs||[]).map(i=>({...i,project:i.project||t.name})),settings:s.settings||null,projectName:t.name})).catch(()=>({runs:[],settings:null,projectName:t.name})))).then(t=>{let s={},i={},r=Date.now();for(let{runs:o,settings:n}of t){n&&(Xs=n);for(let a of o)if(a.archived){if(Wn(a,r))continue;i[a.id]=a}else s[a.id]=a}O.setState({runs:s,archivedRuns:i,runsLoaded:!0}),z()})}function An(){let e=O.getState().projects||[],t=O.getState().currentProjectId,s=t?[t]:e.length>1?e.map(r=>r.name):[];if(s.length===0){O.setState({worktrees:[]});return}let i=s.map(r=>fetch(`/api/projects/${r}/worktrees`).then(o=>o.json()).then(o=>(o.worktrees||[]).map(n=>({...n,project:r}))).catch(()=>[]));Promise.all(i).then(r=>{O.setState({worktrees:r.flat()})})}function H_(){(O.getState().projects||[]).length>1?X_():q.send("list-runs").then(e=>{e.settings&&(Xs=e.settings),O.setRunsBulk(e.runs||[])}).catch(()=>{}),q.send("list-beads-issues").then(e=>{O.setState({beads:{issues:e.issues||[],dbExists:e.dbExists??!1,dbPath:e.dbPath||null,loading:!1}})}).catch(()=>{}),q.send("get-webhook-inbox").then(e=>{O.setState({webhookInbox:{events:e.events||[],controlAction:e.controlAction||"continue"}})}).catch(()=>{}),Pd(),Md(),An(),I.runId&&(I.section!=="beads"&&(q.send("subscribe-run",{runId:I.runId}).catch(()=>{}),q.send("subscribe-log",{stage:Tt==="*"?null:Tt,runId:I.runId}).catch(()=>{})),yl(I.runId),I.section==="beads"&&Bd(I.runId))}q.on("hello",Rx);q.on("projects-updated",e=>{e?.projects&&O.setState({projects:e.projects})});function Dx(e){q.send("unsubscribe-run").catch(()=>{}),q.send("unsubscribe-log").catch(()=>{}),q.send("unsubscribe-events").catch(()=>{}),O.clearLog(),O.setState({currentProjectId:e,runs:{},archivedRuns:{},logLines:[],activeRunId:null,runsLoaded:!1,worktrees:[]}),wd="",Dn=null,Ln=!1,to=!1,Ex(),q.sendRaw({type:"hello-ack",payload:{protocol:2,projectId:e}}),(O.getState().projects||[]).length>1?X_():q.send("list-runs").then(t=>{t.settings&&(Xs=t.settings),O.setRunsBulk(t.runs||[])}).catch(()=>{}),q.send("list-beads-issues").then(t=>{O.setState({beads:{issues:t.issues||[],dbExists:t.dbExists??!1,dbPath:t.dbPath||null,loading:!1}})}).catch(()=>{}),O.setState({webhookInbox:{events:[],controlAction:O.getState().webhookInbox?.controlAction||"continue"}}),q.send("get-webhook-inbox").then(t=>{O.setState({webhookInbox:{events:t.events||[],controlAction:t.controlAction||"continue"}})}).catch(()=>{}),Pd(),Md(),An()}q.onConnection(e=>{U_=e,e==="open"&&q.send("get-preferences").then(t=>{O.setState({preferences:t}),bo(t.theme||"light")}).catch(()=>{}),z()});Xd(e=>{let t=I.runId,s=I.projectId;I=e,e.projectId!==s&&Dx(e.projectId),t&&t!==I.runId&&(_l.clear(),q.send("unsubscribe-run").catch(()=>{}),q.send("unsubscribe-log").catch(()=>{}),O.clearLog(),Mr(),mh()),I.runId&&I.runId!==t&&(I.section==="beads"?Bd(I.runId):(Tt="*",$i=null,q.send("subscribe-run",{runId:I.runId}).catch(()=>{}),q.send("subscribe-log",{stage:null,runId:I.runId}).catch(()=>{}),yl(I.runId))),I.section==="settings"?(_i(null).then(()=>z()),q_()):K_(),I.section==="project-settings"&&_i(O.getState().currentProjectId||null).then(()=>z()),I.section==="costs"&&(vl=!1,J_()),!I.runId&&t&&(Qf(),wf()),z()});function Lx(e){st(e,null,I.projectId)}function Sn(e){st(I.section,e,I.projectId)}function Px(e){e?st(I.section,null,e):st("dashboard",null,null)}function Bx(){let t=O.getState().preferences.theme==="dark"?"light":"dark";q.send("set-preferences",{theme:t}).catch(()=>{}),O.setState({preferences:{theme:t}}),bo(t)}function Mx(e){q.send("set-preferences",{notifications:e}).catch(()=>{}),O.setState({preferences:{notifications:e}})}function Ix(e){q.send("set-preferences",{source_repo:e}).catch(()=>{}),O.setState({preferences:{source_repo:e}})}function Ox(e){if(Tt=e,e!=="*"){let i=O.getRunById(I.runId)?.stages?.[e]?.iterations?.length||0;$i=i>0?i:null}else $i=null;Mr(),O.clearLog(),q.send("unsubscribe-log").catch(()=>{}),q.send("subscribe-log",{stage:e==="*"?null:e,runId:I.runId,iteration:$i}).catch(()=>{}),z()}function zx(e){$i=e,Mr(),O.clearLog(),q.send("unsubscribe-log").catch(()=>{}),q.send("subscribe-log",{stage:Tt==="*"?null:Tt,runId:I.runId,iteration:e}).catch(()=>{}),z()}function Nx(e){fl=e,em(e)}function Fx(){yd=!yd,z()}function _e(e){Ei=e,z(),requestAnimationFrame(()=>{let t=document.getElementById("action-error-dialog");t&&t.show()})}function Hx(){Ei=null,z()}function Wx(){wt({label:"Stop Pipeline?",message:"Are you sure? The current stage will be interrupted and marked as error.",confirmLabel:"Stop",confirmVariant:"danger",onConfirm:jx},z)}async function jx(){Fe="stopping",Ei=null,z();try{let t=Object.values(O.getState().runs).find(r=>r.active)?.id||"current",i=await(await fetch(Qt(`/runs/${t}/stop`),{method:"POST"})).json();i.ok||(Fe=null,_e(i.error||"Failed to stop pipeline"))}catch(e){Fe=null,_e(e?.message||"Failed to stop pipeline")}}function Vx(){Fe="resuming",Ei=null,z(),q.send("resume-run",{runId:I.runId}).then(()=>{Fe=null,z()}).catch(e=>{Fe=null,_e(e?.message||"Failed to resume pipeline")})}async function Ux(){let t=Object.values(O.getState().runs).find(s=>s.active)?.id||"current";Fe="pausing",Ei=null,z();try{let i=await(await fetch(Qt(`/runs/${t}/pause`),{method:"POST"})).json();i.ok||(Fe=null,_e(i.error||"Failed to pause pipeline"))}catch(s){Fe=null,_e(s?.message||"Failed to pause pipeline")}}async function Sd(e){hs={action:"pause",runId:e},z();try{let s=await(await fetch(Qt(`/runs/${e}/pause`),{method:"POST"})).json();s.ok||_e(s.error||"Failed to pause run")}catch(t){_e(t?.message||"Failed to pause run")}finally{hs=null,z()}}async function ul(e){hs={action:"resume",runId:e},z();try{await q.send("resume-run",{runId:e})}catch(t){_e(t?.message||"Failed to resume run")}finally{hs=null,z()}}function pl(e){wt({label:"Stop Pipeline?",message:"Are you sure? The current stage will be interrupted and marked as error.",confirmLabel:"Stop",confirmVariant:"danger",onConfirm:async()=>{hs={action:"stop",runId:e},z();try{let t=await fetch(Qt(`/runs/${e}/stop`),{method:"POST"}),s=await t.json();t.status===409&&s.code==="no_running_process"?_e("Process is no longer running. Use Cancel to force the run into cancelled state."):s.ok||_e(s.error||"Failed to stop run")}catch(t){_e(t?.message||"Failed to stop run")}finally{hs=null,z()}}},z)}function kn(e){wt({label:"Cancel Pipeline?",message:"This will permanently cancel the run. Any running process will be terminated and the pipeline cannot be resumed.",confirmLabel:"Cancel Run",confirmVariant:"danger",onConfirm:async()=>{hs={action:"cancel",runId:e},z();try{let s=await(await fetch(Qt(`/runs/${e}/cancel`),{method:"POST"})).json();s.ok||_e(s.error||"Failed to cancel run")}catch(t){_e(t?.message||"Failed to cancel run")}finally{hs=null,z()}}},z)}async function qx(e){try{let t=await fetch(Qt(`/runs/${e}/control`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"approve",source:"ui-pr-approval"})});if(t.status===404){_e("This run has already finished. Refreshing...");return}if(t.status===409){_e("This run is no longer awaiting approval.");return}t.ok||_e("Could not deliver decision; try again.")}catch{_e("Could not deliver decision; try again.")}}async function Kx(e){try{let t=await fetch(Qt(`/runs/${e}/control`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reject",source:"ui-pr-approval"})});if(t.status===404){_e("This run has already finished. Refreshing...");return}if(t.status===409){_e("This run is no longer awaiting approval.");return}t.ok||_e("Could not deliver decision; try again.")}catch{_e("Could not deliver decision; try again.")}}var{archiveRun:bd,unarchiveRun:Gx}=Qd({showConfirm:wt,showActionError:_e,projectUrl:Qt,store:O,rerender:z});function Yx(e){Dn=e,Ln=!1,to=!1,z()}function Xx(){Dn=null,Ln=!0,to=!1,z()}function Cd(){Dn=null,Ln=!1,to=!1,z()}async function W_(e,t){let s=Qt(`/worktrees/${encodeURIComponent(e)}${t?"?force=1":""}`),i=await fetch(s,{method:"DELETE"}),r=null;try{r=await i.json()}catch{}if(!i.ok||!r?.ok)throw new Error(r?.error||`Cleanup failed (HTTP ${i.status})`)}async function Jx(e,t){if(e===null){let s=(O.getState().worktrees||[]).filter(r=>r.status==="completed");Cd();let i=[];for(let r of s)try{await W_(r.run_id,!1)}catch(o){i.push(`${r.title||r.run_id}: ${o.message}`)}An(),i.length>0&&_e(`Cleanup completed with ${i.length} failure(s):
6778
6792
  ${i.join(`
6779
- `)}`);return}Cd();try{await H_(e,!!t),An()}catch(s){_e(s?.message||"Cleanup failed")}}function Xx(e){$n=e,wt({label:"Restart Stage?",message:`Restart the "${e}" stage? The pipeline will resume from this point.`,confirmLabel:"Restart",confirmVariant:"warning",onConfirm:Jx,onCancel:()=>{$n=null}},z)}async function Jx(){let e=$n;$n=null,z();try{let s=Object.values(O.getState().runs).find(o=>!o.active)?.id||"current",r=await(await fetch(Qt(`/runs/${s}/stages/${e}/restart`),{method:"POST"})).json();r.ok?st("active",null,I.projectId):_e(r.error||"Failed to restart stage")}catch(t){_e(t?.message||"Failed to restart stage")}}function Zx(){I.runId?st(I.section,null,I.projectId):I.section&&I.section!=="dashboard"&&st("dashboard",null,I.projectId)}function Qx(e){xd=e,z()}function ek(e){kd=e,z()}async function tk(e){Cn=e,En=null,z();try{await q.send("start-beads-issue",{issueId:e}),Cn=null,st("active",null,I.projectId)}catch(t){Cn=null,En=t?.message||"Failed to start pipeline",z()}}function sk(){En=null,z()}function Pd(){q.send("list-beads-counts").then(e=>{Ed=e.counts||{},z()}).catch(()=>{})}function Bd(e){xn=!0,z(),q.send("list-beads-by-run",{runId:e}).then(t=>{Td=t.issues||[],xn=!1,z()}).catch(()=>{xn=!1,z()})}function X_(){fetch(Qt("/costs")).then(e=>e.json()).then(e=>{e.ok&&(Ad=e.tokenData||{},vl=!0,z())}).catch(()=>{})}function Md(){let e=O.getState().currentProjectId,t=e?`/api/projects/${e}/info`:"/api/project-info";fetch(t).then(s=>s.json()).then(s=>{let i=s.project?.name??s.name;i!==void 0&&(O.setState({projectName:i}),document.title=eu(i))}).catch(()=>{})}function ik(e){ml=ml===e?null:e,z()}function rk(e){pr=pr===e?null:e,z()}function ok(e){Rd=e,z()}function nk(e){Dd=e,z()}function ak(e){Ld=e,z()}function lk(e){q.send("set-webhook-control",{action:e}).catch(()=>{})}function J_(){q.send("clear-webhook-inbox").catch(()=>{}),pr=null}function ck(e){try{navigator.clipboard.writeText(JSON.stringify(e.envelope,null,2))}catch{}}function hk(){pr=null,z()}function dk(){let t=O.getRunById(I.runId)?.stages?.learn?.status;if(t==="completed"||t==="error"){wt({label:"Re-run Learning Analysis?",message:"This will replace existing learnings. Continue?",confirmLabel:"Re-run",confirmVariant:"warning",onConfirm:W_},z);return}W_()}async function W_(){z();try{let e=I.runId,s=await(await fetch(Qt(`/runs/${e}/learn`),{method:"POST"})).json();if(!s.ok)_e(s.error||"Failed to run learning analysis");else{let i=O.getRunById(e);if(i){let r=new Date().toISOString();O.setRun(e,{...i,stages:{...i.stages||{},learn:{status:"in_progress",pid:s.pid,started_at:r,iterations:[{number:1,status:"in_progress",started_at:r,trigger:"manual"}]}}})}}}catch(e){_e(e?.message||"Failed to run learning analysis")}}function uk(){let e=O.getState(),t="Dashboard",s=!1,i=null,r=null;if(I.section==="beads"&&I.runId){let a=(O.getRunById(I.runId)?.work_request?.title||I.runId).split(`
6793
+ `)}`);return}Cd();try{await W_(e,!!t),An()}catch(s){_e(s?.message||"Cleanup failed")}}function Zx(e){$n=e,wt({label:"Restart Stage?",message:`Restart the "${e}" stage? The pipeline will resume from this point.`,confirmLabel:"Restart",confirmVariant:"warning",onConfirm:Qx,onCancel:()=>{$n=null}},z)}async function Qx(){let e=$n;$n=null,z();try{let s=Object.values(O.getState().runs).find(o=>!o.active)?.id||"current",r=await(await fetch(Qt(`/runs/${s}/stages/${e}/restart`),{method:"POST"})).json();r.ok?st("active",null,I.projectId):_e(r.error||"Failed to restart stage")}catch(t){_e(t?.message||"Failed to restart stage")}}function ek(){I.runId?st(I.section,null,I.projectId):I.section&&I.section!=="dashboard"&&st("dashboard",null,I.projectId)}function tk(e){xd=e,z()}function sk(e){kd=e,z()}async function ik(e){Cn=e,En=null,z();try{await q.send("start-beads-issue",{issueId:e}),Cn=null,st("active",null,I.projectId)}catch(t){Cn=null,En=t?.message||"Failed to start pipeline",z()}}function rk(){En=null,z()}function Pd(){q.send("list-beads-counts").then(e=>{Ed=e.counts||{},z()}).catch(()=>{})}function Bd(e){xn=!0,z(),q.send("list-beads-by-run",{runId:e}).then(t=>{Td=t.issues||[],xn=!1,z()}).catch(()=>{xn=!1,z()})}function J_(){fetch(Qt("/costs")).then(e=>e.json()).then(e=>{e.ok&&(Ad=e.tokenData||{},vl=!0,z())}).catch(()=>{})}function Md(){let e=O.getState().currentProjectId,t=e?`/api/projects/${e}/info`:"/api/project-info";fetch(t).then(s=>s.json()).then(s=>{let i=s.project?.name??s.name;i!==void 0&&(O.setState({projectName:i}),document.title=eu(i))}).catch(()=>{})}function ok(e){ml=ml===e?null:e,z()}function nk(e){pr=pr===e?null:e,z()}function ak(e){Rd=e,z()}function lk(e){Dd=e,z()}function ck(e){Ld=e,z()}function hk(e){q.send("set-webhook-control",{action:e}).catch(()=>{})}function Z_(){q.send("clear-webhook-inbox").catch(()=>{}),pr=null}function dk(e){try{navigator.clipboard.writeText(JSON.stringify(e.envelope,null,2))}catch{}}function uk(){pr=null,z()}function pk(){let t=O.getRunById(I.runId)?.stages?.learn?.status;if(t==="completed"||t==="error"){wt({label:"Re-run Learning Analysis?",message:"This will replace existing learnings. Continue?",confirmLabel:"Re-run",confirmVariant:"warning",onConfirm:j_},z);return}j_()}async function j_(){z();try{let e=I.runId,s=await(await fetch(Qt(`/runs/${e}/learn`),{method:"POST"})).json();if(!s.ok)_e(s.error||"Failed to run learning analysis");else{let i=O.getRunById(e);if(i){let r=new Date().toISOString();O.setRun(e,{...i,stages:{...i.stages||{},learn:{status:"in_progress",pid:s.pid,started_at:r,iterations:[{number:1,status:"in_progress",started_at:r,trigger:"manual"}]}}})}}}catch(e){_e(e?.message||"Failed to run learning analysis")}}function fk(){let e=O.getState(),t="Dashboard",s=!1,i=null,r=null;if(I.section==="beads"&&I.runId){let a=(O.getRunById(I.runId)?.work_request?.title||I.runId).split(`
6780
6794
  `)[0];t=a.length>80?`${a.slice(0,80)}\u2026`:a,s=!0}else if(I.section==="beads"&&!I.runId){t="Beads Issues",s=!0;let o=e.beads?.dbPath;o&&(r=u`<span class="beads-db-path">${E(R(Ml,12))} Beads DB<br><code>${o}</code></span>`)}else if(I.runId){let o=O.getRunById(I.runId),a=(o?.work_request?.title||"Pipeline Details").split(`
6781
6795
  `)[0];if(t=a.length>80?`${a.slice(0,80)}\u2026`:a,s=!0,o){let c=o.pipeline_status||(o.active?"running":"completed"),h={running:"primary",paused:"warning",completed:"success",failed:"danger",cancelled:"neutral",interrupted:"warning"}[c]||"neutral",d=c.charAt(0).toUpperCase()+c.slice(1);if(i=u`<sl-badge variant="${h}" pill>
6782
6796
  ${E(Rt(c,12))}
@@ -6793,11 +6807,11 @@ ${i.join(`
6793
6807
  <button class="action-btn action-btn--primary" disabled>
6794
6808
  ${E(R(Pe,14,"icon-spin"))}
6795
6809
  Resuming\u2026
6796
- </button>`;else{let m=it("pause",c)?u`<button class="action-btn action-btn--amber" @click=${jx}>
6810
+ </button>`;else{let m=it("pause",c)?u`<button class="action-btn action-btn--amber" @click=${Ux}>
6797
6811
  ${E(R(St,14))} Pause
6798
- </button>`:b,p=it("stop",c)?u`<button class="action-btn action-btn--danger" @click=${Fx}>
6812
+ </button>`:b,p=it("stop",c)?u`<button class="action-btn action-btn--danger" @click=${Wx}>
6799
6813
  ${E(R(ti,14))} Stop
6800
- </button>`:b,f=it("resume",c)?u`<button class="action-btn action-btn--primary" @click=${Wx}>
6814
+ </button>`:b,f=it("resume",c)?u`<button class="action-btn action-btn--primary" @click=${Vx}>
6801
6815
  ${E(R(Mi,14))} Resume
6802
6816
  </button>`:b,_=p===b&&it("cancel",c)?u`<button class="action-btn action-btn--danger" @click=${()=>kn(o.id)}>
6803
6817
  ${E(R(ti,14))} Cancel
@@ -6828,7 +6842,7 @@ ${i.join(`
6828
6842
  ${E(R(Mi,14))}
6829
6843
  ${o.isSubmitting?"Starting\u2026":"Start"}
6830
6844
  </button>`}else I.section==="webhooks"?(t="Webhook Inbox",s=!0,(e.webhookInbox?.events||[]).length>0&&(r=u`
6831
- <button class="action-btn action-btn--danger" @click=${J_}>
6845
+ <button class="action-btn action-btn--danger" @click=${Z_}>
6832
6846
  ${E(R(At,14))}
6833
6847
  Clear
6834
6848
  </button>`)):I.section==="costs"?(t="Token & Cost Dashboard",s=!0):I.section==="settings"?(t="Settings",s=!0):I.section==="project-settings"&&(t="Project Settings",s=!0);return!I.section&&!I.runId&&(r=u`
@@ -6838,7 +6852,7 @@ ${i.join(`
6838
6852
  </button>`),u`
6839
6853
  <div class="content-header">
6840
6854
  ${s?u`
6841
- <button class="content-header-back" @click=${Zx}>
6855
+ <button class="content-header-back" @click=${ek}>
6842
6856
  ${E(R(Ll,18))}
6843
6857
  </button>
6844
6858
  `:""}
@@ -6848,7 +6862,7 @@ ${i.join(`
6848
6862
  ${r}
6849
6863
  </div>`:""}
6850
6864
  </div>
6851
- `}function pk(){let e=O.getState(),t=Object.values(e.runs),s=e.currentProjectId,i=s&&(e.projects||[]).length>1?t.filter(l=>(l.project||l._project)===s):t,r={};for(let l of i)r[l.id]=l;let o=Object.values(e.archivedRuns),n=s&&(e.projects||[]).length>1?o.filter(l=>(l.project||l._project)===s):o,a={};for(let l of n)a[l.id]=l;let c={...e,runs:r,archivedRuns:a};if(I.section==="beads")return I.runId?hu(Td,{statusFilter:xd,priorityFilter:kd,starting:Cn,startError:En,onStatusFilter:Qx,onPriorityFilter:ek,onStartIssue:tk,onDismissError:sk,loading:xn,run:O.getRunById(I.runId),runId:I.runId}):cu(i,{onSelectRun:Sn,beadsCounts:Ed});if(I.runId){let l=O.getRunById(I.runId);if(!l&&e.runsLoaded&&s&&(e.projects||[]).length>1)return st(I.section,null,I.projectId),u``;let h={};if(l?.stages){for(let[w,k]of Object.entries(l.stages)){let $=k.iterations||[];$.length>0&&(h[w]=$.length)}Ex(I.runId,l.stages)}let d=fk(e);d.currentLogStage=Tt==="*"?null:Tt,d.currentLogIteration=$i;let m=!!l?.active,p=gh();l&&!p&&Ta(l);let{overview:f,stages:_}=Pm(l,Xs,{promptCache:$s[I.runId]||{},onRestartStage:Xx,stageIterationTab:_l,onStageTabChange:$x});return u`
6865
+ `}function mk(){let e=O.getState(),t=Object.values(e.runs),s=e.currentProjectId,i=s&&(e.projects||[]).length>1?t.filter(l=>(l.project||l._project)===s):t,r={};for(let l of i)r[l.id]=l;let o=Object.values(e.archivedRuns),n=s&&(e.projects||[]).length>1?o.filter(l=>(l.project||l._project)===s):o,a={};for(let l of n)a[l.id]=l;let c={...e,runs:r,archivedRuns:a};if(I.section==="beads")return I.runId?hu(Td,{statusFilter:xd,priorityFilter:kd,starting:Cn,startError:En,onStatusFilter:tk,onPriorityFilter:sk,onStartIssue:ik,onDismissError:rk,loading:xn,run:O.getRunById(I.runId),runId:I.runId}):cu(i,{onSelectRun:Sn,beadsCounts:Ed});if(I.runId){let l=O.getRunById(I.runId);if(!l&&e.runsLoaded&&s&&(e.projects||[]).length>1)return st(I.section,null,I.projectId),u``;let h={};if(l?.stages){for(let[w,k]of Object.entries(l.stages)){let $=k.iterations||[];$.length>0&&(h[w]=$.length)}Ax(I.runId,l.stages)}let d=gk(e);d.currentLogStage=Tt==="*"?null:Tt,d.currentLogIteration=$i;let m=!!l?.active,p=gh();l&&!p&&Ta(l);let{overview:f,stages:_}=Bm(l,Xs,{promptCache:$s[I.runId]||{},onRestartStage:Zx,stageIterationTab:_l,onStageTabChange:Tx});return u`
6852
6866
  <div class="run-detail run-detail-layout">
6853
6867
  <div class="run-detail-layout__overview">
6854
6868
  ${f}
@@ -6859,14 +6873,14 @@ ${i.join(`
6859
6873
  </div>
6860
6874
  <div class="run-detail-layout__logs">
6861
6875
  <div class="run-detail-column-header">Artifacts</div>
6862
- ${Dm(l,{onApprove:Vx,onReject:Ux})}
6876
+ ${Lm(l,{onApprove:qx,onReject:Kx})}
6863
6877
  ${Cf(gh(),m)}
6864
- ${sm(d,{onStageFilter:Mx,onIterationFilter:Ix,onSearch:Ox,onToggleAutoScroll:zx,autoScroll:yd,stageIterations:h,runStages:l?.stages})}
6865
- ${Lm($d.get(I.runId))}
6866
- ${fu(l?.stages?.learn,{onRunLearn:it("learn",l?.pipeline_status)?dk:null})}
6878
+ ${sm(d,{onStageFilter:Ox,onIterationFilter:zx,onSearch:Nx,onToggleAutoScroll:Fx,autoScroll:yd,stageIterations:h,runStages:l?.stages})}
6879
+ ${Pm($d.get(I.runId))}
6880
+ ${fu(l?.stages?.learn,{onRunLearn:it("learn",l?.pipeline_status)?pk:null})}
6867
6881
  </div>
6868
6882
  </div>
6869
- `}if(I.section==="webhooks")return jm(e,{selectedId:pr,categoryFilter:Rd,runFilter:Dd,searchTerm:Ld,onSelectEvent:rk,onCategoryFilter:ok,onRunFilter:nk,onSearch:ak,onSetControl:lk,onClear:J_,onCopyJson:ck,onDismissDetail:hk});if(I.section==="costs")return vl||X_(),Nm(c,{expandedRun:ml,tokenData:Ad,onToggleRun:ik});if(I.section==="new-run")return wm(c,{rerender:z});if(I.section==="project-settings")return gm(e.preferences,{rerender:z,currentProjectId:e.currentProjectId||null});if(I.section==="settings")return Tn===null&&bl(),mm(e.preferences,{rerender:z,onThemeToggle:Lx,onSaveSourceRepo:Bx,onSaveNotifications:Px,onRequestPermission:()=>Rn.requestPermission(),globals:{worktreeDiskWarningBytes:e.worktreeDiskWarningBytes,classifierModel:e.classifierModel,cleanupPolicy:e.cleanupPolicy,maxConcurrentPipelines:e.maxConcurrentPipelines},onSaveGlobals:l=>O.setState(l),projects:e.projects||[],integrations:{status:Tn,config:gl,editingAdapter:ur,forms:Object.fromEntries(["telegram","discord","slack"].map(l=>[l,so(l)]))},onIgStartEdit:_x,onIgCancelEdit:vx,onIgFieldChange:bx,onIgEventToggle:yx,onIgSave:wx,onIgRemove:Sx,onIgDetect:xx,onIgToggleEnabled:Cx,onProjectAdd:l=>{l?.openDialog?(O.setState({addProjectDialogOpen:!0}),z()):(Array.isArray(l)||l?.name)&&fetch("/api/projects").then(h=>h.json()).then(h=>{O.setState({projects:h.projects||[]}),z()}).catch(()=>{})},onProjectRemove:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{O.setState({projects:l.projects||[]}),z()}).catch(()=>{})},onProjectsRefresh:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{O.setState({projects:l.projects||[]}),z()}).catch(()=>{})}});if(I.section==="history")return Bm(i,"history",{onSelectRun:Sn,onResume:ul,onStop:pl,onCancel:kn,onArchive:bd,onUnarchive:qx,archivedRuns:n,statusFilter:dl,runsLoaded:O.getState().runsLoaded,onStatusFilter:l=>{dl=l,z()}});if(I.section==="worktrees")return Vm(e.worktrees||[],{diskWarningBytes:e.worktreeDiskWarningBytes,filter:wd,onFilter:l=>{wd=l,z()},onSelectRun:Sn,onCleanup:Kx,onBulkCleanup:Gx,dialogItem:Dn,dialogBulk:Ln,dialogCheckbox:to,onDialogClose:Cd,onDialogConfirm:Yx,onDialogCheckboxChange:l=>{to=l,z()}});if(I.section==="active"){let l=ft(i.filter(h=>h.active));return u`
6883
+ `}if(I.section==="webhooks")return Vm(e,{selectedId:pr,categoryFilter:Rd,runFilter:Dd,searchTerm:Ld,onSelectEvent:nk,onCategoryFilter:ak,onRunFilter:lk,onSearch:ck,onSetControl:hk,onClear:Z_,onCopyJson:dk,onDismissDetail:uk});if(I.section==="costs")return vl||J_(),Fm(c,{expandedRun:ml,tokenData:Ad,onToggleRun:ok});if(I.section==="new-run")return wm(c,{rerender:z});if(I.section==="project-settings")return gm(e.preferences,{rerender:z,currentProjectId:e.currentProjectId||null});if(I.section==="settings")return Tn===null&&bl(),mm(e.preferences,{rerender:z,onThemeToggle:Bx,onSaveSourceRepo:Ix,onSaveNotifications:Mx,onRequestPermission:()=>Rn.requestPermission(),globals:{worktreeDiskWarningBytes:e.worktreeDiskWarningBytes,classifierModel:e.classifierModel,cleanupPolicy:e.cleanupPolicy,maxConcurrentPipelines:e.maxConcurrentPipelines},onSaveGlobals:l=>O.setState(l),projects:e.projects||[],integrations:{status:Tn,config:gl,editingAdapter:ur,forms:Object.fromEntries(["telegram","discord","slack"].map(l=>[l,so(l)]))},onIgStartEdit:bx,onIgCancelEdit:yx,onIgFieldChange:wx,onIgEventToggle:Sx,onIgSave:Cx,onIgRemove:xx,onIgDetect:$x,onIgToggleEnabled:kx,onProjectAdd:l=>{l?.openDialog?(O.setState({addProjectDialogOpen:!0}),z()):(Array.isArray(l)||l?.name)&&fetch("/api/projects").then(h=>h.json()).then(h=>{O.setState({projects:h.projects||[]}),z()}).catch(()=>{})},onProjectRemove:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{O.setState({projects:l.projects||[]}),z()}).catch(()=>{})},onProjectsRefresh:()=>{fetch("/api/projects").then(l=>l.json()).then(l=>{O.setState({projects:l.projects||[]}),z()}).catch(()=>{})}});if(I.section==="history")return Mm(i,"history",{onSelectRun:Sn,onResume:ul,onStop:pl,onCancel:kn,onArchive:bd,onUnarchive:Gx,archivedRuns:n,statusFilter:dl,runsLoaded:O.getState().runsLoaded,onStatusFilter:l=>{dl=l,z()}});if(I.section==="worktrees")return Um(e.worktrees||[],{diskWarningBytes:e.worktreeDiskWarningBytes,filter:wd,onFilter:l=>{wd=l,z()},onSelectRun:Sn,onCleanup:Yx,onBulkCleanup:Xx,dialogItem:Dn,dialogBulk:Ln,dialogCheckbox:to,onDialogClose:Cd,onDialogConfirm:Jx,onDialogCheckboxChange:l=>{to=l,z()}});if(I.section==="active"){let l=ft(i.filter(h=>h.active));return u`
6870
6884
  <h3 class="dashboard-section-title">Active Runs</h3>
6871
6885
  ${l.length>0?u`
6872
6886
  <div class="active-group">
@@ -6877,17 +6891,17 @@ ${i.join(`
6877
6891
  `:u`<div class="empty-state">No running pipelines</div>`}
6878
6892
  `}return u`
6879
6893
  ${du(c,{onSelectRun:l=>st("active",l,I.projectId),onArchive:bd,onNavigate:(l,h,d)=>{h&&typeof h=="object"&&h.statusFilter?(dl=h.statusFilter,st(l,null,I.projectId)):st(l,h||null,d||I.projectId)},onPause:Sd,onResume:ul,onStop:pl,onCancel:kn})}
6880
- `}function fk(e){let t=e.logLines;if(Tt!=="*"&&(t=t.filter(s=>s.stage===Tt)),fl){let s=fl.toLowerCase();t=t.filter(i=>(i.line||"").toLowerCase().includes(s))}return{...e,logLines:t}}function z(){let e=O.getState(),t=document.getElementById("app");t&&(Fn(u`
6894
+ `}function gk(e){let t=e.logLines;if(Tt!=="*"&&(t=t.filter(s=>s.stage===Tt)),fl){let s=fl.toLowerCase();t=t.filter(i=>(i.line||"").toLowerCase().includes(s))}return{...e,logLines:t}}function z(){let e=O.getState(),t=document.getElementById("app");t&&(Fn(u`
6881
6895
  <div class="app-shell">
6882
- ${Mm(e,I,V_,{onNavigate:Rx,onSelectRun:Sn,onProjectChange:Dx,onAddProject:()=>{O.setState({addProjectDialogOpen:!0}),z()}})}
6896
+ ${Im(e,I,U_,{onNavigate:Lx,onSelectRun:Sn,onProjectChange:Px,onAddProject:()=>{O.setState({addProjectDialogOpen:!0}),z()}})}
6883
6897
  <main class="main-content">
6884
6898
  ${Rn.renderBanner()}
6885
- ${uk()}
6886
- ${pk()}
6899
+ ${fk()}
6900
+ ${mk()}
6887
6901
  </main>
6888
6902
  </div>
6889
6903
  ${Ei?u`
6890
- <sl-dialog id="action-error-dialog" label="Pipeline Error" @sl-after-hide=${Nx}>
6904
+ <sl-dialog id="action-error-dialog" label="Pipeline Error" @sl-after-hide=${Hx}>
6891
6905
  <div class="error-dialog-body">
6892
6906
  ${E(R(br,32,"error-dialog-icon"))}
6893
6907
  <p>${Ei}</p>
@@ -6898,5 +6912,5 @@ ${i.join(`
6898
6912
  ${uo()}
6899
6913
  ${iu(z)}
6900
6914
  ${su(e,{onProjectAdd:s=>{O.setState({addProjectDialogOpen:!1}),fetch("/api/projects").then(i=>i.json()).then(i=>{O.setState({projects:i.projects||[]}),z()}).catch(()=>{})},onClose:()=>{O.setState({addProjectDialogOpen:!1}),z()},rerender:z})}
6901
- `,t),I.runId&&(Tt!=="*"&&tm(I.runId),Sf(I.runId)))}var j_=!1;function mk(){if(j_)return;let e=document.querySelector(".main-content");e&&(e.addEventListener("scroll",()=>{let t=e.querySelector(".content-header");t&&t.classList.toggle("content-header--scrolled",e.scrollTop>10)},{passive:!0}),j_=!0)}Rn.setRerender(z);O.subscribe(()=>z());bo(O.getState().preferences.theme);I.projectId&&O.setState({currentProjectId:I.projectId});Md();Promise.all([fetch("/api/preferences").then(e=>e.ok?e.json():null).catch(()=>null),fetch("/api/status/runs-count").then(e=>e.ok?e.json():null).catch(()=>null)]).then(([e,t])=>{let s={};if(e?.ok){let i=e.preferences?.worca??{};i.ui?.worktree_disk_warning_bytes!=null&&(s.worktreeDiskWarningBytes=i.ui.worktree_disk_warning_bytes),i.circuit_breaker?.classifier_model!=null&&(s.classifierModel=i.circuit_breaker.classifier_model),i.parallel?.cleanup_policy!=null&&(s.cleanupPolicy=i.parallel.cleanup_policy),i.parallel?.max_concurrent_pipelines!=null&&(s.maxConcurrentPipelines=i.parallel.max_concurrent_pipelines)}t?.ok&&typeof t.totalRunning=="number"&&(s.totalRunning=t.totalRunning),Object.keys(s).length>0&&O.setState(s)});I.section==="settings"&&(_i(null).then(()=>z()),U_());I.section==="project-settings"&&_i(O.getState().currentProjectId||null).then(()=>z());setInterval(()=>{fetch("/api/status/runs-count").then(e=>e.ok?e.json():null).then(e=>{if(e?.ok&&typeof e.totalRunning=="number"){let t={totalRunning:e.totalRunning};typeof e.cap=="number"&&(t.maxConcurrentPipelines=e.cap),O.setState(t)}}).catch(()=>{})},5e3);z();mk();
6915
+ `,t),I.runId&&(Tt!=="*"&&tm(I.runId),Sf(I.runId)))}var V_=!1;function _k(){if(V_)return;let e=document.querySelector(".main-content");e&&(e.addEventListener("scroll",()=>{let t=e.querySelector(".content-header");t&&t.classList.toggle("content-header--scrolled",e.scrollTop>10)},{passive:!0}),V_=!0)}Rn.setRerender(z);O.subscribe(()=>z());bo(O.getState().preferences.theme);I.projectId&&O.setState({currentProjectId:I.projectId});Md();Promise.all([fetch("/api/preferences").then(e=>e.ok?e.json():null).catch(()=>null),fetch("/api/status/runs-count").then(e=>e.ok?e.json():null).catch(()=>null)]).then(([e,t])=>{let s={};if(e?.ok){let i=e.preferences?.worca??{};i.ui?.worktree_disk_warning_bytes!=null&&(s.worktreeDiskWarningBytes=i.ui.worktree_disk_warning_bytes),i.circuit_breaker?.classifier_model!=null&&(s.classifierModel=i.circuit_breaker.classifier_model),i.parallel?.cleanup_policy!=null&&(s.cleanupPolicy=i.parallel.cleanup_policy),i.parallel?.max_concurrent_pipelines!=null&&(s.maxConcurrentPipelines=i.parallel.max_concurrent_pipelines)}t?.ok&&typeof t.totalRunning=="number"&&(s.totalRunning=t.totalRunning),Object.keys(s).length>0&&O.setState(s)});I.section==="settings"&&(_i(null).then(()=>z()),q_());I.section==="project-settings"&&_i(O.getState().currentProjectId||null).then(()=>z());setInterval(()=>{fetch("/api/status/runs-count").then(e=>e.ok?e.json():null).then(e=>{if(e?.ok&&typeof e.totalRunning=="number"){let t={totalRunning:e.totalRunning};typeof e.cap=="number"&&(t.maxConcurrentPipelines=e.cap),O.setState(t)}}).catch(()=>{})},5e3);z();_k();
6902
6916
  //# sourceMappingURL=main.bundle.js.map