maxsimcli 3.1.0 → 3.1.1

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.
@@ -75,7 +75,14 @@ Error generating stack: `+p.message+`
75
75
  constructor(\${params}) {
76
76
  \${}
77
77
  }
78
- }`,{label:"class",detail:"definition",type:"keyword"}),ds('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),ds('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],jG=lB.concat([ds("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),ds("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),ds("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),lM=new HL,hB=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Wc(i){return(e,t)=>{let s=e.node.getChild("VariableDefinition");return s&&t(s,i),!0}}const IG=["FunctionDeclaration"],qG={FunctionDeclaration:Wc("function"),ClassDeclaration:Wc("class"),ClassExpression:()=>!0,EnumDeclaration:Wc("constant"),TypeAliasDeclaration:Wc("type"),NamespaceDeclaration:Wc("namespace"),VariableDefinition(i,e){i.matchContext(IG)||e(i,"variable")},TypeDefinition(i,e){e(i,"type")},__proto__:null};function cB(i,e){let t=lM.get(e);if(t)return t;let s=[],r=!0;function n(o,l){let c=i.sliceString(o.from,o.to);s.push({label:c,type:l})}return e.cursor(et.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=qG[o.name];if(l&&l(o,n)||hB.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of cB(i,o.node))s.push(l);return!1}}),lM.set(e,s),s}const hM=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,uB=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function WG(i){let e=ut(i.state).resolveInner(i.pos,-1);if(uB.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&hM.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let s=[];for(let r=e;r;r=r.parent)hB.has(r.name)&&(s=s.concat(cB(i.state.doc,r)));return{options:s,from:t?e.from:i.pos,validFor:hM}}const Jr=yh.define({name:"javascript",parser:ZG.configure({props:[Sf.add({IfStatement:Hp({except:/^\s*({|else\b)/}),TryStatement:Hp({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:_q,SwitchBody:i=>{let e=i.textAfter,t=/^\s*\}/.test(e),s=/^\s*(case|default)\b/.test(e);return i.baseIndent+(t?0:s?1:2)*i.unit},Block:Oq({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":Hp({except:/^\s*{/}),JSXElement(i){let e=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},JSXEscape(i){let e=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),Rh.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":s3,BlockComment(i){return{from:i.from+2,to:i.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),fB={test:i=>/^JSX/.test(i.name),facet:dS({commentTokens:{block:{open:"{/*",close:"*/}"}}})},dB=Jr.configure({dialect:"ts"},"typescript"),pB=Jr.configure({dialect:"jsx",props:[pS.add(i=>i.isTop?[fB]:void 0)]}),mB=Jr.configure({dialect:"jsx ts",props:[pS.add(i=>i.isTop?[fB]:void 0)]},"typescript");let gB=i=>({label:i,type:"keyword"});const OB="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(gB),UG=OB.concat(["declare","implements","private","protected","public"].map(gB));function YG(i={}){let e=i.jsx?i.typescript?mB:pB:i.typescript?dB:Jr,t=i.typescript?jG.concat(UG):lB.concat(OB);return new Yu(e,[Jr.data.of({autocomplete:zU(uB,n$(t))}),Jr.data.of({autocomplete:WG}),i.jsx?GG:[]])}function HG(i){for(;;){if(i.name=="JSXOpenTag"||i.name=="JSXSelfClosingTag"||i.name=="JSXFragmentTag")return i;if(i.name=="JSXEscape"||!i.parent)return null;i=i.parent}}function cM(i,e,t=i.length){for(let s=e==null?void 0:e.firstChild;s;s=s.nextSibling)if(s.name=="JSXIdentifier"||s.name=="JSXBuiltin"||s.name=="JSXNamespacedName"||s.name=="JSXMemberExpression")return i.sliceString(s.from,Math.min(s.to,t));return""}const FG=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),GG=pe.inputHandler.of((i,e,t,s,r)=>{if((FG?i.composing:i.compositionStarted)||i.state.readOnly||e!=t||s!=">"&&s!="/"||!Jr.isActiveAt(i.state,e,-1))return!1;let n=r(),{state:o}=n,l=o.changeByRange(c=>{var u;let{head:d}=c,m=ut(o).resolveInner(d-1,-1),g;if(m.name=="JSXStartTag"&&(m=m.parent),!(o.doc.sliceString(d-1,d)!=s||m.name=="JSXAttributeValue"&&m.to>d)){if(s==">"&&m.name=="JSXFragmentTag")return{range:c,changes:{from:d,insert:"</>"}};if(s=="/"&&m.name=="JSXStartCloseTag"){let _=m.parent,y=_.parent;if(y&&_.from==d-2&&((g=cM(o.doc,y.firstChild,d))||((u=y.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let b=`${g}>`;return{range:ne.cursor(d+b.length,-1),changes:{from:d,insert:b}}}}else if(s==">"){let _=HG(m);if(_&&_.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(d,d+2))&&(g=cM(o.doc,_,d)))return{range:c,changes:{from:d,insert:`</${g}>`}}}}return{range:c}});return l.changes.empty?!1:(i.dispatch([n,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Uc=["_blank","_self","_top","_parent"],H_=["ascii","utf-8","utf-16","latin1","latin1"],F_=["get","post","put","delete"],G_=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Ps=["true","false"],ke={},KG={a:{attrs:{href:null,ping:null,type:null,media:null,target:Uc,hreflang:null}},abbr:ke,address:ke,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:ke,aside:ke,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:ke,base:{attrs:{href:null,target:Uc}},bdi:ke,bdo:ke,blockquote:{attrs:{cite:null}},body:ke,br:ke,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:G_,formmethod:F_,formnovalidate:["novalidate"],formtarget:Uc,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:ke,center:ke,cite:ke,code:ke,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:ke,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:ke,div:ke,dl:ke,dt:ke,em:ke,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:ke,figure:ke,footer:ke,form:{attrs:{action:null,name:null,"accept-charset":H_,autocomplete:["on","off"],enctype:G_,method:F_,novalidate:["novalidate"],target:Uc}},h1:ke,h2:ke,h3:ke,h4:ke,h5:ke,h6:ke,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:ke,hgroup:ke,hr:ke,html:{attrs:{manifest:null}},i:ke,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:G_,formmethod:F_,formnovalidate:["novalidate"],formtarget:Uc,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:ke,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:ke,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:ke,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:H_,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:ke,noscript:ke,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:ke,param:{attrs:{name:null,value:null}},pre:ke,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:ke,rt:ke,ruby:ke,samp:ke,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:H_}},section:ke,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:ke,source:{attrs:{src:null,type:null,media:null}},span:ke,strong:ke,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:ke,summary:ke,sup:ke,table:ke,tbody:ke,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:ke,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:ke,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:ke,time:{attrs:{datetime:null}},title:ke,tr:ke,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:ke,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:ke},_B={accesskey:null,class:null,contenteditable:Ps,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Ps,autocorrect:Ps,autocapitalize:Ps,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Ps,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Ps,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Ps,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Ps,"aria-hidden":Ps,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Ps,"aria-multiselectable":Ps,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Ps,"aria-relevant":null,"aria-required":Ps,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},vB="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(i=>"on"+i);for(let i of vB)_B[i]=null;class of{constructor(e,t){this.tags={...KG,...e},this.globalAttrs={..._B,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}of.default=new of;function Ch(i,e,t=i.length){if(!e)return"";let s=e.firstChild,r=s&&s.getChild("TagName");return r?i.sliceString(r.from,Math.min(r.to,t)):""}function kh(i,e=!1){for(;i;i=i.parent)if(i.name=="Element")if(e)e=!1;else return i;return null}function yB(i,e,t){let s=t.tags[Ch(i,kh(e))];return(s==null?void 0:s.children)||t.allTags}function VS(i,e){let t=[];for(let s=kh(e);s&&!s.type.isTop;s=kh(s.parent)){let r=Ch(i,s);if(r&&s.lastChild.name=="CloseTag")break;r&&t.indexOf(r)<0&&(e.name=="EndTag"||e.from>=s.firstChild.to)&&t.push(r)}return t}const bB=/^[:\-\.\w\u00b7-\uffff]*$/;function uM(i,e,t,s,r){let n=/\s*>/.test(i.sliceDoc(r,r+5))?"":">",o=kh(t,t.name=="StartTag"||t.name=="TagName");return{from:s,to:r,options:yB(i.doc,o,e).map(l=>({label:l,type:"type"})).concat(VS(i.doc,t).map((l,c)=>({label:"/"+l,apply:"/"+l+n,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function fM(i,e,t,s){let r=/\s*>/.test(i.sliceDoc(s,s+5))?"":">";return{from:t,to:s,options:VS(i.doc,e).map((n,o)=>({label:n,apply:n+r,type:"type",boost:99-o})),validFor:bB}}function JG(i,e,t,s){let r=[],n=0;for(let o of yB(i.doc,t,e))r.push({label:"<"+o,type:"type"});for(let o of VS(i.doc,t))r.push({label:"</"+o+">",type:"type",boost:99-n++});return{from:s,to:s,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function eK(i,e,t,s,r){let n=kh(t),o=n?e.tags[Ch(i.doc,n)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],c=o&&o.globalAttrs===!1?l:l.length?l.concat(e.globalAttrNames):e.globalAttrNames;return{from:s,to:r,options:c.map(u=>({label:u,type:"property"})),validFor:bB}}function tK(i,e,t,s,r){var n;let o=(n=t.parent)===null||n===void 0?void 0:n.getChild("AttributeName"),l=[],c;if(o){let u=i.sliceDoc(o.from,o.to),d=e.globalAttrs[u];if(!d){let m=kh(t),g=m?e.tags[Ch(i.doc,m)]:null;d=(g==null?void 0:g.attrs)&&g.attrs[u]}if(d){let m=i.sliceDoc(s,r).toLowerCase(),g='"',_='"';/^['"]/.test(m)?(c=m[0]=='"'?/^[^"]*$/:/^[^']*$/,g="",_=i.sliceDoc(r,r+1)==m[0]?"":m[0],m=m.slice(1),s++):c=/^[^\s<>='"]*$/;for(let y of d)l.push({label:y,apply:g+y+_,type:"constant"})}}return{from:s,to:r,options:l,validFor:c}}function SB(i,e){let{state:t,pos:s}=e,r=ut(t).resolveInner(s,-1),n=r.resolve(s);for(let o=s,l;n==r&&(l=r.childBefore(o));){let c=l.lastChild;if(!c||!c.type.isError||c.from<c.to)break;n=r=l,o=c.from}return r.name=="TagName"?r.parent&&/CloseTag$/.test(r.parent.name)?fM(t,r,r.from,s):uM(t,i,r,r.from,s):r.name=="StartTag"||r.name=="IncompleteTag"?uM(t,i,r,s,s):r.name=="StartCloseTag"||r.name=="IncompleteCloseTag"?fM(t,r,s,s):r.name=="OpenTag"||r.name=="SelfClosingTag"||r.name=="AttributeName"?eK(t,i,r,r.name=="AttributeName"?r.from:s,s):r.name=="Is"||r.name=="AttributeValue"||r.name=="UnquotedAttributeValue"?tK(t,i,r,r.name=="Is"?s:r.from,s):e.explicit&&(n.name=="Element"||n.name=="Text"||n.name=="Document")?JG(t,i,r,s):null}function iK(i){return SB(of.default,i)}function sK(i){let{extraTags:e,extraGlobalAttributes:t}=i,s=t||e?new of(e,t):of.default;return r=>SB(s,r)}const rK=Jr.parser.configure({top:"SingleExpression"}),xB=[{tag:"script",attrs:i=>i.type=="text/typescript"||i.lang=="ts",parser:dB.parser},{tag:"script",attrs:i=>i.type=="text/babel"||i.type=="text/jsx",parser:pB.parser},{tag:"script",attrs:i=>i.type=="text/typescript-jsx",parser:mB.parser},{tag:"script",attrs(i){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(i.type)},parser:rK},{tag:"script",attrs(i){return!i.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(i.type)},parser:Jr.parser},{tag:"style",attrs(i){return(!i.lang||i.lang=="css")&&(!i.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(i.type))},parser:Fm.parser}],wB=[{name:"style",parser:Fm.parser.configure({top:"Styles"})}].concat(vB.map(i=>({name:i,parser:Jr.parser}))),CB=yh.define({name:"html",parser:MF.configure({props:[Sf.add({Element(i){let e=/^(\s*)(<\/)?/.exec(i.textAfter);return i.node.to<=i.pos+e[0].length?i.continue():i.lineIndent(i.node.from)+(e[2]?0:i.unit)},"OpenTag CloseTag SelfClosingTag"(i){return i.column(i.node.from)+i.unit},Document(i){if(i.pos+/\s*/.exec(i.textAfter)[0].length<i.node.to)return i.continue();let e=null,t;for(let s=i.node;;){let r=s.lastChild;if(!r||r.name!="Element"||r.to!=s.to)break;e=s=r}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?i.lineIndent(e.from)+i.unit:null}}),Rh.add({Element(i){let e=i.firstChild,t=i.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:i.to}}}),g3.add({"OpenTag CloseTag":i=>i.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Jp=CB.configure({wrap:tB(xB,wB)});function nK(i={}){let e="",t;i.matchClosingTags===!1&&(e="noMatch"),i.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(i.nestedLanguages&&i.nestedLanguages.length||i.nestedAttributes&&i.nestedAttributes.length)&&(t=tB((i.nestedLanguages||[]).concat(xB),(i.nestedAttributes||[]).concat(wB)));let s=t?CB.configure({wrap:t,dialect:e}):e?Jp.configure({dialect:e}):Jp;return new Yu(s,[Jp.data.of({autocomplete:sK(i)}),i.autoCloseTags!==!1?oK:[],YG().support,uG().support])}const dM=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),oK=pe.inputHandler.of((i,e,t,s,r)=>{if(i.composing||i.state.readOnly||e!=t||s!=">"&&s!="/"||!Jp.isActiveAt(i.state,e,-1))return!1;let n=r(),{state:o}=n,l=o.changeByRange(c=>{var u,d,m;let g=o.doc.sliceString(c.from-1,c.to)==s,{head:_}=c,y=ut(o).resolveInner(_,-1),b;if(g&&s==">"&&y.name=="EndTag"){let x=y.parent;if(((d=(u=x.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(b=Ch(o.doc,x.parent,_))&&!dM.has(b)){let w=_+(o.doc.sliceString(_,_+1)===">"?1:0),k=`</${b}>`;return{range:c,changes:{from:_,to:w,insert:k}}}}else if(g&&s=="/"&&y.name=="IncompleteCloseTag"){let x=y.parent;if(y.from==_-2&&((m=x.lastChild)===null||m===void 0?void 0:m.name)!="CloseTag"&&(b=Ch(o.doc,x,_))&&!dM.has(b)){let w=_+(o.doc.sliceString(_,_+1)===">"?1:0),k=`${b}>`;return{range:ne.cursor(_+k.length,-1),changes:{from:_,to:w,insert:k}}}}return{range:c}});return l.changes.empty?!1:(i.dispatch([n,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),kB=dS({commentTokens:{block:{open:"<!--",close:"-->"}}}),TB=new Le,AB=xH.configure({props:[Rh.add(i=>!i.is("Block")||i.is("Document")||by(i)!=null||aK(i)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),TB.add(by),Sf.add({Document:()=>null}),La.add({Document:kB})]});function by(i){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(i.name);return e?+e[1]:void 0}function aK(i){return i.name=="OrderedList"||i.name=="BulletList"}function lK(i,e){let t=i;for(;;){let s=t.nextSibling,r;if(!s||(r=by(s.type))!=null&&r<=e)break;t=s}return t.to}const hK=i3.of((i,e,t)=>{for(let s=ut(i).resolveInner(t,-1);s&&!(s.from<e);s=s.parent){let r=s.type.prop(TB);if(r==null)continue;let n=lK(s,r);if(n>t)return{from:t,to:n}}return null});function ZS(i){return new rr(kB,i,[],"markdown")}const cK=ZS(AB),uK=AB.configure([LH,BH,$H,DH,{props:[Rh.add({Table:(i,e)=>({from:e.doc.lineAt(i.from).to,to:i.to})})]}]),af=ZS(uK);function fK(i,e){return t=>{if(t&&i){let s=null;if(t=/\S*/.exec(t)[0],typeof i=="function"?s=i(t):s=Qm.matchLanguageName(i,t,!0),s instanceof Qm)return s.support?s.support.language.parser:Uu.getSkippingParser(s.load());if(s)return s.parser}return e?e.parser:null}}class K_{constructor(e,t,s,r,n,o,l){this.node=e,this.from=t,this.to=s,this.spaceBefore=r,this.spaceAfter=n,this.type=o,this.item=l}blank(e,t=!0){let s=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;s.length<e;)s+=" ";return s}else{for(let r=this.to-this.from-s.length-this.spaceAfter.length;r>0;r--)s+=" ";return s+(t?this.spaceAfter:"")}}marker(e,t){let s=this.node.name=="OrderedList"?String(+EB(this.item,e)[2]+t):"";return this.spaceBefore+s+this.type+this.spaceAfter}}function MB(i,e){let t=[],s=[];for(let r=i;r;r=r.parent){if(r.name=="FencedCode")return s;(r.name=="ListItem"||r.name=="Blockquote")&&t.push(r)}for(let r=t.length-1;r>=0;r--){let n=t[r],o,l=e.lineAt(n.from),c=n.from-l.from;if(n.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(c))))s.push(new K_(n,c,c+o[0].length,"",o[1],">",null));else if(n.name=="ListItem"&&n.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(c)))){let u=o[3],d=o[0].length;u.length>=4&&(u=u.slice(0,u.length-4),d-=4),s.push(new K_(n.parent,c,c+d,o[1],u,o[2],n))}else if(n.name=="ListItem"&&n.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(c)))){let u=o[4],d=o[0].length;u.length>4&&(u=u.slice(0,u.length-4),d-=4);let m=o[2];o[3]&&(m+=o[3].replace(/[xX]/," ")),s.push(new K_(n.parent,c,c+d,o[1],u,m,n))}}return s}function EB(i,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(i.from,i.from+10))}function J_(i,e,t,s=0){for(let r=-1,n=i;;){if(n.name=="ListItem"){let l=EB(n,e),c=+l[2];if(r>=0){if(c!=r+1)return;t.push({from:n.from+l[1].length,to:n.from+l[0].length,insert:String(r+2+s)})}r=c}let o=n.nextSibling;if(!o)break;n=o}}function jS(i,e){let t=/^[ \t]*/.exec(i)[0].length;if(!t||e.facet(Qh)!=" ")return i;let s=xr(i,4,t),r="";for(let n=s;n>0;)n>=4?(r+=" ",n-=4):(r+=" ",n--);return r+i.slice(t)}const dK=(i={})=>({state:e,dispatch:t})=>{let s=ut(e),{doc:r}=e,n=null,o=e.changeByRange(l=>{if(!l.empty||!af.isActiveAt(e,l.from,-1)&&!af.isActiveAt(e,l.from,1))return n={range:l};let c=l.from,u=r.lineAt(c),d=MB(s.resolveInner(c,-1),r);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return n={range:l};let m=d[d.length-1];if(m.to-m.spaceAfter.length>c-u.from)return n={range:l};let g=c>=m.to-m.spaceAfter.length&&!/\S/.test(u.text.slice(m.to));if(m.item&&g){let w=m.node.firstChild,k=m.node.getChild("ListItem","ListItem");if(w.to>=c||k&&k.to<c||u.from>0&&!/[^\s>]/.test(r.lineAt(u.from-1).text)||i.nonTightLists===!1){let C=d.length>1?d[d.length-2]:null,A,P="";C&&C.item?(A=u.from+C.from,P=C.marker(r,1)):A=u.from+(C?C.to:0);let E=[{from:A,to:c,insert:P}];return m.node.name=="OrderedList"&&J_(m.item,r,E,-2),C&&C.node.name=="OrderedList"&&J_(C.item,r,E),{range:ne.cursor(A+P.length),changes:E}}else{let C=mM(d,e,u);return{range:ne.cursor(c+C.length+1),changes:{from:u.from,insert:C+e.lineBreak}}}}if(m.node.name=="Blockquote"&&g&&u.from){let w=r.lineAt(u.from-1),k=/>\s*$/.exec(w.text);if(k&&k.index==m.from){let C=e.changes([{from:w.from+k.index,to:w.to},{from:u.from+m.from,to:u.to}]);return{range:l.map(C),changes:C}}}let _=[];m.node.name=="OrderedList"&&J_(m.item,r,_);let y=m.item&&m.item.from<u.from,b="";if(!y||/^[\s\d.)\-+*>]*/.exec(u.text)[0].length>=m.to)for(let w=0,k=d.length-1;w<=k;w++)b+=w==k&&!y?d[w].marker(r,1):d[w].blank(w<k?xr(u.text,4,d[w+1].from)-b.length:null);let x=c;for(;x>u.from&&/\s/.test(u.text.charAt(x-u.from-1));)x--;return b=jS(b,e),mK(m.node,e.doc)&&(b=mM(d,e,u)+e.lineBreak+b),_.push({from:x,to:c,insert:e.lineBreak+b}),{range:ne.cursor(x+b.length+1),changes:_}});return n?!1:(t(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},pK=dK();function pM(i){return i.name=="QuoteMark"||i.name=="ListMark"}function mK(i,e){if(i.name!="OrderedList"&&i.name!="BulletList")return!1;let t=i.firstChild,s=i.getChild("ListItem","ListItem");if(!s)return!1;let r=e.lineAt(t.to),n=e.lineAt(s.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1)<n.number}function mM(i,e,t){let s="";for(let r=0,n=i.length-2;r<=n;r++)s+=i[r].blank(r<n?xr(t.text,4,i[r+1].from)-s.length:null,r<n);return jS(s,e)}function gK(i,e){let t=i.resolveInner(e,-1),s=e;pM(t)&&(s=t.from,t=t.parent);for(let r;r=t.childBefore(s);)if(pM(r))s=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")t=r.lastChild,s=t.to;else break;return t}const OK=({state:i,dispatch:e})=>{let t=ut(i),s=null,r=i.changeByRange(n=>{let o=n.from,{doc:l}=i;if(n.empty&&af.isActiveAt(i,n.from)){let c=l.lineAt(o),u=MB(gK(t,o),l);if(u.length){let d=u[u.length-1],m=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(o-c.from>m&&!/\S/.test(c.text.slice(m,o-c.from)))return{range:ne.cursor(c.from+m),changes:{from:c.from+m,to:o}};if(o-c.from==m&&(!d.item||c.from<=d.item.from||!/\S/.test(c.text.slice(0,d.to)))){let g=c.from+d.from;if(d.item&&d.node.from<d.item.from&&/\S/.test(c.text.slice(d.from,d.to))){let _=d.blank(xr(c.text,4,d.to)-xr(c.text,4,d.from));return g==c.from&&(_=jS(_,i)),{range:ne.cursor(g+_.length),changes:{from:g,to:c.from+d.to,insert:_}}}if(g<o)return{range:ne.cursor(g),changes:{from:g,to:o}}}}}return s={range:n}});return s?!1:(e(i.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},_K=[{key:"Enter",run:pK},{key:"Backspace",run:OK}],PB=nK({matchClosingTags:!1});function vK(i={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:s=!0,base:{parser:r}=cK,completeHTMLTags:n=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=PB}=i;if(!(r instanceof bg))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=i.extensions?[i.extensions]:[],u=[l.support,hK],d;o&&u.push(xK),t instanceof Yu?(u.push(t.support),d=t.language):t&&(d=t);let m=e||d?fK(e,d):void 0;c.push(CH({codeParser:m,htmlParser:l.language.parser})),s&&u.push(Wn.high(Fa.of(_K)));let g=ZS(r.configure(c));return n&&u.push(g.data.of({autocomplete:yK})),new Yu(g,u)}function yK(i){let{state:e,pos:t}=i,s=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!s)return null;let r=ut(e).resolveInner(t,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:t-s[0].length,to:t,options:bK(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let ev=null;function bK(){if(ev)return ev;let i=iK(new wS(We.create({extensions:PB}),0,!0));return ev=i?i.options:[]}const SK=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,xK=pe.domEventHandlers({paste:(i,e)=>{var t;let{main:s}=e.state.selection;if(s.empty)return!1;let r=(t=i.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!af.isActiveAt(e.state,s.from,1)))return!1;let n=ut(e.state),o=!1;return n.iterate({from:s.from,to:s.to,enter:l=>{(l.from>s.from||SK.test(l.name))&&(o=!0)},leave:l=>{l.to<s.to&&(o=!0)}}),o?!1:(e.dispatch({changes:[{from:s.from,insert:"["},{from:s.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});function wK({initialContent:i,filePath:e,onSave:t,onClose:s}){const[r,n]=Y.useState(i),[o,l]=Y.useState(!1),[c,u]=Y.useState(!1),d=Y.useRef(r);Y.useEffect(()=>{d.current=r},[r]);const m=Y.useCallback(b=>{n(b),u(b!==i)},[i]),g=Y.useCallback(async()=>{if(!o){l(!0);try{await t(d.current),u(!1)}catch(b){console.error("[plan-editor] Save failed:",b)}finally{l(!1)}}},[t,o]),_=Y.useCallback(()=>{c&&!window.confirm("Unsaved changes -- discard?")||s()},[c,s]),y=Fa.of([{key:"Mod-s",run:()=>(g(),!0)}]);return Y.useEffect(()=>{const b=x=>{(x.ctrlKey||x.metaKey)&&x.key==="s"&&x.preventDefault()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[]),M.jsxs("div",{className:"fixed inset-0 z-50 bg-background/95 flex flex-col",children:[M.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[M.jsxs("div",{className:"flex items-center gap-3",children:[M.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:e}),c&&M.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-sm bg-warning/20 text-warning font-mono",children:"unsaved"})]}),M.jsxs("div",{className:"flex items-center gap-2",children:[c&&M.jsx("button",{type:"button",onClick:g,disabled:o,className:dt("text-xs px-3 py-1.5 rounded-md font-mono","bg-accent text-foreground","hover:bg-accent-glow","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50"),children:o?"Saving...":"Save"}),M.jsx("button",{type:"button",onClick:_,className:dt("text-xs px-3 py-1.5 rounded-md font-mono","bg-muted text-muted-foreground","hover:bg-danger/20 hover:text-danger","transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50"),children:"Close"})]})]}),M.jsx("div",{className:"flex-1 overflow-auto",children:M.jsx(b$,{value:r,onChange:m,theme:y$,extensions:[vK({base:af}),y],height:"calc(100vh - 56px)",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,bracketMatching:!0,indentOnInput:!0}})})]})}function CK({phaseId:i,onBack:e}){const{plans:t,context:s,research:r,loading:n,error:o,refetch:l}=CZ(i),[c,u]=Y.useState(null),[d,m]=Y.useState(""),g=t.length>0?t[0].frontmatter.phase??i:i,_=Y.useCallback(async x=>{try{const k=x.replace(/^\.planning[\\/]/,"").split(/[\\/]/),C=await fetch(`/api/plan/${k.join("/")}`);if(!C.ok){console.error("[phase-detail] Failed to fetch plan for editing");return}const A=await C.json();m(A.content),u(x)}catch(w){console.error("[phase-detail] Error fetching plan:",w)}},[]),y=Y.useCallback(async x=>{if(!c)return;const k=c.replace(/^\.planning[\\/]/,"").split(/[\\/]/);if(!(await fetch(`/api/plan/${k.join("/")}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})})).ok)throw new Error("Failed to save plan")},[c]),b=Y.useCallback(()=>{u(null),m(""),l()},[l]);return M.jsxs("div",{className:"space-y-6",children:[M.jsxs("button",{type:"button",onClick:e,className:dt("flex items-center gap-2 text-sm text-muted-foreground","hover:text-foreground transition-colors","focus:outline-none focus:ring-2 focus:ring-accent/50 rounded-md px-2 py-1"),children:[M.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M10 3L5 8l5 5"})}),"Back to overview"]}),M.jsxs("div",{children:[M.jsxs("h2",{className:"text-2xl font-semibold tracking-tight",children:[M.jsxs("span",{className:"text-accent font-mono",children:["Phase ",i]}),M.jsx("span",{className:"mx-2 text-muted-foreground",children:"-"}),M.jsx("span",{children:g})]}),M.jsxs("div",{className:"flex gap-2 mt-2",children:[s&&M.jsx("span",{className:"text-xs px-2 py-0.5 rounded-sm bg-success/20 text-success font-mono",children:"context available"}),r&&M.jsx("span",{className:"text-xs px-2 py-0.5 rounded-sm bg-success/20 text-success font-mono",children:"research available"}),!s&&!r&&!n&&M.jsx("span",{className:"text-xs px-2 py-0.5 rounded-sm bg-muted text-muted-foreground font-mono",children:"no context or research"})]})]}),o&&M.jsx("div",{className:"p-4 rounded-lg border border-danger/50 bg-danger/10 text-danger text-sm",children:o}),n&&t.length===0&&M.jsx("div",{className:"space-y-4",children:[1,2,3].map(x=>M.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 animate-pulse",children:[M.jsx("div",{className:"h-6 w-32 bg-muted rounded mb-3"}),M.jsx("div",{className:"h-4 w-3/4 bg-muted rounded mb-2"}),M.jsx("div",{className:"h-4 w-1/2 bg-muted rounded mb-3"}),M.jsxs("div",{className:"space-y-2",children:[M.jsx("div",{className:"h-3 w-full bg-muted rounded"}),M.jsx("div",{className:"h-3 w-5/6 bg-muted rounded"})]})]},x))}),!n&&!o&&t.length===0&&M.jsx("div",{className:"p-8 text-center text-muted-foreground border border-border rounded-lg bg-card",children:M.jsxs("p",{className:"text-sm",children:["No plans yet -- run"," ",M.jsx("code",{className:"font-mono text-accent",children:"/maxsim:plan-phase"})," to create plans"]})}),t.length>0&&M.jsx("div",{className:"space-y-4",children:t.map(x=>M.jsx(TZ,{plan:x,onEdit:_},x.path))}),c&&M.jsx(wK,{initialContent:d,filePath:c,onSave:y,onClose:b})]})}function kK(){const{lastChange:i}=ff(),[e,t]=Y.useState([]),[s,r]=Y.useState([]),[n,o]=Y.useState(!0),[l,c]=Y.useState(null),[u,d]=Y.useState(""),[m,g]=Y.useState(!1),[_,y]=Y.useState(!1),b=Y.useCallback(async()=>{try{c(null);const k=await fetch("/api/todos");if(!k.ok)throw new Error(`Failed to fetch todos: ${k.status}`);const C=await k.json();t(C.pending),r(C.completed)}catch(k){c(k instanceof Error?k.message:"Failed to fetch todos")}finally{o(!1)}},[]);Y.useEffect(()=>{b()},[b]),Y.useEffect(()=>{i>0&&b()},[i,b]);const x=Y.useCallback(async()=>{const k=u.trim();if(k){g(!0);try{if(!(await fetch("/api/todos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:k})})).ok)throw new Error("Failed to create todo");d(""),await b()}catch(C){c(C instanceof Error?C.message:"Failed to create todo")}finally{g(!1)}}},[u,b]),w=Y.useCallback(async(k,C)=>{try{if(!(await fetch("/api/todos",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:k,completed:C})})).ok)throw new Error("Failed to update todo");await b()}catch(A){c(A instanceof Error?A.message:"Failed to update todo")}},[b]);return M.jsxs("div",{className:"space-y-6",children:[M.jsxs("div",{className:"flex items-center justify-between",children:[M.jsx("h2",{className:"font-mono text-lg font-semibold tracking-tight text-foreground",children:"Todos"}),M.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[e.length," pending"]})]}),M.jsxs("div",{className:"flex gap-2",children:[M.jsx("input",{type:"text",value:u,onChange:k=>d(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!m&&x()},placeholder:"Add a new todo...",className:"flex-1 rounded-sm border border-border bg-card px-3 py-2 font-mono text-sm text-foreground placeholder:text-muted-foreground focus:border-accent focus:outline-none"}),M.jsx("button",{type:"button",onClick:x,disabled:m||!u.trim(),className:dt("rounded-sm bg-accent px-4 py-2 font-mono text-xs font-semibold text-foreground transition-colors","hover:bg-accent-glow disabled:opacity-40 disabled:cursor-not-allowed"),children:"Add"})]}),l&&M.jsx("div",{className:"rounded-sm border border-danger/50 bg-danger/10 px-3 py-2 text-sm text-danger",children:l}),n&&M.jsx("div",{className:"space-y-2",children:[1,2,3].map(k=>M.jsxs("div",{className:"flex items-center gap-3 rounded-sm bg-card px-4 py-3",children:[M.jsx("div",{className:"h-4 w-4 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-4 w-48 animate-pulse rounded-sm bg-muted"})]},k))}),!n&&M.jsx("div",{className:"space-y-1",children:e.length===0?M.jsx("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No pending todos"}):e.map(k=>M.jsxs("button",{type:"button",onClick:()=>w(k.file,!0),className:"group flex w-full items-center gap-3 rounded-sm px-4 py-2.5 text-left transition-colors hover:bg-card-hover",children:[M.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-muted-foreground transition-colors group-hover:border-accent"}),M.jsx("span",{className:"text-sm text-foreground",children:k.text})]},k.file))}),!n&&s.length>0&&M.jsxs("div",{className:"border-t border-border pt-4",children:[M.jsxs("button",{type:"button",onClick:()=>y(!_),className:"flex w-full items-center gap-2 text-left",children:[M.jsx("svg",{className:dt("h-3 w-3 text-muted-foreground transition-transform",_&&"rotate-90"),viewBox:"0 0 12 12",fill:"currentColor",children:M.jsx("path",{d:"M4 2l5 4-5 4z"})}),M.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Completed (",s.length,")"]})]}),_&&M.jsx("div",{className:"mt-2 space-y-1",children:s.map(k=>M.jsxs("button",{type:"button",onClick:()=>w(k.file,!1),className:"group flex w-full items-center gap-3 rounded-sm px-4 py-2 text-left transition-colors hover:bg-card-hover",children:[M.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-success bg-success/20",children:M.jsx("svg",{className:"h-3 w-3 text-success",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M2 6l3 3 5-5"})})}),M.jsx("span",{className:"text-sm text-muted-foreground line-through",children:k.text})]},k.file))})]})]})}function TK({onEntryAdded:i}){const[e,t]=Y.useState(!1),[s,r]=Y.useState("decision"),[n,o]=Y.useState(""),[l,c]=Y.useState(""),[u,d]=Y.useState(!1),[m,g]=Y.useState(null),[_,y]=Y.useState(null),b=Y.useCallback(async()=>{const x=l.trim();if(x){d(!0),g(null),y(null);try{if(s==="decision"){const w=await fetch("/api/state/decision",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phase:n.trim()||void 0,text:x})});if(!w.ok){const k=await w.json().catch(()=>({}));throw new Error(k.error||"Could not add decision")}y("Decision added")}else{const w=await fetch("/api/state/blocker",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:x})});if(!w.ok){const k=await w.json().catch(()=>({}));throw new Error(k.error||"Could not add blocker")}y("Blocker added")}c(""),o(""),i==null||i(),setTimeout(()=>y(null),2e3)}catch(w){g(w instanceof Error?w.message:"Failed to update STATE.md")}finally{d(!1)}}},[s,n,l,i]);return M.jsxs("div",{className:"border-t border-border pt-4",children:[M.jsxs("button",{type:"button",onClick:()=>t(!e),className:"flex w-full items-center gap-2 text-left",children:[M.jsx("svg",{className:dt("h-3 w-3 text-muted-foreground transition-transform",e&&"rotate-90"),viewBox:"0 0 12 12",fill:"currentColor",children:M.jsx("path",{d:"M4 2l5 4-5 4z"})}),M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide text-muted-foreground",children:"Add to STATE.md"})]}),e&&M.jsxs("div",{className:"mt-3 space-y-3",children:[M.jsxs("div",{className:"flex gap-1",children:[M.jsx("button",{type:"button",onClick:()=>r("decision"),className:dt("rounded-sm px-3 py-1 font-mono text-xs transition-colors",s==="decision"?"bg-accent/20 text-accent":"text-muted-foreground hover:text-foreground"),children:"Decision"}),M.jsx("button",{type:"button",onClick:()=>r("blocker"),className:dt("rounded-sm px-3 py-1 font-mono text-xs transition-colors",s==="blocker"?"bg-danger/20 text-danger":"text-muted-foreground hover:text-foreground"),children:"Blocker"})]}),s==="decision"&&M.jsx("input",{type:"text",value:n,onChange:x=>o(x.target.value),placeholder:"Phase (e.g. 13-06)",className:"w-full rounded-sm border border-border bg-card px-3 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground focus:border-accent focus:outline-none"}),M.jsx("input",{type:"text",value:l,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!u&&b()},placeholder:s==="decision"?"Decision text...":"Blocker description...",className:"w-full rounded-sm border border-border bg-card px-3 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground focus:border-accent focus:outline-none"}),M.jsx("button",{type:"button",onClick:b,disabled:u||!l.trim(),className:dt("rounded-sm px-3 py-1.5 font-mono text-xs font-semibold transition-colors","disabled:opacity-40 disabled:cursor-not-allowed",s==="decision"?"bg-accent/20 text-accent hover:bg-accent/30":"bg-danger/20 text-danger hover:bg-danger/30"),children:u?"Saving...":`Add ${s==="decision"?"Decision":"Blocker"}`}),m&&M.jsx("p",{className:"text-xs text-danger",children:m}),_&&M.jsx("p",{className:"text-xs text-success",children:_})]})]})}function AK(i){return i.map(e=>({text:e.replace(/~~(.+)~~/,"$1").replace(/\s*RESOLVED.*$/i,"").trim(),resolved:e.includes("RESOLVED")||e.startsWith("~~")&&e.endsWith("~~")}))}function MK(){const{state:i}=fb(),[e,t]=Y.useState(!1),[s,r]=Y.useState(null),[n,o]=Y.useState(null),[l,c]=Y.useState(0),u=AK((i==null?void 0:i.blockers)??[]),d=u.filter(y=>!y.resolved),m=u.filter(y=>y.resolved),g=Y.useCallback(async y=>{r(y),o(null);try{if(!(await fetch("/api/state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({field:"blockers",value:`~~${y}~~ RESOLVED`})})).ok)throw new Error("Failed to resolve blocker");c(x=>x+1)}catch(b){o(b instanceof Error?b.message:"Failed to resolve blocker")}finally{r(null)}},[]),_=Y.useCallback(()=>{c(y=>y+1)},[]);return M.jsxs("div",{className:"space-y-6",children:[M.jsxs("div",{className:"flex items-center justify-between",children:[M.jsx("h2",{className:"font-mono text-lg font-semibold tracking-tight text-foreground",children:"Blockers"}),M.jsx("span",{className:dt("font-mono text-xs",d.length>0?"text-danger":"text-success"),children:d.length>0?`${d.length} active`:"No active blockers"})]}),n&&M.jsx("div",{className:"rounded-sm border border-danger/50 bg-danger/10 px-3 py-2 text-sm text-danger",children:n}),d.length===0?M.jsx("div",{className:"rounded-sm border border-success/30 bg-success/5 px-4 py-6 text-center",children:M.jsx("p",{className:"text-sm text-success",children:"No active blockers"})}):M.jsx("div",{className:"space-y-2",children:d.map(y=>M.jsxs("div",{className:"flex items-start gap-3 rounded-sm border border-border bg-card px-4 py-3",children:[M.jsx("span",{className:"mt-1 inline-block h-2 w-2 shrink-0 rounded-full bg-danger"}),M.jsx("div",{className:"flex-1",children:M.jsx("p",{className:"text-sm text-foreground",children:y.text})}),M.jsx("button",{type:"button",onClick:()=>g(y.text),disabled:s===y.text,className:dt("shrink-0 rounded-sm px-3 py-1 font-mono text-xs transition-colors","bg-success/20 text-success hover:bg-success/30","disabled:opacity-40 disabled:cursor-not-allowed"),children:s===y.text?"...":"Resolve"})]},y.text))}),m.length>0&&M.jsxs("div",{className:"border-t border-border pt-4",children:[M.jsxs("button",{type:"button",onClick:()=>t(!e),className:"flex w-full items-center gap-2 text-left",children:[M.jsx("svg",{className:dt("h-3 w-3 text-muted-foreground transition-transform",e&&"rotate-90"),viewBox:"0 0 12 12",fill:"currentColor",children:M.jsx("path",{d:"M4 2l5 4-5 4z"})}),M.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Resolved (",m.length,")"]})]}),e&&M.jsx("div",{className:"mt-2 space-y-1",children:m.map(y=>M.jsxs("div",{className:"flex items-center gap-3 rounded-sm px-4 py-2",children:[M.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-muted"}),M.jsx("p",{className:"text-sm text-muted-foreground line-through",children:y.text})]},y.text))})]}),M.jsx(TK,{onEntryAdded:_})]},l)}function EK({sidebar:i,children:e}){return M.jsxs("div",{className:"flex h-screen overflow-hidden",children:[M.jsx("div",{className:"hidden md:flex",children:i}),M.jsx("main",{className:"flex flex-1 flex-col overflow-hidden",children:e})]})}function PK(i){switch(i){case"complete":return"bg-success";case"partial":return"bg-accent";case"planned":case"researched":case"discussed":return"bg-muted-foreground";default:return"bg-muted"}}function QK({activeView:i,activePhaseId:e,onNavigate:t}){const{roadmap:s,state:r,todos:n}=fb(),{connected:o}=ff(),l=((s==null?void 0:s.phases)??[]).map(m=>({number:m.number,name:m.name,goal:m.goal??"",dependsOn:m.depends_on?[m.depends_on]:[],planCount:m.plan_count,summaryCount:m.summary_count,diskStatus:m.disk_status,roadmapComplete:m.roadmap_complete,hasContext:m.has_context,hasResearch:m.has_research})),c=(s==null?void 0:s.current_phase)??null,u=(r==null?void 0:r.blockers.filter(m=>!m.includes("RESOLVED")).length)??0,d=(n==null?void 0:n.pending.length)??0;return M.jsxs("aside",{className:"flex h-full w-64 shrink-0 flex-col border-r border-border bg-card",children:[M.jsx("div",{className:"border-b border-border px-4 py-4",children:M.jsxs("button",{type:"button",onClick:()=>t("overview"),className:"flex flex-col gap-0.5 text-left",children:[M.jsx("span",{className:"font-mono text-lg font-bold tracking-tight text-foreground",children:"MAXSIM"}),M.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:"Dashboard"})]})}),M.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[M.jsx("div",{className:"px-3 pb-1",children:M.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:"Phases"})}),M.jsx("nav",{className:"flex flex-col gap-0.5 px-1",children:l.map(m=>{const g=i==="phase"&&e===m.number,_=m.number===c;return M.jsxs("button",{type:"button",onClick:()=>t("phase",m.number),className:dt("flex w-full items-center gap-2.5 rounded-sm px-3 py-1.5 text-left text-sm transition-colors",g?"border-l-2 border-l-accent bg-card-hover text-foreground":"border-l-2 border-l-transparent hover:bg-card-hover",_&&!g&&"border-l-accent-glow"),children:[M.jsx("span",{className:dt("inline-block h-2 w-2 shrink-0 rounded-full",PK(m.diskStatus))}),M.jsx("span",{className:dt("font-mono text-xs font-semibold",_||g?"text-accent":"text-muted-foreground"),children:m.number}),M.jsx("span",{className:"truncate text-xs text-foreground",children:m.name})]},m.number)})})]}),M.jsxs("div",{className:"border-t border-border px-1 py-2",children:[M.jsxs("button",{type:"button",onClick:()=>t("todos"),className:dt("flex w-full items-center justify-between rounded-sm px-3 py-2 text-left text-sm transition-colors",i==="todos"?"bg-card-hover text-foreground":"hover:bg-card-hover text-muted-foreground"),children:[M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Todos"}),d>0&&M.jsx("span",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-sm bg-warning/20 px-1 font-mono text-[10px] font-bold text-warning",children:d})]}),M.jsxs("button",{type:"button",onClick:()=>t("blockers"),className:dt("flex w-full items-center justify-between rounded-sm px-3 py-2 text-left text-sm transition-colors",i==="blockers"?"bg-card-hover text-foreground":"hover:bg-card-hover text-muted-foreground"),children:[M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Blockers"}),u>0&&M.jsx("span",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-sm bg-danger/20 px-1 font-mono text-[10px] font-bold text-danger shadow-[0_0_6px_rgba(239,68,68,0.3)]",children:u})]})]}),M.jsx("div",{className:"border-t border-border px-1 py-2",children:M.jsxs("button",{type:"button",onClick:()=>t("terminal"),className:dt("flex w-full items-center gap-2.5 rounded-sm px-3 py-2 text-left text-sm transition-colors",i==="terminal"?"bg-card-hover text-foreground":"hover:bg-card-hover text-muted-foreground"),children:[M.jsx("span",{className:"font-mono text-xs font-bold",children:">_"}),M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Terminal"})]})}),M.jsx("div",{className:"border-t border-border px-4 py-3",children:M.jsxs("div",{className:"flex items-center gap-2",children:[M.jsx("span",{className:dt("inline-block h-2 w-2 rounded-full",o?"bg-success":"bg-danger")}),M.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:o?"Connected":"Disconnected"})]})})]})}/**
78
+ }`,{label:"class",detail:"definition",type:"keyword"}),ds('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),ds('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],jG=lB.concat([ds("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),ds("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),ds("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),lM=new HL,hB=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function Wc(i){return(e,t)=>{let s=e.node.getChild("VariableDefinition");return s&&t(s,i),!0}}const IG=["FunctionDeclaration"],qG={FunctionDeclaration:Wc("function"),ClassDeclaration:Wc("class"),ClassExpression:()=>!0,EnumDeclaration:Wc("constant"),TypeAliasDeclaration:Wc("type"),NamespaceDeclaration:Wc("namespace"),VariableDefinition(i,e){i.matchContext(IG)||e(i,"variable")},TypeDefinition(i,e){e(i,"type")},__proto__:null};function cB(i,e){let t=lM.get(e);if(t)return t;let s=[],r=!0;function n(o,l){let c=i.sliceString(o.from,o.to);s.push({label:c,type:l})}return e.cursor(et.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=qG[o.name];if(l&&l(o,n)||hB.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of cB(i,o.node))s.push(l);return!1}}),lM.set(e,s),s}const hM=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,uB=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function WG(i){let e=ut(i.state).resolveInner(i.pos,-1);if(uB.indexOf(e.name)>-1)return null;let t=e.name=="VariableName"||e.to-e.from<20&&hM.test(i.state.sliceDoc(e.from,e.to));if(!t&&!i.explicit)return null;let s=[];for(let r=e;r;r=r.parent)hB.has(r.name)&&(s=s.concat(cB(i.state.doc,r)));return{options:s,from:t?e.from:i.pos,validFor:hM}}const Jr=yh.define({name:"javascript",parser:ZG.configure({props:[Sf.add({IfStatement:Hp({except:/^\s*({|else\b)/}),TryStatement:Hp({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:_q,SwitchBody:i=>{let e=i.textAfter,t=/^\s*\}/.test(e),s=/^\s*(case|default)\b/.test(e);return i.baseIndent+(t?0:s?1:2)*i.unit},Block:Oq({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":Hp({except:/^\s*{/}),JSXElement(i){let e=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},JSXEscape(i){let e=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),Rh.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":s3,BlockComment(i){return{from:i.from+2,to:i.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),fB={test:i=>/^JSX/.test(i.name),facet:dS({commentTokens:{block:{open:"{/*",close:"*/}"}}})},dB=Jr.configure({dialect:"ts"},"typescript"),pB=Jr.configure({dialect:"jsx",props:[pS.add(i=>i.isTop?[fB]:void 0)]}),mB=Jr.configure({dialect:"jsx ts",props:[pS.add(i=>i.isTop?[fB]:void 0)]},"typescript");let gB=i=>({label:i,type:"keyword"});const OB="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(gB),UG=OB.concat(["declare","implements","private","protected","public"].map(gB));function YG(i={}){let e=i.jsx?i.typescript?mB:pB:i.typescript?dB:Jr,t=i.typescript?jG.concat(UG):lB.concat(OB);return new Yu(e,[Jr.data.of({autocomplete:zU(uB,n$(t))}),Jr.data.of({autocomplete:WG}),i.jsx?GG:[]])}function HG(i){for(;;){if(i.name=="JSXOpenTag"||i.name=="JSXSelfClosingTag"||i.name=="JSXFragmentTag")return i;if(i.name=="JSXEscape"||!i.parent)return null;i=i.parent}}function cM(i,e,t=i.length){for(let s=e==null?void 0:e.firstChild;s;s=s.nextSibling)if(s.name=="JSXIdentifier"||s.name=="JSXBuiltin"||s.name=="JSXNamespacedName"||s.name=="JSXMemberExpression")return i.sliceString(s.from,Math.min(s.to,t));return""}const FG=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),GG=pe.inputHandler.of((i,e,t,s,r)=>{if((FG?i.composing:i.compositionStarted)||i.state.readOnly||e!=t||s!=">"&&s!="/"||!Jr.isActiveAt(i.state,e,-1))return!1;let n=r(),{state:o}=n,l=o.changeByRange(c=>{var u;let{head:d}=c,m=ut(o).resolveInner(d-1,-1),g;if(m.name=="JSXStartTag"&&(m=m.parent),!(o.doc.sliceString(d-1,d)!=s||m.name=="JSXAttributeValue"&&m.to>d)){if(s==">"&&m.name=="JSXFragmentTag")return{range:c,changes:{from:d,insert:"</>"}};if(s=="/"&&m.name=="JSXStartCloseTag"){let _=m.parent,y=_.parent;if(y&&_.from==d-2&&((g=cM(o.doc,y.firstChild,d))||((u=y.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let b=`${g}>`;return{range:ne.cursor(d+b.length,-1),changes:{from:d,insert:b}}}}else if(s==">"){let _=HG(m);if(_&&_.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(d,d+2))&&(g=cM(o.doc,_,d)))return{range:c,changes:{from:d,insert:`</${g}>`}}}}return{range:c}});return l.changes.empty?!1:(i.dispatch([n,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),Uc=["_blank","_self","_top","_parent"],H_=["ascii","utf-8","utf-16","latin1","latin1"],F_=["get","post","put","delete"],G_=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Ps=["true","false"],ke={},KG={a:{attrs:{href:null,ping:null,type:null,media:null,target:Uc,hreflang:null}},abbr:ke,address:ke,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:ke,aside:ke,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:ke,base:{attrs:{href:null,target:Uc}},bdi:ke,bdo:ke,blockquote:{attrs:{cite:null}},body:ke,br:ke,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:G_,formmethod:F_,formnovalidate:["novalidate"],formtarget:Uc,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:ke,center:ke,cite:ke,code:ke,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:ke,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:ke,div:ke,dl:ke,dt:ke,em:ke,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:ke,figure:ke,footer:ke,form:{attrs:{action:null,name:null,"accept-charset":H_,autocomplete:["on","off"],enctype:G_,method:F_,novalidate:["novalidate"],target:Uc}},h1:ke,h2:ke,h3:ke,h4:ke,h5:ke,h6:ke,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:ke,hgroup:ke,hr:ke,html:{attrs:{manifest:null}},i:ke,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:G_,formmethod:F_,formnovalidate:["novalidate"],formtarget:Uc,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:ke,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:ke,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:ke,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:H_,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:ke,noscript:ke,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:ke,param:{attrs:{name:null,value:null}},pre:ke,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:ke,rt:ke,ruby:ke,samp:ke,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:H_}},section:ke,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:ke,source:{attrs:{src:null,type:null,media:null}},span:ke,strong:ke,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:ke,summary:ke,sup:ke,table:ke,tbody:ke,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:ke,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:ke,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:ke,time:{attrs:{datetime:null}},title:ke,tr:ke,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:ke,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:ke},_B={accesskey:null,class:null,contenteditable:Ps,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Ps,autocorrect:Ps,autocapitalize:Ps,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Ps,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Ps,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Ps,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Ps,"aria-hidden":Ps,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Ps,"aria-multiselectable":Ps,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Ps,"aria-relevant":null,"aria-required":Ps,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},vB="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(i=>"on"+i);for(let i of vB)_B[i]=null;class of{constructor(e,t){this.tags={...KG,...e},this.globalAttrs={..._B,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}}of.default=new of;function Ch(i,e,t=i.length){if(!e)return"";let s=e.firstChild,r=s&&s.getChild("TagName");return r?i.sliceString(r.from,Math.min(r.to,t)):""}function kh(i,e=!1){for(;i;i=i.parent)if(i.name=="Element")if(e)e=!1;else return i;return null}function yB(i,e,t){let s=t.tags[Ch(i,kh(e))];return(s==null?void 0:s.children)||t.allTags}function VS(i,e){let t=[];for(let s=kh(e);s&&!s.type.isTop;s=kh(s.parent)){let r=Ch(i,s);if(r&&s.lastChild.name=="CloseTag")break;r&&t.indexOf(r)<0&&(e.name=="EndTag"||e.from>=s.firstChild.to)&&t.push(r)}return t}const bB=/^[:\-\.\w\u00b7-\uffff]*$/;function uM(i,e,t,s,r){let n=/\s*>/.test(i.sliceDoc(r,r+5))?"":">",o=kh(t,t.name=="StartTag"||t.name=="TagName");return{from:s,to:r,options:yB(i.doc,o,e).map(l=>({label:l,type:"type"})).concat(VS(i.doc,t).map((l,c)=>({label:"/"+l,apply:"/"+l+n,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function fM(i,e,t,s){let r=/\s*>/.test(i.sliceDoc(s,s+5))?"":">";return{from:t,to:s,options:VS(i.doc,e).map((n,o)=>({label:n,apply:n+r,type:"type",boost:99-o})),validFor:bB}}function JG(i,e,t,s){let r=[],n=0;for(let o of yB(i.doc,t,e))r.push({label:"<"+o,type:"type"});for(let o of VS(i.doc,t))r.push({label:"</"+o+">",type:"type",boost:99-n++});return{from:s,to:s,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function eK(i,e,t,s,r){let n=kh(t),o=n?e.tags[Ch(i.doc,n)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],c=o&&o.globalAttrs===!1?l:l.length?l.concat(e.globalAttrNames):e.globalAttrNames;return{from:s,to:r,options:c.map(u=>({label:u,type:"property"})),validFor:bB}}function tK(i,e,t,s,r){var n;let o=(n=t.parent)===null||n===void 0?void 0:n.getChild("AttributeName"),l=[],c;if(o){let u=i.sliceDoc(o.from,o.to),d=e.globalAttrs[u];if(!d){let m=kh(t),g=m?e.tags[Ch(i.doc,m)]:null;d=(g==null?void 0:g.attrs)&&g.attrs[u]}if(d){let m=i.sliceDoc(s,r).toLowerCase(),g='"',_='"';/^['"]/.test(m)?(c=m[0]=='"'?/^[^"]*$/:/^[^']*$/,g="",_=i.sliceDoc(r,r+1)==m[0]?"":m[0],m=m.slice(1),s++):c=/^[^\s<>='"]*$/;for(let y of d)l.push({label:y,apply:g+y+_,type:"constant"})}}return{from:s,to:r,options:l,validFor:c}}function SB(i,e){let{state:t,pos:s}=e,r=ut(t).resolveInner(s,-1),n=r.resolve(s);for(let o=s,l;n==r&&(l=r.childBefore(o));){let c=l.lastChild;if(!c||!c.type.isError||c.from<c.to)break;n=r=l,o=c.from}return r.name=="TagName"?r.parent&&/CloseTag$/.test(r.parent.name)?fM(t,r,r.from,s):uM(t,i,r,r.from,s):r.name=="StartTag"||r.name=="IncompleteTag"?uM(t,i,r,s,s):r.name=="StartCloseTag"||r.name=="IncompleteCloseTag"?fM(t,r,s,s):r.name=="OpenTag"||r.name=="SelfClosingTag"||r.name=="AttributeName"?eK(t,i,r,r.name=="AttributeName"?r.from:s,s):r.name=="Is"||r.name=="AttributeValue"||r.name=="UnquotedAttributeValue"?tK(t,i,r,r.name=="Is"?s:r.from,s):e.explicit&&(n.name=="Element"||n.name=="Text"||n.name=="Document")?JG(t,i,r,s):null}function iK(i){return SB(of.default,i)}function sK(i){let{extraTags:e,extraGlobalAttributes:t}=i,s=t||e?new of(e,t):of.default;return r=>SB(s,r)}const rK=Jr.parser.configure({top:"SingleExpression"}),xB=[{tag:"script",attrs:i=>i.type=="text/typescript"||i.lang=="ts",parser:dB.parser},{tag:"script",attrs:i=>i.type=="text/babel"||i.type=="text/jsx",parser:pB.parser},{tag:"script",attrs:i=>i.type=="text/typescript-jsx",parser:mB.parser},{tag:"script",attrs(i){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(i.type)},parser:rK},{tag:"script",attrs(i){return!i.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(i.type)},parser:Jr.parser},{tag:"style",attrs(i){return(!i.lang||i.lang=="css")&&(!i.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(i.type))},parser:Fm.parser}],wB=[{name:"style",parser:Fm.parser.configure({top:"Styles"})}].concat(vB.map(i=>({name:i,parser:Jr.parser}))),CB=yh.define({name:"html",parser:MF.configure({props:[Sf.add({Element(i){let e=/^(\s*)(<\/)?/.exec(i.textAfter);return i.node.to<=i.pos+e[0].length?i.continue():i.lineIndent(i.node.from)+(e[2]?0:i.unit)},"OpenTag CloseTag SelfClosingTag"(i){return i.column(i.node.from)+i.unit},Document(i){if(i.pos+/\s*/.exec(i.textAfter)[0].length<i.node.to)return i.continue();let e=null,t;for(let s=i.node;;){let r=s.lastChild;if(!r||r.name!="Element"||r.to!=s.to)break;e=s=r}return e&&!((t=e.lastChild)&&(t.name=="CloseTag"||t.name=="SelfClosingTag"))?i.lineIndent(e.from)+i.unit:null}}),Rh.add({Element(i){let e=i.firstChild,t=i.lastChild;return!e||e.name!="OpenTag"?null:{from:e.to,to:t.name=="CloseTag"?t.from:i.to}}}),g3.add({"OpenTag CloseTag":i=>i.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Jp=CB.configure({wrap:tB(xB,wB)});function nK(i={}){let e="",t;i.matchClosingTags===!1&&(e="noMatch"),i.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(i.nestedLanguages&&i.nestedLanguages.length||i.nestedAttributes&&i.nestedAttributes.length)&&(t=tB((i.nestedLanguages||[]).concat(xB),(i.nestedAttributes||[]).concat(wB)));let s=t?CB.configure({wrap:t,dialect:e}):e?Jp.configure({dialect:e}):Jp;return new Yu(s,[Jp.data.of({autocomplete:sK(i)}),i.autoCloseTags!==!1?oK:[],YG().support,uG().support])}const dM=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),oK=pe.inputHandler.of((i,e,t,s,r)=>{if(i.composing||i.state.readOnly||e!=t||s!=">"&&s!="/"||!Jp.isActiveAt(i.state,e,-1))return!1;let n=r(),{state:o}=n,l=o.changeByRange(c=>{var u,d,m;let g=o.doc.sliceString(c.from-1,c.to)==s,{head:_}=c,y=ut(o).resolveInner(_,-1),b;if(g&&s==">"&&y.name=="EndTag"){let x=y.parent;if(((d=(u=x.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(b=Ch(o.doc,x.parent,_))&&!dM.has(b)){let w=_+(o.doc.sliceString(_,_+1)===">"?1:0),k=`</${b}>`;return{range:c,changes:{from:_,to:w,insert:k}}}}else if(g&&s=="/"&&y.name=="IncompleteCloseTag"){let x=y.parent;if(y.from==_-2&&((m=x.lastChild)===null||m===void 0?void 0:m.name)!="CloseTag"&&(b=Ch(o.doc,x,_))&&!dM.has(b)){let w=_+(o.doc.sliceString(_,_+1)===">"?1:0),k=`${b}>`;return{range:ne.cursor(_+k.length,-1),changes:{from:_,to:w,insert:k}}}}return{range:c}});return l.changes.empty?!1:(i.dispatch([n,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),kB=dS({commentTokens:{block:{open:"<!--",close:"-->"}}}),TB=new Le,AB=xH.configure({props:[Rh.add(i=>!i.is("Block")||i.is("Document")||by(i)!=null||aK(i)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),TB.add(by),Sf.add({Document:()=>null}),La.add({Document:kB})]});function by(i){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(i.name);return e?+e[1]:void 0}function aK(i){return i.name=="OrderedList"||i.name=="BulletList"}function lK(i,e){let t=i;for(;;){let s=t.nextSibling,r;if(!s||(r=by(s.type))!=null&&r<=e)break;t=s}return t.to}const hK=i3.of((i,e,t)=>{for(let s=ut(i).resolveInner(t,-1);s&&!(s.from<e);s=s.parent){let r=s.type.prop(TB);if(r==null)continue;let n=lK(s,r);if(n>t)return{from:t,to:n}}return null});function ZS(i){return new rr(kB,i,[],"markdown")}const cK=ZS(AB),uK=AB.configure([LH,BH,$H,DH,{props:[Rh.add({Table:(i,e)=>({from:e.doc.lineAt(i.from).to,to:i.to})})]}]),af=ZS(uK);function fK(i,e){return t=>{if(t&&i){let s=null;if(t=/\S*/.exec(t)[0],typeof i=="function"?s=i(t):s=Qm.matchLanguageName(i,t,!0),s instanceof Qm)return s.support?s.support.language.parser:Uu.getSkippingParser(s.load());if(s)return s.parser}return e?e.parser:null}}class K_{constructor(e,t,s,r,n,o,l){this.node=e,this.from=t,this.to=s,this.spaceBefore=r,this.spaceAfter=n,this.type=o,this.item=l}blank(e,t=!0){let s=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;s.length<e;)s+=" ";return s}else{for(let r=this.to-this.from-s.length-this.spaceAfter.length;r>0;r--)s+=" ";return s+(t?this.spaceAfter:"")}}marker(e,t){let s=this.node.name=="OrderedList"?String(+EB(this.item,e)[2]+t):"";return this.spaceBefore+s+this.type+this.spaceAfter}}function MB(i,e){let t=[],s=[];for(let r=i;r;r=r.parent){if(r.name=="FencedCode")return s;(r.name=="ListItem"||r.name=="Blockquote")&&t.push(r)}for(let r=t.length-1;r>=0;r--){let n=t[r],o,l=e.lineAt(n.from),c=n.from-l.from;if(n.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(c))))s.push(new K_(n,c,c+o[0].length,"",o[1],">",null));else if(n.name=="ListItem"&&n.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(c)))){let u=o[3],d=o[0].length;u.length>=4&&(u=u.slice(0,u.length-4),d-=4),s.push(new K_(n.parent,c,c+d,o[1],u,o[2],n))}else if(n.name=="ListItem"&&n.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(c)))){let u=o[4],d=o[0].length;u.length>4&&(u=u.slice(0,u.length-4),d-=4);let m=o[2];o[3]&&(m+=o[3].replace(/[xX]/," ")),s.push(new K_(n.parent,c,c+d,o[1],u,m,n))}}return s}function EB(i,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(i.from,i.from+10))}function J_(i,e,t,s=0){for(let r=-1,n=i;;){if(n.name=="ListItem"){let l=EB(n,e),c=+l[2];if(r>=0){if(c!=r+1)return;t.push({from:n.from+l[1].length,to:n.from+l[0].length,insert:String(r+2+s)})}r=c}let o=n.nextSibling;if(!o)break;n=o}}function jS(i,e){let t=/^[ \t]*/.exec(i)[0].length;if(!t||e.facet(Qh)!=" ")return i;let s=xr(i,4,t),r="";for(let n=s;n>0;)n>=4?(r+=" ",n-=4):(r+=" ",n--);return r+i.slice(t)}const dK=(i={})=>({state:e,dispatch:t})=>{let s=ut(e),{doc:r}=e,n=null,o=e.changeByRange(l=>{if(!l.empty||!af.isActiveAt(e,l.from,-1)&&!af.isActiveAt(e,l.from,1))return n={range:l};let c=l.from,u=r.lineAt(c),d=MB(s.resolveInner(c,-1),r);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return n={range:l};let m=d[d.length-1];if(m.to-m.spaceAfter.length>c-u.from)return n={range:l};let g=c>=m.to-m.spaceAfter.length&&!/\S/.test(u.text.slice(m.to));if(m.item&&g){let w=m.node.firstChild,k=m.node.getChild("ListItem","ListItem");if(w.to>=c||k&&k.to<c||u.from>0&&!/[^\s>]/.test(r.lineAt(u.from-1).text)||i.nonTightLists===!1){let C=d.length>1?d[d.length-2]:null,A,P="";C&&C.item?(A=u.from+C.from,P=C.marker(r,1)):A=u.from+(C?C.to:0);let E=[{from:A,to:c,insert:P}];return m.node.name=="OrderedList"&&J_(m.item,r,E,-2),C&&C.node.name=="OrderedList"&&J_(C.item,r,E),{range:ne.cursor(A+P.length),changes:E}}else{let C=mM(d,e,u);return{range:ne.cursor(c+C.length+1),changes:{from:u.from,insert:C+e.lineBreak}}}}if(m.node.name=="Blockquote"&&g&&u.from){let w=r.lineAt(u.from-1),k=/>\s*$/.exec(w.text);if(k&&k.index==m.from){let C=e.changes([{from:w.from+k.index,to:w.to},{from:u.from+m.from,to:u.to}]);return{range:l.map(C),changes:C}}}let _=[];m.node.name=="OrderedList"&&J_(m.item,r,_);let y=m.item&&m.item.from<u.from,b="";if(!y||/^[\s\d.)\-+*>]*/.exec(u.text)[0].length>=m.to)for(let w=0,k=d.length-1;w<=k;w++)b+=w==k&&!y?d[w].marker(r,1):d[w].blank(w<k?xr(u.text,4,d[w+1].from)-b.length:null);let x=c;for(;x>u.from&&/\s/.test(u.text.charAt(x-u.from-1));)x--;return b=jS(b,e),mK(m.node,e.doc)&&(b=mM(d,e,u)+e.lineBreak+b),_.push({from:x,to:c,insert:e.lineBreak+b}),{range:ne.cursor(x+b.length+1),changes:_}});return n?!1:(t(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},pK=dK();function pM(i){return i.name=="QuoteMark"||i.name=="ListMark"}function mK(i,e){if(i.name!="OrderedList"&&i.name!="BulletList")return!1;let t=i.firstChild,s=i.getChild("ListItem","ListItem");if(!s)return!1;let r=e.lineAt(t.to),n=e.lineAt(s.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1)<n.number}function mM(i,e,t){let s="";for(let r=0,n=i.length-2;r<=n;r++)s+=i[r].blank(r<n?xr(t.text,4,i[r+1].from)-s.length:null,r<n);return jS(s,e)}function gK(i,e){let t=i.resolveInner(e,-1),s=e;pM(t)&&(s=t.from,t=t.parent);for(let r;r=t.childBefore(s);)if(pM(r))s=r.from;else if(r.name=="OrderedList"||r.name=="BulletList")t=r.lastChild,s=t.to;else break;return t}const OK=({state:i,dispatch:e})=>{let t=ut(i),s=null,r=i.changeByRange(n=>{let o=n.from,{doc:l}=i;if(n.empty&&af.isActiveAt(i,n.from)){let c=l.lineAt(o),u=MB(gK(t,o),l);if(u.length){let d=u[u.length-1],m=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(o-c.from>m&&!/\S/.test(c.text.slice(m,o-c.from)))return{range:ne.cursor(c.from+m),changes:{from:c.from+m,to:o}};if(o-c.from==m&&(!d.item||c.from<=d.item.from||!/\S/.test(c.text.slice(0,d.to)))){let g=c.from+d.from;if(d.item&&d.node.from<d.item.from&&/\S/.test(c.text.slice(d.from,d.to))){let _=d.blank(xr(c.text,4,d.to)-xr(c.text,4,d.from));return g==c.from&&(_=jS(_,i)),{range:ne.cursor(g+_.length),changes:{from:g,to:c.from+d.to,insert:_}}}if(g<o)return{range:ne.cursor(g),changes:{from:g,to:o}}}}}return s={range:n}});return s?!1:(e(i.update(r,{scrollIntoView:!0,userEvent:"delete"})),!0)},_K=[{key:"Enter",run:pK},{key:"Backspace",run:OK}],PB=nK({matchClosingTags:!1});function vK(i={}){let{codeLanguages:e,defaultCodeLanguage:t,addKeymap:s=!0,base:{parser:r}=cK,completeHTMLTags:n=!0,pasteURLAsLink:o=!0,htmlTagLanguage:l=PB}=i;if(!(r instanceof bg))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=i.extensions?[i.extensions]:[],u=[l.support,hK],d;o&&u.push(xK),t instanceof Yu?(u.push(t.support),d=t.language):t&&(d=t);let m=e||d?fK(e,d):void 0;c.push(CH({codeParser:m,htmlParser:l.language.parser})),s&&u.push(Wn.high(Fa.of(_K)));let g=ZS(r.configure(c));return n&&u.push(g.data.of({autocomplete:yK})),new Yu(g,u)}function yK(i){let{state:e,pos:t}=i,s=/<[:\-\.\w\u00b7-\uffff]*$/.exec(e.sliceDoc(t-25,t));if(!s)return null;let r=ut(e).resolveInner(t,-1);for(;r&&!r.type.isTop;){if(r.name=="CodeBlock"||r.name=="FencedCode"||r.name=="ProcessingInstructionBlock"||r.name=="CommentBlock"||r.name=="Link"||r.name=="Image")return null;r=r.parent}return{from:t-s[0].length,to:t,options:bK(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let ev=null;function bK(){if(ev)return ev;let i=iK(new wS(We.create({extensions:PB}),0,!0));return ev=i?i.options:[]}const SK=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,xK=pe.domEventHandlers({paste:(i,e)=>{var t;let{main:s}=e.state.selection;if(s.empty)return!1;let r=(t=i.clipboardData)===null||t===void 0?void 0:t.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!af.isActiveAt(e.state,s.from,1)))return!1;let n=ut(e.state),o=!1;return n.iterate({from:s.from,to:s.to,enter:l=>{(l.from>s.from||SK.test(l.name))&&(o=!0)},leave:l=>{l.to<s.to&&(o=!0)}}),o?!1:(e.dispatch({changes:[{from:s.from,insert:"["},{from:s.to,insert:`](${r})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});function wK({initialContent:i,filePath:e,onSave:t,onClose:s}){const[r,n]=Y.useState(i),[o,l]=Y.useState(!1),[c,u]=Y.useState(!1),d=Y.useRef(r);Y.useEffect(()=>{d.current=r},[r]);const m=Y.useCallback(b=>{n(b),u(b!==i)},[i]),g=Y.useCallback(async()=>{if(!o){l(!0);try{await t(d.current),u(!1)}catch(b){console.error("[plan-editor] Save failed:",b)}finally{l(!1)}}},[t,o]),_=Y.useCallback(()=>{c&&!window.confirm("Unsaved changes -- discard?")||s()},[c,s]),y=Fa.of([{key:"Mod-s",run:()=>(g(),!0)}]);return Y.useEffect(()=>{const b=x=>{(x.ctrlKey||x.metaKey)&&x.key==="s"&&x.preventDefault()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[]),M.jsxs("div",{className:"fixed inset-0 z-50 bg-background/95 flex flex-col",children:[M.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-card",children:[M.jsxs("div",{className:"flex items-center gap-3",children:[M.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:e}),c&&M.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-sm bg-warning/20 text-warning font-mono",children:"unsaved"})]}),M.jsxs("div",{className:"flex items-center gap-2",children:[c&&M.jsx("button",{type:"button",onClick:g,disabled:o,className:dt("text-xs px-3 py-1.5 rounded-md font-mono","bg-accent text-foreground","hover:bg-accent-glow","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50"),children:o?"Saving...":"Save"}),M.jsx("button",{type:"button",onClick:_,className:dt("text-xs px-3 py-1.5 rounded-md font-mono","bg-muted text-muted-foreground","hover:bg-danger/20 hover:text-danger","transition-colors focus:outline-none focus:ring-2 focus:ring-accent/50"),children:"Close"})]})]}),M.jsx("div",{className:"flex-1 overflow-auto",children:M.jsx(b$,{value:r,onChange:m,theme:y$,extensions:[vK({base:af}),y],height:"calc(100vh - 56px)",basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0,bracketMatching:!0,indentOnInput:!0}})})]})}function CK({phaseId:i,onBack:e}){const{plans:t,context:s,research:r,loading:n,error:o,refetch:l}=CZ(i),[c,u]=Y.useState(null),[d,m]=Y.useState(""),g=t.length>0?t[0].frontmatter.phase??i:i,_=Y.useCallback(async x=>{try{const k=x.replace(/^\.planning[\\/]/,"").split(/[\\/]/),C=await fetch(`/api/plan/${k.join("/")}`);if(!C.ok){console.error("[phase-detail] Failed to fetch plan for editing");return}const A=await C.json();m(A.content),u(x)}catch(w){console.error("[phase-detail] Error fetching plan:",w)}},[]),y=Y.useCallback(async x=>{if(!c)return;const k=c.replace(/^\.planning[\\/]/,"").split(/[\\/]/);if(!(await fetch(`/api/plan/${k.join("/")}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:x})})).ok)throw new Error("Failed to save plan")},[c]),b=Y.useCallback(()=>{u(null),m(""),l()},[l]);return M.jsxs("div",{className:"space-y-6",children:[M.jsxs("button",{type:"button",onClick:e,className:dt("flex items-center gap-2 text-sm text-muted-foreground","hover:text-foreground transition-colors","focus:outline-none focus:ring-2 focus:ring-accent/50 rounded-md px-2 py-1"),children:[M.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M10 3L5 8l5 5"})}),"Back to overview"]}),M.jsxs("div",{children:[M.jsxs("h2",{className:"text-2xl font-semibold tracking-tight",children:[M.jsxs("span",{className:"text-accent font-mono",children:["Phase ",i]}),M.jsx("span",{className:"mx-2 text-muted-foreground",children:"-"}),M.jsx("span",{children:g})]}),M.jsxs("div",{className:"flex gap-2 mt-2",children:[s&&M.jsx("span",{className:"text-xs px-2 py-0.5 rounded-sm bg-success/20 text-success font-mono",children:"context available"}),r&&M.jsx("span",{className:"text-xs px-2 py-0.5 rounded-sm bg-success/20 text-success font-mono",children:"research available"}),!s&&!r&&!n&&M.jsx("span",{className:"text-xs px-2 py-0.5 rounded-sm bg-muted text-muted-foreground font-mono",children:"no context or research"})]})]}),o&&M.jsx("div",{className:"p-4 rounded-lg border border-danger/50 bg-danger/10 text-danger text-sm",children:o}),n&&t.length===0&&M.jsx("div",{className:"space-y-4",children:[1,2,3].map(x=>M.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 animate-pulse",children:[M.jsx("div",{className:"h-6 w-32 bg-muted rounded mb-3"}),M.jsx("div",{className:"h-4 w-3/4 bg-muted rounded mb-2"}),M.jsx("div",{className:"h-4 w-1/2 bg-muted rounded mb-3"}),M.jsxs("div",{className:"space-y-2",children:[M.jsx("div",{className:"h-3 w-full bg-muted rounded"}),M.jsx("div",{className:"h-3 w-5/6 bg-muted rounded"})]})]},x))}),!n&&!o&&t.length===0&&M.jsx("div",{className:"p-8 text-center text-muted-foreground border border-border rounded-lg bg-card",children:M.jsxs("p",{className:"text-sm",children:["No plans yet -- run"," ",M.jsx("code",{className:"font-mono text-accent",children:"/maxsim:plan-phase"})," to create plans"]})}),t.length>0&&M.jsx("div",{className:"space-y-4",children:t.map(x=>M.jsx(TZ,{plan:x,onEdit:_},x.path))}),c&&M.jsx(wK,{initialContent:d,filePath:c,onSave:y,onClose:b})]})}function kK(){const{lastChange:i}=ff(),[e,t]=Y.useState([]),[s,r]=Y.useState([]),[n,o]=Y.useState(!0),[l,c]=Y.useState(null),[u,d]=Y.useState(""),[m,g]=Y.useState(!1),[_,y]=Y.useState(!1),b=Y.useCallback(async()=>{try{c(null);const k=await fetch("/api/todos");if(!k.ok)throw new Error(`Failed to fetch todos: ${k.status}`);const C=await k.json();t(C.pending),r(C.completed)}catch(k){c(k instanceof Error?k.message:"Failed to fetch todos")}finally{o(!1)}},[]);Y.useEffect(()=>{b()},[b]),Y.useEffect(()=>{i>0&&b()},[i,b]);const x=Y.useCallback(async()=>{const k=u.trim();if(k){g(!0);try{if(!(await fetch("/api/todos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:k})})).ok)throw new Error("Failed to create todo");d(""),await b()}catch(C){c(C instanceof Error?C.message:"Failed to create todo")}finally{g(!1)}}},[u,b]),w=Y.useCallback(async(k,C)=>{try{if(!(await fetch("/api/todos",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:k,completed:C})})).ok)throw new Error("Failed to update todo");await b()}catch(A){c(A instanceof Error?A.message:"Failed to update todo")}},[b]);return M.jsxs("div",{className:"space-y-6",children:[M.jsxs("div",{className:"flex items-center justify-between",children:[M.jsx("h2",{className:"font-mono text-lg font-semibold tracking-tight text-foreground",children:"Todos"}),M.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:[e.length," pending"]})]}),M.jsxs("div",{className:"flex gap-2",children:[M.jsx("input",{type:"text",value:u,onChange:k=>d(k.target.value),onKeyDown:k=>{k.key==="Enter"&&!m&&x()},placeholder:"Add a new todo...",className:"flex-1 rounded-sm border border-border bg-card px-3 py-2 font-mono text-sm text-foreground placeholder:text-muted-foreground focus:border-accent focus:outline-none"}),M.jsx("button",{type:"button",onClick:x,disabled:m||!u.trim(),className:dt("rounded-sm bg-accent px-4 py-2 font-mono text-xs font-semibold text-foreground transition-colors","hover:bg-accent-glow disabled:opacity-40 disabled:cursor-not-allowed"),children:"Add"})]}),l&&M.jsx("div",{className:"rounded-sm border border-danger/50 bg-danger/10 px-3 py-2 text-sm text-danger",children:l}),n&&M.jsx("div",{className:"space-y-2",children:[1,2,3].map(k=>M.jsxs("div",{className:"flex items-center gap-3 rounded-sm bg-card px-4 py-3",children:[M.jsx("div",{className:"h-4 w-4 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-4 w-48 animate-pulse rounded-sm bg-muted"})]},k))}),!n&&M.jsx("div",{className:"space-y-1",children:e.length===0?M.jsx("p",{className:"px-4 py-6 text-center text-sm text-muted-foreground",children:"No pending todos"}):e.map(k=>M.jsxs("button",{type:"button",onClick:()=>w(k.file,!0),className:"group flex w-full items-center gap-3 rounded-sm px-4 py-2.5 text-left transition-colors hover:bg-card-hover",children:[M.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-muted-foreground transition-colors group-hover:border-accent"}),M.jsx("span",{className:"text-sm text-foreground",children:k.text})]},k.file))}),!n&&s.length>0&&M.jsxs("div",{className:"border-t border-border pt-4",children:[M.jsxs("button",{type:"button",onClick:()=>y(!_),className:"flex w-full items-center gap-2 text-left",children:[M.jsx("svg",{className:dt("h-3 w-3 text-muted-foreground transition-transform",_&&"rotate-90"),viewBox:"0 0 12 12",fill:"currentColor",children:M.jsx("path",{d:"M4 2l5 4-5 4z"})}),M.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Completed (",s.length,")"]})]}),_&&M.jsx("div",{className:"mt-2 space-y-1",children:s.map(k=>M.jsxs("button",{type:"button",onClick:()=>w(k.file,!1),className:"group flex w-full items-center gap-3 rounded-sm px-4 py-2 text-left transition-colors hover:bg-card-hover",children:[M.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border border-success bg-success/20",children:M.jsx("svg",{className:"h-3 w-3 text-success",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M2 6l3 3 5-5"})})}),M.jsx("span",{className:"text-sm text-muted-foreground line-through",children:k.text})]},k.file))})]})]})}function TK({onEntryAdded:i}){const[e,t]=Y.useState(!1),[s,r]=Y.useState("decision"),[n,o]=Y.useState(""),[l,c]=Y.useState(""),[u,d]=Y.useState(!1),[m,g]=Y.useState(null),[_,y]=Y.useState(null),b=Y.useCallback(async()=>{const x=l.trim();if(x){d(!0),g(null),y(null);try{if(s==="decision"){const w=await fetch("/api/state/decision",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phase:n.trim()||void 0,text:x})});if(!w.ok){const k=await w.json().catch(()=>({}));throw new Error(k.error||"Could not add decision")}y("Decision added")}else{const w=await fetch("/api/state/blocker",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:x})});if(!w.ok){const k=await w.json().catch(()=>({}));throw new Error(k.error||"Could not add blocker")}y("Blocker added")}c(""),o(""),i==null||i(),setTimeout(()=>y(null),2e3)}catch(w){g(w instanceof Error?w.message:"Failed to update STATE.md")}finally{d(!1)}}},[s,n,l,i]);return M.jsxs("div",{className:"border-t border-border pt-4",children:[M.jsxs("button",{type:"button",onClick:()=>t(!e),className:"flex w-full items-center gap-2 text-left",children:[M.jsx("svg",{className:dt("h-3 w-3 text-muted-foreground transition-transform",e&&"rotate-90"),viewBox:"0 0 12 12",fill:"currentColor",children:M.jsx("path",{d:"M4 2l5 4-5 4z"})}),M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide text-muted-foreground",children:"Add to STATE.md"})]}),e&&M.jsxs("div",{className:"mt-3 space-y-3",children:[M.jsxs("div",{className:"flex gap-1",children:[M.jsx("button",{type:"button",onClick:()=>r("decision"),className:dt("rounded-sm px-3 py-1 font-mono text-xs transition-colors",s==="decision"?"bg-accent/20 text-accent":"text-muted-foreground hover:text-foreground"),children:"Decision"}),M.jsx("button",{type:"button",onClick:()=>r("blocker"),className:dt("rounded-sm px-3 py-1 font-mono text-xs transition-colors",s==="blocker"?"bg-danger/20 text-danger":"text-muted-foreground hover:text-foreground"),children:"Blocker"})]}),s==="decision"&&M.jsx("input",{type:"text",value:n,onChange:x=>o(x.target.value),placeholder:"Phase (e.g. 13-06)",className:"w-full rounded-sm border border-border bg-card px-3 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground focus:border-accent focus:outline-none"}),M.jsx("input",{type:"text",value:l,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!u&&b()},placeholder:s==="decision"?"Decision text...":"Blocker description...",className:"w-full rounded-sm border border-border bg-card px-3 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground focus:border-accent focus:outline-none"}),M.jsx("button",{type:"button",onClick:b,disabled:u||!l.trim(),className:dt("rounded-sm px-3 py-1.5 font-mono text-xs font-semibold transition-colors","disabled:opacity-40 disabled:cursor-not-allowed",s==="decision"?"bg-accent/20 text-accent hover:bg-accent/30":"bg-danger/20 text-danger hover:bg-danger/30"),children:u?"Saving...":`Add ${s==="decision"?"Decision":"Blocker"}`}),m&&M.jsx("p",{className:"text-xs text-danger",children:m}),_&&M.jsx("p",{className:"text-xs text-success",children:_})]})]})}function AK(i){return i.map(e=>({text:e.replace(/~~(.+)~~/,"$1").replace(/\s*RESOLVED.*$/i,"").trim(),resolved:e.includes("RESOLVED")||e.startsWith("~~")&&e.endsWith("~~")}))}function MK(){const{state:i}=fb(),[e,t]=Y.useState(!1),[s,r]=Y.useState(null),[n,o]=Y.useState(null),[l,c]=Y.useState(0),u=AK((i==null?void 0:i.blockers)??[]),d=u.filter(y=>!y.resolved),m=u.filter(y=>y.resolved),g=Y.useCallback(async y=>{r(y),o(null);try{if(!(await fetch("/api/state",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({field:"blockers",value:`~~${y}~~ RESOLVED`})})).ok)throw new Error("Failed to resolve blocker");c(x=>x+1)}catch(b){o(b instanceof Error?b.message:"Failed to resolve blocker")}finally{r(null)}},[]),_=Y.useCallback(()=>{c(y=>y+1)},[]);return M.jsxs("div",{className:"space-y-6",children:[M.jsxs("div",{className:"flex items-center justify-between",children:[M.jsx("h2",{className:"font-mono text-lg font-semibold tracking-tight text-foreground",children:"Blockers"}),M.jsx("span",{className:dt("font-mono text-xs",d.length>0?"text-danger":"text-success"),children:d.length>0?`${d.length} active`:"No active blockers"})]}),n&&M.jsx("div",{className:"rounded-sm border border-danger/50 bg-danger/10 px-3 py-2 text-sm text-danger",children:n}),d.length===0?M.jsx("div",{className:"rounded-sm border border-success/30 bg-success/5 px-4 py-6 text-center",children:M.jsx("p",{className:"text-sm text-success",children:"No active blockers"})}):M.jsx("div",{className:"space-y-2",children:d.map(y=>M.jsxs("div",{className:"flex items-start gap-3 rounded-sm border border-border bg-card px-4 py-3",children:[M.jsx("span",{className:"mt-1 inline-block h-2 w-2 shrink-0 rounded-full bg-danger"}),M.jsx("div",{className:"flex-1",children:M.jsx("p",{className:"text-sm text-foreground",children:y.text})}),M.jsx("button",{type:"button",onClick:()=>g(y.text),disabled:s===y.text,className:dt("shrink-0 rounded-sm px-3 py-1 font-mono text-xs transition-colors","bg-success/20 text-success hover:bg-success/30","disabled:opacity-40 disabled:cursor-not-allowed"),children:s===y.text?"...":"Resolve"})]},y.text))}),m.length>0&&M.jsxs("div",{className:"border-t border-border pt-4",children:[M.jsxs("button",{type:"button",onClick:()=>t(!e),className:"flex w-full items-center gap-2 text-left",children:[M.jsx("svg",{className:dt("h-3 w-3 text-muted-foreground transition-transform",e&&"rotate-90"),viewBox:"0 0 12 12",fill:"currentColor",children:M.jsx("path",{d:"M4 2l5 4-5 4z"})}),M.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Resolved (",m.length,")"]})]}),e&&M.jsx("div",{className:"mt-2 space-y-1",children:m.map(y=>M.jsxs("div",{className:"flex items-center gap-3 rounded-sm px-4 py-2",children:[M.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-muted"}),M.jsx("p",{className:"text-sm text-muted-foreground line-through",children:y.text})]},y.text))})]}),M.jsx(TK,{onEntryAdded:_})]},l)}function EK({sidebar:i,children:e}){return M.jsxs("div",{className:"flex h-screen overflow-hidden",children:[M.jsx("div",{className:"hidden md:flex",children:i}),M.jsx("main",{className:"flex flex-1 flex-col overflow-hidden",children:e})]})}var Nl={},tv,gM;function PK(){return gM||(gM=1,tv=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),tv}var iv={},wo={},OM;function Ga(){if(OM)return wo;OM=1;let i;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return wo.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},wo.getSymbolTotalCodewords=function(s){return e[s]},wo.getBCHDigit=function(t){let s=0;for(;t!==0;)s++,t>>>=1;return s},wo.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');i=s},wo.isKanjiModeEnabled=function(){return typeof i<"u"},wo.toSJIS=function(s){return i(s)},wo}var sv={},_M;function IS(){return _M||(_M=1,(function(i){i.L={bit:1},i.M={bit:0},i.Q={bit:3},i.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return i.L;case"m":case"medium":return i.M;case"q":case"quartile":return i.Q;case"h":case"high":return i.H;default:throw new Error("Unknown EC Level: "+t)}}i.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},i.from=function(s,r){if(i.isValid(s))return s;try{return e(s)}catch{return r}}})(sv)),sv}var rv,vM;function QK(){if(vM)return rv;vM=1;function i(){this.buffer=[],this.length=0}return i.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let s=0;s<t;s++)this.putBit((e>>>t-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},rv=i,rv}var nv,yM;function RK(){if(yM)return nv;yM=1;function i(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return i.prototype.set=function(e,t,s,r){const n=e*this.size+t;this.data[n]=s,r&&(this.reservedBit[n]=!0)},i.prototype.get=function(e,t){return this.data[e*this.size+t]},i.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s},i.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},nv=i,nv}var ov={},bM;function LK(){return bM||(bM=1,(function(i){const e=Ga().getSymbolSize;i.getRowColCoords=function(s){if(s===1)return[];const r=Math.floor(s/7)+2,n=e(s),o=n===145?26:Math.ceil((n-13)/(2*r-2))*2,l=[n-7];for(let c=1;c<r-1;c++)l[c]=l[c-1]-o;return l.push(6),l.reverse()},i.getPositions=function(s){const r=[],n=i.getRowColCoords(s),o=n.length;for(let l=0;l<o;l++)for(let c=0;c<o;c++)l===0&&c===0||l===0&&c===o-1||l===o-1&&c===0||r.push([n[l],n[c]]);return r}})(ov)),ov}var av={},SM;function $K(){if(SM)return av;SM=1;const i=Ga().getSymbolSize,e=7;return av.getPositions=function(s){const r=i(s);return[[0,0],[r-e,0],[0,r-e]]},av}var lv={},xM;function BK(){return xM||(xM=1,(function(i){i.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};i.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},i.from=function(r){return i.isValid(r)?parseInt(r,10):void 0},i.getPenaltyN1=function(r){const n=r.size;let o=0,l=0,c=0,u=null,d=null;for(let m=0;m<n;m++){l=c=0,u=d=null;for(let g=0;g<n;g++){let _=r.get(m,g);_===u?l++:(l>=5&&(o+=e.N1+(l-5)),u=_,l=1),_=r.get(g,m),_===d?c++:(c>=5&&(o+=e.N1+(c-5)),d=_,c=1)}l>=5&&(o+=e.N1+(l-5)),c>=5&&(o+=e.N1+(c-5))}return o},i.getPenaltyN2=function(r){const n=r.size;let o=0;for(let l=0;l<n-1;l++)for(let c=0;c<n-1;c++){const u=r.get(l,c)+r.get(l,c+1)+r.get(l+1,c)+r.get(l+1,c+1);(u===4||u===0)&&o++}return o*e.N2},i.getPenaltyN3=function(r){const n=r.size;let o=0,l=0,c=0;for(let u=0;u<n;u++){l=c=0;for(let d=0;d<n;d++)l=l<<1&2047|r.get(u,d),d>=10&&(l===1488||l===93)&&o++,c=c<<1&2047|r.get(d,u),d>=10&&(c===1488||c===93)&&o++}return o*e.N3},i.getPenaltyN4=function(r){let n=0;const o=r.data.length;for(let c=0;c<o;c++)n+=r.data[c];return Math.abs(Math.ceil(n*100/o/5)-10)*e.N4};function t(s,r,n){switch(s){case i.Patterns.PATTERN000:return(r+n)%2===0;case i.Patterns.PATTERN001:return r%2===0;case i.Patterns.PATTERN010:return n%3===0;case i.Patterns.PATTERN011:return(r+n)%3===0;case i.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case i.Patterns.PATTERN101:return r*n%2+r*n%3===0;case i.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case i.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}i.applyMask=function(r,n){const o=n.size;for(let l=0;l<o;l++)for(let c=0;c<o;c++)n.isReserved(c,l)||n.xor(c,l,t(r,c,l))},i.getBestMask=function(r,n){const o=Object.keys(i.Patterns).length;let l=0,c=1/0;for(let u=0;u<o;u++){n(u),i.applyMask(u,r);const d=i.getPenaltyN1(r)+i.getPenaltyN2(r)+i.getPenaltyN3(r)+i.getPenaltyN4(r);i.applyMask(u,r),d<c&&(c=d,l=u)}return l}})(lv)),lv}var Cp={},wM;function QB(){if(wM)return Cp;wM=1;const i=IS(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],t=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Cp.getBlocksCount=function(r,n){switch(n){case i.L:return e[(r-1)*4+0];case i.M:return e[(r-1)*4+1];case i.Q:return e[(r-1)*4+2];case i.H:return e[(r-1)*4+3];default:return}},Cp.getTotalCodewordsCount=function(r,n){switch(n){case i.L:return t[(r-1)*4+0];case i.M:return t[(r-1)*4+1];case i.Q:return t[(r-1)*4+2];case i.H:return t[(r-1)*4+3];default:return}},Cp}var hv={},Yc={},CM;function DK(){if(CM)return Yc;CM=1;const i=new Uint8Array(512),e=new Uint8Array(256);return(function(){let s=1;for(let r=0;r<255;r++)i[r]=s,e[s]=r,s<<=1,s&256&&(s^=285);for(let r=255;r<512;r++)i[r]=i[r-255]})(),Yc.log=function(s){if(s<1)throw new Error("log("+s+")");return e[s]},Yc.exp=function(s){return i[s]},Yc.mul=function(s,r){return s===0||r===0?0:i[e[s]+e[r]]},Yc}var kM;function zK(){return kM||(kM=1,(function(i){const e=DK();i.mul=function(s,r){const n=new Uint8Array(s.length+r.length-1);for(let o=0;o<s.length;o++)for(let l=0;l<r.length;l++)n[o+l]^=e.mul(s[o],r[l]);return n},i.mod=function(s,r){let n=new Uint8Array(s);for(;n.length-r.length>=0;){const o=n[0];for(let c=0;c<r.length;c++)n[c]^=e.mul(r[c],o);let l=0;for(;l<n.length&&n[l]===0;)l++;n=n.slice(l)}return n},i.generateECPolynomial=function(s){let r=new Uint8Array([1]);for(let n=0;n<s;n++)r=i.mul(r,new Uint8Array([1,e.exp(n)]));return r}})(hv)),hv}var cv,TM;function NK(){if(TM)return cv;TM=1;const i=zK();function e(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(s){this.degree=s,this.genPoly=i.generateECPolynomial(this.degree)},e.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(s.length+this.degree);r.set(s);const n=i.mod(r,this.genPoly),o=this.degree-n.length;if(o>0){const l=new Uint8Array(this.degree);return l.set(n,o),l}return n},cv=e,cv}var uv={},fv={},dv={},AM;function RB(){return AM||(AM=1,dv.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),dv}var Br={},MM;function LB(){if(MM)return Br;MM=1;const i="[0-9]+",e="[A-Z $%*+\\-./:]+";let t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";t=t.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+t+`)(?:.|[\r
79
+ ]))+`;Br.KANJI=new RegExp(t,"g"),Br.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Br.BYTE=new RegExp(s,"g"),Br.NUMERIC=new RegExp(i,"g"),Br.ALPHANUMERIC=new RegExp(e,"g");const r=new RegExp("^"+t+"$"),n=new RegExp("^"+i+"$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Br.testKanji=function(c){return r.test(c)},Br.testNumeric=function(c){return n.test(c)},Br.testAlphanumeric=function(c){return o.test(c)},Br}var EM;function Ka(){return EM||(EM=1,(function(i){const e=RB(),t=LB();i.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},i.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},i.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},i.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},i.MIXED={bit:-1},i.getCharCountIndicator=function(n,o){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?n.ccBits[0]:o<27?n.ccBits[1]:n.ccBits[2]},i.getBestModeForData=function(n){return t.testNumeric(n)?i.NUMERIC:t.testAlphanumeric(n)?i.ALPHANUMERIC:t.testKanji(n)?i.KANJI:i.BYTE},i.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},i.isValid=function(n){return n&&n.bit&&n.ccBits};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return i.NUMERIC;case"alphanumeric":return i.ALPHANUMERIC;case"kanji":return i.KANJI;case"byte":return i.BYTE;default:throw new Error("Unknown mode: "+r)}}i.from=function(n,o){if(i.isValid(n))return n;try{return s(n)}catch{return o}}})(fv)),fv}var PM;function XK(){return PM||(PM=1,(function(i){const e=Ga(),t=QB(),s=IS(),r=Ka(),n=RB(),o=7973,l=e.getBCHDigit(o);function c(g,_,y){for(let b=1;b<=40;b++)if(_<=i.getCapacity(b,y,g))return b}function u(g,_){return r.getCharCountIndicator(g,_)+4}function d(g,_){let y=0;return g.forEach(function(b){const x=u(b.mode,_);y+=x+b.getBitsLength()}),y}function m(g,_){for(let y=1;y<=40;y++)if(d(g,y)<=i.getCapacity(y,_,r.MIXED))return y}i.from=function(_,y){return n.isValid(_)?parseInt(_,10):y},i.getCapacity=function(_,y,b){if(!n.isValid(_))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=r.BYTE);const x=e.getSymbolTotalCodewords(_),w=t.getTotalCodewordsCount(_,y),k=(x-w)*8;if(b===r.MIXED)return k;const C=k-u(b,_);switch(b){case r.NUMERIC:return Math.floor(C/10*3);case r.ALPHANUMERIC:return Math.floor(C/11*2);case r.KANJI:return Math.floor(C/13);case r.BYTE:default:return Math.floor(C/8)}},i.getBestVersionForData=function(_,y){let b;const x=s.from(y,s.M);if(Array.isArray(_)){if(_.length>1)return m(_,x);if(_.length===0)return 1;b=_[0]}else b=_;return c(b.mode,b.getLength(),x)},i.getEncodedBits=function(_){if(!n.isValid(_)||_<7)throw new Error("Invalid QR Code version");let y=_<<12;for(;e.getBCHDigit(y)-l>=0;)y^=o<<e.getBCHDigit(y)-l;return _<<12|y}})(uv)),uv}var pv={},QM;function VK(){if(QM)return pv;QM=1;const i=Ga(),e=1335,t=21522,s=i.getBCHDigit(e);return pv.getEncodedBits=function(n,o){const l=n.bit<<3|o;let c=l<<10;for(;i.getBCHDigit(c)-s>=0;)c^=e<<i.getBCHDigit(c)-s;return(l<<10|c)^t},pv}var mv={},gv,RM;function ZK(){if(RM)return gv;RM=1;const i=Ka();function e(t){this.mode=i.NUMERIC,this.data=t.toString()}return e.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(s){let r,n,o;for(r=0;r+3<=this.data.length;r+=3)n=this.data.substr(r,3),o=parseInt(n,10),s.put(o,10);const l=this.data.length-r;l>0&&(n=this.data.substr(r),o=parseInt(n,10),s.put(o,l*3+1))},gv=e,gv}var Ov,LM;function jK(){if(LM)return Ov;LM=1;const i=Ka(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function t(s){this.mode=i.ALPHANUMERIC,this.data=s}return t.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){let n;for(n=0;n+2<=this.data.length;n+=2){let o=e.indexOf(this.data[n])*45;o+=e.indexOf(this.data[n+1]),r.put(o,11)}this.data.length%2&&r.put(e.indexOf(this.data[n]),6)},Ov=t,Ov}var _v,$M;function IK(){if($M)return _v;$M=1;const i=Ka();function e(t){this.mode=i.BYTE,typeof t=="string"?this.data=new TextEncoder().encode(t):this.data=new Uint8Array(t)}return e.getBitsLength=function(s){return s*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){for(let s=0,r=this.data.length;s<r;s++)t.put(this.data[s],8)},_v=e,_v}var vv,BM;function qK(){if(BM)return vv;BM=1;const i=Ka(),e=Ga();function t(s){this.mode=i.KANJI,this.data=s}return t.getBitsLength=function(r){return r*13},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let r;for(r=0;r<this.data.length;r++){let n=e.toSJIS(this.data[r]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
80
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),s.put(n,13)}},vv=t,vv}var yv={exports:{}},DM;function WK(){return DM||(DM=1,(function(i){var e={single_source_shortest_paths:function(t,s,r){var n={},o={};o[s]=0;var l=e.PriorityQueue.make();l.push(s,0);for(var c,u,d,m,g,_,y,b,x;!l.empty();){c=l.pop(),u=c.value,m=c.cost,g=t[u]||{};for(d in g)g.hasOwnProperty(d)&&(_=g[d],y=m+_,b=o[d],x=typeof o[d]>"u",(x||b>y)&&(o[d]=y,l.push(d,y),n[d]=u))}if(typeof r<"u"&&typeof o[r]>"u"){var w=["Could not find a path from ",s," to ",r,"."].join("");throw new Error(w)}return n},extract_shortest_path_from_predecessor_list:function(t,s){for(var r=[],n=s;n;)r.push(n),t[n],n=t[n];return r.reverse(),r},find_path:function(t,s,r){var n=e.single_source_shortest_paths(t,s,r);return e.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(t){var s=e.PriorityQueue,r={},n;t=t||{};for(n in s)s.hasOwnProperty(n)&&(r[n]=s[n]);return r.queue=[],r.sorter=t.sorter||s.default_sorter,r},default_sorter:function(t,s){return t.cost-s.cost},push:function(t,s){var r={value:t,cost:s};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};i.exports=e})(yv)),yv.exports}var zM;function UK(){return zM||(zM=1,(function(i){const e=Ka(),t=ZK(),s=jK(),r=IK(),n=qK(),o=LB(),l=Ga(),c=WK();function u(w){return unescape(encodeURIComponent(w)).length}function d(w,k,C){const A=[];let P;for(;(P=w.exec(C))!==null;)A.push({data:P[0],index:P.index,mode:k,length:P[0].length});return A}function m(w){const k=d(o.NUMERIC,e.NUMERIC,w),C=d(o.ALPHANUMERIC,e.ALPHANUMERIC,w);let A,P;return l.isKanjiModeEnabled()?(A=d(o.BYTE,e.BYTE,w),P=d(o.KANJI,e.KANJI,w)):(A=d(o.BYTE_KANJI,e.BYTE,w),P=[]),k.concat(C,A,P).sort(function($,z){return $.index-z.index}).map(function($){return{data:$.data,mode:$.mode,length:$.length}})}function g(w,k){switch(k){case e.NUMERIC:return t.getBitsLength(w);case e.ALPHANUMERIC:return s.getBitsLength(w);case e.KANJI:return n.getBitsLength(w);case e.BYTE:return r.getBitsLength(w)}}function _(w){return w.reduce(function(k,C){const A=k.length-1>=0?k[k.length-1]:null;return A&&A.mode===C.mode?(k[k.length-1].data+=C.data,k):(k.push(C),k)},[])}function y(w){const k=[];for(let C=0;C<w.length;C++){const A=w[C];switch(A.mode){case e.NUMERIC:k.push([A,{data:A.data,mode:e.ALPHANUMERIC,length:A.length},{data:A.data,mode:e.BYTE,length:A.length}]);break;case e.ALPHANUMERIC:k.push([A,{data:A.data,mode:e.BYTE,length:A.length}]);break;case e.KANJI:k.push([A,{data:A.data,mode:e.BYTE,length:u(A.data)}]);break;case e.BYTE:k.push([{data:A.data,mode:e.BYTE,length:u(A.data)}])}}return k}function b(w,k){const C={},A={start:{}};let P=["start"];for(let E=0;E<w.length;E++){const $=w[E],z=[];for(let I=0;I<$.length;I++){const se=$[I],F=""+E+I;z.push(F),C[F]={node:se,lastCount:0},A[F]={};for(let R=0;R<P.length;R++){const L=P[R];C[L]&&C[L].node.mode===se.mode?(A[L][F]=g(C[L].lastCount+se.length,se.mode)-g(C[L].lastCount,se.mode),C[L].lastCount+=se.length):(C[L]&&(C[L].lastCount=se.length),A[L][F]=g(se.length,se.mode)+4+e.getCharCountIndicator(se.mode,k))}}P=z}for(let E=0;E<P.length;E++)A[P[E]].end=0;return{map:A,table:C}}function x(w,k){let C;const A=e.getBestModeForData(w);if(C=e.from(k,A),C!==e.BYTE&&C.bit<A.bit)throw new Error('"'+w+'" cannot be encoded with mode '+e.toString(C)+`.
81
+ Suggested mode is: `+e.toString(A));switch(C===e.KANJI&&!l.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new t(w);case e.ALPHANUMERIC:return new s(w);case e.KANJI:return new n(w);case e.BYTE:return new r(w)}}i.fromArray=function(k){return k.reduce(function(C,A){return typeof A=="string"?C.push(x(A,null)):A.data&&C.push(x(A.data,A.mode)),C},[])},i.fromString=function(k,C){const A=m(k,l.isKanjiModeEnabled()),P=y(A),E=b(P,C),$=c.find_path(E.map,"start","end"),z=[];for(let I=1;I<$.length-1;I++)z.push(E.table[$[I]].node);return i.fromArray(_(z))},i.rawSplit=function(k){return i.fromArray(m(k,l.isKanjiModeEnabled()))}})(mv)),mv}var NM;function YK(){if(NM)return iv;NM=1;const i=Ga(),e=IS(),t=QK(),s=RK(),r=LK(),n=$K(),o=BK(),l=QB(),c=NK(),u=XK(),d=VK(),m=Ka(),g=UK();function _(E,$){const z=E.size,I=n.getPositions($);for(let se=0;se<I.length;se++){const F=I[se][0],R=I[se][1];for(let L=-1;L<=7;L++)if(!(F+L<=-1||z<=F+L))for(let N=-1;N<=7;N++)R+N<=-1||z<=R+N||(L>=0&&L<=6&&(N===0||N===6)||N>=0&&N<=6&&(L===0||L===6)||L>=2&&L<=4&&N>=2&&N<=4?E.set(F+L,R+N,!0,!0):E.set(F+L,R+N,!1,!0))}}function y(E){const $=E.size;for(let z=8;z<$-8;z++){const I=z%2===0;E.set(z,6,I,!0),E.set(6,z,I,!0)}}function b(E,$){const z=r.getPositions($);for(let I=0;I<z.length;I++){const se=z[I][0],F=z[I][1];for(let R=-2;R<=2;R++)for(let L=-2;L<=2;L++)R===-2||R===2||L===-2||L===2||R===0&&L===0?E.set(se+R,F+L,!0,!0):E.set(se+R,F+L,!1,!0)}}function x(E,$){const z=E.size,I=u.getEncodedBits($);let se,F,R;for(let L=0;L<18;L++)se=Math.floor(L/3),F=L%3+z-8-3,R=(I>>L&1)===1,E.set(se,F,R,!0),E.set(F,se,R,!0)}function w(E,$,z){const I=E.size,se=d.getEncodedBits($,z);let F,R;for(F=0;F<15;F++)R=(se>>F&1)===1,F<6?E.set(F,8,R,!0):F<8?E.set(F+1,8,R,!0):E.set(I-15+F,8,R,!0),F<8?E.set(8,I-F-1,R,!0):F<9?E.set(8,15-F-1+1,R,!0):E.set(8,15-F-1,R,!0);E.set(I-8,8,1,!0)}function k(E,$){const z=E.size;let I=-1,se=z-1,F=7,R=0;for(let L=z-1;L>0;L-=2)for(L===6&&L--;;){for(let N=0;N<2;N++)if(!E.isReserved(se,L-N)){let Z=!1;R<$.length&&(Z=($[R]>>>F&1)===1),E.set(se,L-N,Z),F--,F===-1&&(R++,F=7)}if(se+=I,se<0||z<=se){se-=I,I=-I;break}}}function C(E,$,z){const I=new t;z.forEach(function(N){I.put(N.mode.bit,4),I.put(N.getLength(),m.getCharCountIndicator(N.mode,E)),N.write(I)});const se=i.getSymbolTotalCodewords(E),F=l.getTotalCodewordsCount(E,$),R=(se-F)*8;for(I.getLengthInBits()+4<=R&&I.put(0,4);I.getLengthInBits()%8!==0;)I.putBit(0);const L=(R-I.getLengthInBits())/8;for(let N=0;N<L;N++)I.put(N%2?17:236,8);return A(I,E,$)}function A(E,$,z){const I=i.getSymbolTotalCodewords($),se=l.getTotalCodewordsCount($,z),F=I-se,R=l.getBlocksCount($,z),L=I%R,N=R-L,Z=Math.floor(I/R),Q=Math.floor(F/R),X=Q+1,W=Z-Q,U=new c(W);let q=0;const D=new Array(R),G=new Array(R);let ie=0;const ce=new Uint8Array(E.buffer);for(let ye=0;ye<R;ye++){const mt=ye<N?Q:X;D[ye]=ce.slice(q,q+mt),G[ye]=U.encode(D[ye]),q+=mt,ie=Math.max(ie,mt)}const he=new Uint8Array(I);let de=0,ge,Ae;for(ge=0;ge<ie;ge++)for(Ae=0;Ae<R;Ae++)ge<D[Ae].length&&(he[de++]=D[Ae][ge]);for(ge=0;ge<W;ge++)for(Ae=0;Ae<R;Ae++)he[de++]=G[Ae][ge];return he}function P(E,$,z,I){let se;if(Array.isArray(E))se=g.fromArray(E);else if(typeof E=="string"){let Z=$;if(!Z){const Q=g.rawSplit(E);Z=u.getBestVersionForData(Q,z)}se=g.fromString(E,Z||40)}else throw new Error("Invalid data");const F=u.getBestVersionForData(se,z);if(!F)throw new Error("The amount of data is too big to be stored in a QR Code");if(!$)$=F;else if($<F)throw new Error(`
82
+ The chosen QR Code version cannot contain this amount of data.
83
+ Minimum version required to store current data is: `+F+`.
84
+ `);const R=C($,z,se),L=i.getSymbolSize($),N=new s(L);return _(N,$),y(N),b(N,$),w(N,z,0),$>=7&&x(N,$),k(N,R),isNaN(I)&&(I=o.getBestMask(N,w.bind(null,N,z))),o.applyMask(I,N),w(N,z,I),{modules:N,version:$,errorCorrectionLevel:z,maskPattern:I,segments:se}}return iv.create=function($,z){if(typeof $>"u"||$==="")throw new Error("No input text");let I=e.M,se,F;return typeof z<"u"&&(I=e.from(z.errorCorrectionLevel,e.M),se=u.from(z.version),F=o.from(z.maskPattern),z.toSJISFunc&&i.setToSJISFunction(z.toSJISFunc)),P($,se,I,F)},iv}var bv={},Sv={},XM;function $B(){return XM||(XM=1,(function(i){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");let s=t.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+t);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(n){return[n,n]}))),s.length===6&&s.push("F","F");const r=parseInt(s.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+s.slice(0,6).join("")}}i.getOptions=function(s){s||(s={}),s.color||(s.color={});const r=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,n=s.width&&s.width>=21?s.width:void 0,o=s.scale||4;return{width:n,scale:n?4:o,margin:r,color:{dark:e(s.color.dark||"#000000ff"),light:e(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},i.getScale=function(s,r){return r.width&&r.width>=s+r.margin*2?r.width/(s+r.margin*2):r.scale},i.getImageWidth=function(s,r){const n=i.getScale(s,r);return Math.floor((s+r.margin*2)*n)},i.qrToImageData=function(s,r,n){const o=r.modules.size,l=r.modules.data,c=i.getScale(o,n),u=Math.floor((o+n.margin*2)*c),d=n.margin*c,m=[n.color.light,n.color.dark];for(let g=0;g<u;g++)for(let _=0;_<u;_++){let y=(g*u+_)*4,b=n.color.light;if(g>=d&&_>=d&&g<u-d&&_<u-d){const x=Math.floor((g-d)/c),w=Math.floor((_-d)/c);b=m[l[x*o+w]?1:0]}s[y++]=b.r,s[y++]=b.g,s[y++]=b.b,s[y]=b.a}}})(Sv)),Sv}var VM;function HK(){return VM||(VM=1,(function(i){const e=$B();function t(r,n,o){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=o,n.width=o,n.style.height=o+"px",n.style.width=o+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}i.render=function(n,o,l){let c=l,u=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(u=s()),c=e.getOptions(c);const d=e.getImageWidth(n.modules.size,c),m=u.getContext("2d"),g=m.createImageData(d,d);return e.qrToImageData(g.data,n,c),t(m,u,d),m.putImageData(g,0,0),u},i.renderToDataURL=function(n,o,l){let c=l;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const u=i.render(n,o,c),d=c.type||"image/png",m=c.rendererOpts||{};return u.toDataURL(d,m.quality)}})(bv)),bv}var xv={},ZM;function FK(){if(ZM)return xv;ZM=1;const i=$B();function e(r,n){const o=r.a/255,l=n+'="'+r.hex+'"';return o<1?l+" "+n+'-opacity="'+o.toFixed(2).slice(1)+'"':l}function t(r,n,o){let l=r+n;return typeof o<"u"&&(l+=" "+o),l}function s(r,n,o){let l="",c=0,u=!1,d=0;for(let m=0;m<r.length;m++){const g=Math.floor(m%n),_=Math.floor(m/n);!g&&!u&&(u=!0),r[m]?(d++,m>0&&g>0&&r[m-1]||(l+=u?t("M",g+o,.5+_+o):t("m",c,0),c=0,u=!1),g+1<n&&r[m+1]||(l+=t("h",d),d=0)):c++}return l}return xv.render=function(n,o,l){const c=i.getOptions(o),u=n.modules.size,d=n.modules.data,m=u+c.margin*2,g=c.color.light.a?"<path "+e(c.color.light,"fill")+' d="M0 0h'+m+"v"+m+'H0z"/>':"",_="<path "+e(c.color.dark,"stroke")+' d="'+s(d,u,c.margin)+'"/>',y='viewBox="0 0 '+m+" "+m+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+y+' shape-rendering="crispEdges">'+g+_+`</svg>
85
+ `;return typeof l=="function"&&l(null,x),x},xv}var jM;function GK(){if(jM)return Nl;jM=1;const i=PK(),e=YK(),t=HK(),s=FK();function r(n,o,l,c,u){const d=[].slice.call(arguments,1),m=d.length,g=typeof d[m-1]=="function";if(!g&&!i())throw new Error("Callback required as last argument");if(g){if(m<2)throw new Error("Too few arguments provided");m===2?(u=l,l=o,o=c=void 0):m===3&&(o.getContext&&typeof u>"u"?(u=c,c=void 0):(u=c,c=l,l=o,o=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(l=o,o=c=void 0):m===2&&!o.getContext&&(c=l,l=o,o=void 0),new Promise(function(_,y){try{const b=e.create(l,c);_(n(b,o,c))}catch(b){y(b)}})}try{const _=e.create(l,c);u(null,n(_,o,c))}catch(_){u(_)}}return Nl.create=e.create,Nl.toCanvas=r.bind(null,t.render),Nl.toDataURL=r.bind(null,t.renderToDataURL),Nl.toString=r.bind(null,function(n,o,l){return s.render(n,l)}),Nl}var KK=GK();const JK=Cz(KK);function eJ(){const[i,e]=Y.useState(null),[t,s]=Y.useState(!1),[r,n]=Y.useState(null);return Y.useEffect(()=>{fetch("/api/server-info").then(o=>o.json()).then(o=>e(o)).catch(()=>{})},[]),Y.useEffect(()=>{i!=null&&i.networkUrl&&JK.toDataURL(i.networkUrl,{width:192,margin:2}).then(n).catch(()=>{})},[i==null?void 0:i.networkUrl]),!(i!=null&&i.networkEnabled)||!i.networkUrl?null:M.jsxs("div",{className:"relative border-t border-border px-1 py-2",children:[t&&M.jsxs("div",{className:"absolute bottom-full left-2 right-2 mb-2 rounded-lg border border-border bg-card p-3 shadow-xl",children:[M.jsx("p",{className:"mb-0.5 font-mono text-[9px] uppercase tracking-widest text-muted-foreground",children:"Local Network"}),M.jsx("p",{className:"mb-3 font-mono text-[11px] break-all text-foreground",children:i.networkUrl}),r&&M.jsx("img",{src:r,alt:"QR code for local network access",width:192,height:192,className:"w-full rounded-sm"}),M.jsx("p",{className:"mt-2 font-mono text-[9px] text-muted-foreground",children:"Scan to open on another device"})]}),M.jsxs("button",{type:"button",onClick:()=>s(o=>!o),title:t?"Close QR code":"Open dashboard on another device",className:"flex w-full items-center gap-2.5 rounded-sm px-3 py-2 text-left text-sm transition-colors hover:bg-card-hover text-muted-foreground",children:[M.jsx(tJ,{}),M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Share"})]})]})}function tJ(){return M.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[M.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),M.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),M.jsx("rect",{x:"3",y:"14",width:"7",height:"7"}),M.jsx("rect",{x:"14",y:"14",width:"3",height:"3"}),M.jsx("line",{x1:"14",y1:"20",x2:"20",y2:"20"}),M.jsx("line",{x1:"20",y1:"14",x2:"20",y2:"17"})]})}function iJ(i){switch(i){case"complete":return"bg-success";case"partial":return"bg-accent";case"planned":case"researched":case"discussed":return"bg-muted-foreground";default:return"bg-muted"}}function sJ({activeView:i,activePhaseId:e,onNavigate:t}){const{roadmap:s,state:r,todos:n}=fb(),{connected:o}=ff(),l=((s==null?void 0:s.phases)??[]).map(m=>({number:m.number,name:m.name,goal:m.goal??"",dependsOn:m.depends_on?[m.depends_on]:[],planCount:m.plan_count,summaryCount:m.summary_count,diskStatus:m.disk_status,roadmapComplete:m.roadmap_complete,hasContext:m.has_context,hasResearch:m.has_research})),c=(s==null?void 0:s.current_phase)??null,u=(r==null?void 0:r.blockers.filter(m=>!m.includes("RESOLVED")).length)??0,d=(n==null?void 0:n.pending.length)??0;return M.jsxs("aside",{className:"flex h-full w-64 shrink-0 flex-col border-r border-border bg-card",children:[M.jsx("div",{className:"border-b border-border px-4 py-4",children:M.jsxs("button",{type:"button",onClick:()=>t("overview"),className:"flex flex-col gap-0.5 text-left",children:[M.jsx("span",{className:"font-mono text-lg font-bold tracking-tight text-foreground",children:"MAXSIM"}),M.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:"Dashboard"})]})}),M.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[M.jsx("div",{className:"px-3 pb-1",children:M.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-muted-foreground",children:"Phases"})}),M.jsx("nav",{className:"flex flex-col gap-0.5 px-1",children:l.map(m=>{const g=i==="phase"&&e===m.number,_=m.number===c;return M.jsxs("button",{type:"button",onClick:()=>t("phase",m.number),className:dt("flex w-full items-center gap-2.5 rounded-sm px-3 py-1.5 text-left text-sm transition-colors",g?"border-l-2 border-l-accent bg-card-hover text-foreground":"border-l-2 border-l-transparent hover:bg-card-hover",_&&!g&&"border-l-accent-glow"),children:[M.jsx("span",{className:dt("inline-block h-2 w-2 shrink-0 rounded-full",iJ(m.diskStatus))}),M.jsx("span",{className:dt("font-mono text-xs font-semibold",_||g?"text-accent":"text-muted-foreground"),children:m.number}),M.jsx("span",{className:"truncate text-xs text-foreground",children:m.name})]},m.number)})})]}),M.jsxs("div",{className:"border-t border-border px-1 py-2",children:[M.jsxs("button",{type:"button",onClick:()=>t("todos"),className:dt("flex w-full items-center justify-between rounded-sm px-3 py-2 text-left text-sm transition-colors",i==="todos"?"bg-card-hover text-foreground":"hover:bg-card-hover text-muted-foreground"),children:[M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Todos"}),d>0&&M.jsx("span",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-sm bg-warning/20 px-1 font-mono text-[10px] font-bold text-warning",children:d})]}),M.jsxs("button",{type:"button",onClick:()=>t("blockers"),className:dt("flex w-full items-center justify-between rounded-sm px-3 py-2 text-left text-sm transition-colors",i==="blockers"?"bg-card-hover text-foreground":"hover:bg-card-hover text-muted-foreground"),children:[M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Blockers"}),u>0&&M.jsx("span",{className:"inline-flex h-5 min-w-5 items-center justify-center rounded-sm bg-danger/20 px-1 font-mono text-[10px] font-bold text-danger shadow-[0_0_6px_rgba(239,68,68,0.3)]",children:u})]})]}),M.jsx("div",{className:"border-t border-border px-1 py-2",children:M.jsxs("button",{type:"button",onClick:()=>t("terminal"),className:dt("flex w-full items-center gap-2.5 rounded-sm px-3 py-2 text-left text-sm transition-colors",i==="terminal"?"bg-card-hover text-foreground":"hover:bg-card-hover text-muted-foreground"),children:[M.jsx("span",{className:"font-mono text-xs font-bold",children:">_"}),M.jsx("span",{className:"font-mono text-xs uppercase tracking-wide",children:"Terminal"})]})}),M.jsx(eJ,{}),M.jsx("div",{className:"border-t border-border px-4 py-3",children:M.jsxs("div",{className:"flex items-center gap-2",children:[M.jsx("span",{className:dt("inline-block h-2 w-2 rounded-full",o?"bg-success":"bg-danger")}),M.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:o?"Connected":"Disconnected"})]})})]})}/**
79
86
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
80
87
  * @license MIT
81
88
  *
@@ -86,22 +93,22 @@ Error generating stack: `+p.message+`
86
93
  * Fabrice Bellard's javascript vt100 for jslinux:
87
94
  * http://bellard.org/jslinux/
88
95
  * Copyright (c) 2011 Fabrice Bellard
89
- */var QB=Object.defineProperty,RK=Object.getOwnPropertyDescriptor,LK=(i,e)=>{for(var t in e)QB(i,t,{get:e[t],enumerable:!0})},Lt=(i,e,t,s)=>{for(var r=s>1?void 0:s?RK(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&QB(e,t,r),r},Oe=(i,e)=>(t,s)=>e(t,s,i),gM="Terminal input",Sy={get:()=>gM,set:i=>gM=i},OM="Too much output to announce, navigate to rows manually to read",xy={get:()=>OM,set:i=>OM=i};function $K(i){return i.replace(/\r?\n/g,"\r")}function BK(i,e){return e?"\x1B[200~"+i+"\x1B[201~":i}function DK(i,e){i.clipboardData&&i.clipboardData.setData("text/plain",e.selectionText),i.preventDefault()}function zK(i,e,t,s){if(i.stopPropagation(),i.clipboardData){let r=i.clipboardData.getData("text/plain");RB(r,e,t,s)}}function RB(i,e,t,s){i=$K(i),i=BK(i,t.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),t.triggerDataEvent(i,!0),e.value=""}function LB(i,e,t){let s=t.getBoundingClientRect(),r=i.clientX-s.left-10,n=i.clientY-s.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function _M(i,e,t,s,r){LB(i,e,t),r&&s.rightClickSelect(i),e.value=s.selectionText,e.select()}function $o(i){return i>65535?(i-=65536,String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)}function Sg(i,e=0,t=i.length){let s="";for(let r=e;r<t;++r){let n=i[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var NK=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=n;o<s;++o){let l=e.charCodeAt(o);if(55296<=l&&l<=56319){if(++o>=s)return this._interim=l,r;let c=e.charCodeAt(o);56320<=c&&c<=57343?t[r++]=(l-55296)*1024+c-56320+65536:(t[r++]=l,t[r++]=c);continue}l!==65279&&(t[r++]=l)}return r}},XK=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,n,o,l,c,u=0,d=0;if(this.interim[0]){let _=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let b=0,x;for(;(x=this.interim[++b]&63)&&b<4;)y<<=6,y|=x;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=w-b;for(;d<k;){if(d>=s)return 0;if(x=e[d++],(x&192)!==128){d--,_=!0;break}else this.interim[b++]=x,y<<=6,y|=x&63}_||(w===2?y<128?d--:t[r++]=y:w===3?y<2048||y>=55296&&y<=57343||y===65279||(t[r++]=y):y<65536||y>1114111||(t[r++]=y)),this.interim.fill(0)}let m=s-4,g=d;for(;g<s;){for(;g<m&&!((n=e[g])&128)&&!((o=e[g+1])&128)&&!((l=e[g+2])&128)&&!((c=e[g+3])&128);)t[r++]=n,t[r++]=o,t[r++]=l,t[r++]=c,g+=4;if(n=e[g++],n<128)t[r++]=n;else if((n&224)===192){if(g>=s)return this.interim[0]=n,r;if(o=e[g++],(o&192)!==128){g--;continue}if(u=(n&31)<<6|o&63,u<128){g--;continue}t[r++]=u}else if((n&240)===224){if(g>=s)return this.interim[0]=n,r;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=s)return this.interim[0]=n,this.interim[1]=o,r;if(l=e[g++],(l&192)!==128){g--;continue}if(u=(n&15)<<12|(o&63)<<6|l&63,u<2048||u>=55296&&u<=57343||u===65279)continue;t[r++]=u}else if((n&248)===240){if(g>=s)return this.interim[0]=n,r;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=s)return this.interim[0]=n,this.interim[1]=o,r;if(l=e[g++],(l&192)!==128){g--;continue}if(g>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=l,r;if(c=e[g++],(c&192)!==128){g--;continue}if(u=(n&7)<<18|(o&63)<<12|(l&63)<<6|c&63,u<65536||u>1114111)continue;t[r++]=u}}return r}},$B="",No=" ",Af=class BB{constructor(){this.fg=0,this.bg=0,this.extended=new Gm}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new BB;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},Gm=class DB{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new DB(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},lr=class zB extends Af{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Gm,this.combinedData=""}static fromCharData(e){let t=new zB;return t.setFromCharData(e),t}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?$o(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},vM="di$target",wy="di$dependencies",tv=new Map;function VK(i){return i[wy]||[]}function xi(i){if(tv.has(i))return tv.get(i);let e=function(t,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");ZK(e,t,r)};return e._id=i,tv.set(i,e),e}function ZK(i,e,t){e[vM]===e?e[wy].push({id:i,index:t}):(e[wy]=[{id:i,index:t}],e[vM]=e)}var is=xi("BufferService"),NB=xi("CoreMouseService"),Ga=xi("CoreService"),jK=xi("CharsetService"),IS=xi("InstantiationService"),XB=xi("LogService"),ss=xi("OptionsService"),VB=xi("OscLinkService"),IK=xi("UnicodeService"),Mf=xi("DecorationService"),Cy=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var m;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],n=this._optionsService.rawOptions.linkHandler,o=new lr,l=s.getTrimmedLength(),c=-1,u=-1,d=!1;for(let g=0;g<l;g++)if(!(u===-1&&!s.hasContent(g))){if(s.loadCell(g,o),o.hasExtendedAttrs()&&o.extended.urlId)if(u===-1){u=g,c=o.extended.urlId;continue}else d=o.extended.urlId!==c;else u!==-1&&(d=!0);if(d||u!==-1&&g===l-1){let _=(m=this._oscLinkService.getLinkData(c))==null?void 0:m.uri;if(_){let y={start:{x:u+1,y:e},end:{x:g+(!d&&g===l-1?1:0),y:e}},b=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let x=new URL(_);["http:","https:"].includes(x.protocol)||(b=!0)}catch{b=!0}b||r.push({text:_,range:y,activate:(x,w)=>n?n.activate(x,w,y):qK(x,w),hover:(x,w)=>{var k;return(k=n==null?void 0:n.hover)==null?void 0:k.call(n,x,w,y)},leave:(x,w)=>{var k;return(k=n==null?void 0:n.leave)==null?void 0:k.call(n,x,w,y)}})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(u=g,c=o.extended.urlId):(u=-1,c=-1)}}t(r)}};Cy=Lt([Oe(0,is),Oe(1,ss),Oe(2,VB)],Cy);function qK(i,e){if(confirm(`Do you want to navigate to ${e}?
96
+ */var BB=Object.defineProperty,rJ=Object.getOwnPropertyDescriptor,nJ=(i,e)=>{for(var t in e)BB(i,t,{get:e[t],enumerable:!0})},Lt=(i,e,t,s)=>{for(var r=s>1?void 0:s?rJ(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&BB(e,t,r),r},Oe=(i,e)=>(t,s)=>e(t,s,i),IM="Terminal input",Sy={get:()=>IM,set:i=>IM=i},qM="Too much output to announce, navigate to rows manually to read",xy={get:()=>qM,set:i=>qM=i};function oJ(i){return i.replace(/\r?\n/g,"\r")}function aJ(i,e){return e?"\x1B[200~"+i+"\x1B[201~":i}function lJ(i,e){i.clipboardData&&i.clipboardData.setData("text/plain",e.selectionText),i.preventDefault()}function hJ(i,e,t,s){if(i.stopPropagation(),i.clipboardData){let r=i.clipboardData.getData("text/plain");DB(r,e,t,s)}}function DB(i,e,t,s){i=oJ(i),i=aJ(i,t.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),t.triggerDataEvent(i,!0),e.value=""}function zB(i,e,t){let s=t.getBoundingClientRect(),r=i.clientX-s.left-10,n=i.clientY-s.top-10;e.style.width="20px",e.style.height="20px",e.style.left=`${r}px`,e.style.top=`${n}px`,e.style.zIndex="1000",e.focus()}function WM(i,e,t,s,r){zB(i,e,t),r&&s.rightClickSelect(i),e.value=s.selectionText,e.select()}function $o(i){return i>65535?(i-=65536,String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)}function Sg(i,e=0,t=i.length){let s="";for(let r=e;r<t;++r){let n=i[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var cJ=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let r=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[r++]=(this._interim-55296)*1024+o-56320+65536:(t[r++]=this._interim,t[r++]=o),this._interim=0}for(let o=n;o<s;++o){let l=e.charCodeAt(o);if(55296<=l&&l<=56319){if(++o>=s)return this._interim=l,r;let c=e.charCodeAt(o);56320<=c&&c<=57343?t[r++]=(l-55296)*1024+c-56320+65536:(t[r++]=l,t[r++]=c);continue}l!==65279&&(t[r++]=l)}return r}},uJ=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let r=0,n,o,l,c,u=0,d=0;if(this.interim[0]){let _=!1,y=this.interim[0];y&=(y&224)===192?31:(y&240)===224?15:7;let b=0,x;for(;(x=this.interim[++b]&63)&&b<4;)y<<=6,y|=x;let w=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,k=w-b;for(;d<k;){if(d>=s)return 0;if(x=e[d++],(x&192)!==128){d--,_=!0;break}else this.interim[b++]=x,y<<=6,y|=x&63}_||(w===2?y<128?d--:t[r++]=y:w===3?y<2048||y>=55296&&y<=57343||y===65279||(t[r++]=y):y<65536||y>1114111||(t[r++]=y)),this.interim.fill(0)}let m=s-4,g=d;for(;g<s;){for(;g<m&&!((n=e[g])&128)&&!((o=e[g+1])&128)&&!((l=e[g+2])&128)&&!((c=e[g+3])&128);)t[r++]=n,t[r++]=o,t[r++]=l,t[r++]=c,g+=4;if(n=e[g++],n<128)t[r++]=n;else if((n&224)===192){if(g>=s)return this.interim[0]=n,r;if(o=e[g++],(o&192)!==128){g--;continue}if(u=(n&31)<<6|o&63,u<128){g--;continue}t[r++]=u}else if((n&240)===224){if(g>=s)return this.interim[0]=n,r;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=s)return this.interim[0]=n,this.interim[1]=o,r;if(l=e[g++],(l&192)!==128){g--;continue}if(u=(n&15)<<12|(o&63)<<6|l&63,u<2048||u>=55296&&u<=57343||u===65279)continue;t[r++]=u}else if((n&248)===240){if(g>=s)return this.interim[0]=n,r;if(o=e[g++],(o&192)!==128){g--;continue}if(g>=s)return this.interim[0]=n,this.interim[1]=o,r;if(l=e[g++],(l&192)!==128){g--;continue}if(g>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=l,r;if(c=e[g++],(c&192)!==128){g--;continue}if(u=(n&7)<<18|(o&63)<<12|(l&63)<<6|c&63,u<65536||u>1114111)continue;t[r++]=u}}return r}},NB="",No=" ",Af=class XB{constructor(){this.fg=0,this.bg=0,this.extended=new Gm}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new XB;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},Gm=class VB{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new VB(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},lr=class ZB extends Af{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Gm,this.combinedData=""}static fromCharData(e){let t=new ZB;return t.setFromCharData(e),t}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?$o(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},UM="di$target",wy="di$dependencies",wv=new Map;function fJ(i){return i[wy]||[]}function xi(i){if(wv.has(i))return wv.get(i);let e=function(t,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");dJ(e,t,r)};return e._id=i,wv.set(i,e),e}function dJ(i,e,t){e[UM]===e?e[wy].push({id:i,index:t}):(e[wy]=[{id:i,index:t}],e[UM]=e)}var is=xi("BufferService"),jB=xi("CoreMouseService"),Ja=xi("CoreService"),pJ=xi("CharsetService"),qS=xi("InstantiationService"),IB=xi("LogService"),ss=xi("OptionsService"),qB=xi("OscLinkService"),mJ=xi("UnicodeService"),Mf=xi("DecorationService"),Cy=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var m;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let r=[],n=this._optionsService.rawOptions.linkHandler,o=new lr,l=s.getTrimmedLength(),c=-1,u=-1,d=!1;for(let g=0;g<l;g++)if(!(u===-1&&!s.hasContent(g))){if(s.loadCell(g,o),o.hasExtendedAttrs()&&o.extended.urlId)if(u===-1){u=g,c=o.extended.urlId;continue}else d=o.extended.urlId!==c;else u!==-1&&(d=!0);if(d||u!==-1&&g===l-1){let _=(m=this._oscLinkService.getLinkData(c))==null?void 0:m.uri;if(_){let y={start:{x:u+1,y:e},end:{x:g+(!d&&g===l-1?1:0),y:e}},b=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let x=new URL(_);["http:","https:"].includes(x.protocol)||(b=!0)}catch{b=!0}b||r.push({text:_,range:y,activate:(x,w)=>n?n.activate(x,w,y):gJ(x,w),hover:(x,w)=>{var k;return(k=n==null?void 0:n.hover)==null?void 0:k.call(n,x,w,y)},leave:(x,w)=>{var k;return(k=n==null?void 0:n.leave)==null?void 0:k.call(n,x,w,y)}})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(u=g,c=o.extended.urlId):(u=-1,c=-1)}}t(r)}};Cy=Lt([Oe(0,is),Oe(1,ss),Oe(2,qB)],Cy);function gJ(i,e){if(confirm(`Do you want to navigate to ${e}?
90
97
 
91
- WARNING: This link could potentially be dangerous`)){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var xg=xi("CharSizeService"),Un=xi("CoreBrowserService"),qS=xi("MouseService"),Yn=xi("RenderService"),WK=xi("SelectionService"),ZB=xi("CharacterJoinerService"),Dh=xi("ThemeService"),jB=xi("LinkProviderService"),UK=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?yM.isErrorNoTelemetry(e)?new yM(e.message+`
98
+ WARNING: This link could potentially be dangerous`)){let t=window.open();if(t){try{t.opener=null}catch{}t.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}var xg=xi("CharSizeService"),Un=xi("CoreBrowserService"),WS=xi("MouseService"),Yn=xi("RenderService"),OJ=xi("SelectionService"),WB=xi("CharacterJoinerService"),Dh=xi("ThemeService"),UB=xi("LinkProviderService"),_J=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?YM.isErrorNoTelemetry(e)?new YM(e.message+`
92
99
 
93
100
  `+e.stack):new Error(e.message+`
94
101
 
95
- `+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)}},YK=new UK;function em(i){HK(i)||YK.onUnexpectedError(i)}var ky="Canceled";function HK(i){return i instanceof FK?!0:i instanceof Error&&i.name===ky&&i.message===ky}var FK=class extends Error{constructor(){super(ky),this.name=this.message}};function GK(i){return new Error(`Illegal argument: ${i}`)}var yM=class Ty extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Ty)return e;let t=new Ty;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Ay=class IB extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,IB.prototype)}};function Qs(i,e=0){return i[i.length-(1+e)]}var KK;(i=>{function e(n){return n<0}i.isLessThan=e;function t(n){return n<=0}i.isLessThanOrEqual=t;function s(n){return n>0}i.isGreaterThan=s;function r(n){return n===0}i.isNeitherLessOrGreaterThan=r,i.greaterThan=1,i.lessThan=-1,i.neitherLessOrGreaterThan=0})(KK||(KK={}));function JK(i,e){let t=this,s=!1,r;return function(){return s||(s=!0,e||(r=i.apply(t,arguments))),r}}var qB;(i=>{function e(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}i.is=e;let t=Object.freeze([]);function s(){return t}i.empty=s;function*r(A){yield A}i.single=r;function n(A){return e(A)?A:r(A)}i.wrap=n;function o(A){return A||t}i.from=o;function*l(A){for(let P=A.length-1;P>=0;P--)yield A[P]}i.reverse=l;function c(A){return!A||A[Symbol.iterator]().next().done===!0}i.isEmpty=c;function u(A){return A[Symbol.iterator]().next().value}i.first=u;function d(A,P){let E=0;for(let $ of A)if(P($,E++))return!0;return!1}i.some=d;function m(A,P){for(let E of A)if(P(E))return E}i.find=m;function*g(A,P){for(let E of A)P(E)&&(yield E)}i.filter=g;function*_(A,P){let E=0;for(let $ of A)yield P($,E++)}i.map=_;function*y(A,P){let E=0;for(let $ of A)yield*P($,E++)}i.flatMap=y;function*b(...A){for(let P of A)yield*P}i.concat=b;function x(A,P,E){let $=E;for(let z of A)$=P($,z);return $}i.reduce=x;function*w(A,P,E=A.length){for(P<0&&(P+=A.length),E<0?E+=A.length:E>A.length&&(E=A.length);P<E;P++)yield A[P]}i.slice=w;function k(A,P=Number.POSITIVE_INFINITY){let E=[];if(P===0)return[E,A];let $=A[Symbol.iterator]();for(let z=0;z<P;z++){let I=$.next();if(I.done)return[E,i.empty()];E.push(I.value)}return[E,{[Symbol.iterator](){return $}}]}i.consume=k;async function C(A){let P=[];for await(let E of A)P.push(E);return Promise.resolve(P)}i.asyncToArray=C})(qB||(qB={}));function Ua(i){if(qB.is(i)){let e=[];for(let t of i)if(t)try{t.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(i)?[]:i}else if(i)return i.dispose(),i}function eJ(...i){return xt(()=>Ua(i))}function xt(i){return{dispose:JK(()=>{i()})}}var WB=class UB{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ua(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?UB.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};WB.DISABLE_DISPOSED_WARNING=!1;var Vo=WB,Xe=class{constructor(){this._store=new Vo,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Xe.None=Object.freeze({dispose(){}});var Th=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},zn=typeof window=="object"?window:globalThis,My=class Ey{constructor(e){this.element=e,this.next=Ey.Undefined,this.prev=Ey.Undefined}};My.Undefined=new My(void 0);var wt=My,bM=class{constructor(){this._first=wt.Undefined,this._last=wt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===wt.Undefined}clear(){let e=this._first;for(;e!==wt.Undefined;){let t=e.next;e.prev=wt.Undefined,e.next=wt.Undefined,e=t}this._first=wt.Undefined,this._last=wt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new wt(e);if(this._first===wt.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==wt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==wt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==wt.Undefined&&e.next!==wt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===wt.Undefined&&e.next===wt.Undefined?(this._first=wt.Undefined,this._last=wt.Undefined):e.next===wt.Undefined?(this._last=this._last.prev,this._last.next=wt.Undefined):e.prev===wt.Undefined&&(this._first=this._first.next,this._first.prev=wt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==wt.Undefined;)yield e.element,e=e.next}},tJ=globalThis.performance&&typeof globalThis.performance.now=="function",iJ=class YB{static create(e){return new YB(e)}constructor(e){this._now=tJ&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Di;(i=>{i.None=()=>Xe.None;function e(R,L){return m(R,()=>{},0,void 0,!0,void 0,L)}i.defer=e;function t(R){return(L,N=null,Z)=>{let Q=!1,X;return X=R(W=>{if(!Q)return X?X.dispose():Q=!0,L.call(N,W)},null,Z),Q&&X.dispose(),X}}i.once=t;function s(R,L,N){return u((Z,Q=null,X)=>R(W=>Z.call(Q,L(W)),null,X),N)}i.map=s;function r(R,L,N){return u((Z,Q=null,X)=>R(W=>{L(W),Z.call(Q,W)},null,X),N)}i.forEach=r;function n(R,L,N){return u((Z,Q=null,X)=>R(W=>L(W)&&Z.call(Q,W),null,X),N)}i.filter=n;function o(R){return R}i.signal=o;function l(...R){return(L,N=null,Z)=>{let Q=eJ(...R.map(X=>X(W=>L.call(N,W))));return d(Q,Z)}}i.any=l;function c(R,L,N,Z){let Q=N;return s(R,X=>(Q=L(Q,X),Q),Z)}i.reduce=c;function u(R,L){let N,Z={onWillAddFirstListener(){N=R(Q.fire,Q)},onDidRemoveLastListener(){N==null||N.dispose()}},Q=new fe(Z);return L==null||L.add(Q),Q.event}function d(R,L){return L instanceof Array?L.push(R):L&&L.add(R),R}function m(R,L,N=100,Z=!1,Q=!1,X,W){let U,q,D,G=0,ie,ce={leakWarningThreshold:X,onWillAddFirstListener(){U=R(de=>{G++,q=L(q,de),Z&&!D&&(he.fire(q),q=void 0),ie=()=>{let ge=q;q=void 0,D=void 0,(!Z||G>1)&&he.fire(ge),G=0},typeof N=="number"?(clearTimeout(D),D=setTimeout(ie,N)):D===void 0&&(D=0,queueMicrotask(ie))})},onWillRemoveListener(){Q&&G>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,U.dispose()}},he=new fe(ce);return W==null||W.add(he),he.event}i.debounce=m;function g(R,L=0,N){return i.debounce(R,(Z,Q)=>Z?(Z.push(Q),Z):[Q],L,void 0,!0,void 0,N)}i.accumulate=g;function _(R,L=(Z,Q)=>Z===Q,N){let Z=!0,Q;return n(R,X=>{let W=Z||!L(X,Q);return Z=!1,Q=X,W},N)}i.latch=_;function y(R,L,N){return[i.filter(R,L,N),i.filter(R,Z=>!L(Z),N)]}i.split=y;function b(R,L=!1,N=[],Z){let Q=N.slice(),X=R(q=>{Q?Q.push(q):U.fire(q)});Z&&Z.add(X);let W=()=>{Q==null||Q.forEach(q=>U.fire(q)),Q=null},U=new fe({onWillAddFirstListener(){X||(X=R(q=>U.fire(q)),Z&&Z.add(X))},onDidAddFirstListener(){Q&&(L?setTimeout(W):W())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return Z&&Z.add(U),U.event}i.buffer=b;function x(R,L){return(N,Z,Q)=>{let X=L(new k);return R(function(W){let U=X.evaluate(W);U!==w&&N.call(Z,U)},void 0,Q)}}i.chain=x;let w=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(N=>(L(N),N)),this}filter(L){return this.steps.push(N=>L(N)?N:w),this}reduce(L,N){let Z=N;return this.steps.push(Q=>(Z=L(Z,Q),Z)),this}latch(L=(N,Z)=>N===Z){let N=!0,Z;return this.steps.push(Q=>{let X=N||!L(Q,Z);return N=!1,Z=Q,X?Q:w}),this}evaluate(L){for(let N of this.steps)if(L=N(L),L===w)break;return L}}function C(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.on(L,Z),X=()=>R.removeListener(L,Z),W=new fe({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromNodeEventEmitter=C;function A(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.addEventListener(L,Z),X=()=>R.removeEventListener(L,Z),W=new fe({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromDOMEventEmitter=A;function P(R){return new Promise(L=>t(R)(L))}i.toPromise=P;function E(R){let L=new fe;return R.then(N=>{L.fire(N)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}i.fromPromise=E;function $(R,L){return R(N=>L.fire(N))}i.forward=$;function z(R,L,N){return L(N),R(Z=>L(Z))}i.runAndSubscribe=z;class I{constructor(L,N){this._observable=L,this._counter=0,this._hasChanged=!1;let Z={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new fe(Z),N&&N.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,N){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function se(R,L){return new I(R,L).emitter.event}i.fromObservable=se;function F(R){return(L,N,Z)=>{let Q=0,X=!1,W={beginUpdate(){Q++},endUpdate(){Q--,Q===0&&(R.reportChanges(),X&&(X=!1,L.call(N)))},handlePossibleChange(){},handleChange(){X=!0}};R.addObserver(W),R.reportChanges();let U={dispose(){R.removeObserver(W)}};return Z instanceof Vo?Z.add(U):Array.isArray(Z)&&Z.push(U),U}}i.fromObservableLight=F})(Di||(Di={}));var Py=class Qy{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Qy._idPool++}`,Qy.all.add(this)}start(e){this._stopWatch=new iJ,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Py.all=new Set,Py._idPool=0;var sJ=Py,rJ=-1,HB=class FB{constructor(e,t,s=(FB._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=t,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,t){let s=this.threshold;if(s<=0||t<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let c=new aJ(l,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[s,r]of this._stacks)(!e||t<r)&&(e=[s,r],t=r);return e}};HB._idPool=1;var nJ=HB,oJ=class GB{constructor(e){this.value=e}static create(){let e=new Error;return new GB(e.stack??"")}print(){console.warn(this.value.split(`
102
+ `+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)}},vJ=new _J;function em(i){yJ(i)||vJ.onUnexpectedError(i)}var ky="Canceled";function yJ(i){return i instanceof bJ?!0:i instanceof Error&&i.name===ky&&i.message===ky}var bJ=class extends Error{constructor(){super(ky),this.name=this.message}};function SJ(i){return new Error(`Illegal argument: ${i}`)}var YM=class Ty extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof Ty)return e;let t=new Ty;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Ay=class YB extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,YB.prototype)}};function Qs(i,e=0){return i[i.length-(1+e)]}var xJ;(i=>{function e(n){return n<0}i.isLessThan=e;function t(n){return n<=0}i.isLessThanOrEqual=t;function s(n){return n>0}i.isGreaterThan=s;function r(n){return n===0}i.isNeitherLessOrGreaterThan=r,i.greaterThan=1,i.lessThan=-1,i.neitherLessOrGreaterThan=0})(xJ||(xJ={}));function wJ(i,e){let t=this,s=!1,r;return function(){return s||(s=!0,e||(r=i.apply(t,arguments))),r}}var HB;(i=>{function e(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}i.is=e;let t=Object.freeze([]);function s(){return t}i.empty=s;function*r(A){yield A}i.single=r;function n(A){return e(A)?A:r(A)}i.wrap=n;function o(A){return A||t}i.from=o;function*l(A){for(let P=A.length-1;P>=0;P--)yield A[P]}i.reverse=l;function c(A){return!A||A[Symbol.iterator]().next().done===!0}i.isEmpty=c;function u(A){return A[Symbol.iterator]().next().value}i.first=u;function d(A,P){let E=0;for(let $ of A)if(P($,E++))return!0;return!1}i.some=d;function m(A,P){for(let E of A)if(P(E))return E}i.find=m;function*g(A,P){for(let E of A)P(E)&&(yield E)}i.filter=g;function*_(A,P){let E=0;for(let $ of A)yield P($,E++)}i.map=_;function*y(A,P){let E=0;for(let $ of A)yield*P($,E++)}i.flatMap=y;function*b(...A){for(let P of A)yield*P}i.concat=b;function x(A,P,E){let $=E;for(let z of A)$=P($,z);return $}i.reduce=x;function*w(A,P,E=A.length){for(P<0&&(P+=A.length),E<0?E+=A.length:E>A.length&&(E=A.length);P<E;P++)yield A[P]}i.slice=w;function k(A,P=Number.POSITIVE_INFINITY){let E=[];if(P===0)return[E,A];let $=A[Symbol.iterator]();for(let z=0;z<P;z++){let I=$.next();if(I.done)return[E,i.empty()];E.push(I.value)}return[E,{[Symbol.iterator](){return $}}]}i.consume=k;async function C(A){let P=[];for await(let E of A)P.push(E);return Promise.resolve(P)}i.asyncToArray=C})(HB||(HB={}));function Ua(i){if(HB.is(i)){let e=[];for(let t of i)if(t)try{t.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(i)?[]:i}else if(i)return i.dispose(),i}function CJ(...i){return xt(()=>Ua(i))}function xt(i){return{dispose:wJ(()=>{i()})}}var FB=class GB{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ua(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?GB.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};FB.DISABLE_DISPOSED_WARNING=!1;var Vo=FB,Xe=class{constructor(){this._store=new Vo,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Xe.None=Object.freeze({dispose(){}});var Th=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},zn=typeof window=="object"?window:globalThis,My=class Ey{constructor(e){this.element=e,this.next=Ey.Undefined,this.prev=Ey.Undefined}};My.Undefined=new My(void 0);var wt=My,HM=class{constructor(){this._first=wt.Undefined,this._last=wt.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===wt.Undefined}clear(){let e=this._first;for(;e!==wt.Undefined;){let t=e.next;e.prev=wt.Undefined,e.next=wt.Undefined,e=t}this._first=wt.Undefined,this._last=wt.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new wt(e);if(this._first===wt.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==wt.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==wt.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==wt.Undefined&&e.next!==wt.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===wt.Undefined&&e.next===wt.Undefined?(this._first=wt.Undefined,this._last=wt.Undefined):e.next===wt.Undefined?(this._last=this._last.prev,this._last.next=wt.Undefined):e.prev===wt.Undefined&&(this._first=this._first.next,this._first.prev=wt.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==wt.Undefined;)yield e.element,e=e.next}},kJ=globalThis.performance&&typeof globalThis.performance.now=="function",TJ=class KB{static create(e){return new KB(e)}constructor(e){this._now=kJ&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Di;(i=>{i.None=()=>Xe.None;function e(R,L){return m(R,()=>{},0,void 0,!0,void 0,L)}i.defer=e;function t(R){return(L,N=null,Z)=>{let Q=!1,X;return X=R(W=>{if(!Q)return X?X.dispose():Q=!0,L.call(N,W)},null,Z),Q&&X.dispose(),X}}i.once=t;function s(R,L,N){return u((Z,Q=null,X)=>R(W=>Z.call(Q,L(W)),null,X),N)}i.map=s;function r(R,L,N){return u((Z,Q=null,X)=>R(W=>{L(W),Z.call(Q,W)},null,X),N)}i.forEach=r;function n(R,L,N){return u((Z,Q=null,X)=>R(W=>L(W)&&Z.call(Q,W),null,X),N)}i.filter=n;function o(R){return R}i.signal=o;function l(...R){return(L,N=null,Z)=>{let Q=CJ(...R.map(X=>X(W=>L.call(N,W))));return d(Q,Z)}}i.any=l;function c(R,L,N,Z){let Q=N;return s(R,X=>(Q=L(Q,X),Q),Z)}i.reduce=c;function u(R,L){let N,Z={onWillAddFirstListener(){N=R(Q.fire,Q)},onDidRemoveLastListener(){N==null||N.dispose()}},Q=new fe(Z);return L==null||L.add(Q),Q.event}function d(R,L){return L instanceof Array?L.push(R):L&&L.add(R),R}function m(R,L,N=100,Z=!1,Q=!1,X,W){let U,q,D,G=0,ie,ce={leakWarningThreshold:X,onWillAddFirstListener(){U=R(de=>{G++,q=L(q,de),Z&&!D&&(he.fire(q),q=void 0),ie=()=>{let ge=q;q=void 0,D=void 0,(!Z||G>1)&&he.fire(ge),G=0},typeof N=="number"?(clearTimeout(D),D=setTimeout(ie,N)):D===void 0&&(D=0,queueMicrotask(ie))})},onWillRemoveListener(){Q&&G>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,U.dispose()}},he=new fe(ce);return W==null||W.add(he),he.event}i.debounce=m;function g(R,L=0,N){return i.debounce(R,(Z,Q)=>Z?(Z.push(Q),Z):[Q],L,void 0,!0,void 0,N)}i.accumulate=g;function _(R,L=(Z,Q)=>Z===Q,N){let Z=!0,Q;return n(R,X=>{let W=Z||!L(X,Q);return Z=!1,Q=X,W},N)}i.latch=_;function y(R,L,N){return[i.filter(R,L,N),i.filter(R,Z=>!L(Z),N)]}i.split=y;function b(R,L=!1,N=[],Z){let Q=N.slice(),X=R(q=>{Q?Q.push(q):U.fire(q)});Z&&Z.add(X);let W=()=>{Q==null||Q.forEach(q=>U.fire(q)),Q=null},U=new fe({onWillAddFirstListener(){X||(X=R(q=>U.fire(q)),Z&&Z.add(X))},onDidAddFirstListener(){Q&&(L?setTimeout(W):W())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return Z&&Z.add(U),U.event}i.buffer=b;function x(R,L){return(N,Z,Q)=>{let X=L(new k);return R(function(W){let U=X.evaluate(W);U!==w&&N.call(Z,U)},void 0,Q)}}i.chain=x;let w=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(N=>(L(N),N)),this}filter(L){return this.steps.push(N=>L(N)?N:w),this}reduce(L,N){let Z=N;return this.steps.push(Q=>(Z=L(Z,Q),Z)),this}latch(L=(N,Z)=>N===Z){let N=!0,Z;return this.steps.push(Q=>{let X=N||!L(Q,Z);return N=!1,Z=Q,X?Q:w}),this}evaluate(L){for(let N of this.steps)if(L=N(L),L===w)break;return L}}function C(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.on(L,Z),X=()=>R.removeListener(L,Z),W=new fe({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromNodeEventEmitter=C;function A(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.addEventListener(L,Z),X=()=>R.removeEventListener(L,Z),W=new fe({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromDOMEventEmitter=A;function P(R){return new Promise(L=>t(R)(L))}i.toPromise=P;function E(R){let L=new fe;return R.then(N=>{L.fire(N)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}i.fromPromise=E;function $(R,L){return R(N=>L.fire(N))}i.forward=$;function z(R,L,N){return L(N),R(Z=>L(Z))}i.runAndSubscribe=z;class I{constructor(L,N){this._observable=L,this._counter=0,this._hasChanged=!1;let Z={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new fe(Z),N&&N.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,N){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function se(R,L){return new I(R,L).emitter.event}i.fromObservable=se;function F(R){return(L,N,Z)=>{let Q=0,X=!1,W={beginUpdate(){Q++},endUpdate(){Q--,Q===0&&(R.reportChanges(),X&&(X=!1,L.call(N)))},handlePossibleChange(){},handleChange(){X=!0}};R.addObserver(W),R.reportChanges();let U={dispose(){R.removeObserver(W)}};return Z instanceof Vo?Z.add(U):Array.isArray(Z)&&Z.push(U),U}}i.fromObservableLight=F})(Di||(Di={}));var Py=class Qy{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${Qy._idPool++}`,Qy.all.add(this)}start(e){this._stopWatch=new TJ,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Py.all=new Set,Py._idPool=0;var AJ=Py,MJ=-1,JB=class eD{constructor(e,t,s=(eD._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=t,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,t){let s=this.threshold;if(s<=0||t<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let c=new QJ(l,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[s,r]of this._stacks)(!e||t<r)&&(e=[s,r],t=r);return e}};JB._idPool=1;var EJ=JB,PJ=class tD{constructor(e){this.value=e}static create(){let e=new Error;return new tD(e.stack??"")}print(){console.warn(this.value.split(`
96
103
  `).slice(2).join(`
97
- `))}},aJ=class extends Error{constructor(i,e){super(i),this.name="ListenerLeakError",this.stack=e}},lJ=class extends Error{constructor(i,e){super(i),this.name="ListenerRefusalError",this.stack=e}},hJ=0,iv=class{constructor(e){this.value=e,this.id=hJ++}},cJ=2,uJ,fe=class{constructor(e){var t,s,r,n;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new nJ((e==null?void 0:e.onListenerError)??em,((s=this._options)==null?void 0:s.leakWarningThreshold)??rJ):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new sJ(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var e,t,s,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var l,c,u,d,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let g=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(g);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new lJ(`${g}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||em)(y),Xe.None}if(this._disposed)return Xe.None;t&&(e=e.bind(t));let r=new iv(e),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=oJ.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof iv?(this._deliveryQueue??(this._deliveryQueue=new fJ),this._listeners=[this._listeners,r]):this._listeners.push(r):((u=(c=this._options)==null?void 0:c.onWillAddFirstListener)==null||u.call(c,this),this._listeners=r,(m=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||m.call(d,this)),this._size++;let o=xt(()=>{n==null||n(),this._removeListener(r)});return s instanceof Vo?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var n,o,l,c;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(c=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||c.call(l,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 r=this._deliveryQueue.current===this;if(this._size*cJ<=t.length){let u=0;for(let d=0;d<t.length;d++)t[d]?t[u++]=t[d]:r&&(this._deliveryQueue.end--,u<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=u}}_deliver(e,t){var r;if(!e)return;let s=((r=this._options)==null?void 0:r.onListenerError)||em;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,s,r,n;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof iv)this._deliver(this._listeners,e);else{let o=this._deliveryQueue;o.enqueue(this,e,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},fJ=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}},Ry=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new fe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new fe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Ry.INSTANCE=new Ry;var WS=Ry;function dJ(i,e,t){typeof e=="string"&&(e=i.matchMedia(e)),e.addEventListener("change",t)}WS.INSTANCE.onDidChangeZoomLevel;function pJ(i){return WS.INSTANCE.getZoomFactor(i)}WS.INSTANCE.onDidChangeFullscreen;var zh=typeof navigator=="object"?navigator.userAgent:"",Ly=zh.indexOf("Firefox")>=0,mJ=zh.indexOf("AppleWebKit")>=0,US=zh.indexOf("Chrome")>=0,gJ=!US&&zh.indexOf("Safari")>=0;zh.indexOf("Electron/")>=0;zh.indexOf("Android")>=0;var sv=!1;if(typeof zn.matchMedia=="function"){let i=zn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=zn.matchMedia("(display-mode: fullscreen)");sv=i.matches,dJ(zn,i,({matches:t})=>{sv&&e.matches||(sv=t)})}var ih="en",$y=!1,By=!1,tm=!1,KB=!1,Cp,im=ih,SM=ih,OJ,gr,Xa=globalThis,Ri,fP;typeof Xa.vscode<"u"&&typeof Xa.vscode.process<"u"?Ri=Xa.vscode.process:typeof process<"u"&&typeof((fP=process==null?void 0:process.versions)==null?void 0:fP.node)=="string"&&(Ri=process);var dP,_J=typeof((dP=Ri==null?void 0:Ri.versions)==null?void 0:dP.electron)=="string",vJ=_J&&(Ri==null?void 0:Ri.type)==="renderer",pP;if(typeof Ri=="object"){$y=Ri.platform==="win32",By=Ri.platform==="darwin",tm=Ri.platform==="linux",tm&&Ri.env.SNAP&&Ri.env.SNAP_REVISION,Ri.env.CI||Ri.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Cp=ih,im=ih;let i=Ri.env.VSCODE_NLS_CONFIG;if(i)try{let e=JSON.parse(i);Cp=e.userLocale,SM=e.osLocale,im=e.resolvedLanguage||ih,OJ=(pP=e.languagePack)==null?void 0:pP.translationsConfigFile}catch{}KB=!0}else typeof navigator=="object"&&!vJ?(gr=navigator.userAgent,$y=gr.indexOf("Windows")>=0,By=gr.indexOf("Macintosh")>=0,(gr.indexOf("Macintosh")>=0||gr.indexOf("iPad")>=0||gr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,tm=gr.indexOf("Linux")>=0,(gr==null?void 0:gr.indexOf("Mobi"))>=0,im=globalThis._VSCODE_NLS_LANGUAGE||ih,Cp=navigator.language.toLowerCase(),SM=Cp):console.error("Unable to resolve platform.");var JB=$y,en=By,yJ=tm,xM=KB,sn=gr,wo=im,bJ;(i=>{function e(){return wo}i.value=e;function t(){return wo.length===2?wo==="en":wo.length>=3?wo[0]==="e"&&wo[1]==="n"&&wo[2]==="-":!1}i.isDefaultVariant=t;function s(){return wo==="en"}i.isDefault=s})(bJ||(bJ={}));var SJ=typeof Xa.postMessage=="function"&&!Xa.importScripts;(()=>{if(SJ){let i=[];Xa.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let s=0,r=i.length;s<r;s++){let n=i[s];if(n.id===t.data.vscodeScheduleAsyncWork){i.splice(s,1),n.callback();return}}});let e=0;return t=>{let s=++e;i.push({id:s,callback:t}),Xa.postMessage({vscodeScheduleAsyncWork:s},"*")}}return i=>setTimeout(i)})();var xJ=!!(sn&&sn.indexOf("Chrome")>=0);sn&&sn.indexOf("Firefox")>=0;!xJ&&sn&&sn.indexOf("Safari")>=0;sn&&sn.indexOf("Edg/")>=0;sn&&sn.indexOf("Android")>=0;var Nl=typeof navigator=="object"?navigator:{};xM||document.queryCommandSupported&&document.queryCommandSupported("copy")||Nl&&Nl.clipboard&&Nl.clipboard.writeText,xM||Nl&&Nl.clipboard&&Nl.clipboard.readText;var YS=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}},rv=new YS,wM=new YS,CM=new YS,wJ=new Array(230),eD;(i=>{function e(l){return rv.keyCodeToStr(l)}i.toString=e;function t(l){return rv.strToKeyCode(l)}i.fromString=t;function s(l){return wM.keyCodeToStr(l)}i.toUserSettingsUS=s;function r(l){return CM.keyCodeToStr(l)}i.toUserSettingsGeneral=r;function n(l){return wM.strToKeyCode(l)||CM.strToKeyCode(l)}i.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return rv.keyCodeToStr(l)}i.toElectronAccelerator=o})(eD||(eD={}));var CJ=class tD{constructor(e,t,s,r,n){this.ctrlKey=e,this.shiftKey=t,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof tD&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",t=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${t}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new kJ([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},kJ=class{constructor(i){if(i.length===0)throw GK("chords");this.chords=i}getHashCode(){let i="";for(let e=0,t=this.chords.length;e<t;e++)e!==0&&(i+=";"),i+=this.chords[e].getHashCode();return i}equals(i){if(i===null||this.chords.length!==i.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(i.chords[e]))return!1;return!0}};function TJ(i){if(i.charCode){let t=String.fromCharCode(i.charCode).toUpperCase();return eD.fromString(t)}let e=i.keyCode;if(e===3)return 7;if(Ly)switch(e){case 59:return 85;case 60:if(yJ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(en)return 57;break}else if(mJ&&(en&&e===93||!en&&e===92))return 57;return wJ[e]||0}var AJ=en?256:2048,MJ=512,EJ=1024,PJ=en?2048:256,kM=class{constructor(i){var t;this._standardKeyboardEventBrand=!0;let e=i;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=(t=e.getModifierState)==null?void 0:t.call(e,"AltGraph"),this.keyCode=TJ(e),this.code=e.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(i){return this._asKeybinding===i}_computeKeybinding(){let i=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(i=this.keyCode);let e=0;return this.ctrlKey&&(e|=AJ),this.altKey&&(e|=MJ),this.shiftKey&&(e|=EJ),this.metaKey&&(e|=PJ),e|=i,e}_computeKeyCodeChord(){let i=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(i=this.keyCode),new CJ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,i)}},TM=new WeakMap;function QJ(i){if(!i.parent||i.parent===i)return null;try{let e=i.location,t=i.parent.location;if(e.origin!=="null"&&t.origin!=="null"&&e.origin!==t.origin)return null}catch{return null}return i.parent}var RJ=class{static getSameOriginWindowChain(i){let e=TM.get(i);if(!e){e=[],TM.set(i,e);let t=i,s;do s=QJ(t),s?e.push({window:new WeakRef(t),iframeElement:t.frameElement||null}):e.push({window:new WeakRef(t),iframeElement:null}),t=s;while(t)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(i,e){if(!e||i===e)return{top:0,left:0};let t=0,s=0,r=this.getSameOriginWindowChain(i);for(let n of r){let o=n.window.deref();if(t+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===e||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();t+=l.top,s+=l.left}return{top:t,left:s}}},kp=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=RJ.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},AM=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let r=!1;if(US){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,l=e,c=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*c):this.deltaY=o.wheelDeltaY/120;else if(typeof l.VERTICAL_AXIS<"u"&&l.axis===l.VERTICAL_AXIS)this.deltaY=-l.detail/3;else if(e.type==="wheel"){let u=e;u.deltaMode===u.DOM_DELTA_LINE?Ly&&!en?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")gJ&&JB?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*c):this.deltaX=o.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let u=e;u.deltaMode===u.DOM_DELTA_LINE?Ly&&!en?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*c):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},iD=Object.freeze(function(i,e){let t=setTimeout(i.bind(e),0);return{dispose(){clearTimeout(t)}}}),LJ;(i=>{function e(t){return t===i.None||t===i.Cancelled||t instanceof $J?!0:!t||typeof t!="object"?!1:typeof t.isCancellationRequested=="boolean"&&typeof t.onCancellationRequested=="function"}i.isCancellationToken=e,i.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Di.None}),i.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:iD})})(LJ||(LJ={}));var $J=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?iD:(this._emitter||(this._emitter=new fe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},HS=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 Ay("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ay("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},BJ=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Ay("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=xt(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},DJ;(i=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}i.settled=e;function t(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}i.withAsyncBody=t})(DJ||(DJ={}));var MM=class Fs{static fromArray(e){return new Fs(t=>{t.emitMany(e)})}static fromPromise(e){return new Fs(async t=>{t.emitMany(await e)})}static fromPromises(e){return new Fs(async t=>{await Promise.all(e.map(async s=>t.emitOne(await s)))})}static merge(e){return new Fs(async t=>{await Promise.all(e.map(async s=>{for await(let r of s)t.emitOne(r)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new fe,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Di.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var t;return(t=this._onReturn)==null||t.call(this),{done:!0,value:void 0}}}}static map(e,t){return new Fs(async s=>{for await(let r of e)s.emitOne(t(r))})}map(e){return Fs.map(this,e)}static filter(e,t){return new Fs(async s=>{for await(let r of e)t(r)&&s.emitOne(r)})}filter(e){return Fs.filter(this,e)}static coalesce(e){return Fs.filter(e,t=>!!t)}coalesce(){return Fs.coalesce(this)}static async toPromise(e){let t=[];for await(let s of e)t.push(s);return t}toPromise(){return Fs.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};MM.EMPTY=MM.fromArray([]);var{getWindow:Fr,getWindowId:zJ,onDidRegisterWindow:NJ}=(function(){let i=new Map,e={window:zn,disposables:new Vo};i.set(zn.vscodeWindowId,e);let t=new fe,s=new fe,r=new fe;function n(o,l){return(typeof o=="number"?i.get(o):void 0)??(l?e:void 0)}return{onDidRegisterWindow:t.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(i.has(o.vscodeWindowId))return Xe.None;let l=new Vo,c={window:o,disposables:l.add(new Vo)};return i.set(o.vscodeWindowId,c),l.add(xt(()=>{i.delete(o.vscodeWindowId),s.fire(o)})),l.add(Qe(o,ci.BEFORE_UNLOAD,()=>{r.fire(o)})),t.fire(c),l},getWindows(){return i.values()},getWindowsCount(){return i.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return i.has(o)},getWindowById:n,getWindow(o){var u;let l=o;if((u=l==null?void 0:l.ownerDocument)!=null&&u.defaultView)return l.ownerDocument.defaultView.window;let c=o;return c!=null&&c.view?c.view.window:zn},getDocument(o){return Fr(o).document}}})(),XJ=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Qe(i,e,t,s){return new XJ(i,e,t,s)}var EM=function(i,e,t,s){return Qe(i,e,t,s)},FS,VJ=class extends BJ{constructor(i){super(),this.defaultTarget=i&&Fr(i)}cancelAndSet(i,e,t){return super.cancelAndSet(i,e,t??this.defaultTarget)}},PM=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){em(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let i=new Map,e=new Map,t=new Map,s=new Map,r=n=>{t.set(n,!1);let o=i.get(n)??[];for(e.set(n,o),i.set(n,[]),s.set(n,!0);o.length>0;)o.sort(PM.sort),o.shift().execute();s.set(n,!1)};FS=(n,o,l=0)=>{let c=zJ(n),u=new PM(o,l),d=i.get(c);return d||(d=[],i.set(c,d)),d.push(u),t.get(c)||(t.set(c,!0),n.requestAnimationFrame(()=>r(c))),u}})();function ZJ(i){let e=i.getBoundingClientRect(),t=Fr(i);return{left:e.left+t.scrollX,top:e.top+t.scrollY,width:e.width,height:e.height}}var ci={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},jJ=class{constructor(i){this.domNode=i,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(i){let e=us(i);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(i){let e=us(i);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(i){let e=us(i);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(i){let e=us(i);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(i){let e=us(i);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(i){let e=us(i);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(i){let e=us(i);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(i){let e=us(i);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(i){let e=us(i);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(i){let e=us(i);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(i){let e=us(i);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(i){this._fontFamily!==i&&(this._fontFamily=i,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(i){this._fontWeight!==i&&(this._fontWeight=i,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(i){let e=us(i);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(i){this._fontStyle!==i&&(this._fontStyle=i,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(i){this._fontFeatureSettings!==i&&(this._fontFeatureSettings=i,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(i){this._fontVariationSettings!==i&&(this._fontVariationSettings=i,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(i){this._textDecoration!==i&&(this._textDecoration=i,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(i){let e=us(i);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(i){let e=us(i);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(i){this._className!==i&&(this._className=i,this.domNode.className=this._className)}toggleClassName(i,e){this.domNode.classList.toggle(i,e),this._className=this.domNode.className}setDisplay(i){this._display!==i&&(this._display=i,this.domNode.style.display=this._display)}setPosition(i){this._position!==i&&(this._position=i,this.domNode.style.position=this._position)}setVisibility(i){this._visibility!==i&&(this._visibility=i,this.domNode.style.visibility=this._visibility)}setColor(i){this._color!==i&&(this._color=i,this.domNode.style.color=this._color)}setBackgroundColor(i){this._backgroundColor!==i&&(this._backgroundColor=i,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(i){this._layerHint!==i&&(this._layerHint=i,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(i){this._boxShadow!==i&&(this._boxShadow=i,this.domNode.style.boxShadow=i)}setContain(i){this._contain!==i&&(this._contain=i,this.domNode.style.contain=this._contain)}setAttribute(i,e){this.domNode.setAttribute(i,e)}removeAttribute(i){this.domNode.removeAttribute(i)}appendChild(i){this.domNode.appendChild(i.domNode)}removeChild(i){this.domNode.removeChild(i.domNode)}};function us(i){return typeof i=="number"?`${i}px`:i}function Eu(i){return new jJ(i)}var sD=class{constructor(){this._hooks=new Vo,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,r,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(xt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Fr(e)}this._hooks.add(Qe(o,ci.POINTER_MOVE,l=>{if(l.buttons!==s){this.stopMonitoring(!0);return}l.preventDefault(),this._pointerMoveCallback(l)})),this._hooks.add(Qe(o,ci.POINTER_UP,l=>this.stopMonitoring(!0)))}};function IJ(i,e,t){let s=null,r=null;if(typeof t.value=="function"?(s="value",r=t.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof t.get=="function"&&(s="get",r=t.get),!r)throw new Error("not supported");let n=`$memoize$${e}`;t[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Vr;(i=>(i.Tap="-xterm-gesturetap",i.Change="-xterm-gesturechange",i.Start="-xterm-gesturestart",i.End="-xterm-gesturesend",i.Contextmenu="-xterm-gesturecontextmenu"))(Vr||(Vr={}));var uu=class Xi extends Xe{constructor(){super(),this.dispatched=!1,this.targets=new bM,this.ignoreTargets=new bM,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Di.runAndSubscribe(NJ,({window:e,disposables:t})=>{t.add(Qe(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),t.add(Qe(e.document,"touchend",s=>this.onTouchEnd(e,s))),t.add(Qe(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:zn,disposables:this._store}))}static addTarget(e){if(!Xi.isTouchDevice())return Xe.None;Xi.INSTANCE||(Xi.INSTANCE=new Xi);let t=Xi.INSTANCE.targets.push(e);return xt(t)}static ignoreTarget(e){if(!Xi.isTouchDevice())return Xe.None;Xi.INSTANCE||(Xi.INSTANCE=new Xi);let t=Xi.INSTANCE.ignoreTargets.push(e);return xt(t)}static isTouchDevice(){return"ontouchstart"in zn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=e.targetTouches.length;s<r;s++){let n=e.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:t,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[t],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Vr.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,t){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=t.changedTouches.length;n<o;n++){let l=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],u=Date.now()-c.initialTimeStamp;if(u<Xi.HOLD_DELAY&&Math.abs(c.initialPageX-Qs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Qs(c.rollingPageY))<30){let d=this.newGestureEvent(Vr.Tap,c.initialTarget);d.pageX=Qs(c.rollingPageX),d.pageY=Qs(c.rollingPageY),this.dispatchEvent(d)}else if(u>=Xi.HOLD_DELAY&&Math.abs(c.initialPageX-Qs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Qs(c.rollingPageY))<30){let d=this.newGestureEvent(Vr.Contextmenu,c.initialTarget);d.pageX=Qs(c.rollingPageX),d.pageY=Qs(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Qs(c.rollingPageX),m=Qs(c.rollingPageY),g=Qs(c.rollingTimestamps)-c.rollingTimestamps[0],_=d-c.rollingPageX[0],y=m-c.rollingPageY[0],b=[...this.targets].filter(x=>c.initialTarget instanceof Node&&x.contains(c.initialTarget));this.inertia(e,b,s,Math.abs(_)/g,_>0?1:-1,d,Math.abs(y)/g,y>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(Vr.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,t){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=t,s.tapCount=0,s}dispatchEvent(e){if(e.type===Vr.Tap){let t=new Date().getTime(),s=0;t-this._lastSetTapCountTime>Xi.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=t,e.tapCount=s}else(e.type===Vr.Change||e.type===Vr.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(e.initialTarget))return;let t=[];for(let s of this.targets)if(s.contains(e.initialTarget)){let r=0,n=e.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;t.push([r,s])}t.sort((s,r)=>s[0]-r[0]);for(let[s,r]of t)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,t,s,r,n,o,l,c,u){this.handle=FS(e,()=>{let d=Date.now(),m=d-s,g=0,_=0,y=!0;r+=Xi.SCROLL_FRICTION*m,l+=Xi.SCROLL_FRICTION*m,r>0&&(y=!1,g=n*r*m),l>0&&(y=!1,_=c*l*m);let b=this.newGestureEvent(Vr.Change);b.translationX=g,b.translationY=_,t.forEach(x=>x.dispatchEvent(b)),y||this.inertia(e,t,d,r,n,o+g,l,c,u+_)})}onTouchMove(e){let t=Date.now();for(let s=0,r=e.changedTouches.length;s<r;s++){let n=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],l=this.newGestureEvent(Vr.Change,o.initialTarget);l.translationX=n.pageX-Qs(o.rollingPageX),l.translationY=n.pageY-Qs(o.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(t)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};uu.SCROLL_FRICTION=-.005,uu.HOLD_DELAY=700,uu.CLEAR_TAP_COUNT_TIME=400,Lt([IJ],uu,"isTouchDevice",1);var qJ=uu,GS=class extends Xe{onclick(e,t){this._register(Qe(e,ci.CLICK,s=>t(new kp(Fr(e),s))))}onmousedown(e,t){this._register(Qe(e,ci.MOUSE_DOWN,s=>t(new kp(Fr(e),s))))}onmouseover(e,t){this._register(Qe(e,ci.MOUSE_OVER,s=>t(new kp(Fr(e),s))))}onmouseleave(e,t){this._register(Qe(e,ci.MOUSE_LEAVE,s=>t(new kp(Fr(e),s))))}onkeydown(e,t){this._register(Qe(e,ci.KEY_DOWN,s=>t(new kM(s))))}onkeyup(e,t){this._register(Qe(e,ci.KEY_UP,s=>t(new kM(s))))}oninput(e,t){this._register(Qe(e,ci.INPUT,t))}onblur(e,t){this._register(Qe(e,ci.BLUR,t))}onfocus(e,t){this._register(Qe(e,ci.FOCUS,t))}onchange(e,t){this._register(Qe(e,ci.CHANGE,t))}ignoreGesture(e){return qJ.ignoreTarget(e)}},QM=11,WJ=class extends GS{constructor(i){super(),this._onActivate=i.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=i.bgWidth+"px",this.bgDomNode.style.height=i.bgHeight+"px",typeof i.top<"u"&&(this.bgDomNode.style.top="0px"),typeof i.left<"u"&&(this.bgDomNode.style.left="0px"),typeof i.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof i.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=i.className,this.domNode.style.position="absolute",this.domNode.style.width=QM+"px",this.domNode.style.height=QM+"px",typeof i.top<"u"&&(this.domNode.style.top=i.top+"px"),typeof i.left<"u"&&(this.domNode.style.left=i.left+"px"),typeof i.bottom<"u"&&(this.domNode.style.bottom=i.bottom+"px"),typeof i.right<"u"&&(this.domNode.style.right=i.right+"px"),this._pointerMoveMonitor=this._register(new sD),this._register(EM(this.bgDomNode,ci.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(EM(this.domNode,ci.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new VJ),this._pointerdownScheduleRepeatTimer=this._register(new HS)}_arrowPointerDown(i){if(!i.target||!(i.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Fr(i))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(i.target,i.pointerId,i.buttons,t=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),i.preventDefault()}},UJ=class Dy{constructor(e,t,s,r,n,o,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t=t|0,s=s|0,r=r|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,t<0&&(t=0),r+t>s&&(r=s-t),r<0&&(r=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=t,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,t){return new Dy(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,t?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,t?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new Dy(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let s=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:c}}},YJ=class extends Xe{constructor(i){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=i.smoothScrollDuration,this._scheduleAtNextAnimationFrame=i.scheduleAtNextAnimationFrame,this._state=new UJ(i.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(i){this._smoothScrollDuration=i}validateScrollPosition(i){return this._state.withScrollPosition(i)}getScrollDimensions(){return this._state}setScrollDimensions(i,e){var s;let t=this._state.withScrollDimensions(i,e);this._setState(t,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(i){let e=this._state.withScrollPosition(i);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(i,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(i);if(this._smoothScrolling){i={scrollLeft:typeof i.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:i.scrollLeft,scrollTop:typeof i.scrollTop>"u"?this._smoothScrolling.to.scrollTop:i.scrollTop};let t=this._state.withScrollPosition(i);if(this._smoothScrolling.to.scrollLeft===t.scrollLeft&&this._smoothScrolling.to.scrollTop===t.scrollTop)return;let s;e?s=new LM(this._smoothScrolling.from,t,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,t,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let t=this._state.withScrollPosition(i);this._smoothScrolling=LM.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let i=this._smoothScrolling.tick(),e=this._state.withScrollPosition(i);if(this._setState(e,!0),!!this._smoothScrolling){if(i.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(i,e){let t=this._state;t.equals(i)||(this._state=i,this._onScroll.fire(this._state.createScrollEvent(t,e)))}},RM=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function nv(i,e){let t=e-i;return function(s){return i+t*GJ(s)}}function HJ(i,e,t){return function(s){return s<t?i(s/t):e((s-t)/(1-t))}}var LM=class zy{constructor(e,t,s,r){this.from=e,this.to=t,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,s){if(Math.abs(e-t)>2.5*s){let r,n;return e<t?(r=e+.75*s,n=t-.75*s):(r=e-.75*s,n=t+.75*s),HJ(nv(e,r),nv(n,t),.33)}return nv(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;if(t<1){let s=this.scrollLeft(t),r=this.scrollTop(t);return new RM(s,r,!1)}return new RM(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,t,s){return zy.start(e,t,s)}static start(e,t,s){s=s+10;let r=Date.now()-10;return new zy(e,t,r,s)}};function FJ(i){return Math.pow(i,3)}function GJ(i){return 1-FJ(1-i)}var KJ=class extends Xe{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 HS)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},JJ=140,rD=class extends GS{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 KJ(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new sD),this._shouldRender=!0,this.domNode=Eu(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(Qe(this.domNode.domNode,ci.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new WJ(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=Eu(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 r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Qe(this.slider.domNode,ci.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.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(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=r?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 n=ZJ(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),l=Math.abs(o-s);if(JB&&l>JJ){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let c=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(c))},()=>{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()}},nD=class Ny{constructor(e,t,s,r,n,o){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ny(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t?(this._visibleSize=t,this._refreshComputedValues(),!0):!1}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t?(this._scrollSize=t,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t?(this._scrollPosition=t,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,s,r,n){let o=Math.max(0,s-e),l=Math.max(0,o-2*t),c=r>0&&r>s;if(!c)return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let u=Math.round(Math.max(20,Math.floor(s*l/r))),d=(l-u)/(r-s),m=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(u),computedSliderRatio:d,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let e=Ny._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,s=this._scrollPosition;return t<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},eee=class extends rD{constructor(e,t,s){let r=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new nD(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,n.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}},tee=class extends rD{constructor(i,e,t){let s=i.getScrollDimensions(),r=i.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:t,scrollbarState:new nD(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:i,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(i,e){this.slider.setHeight(i),this.slider.setTop(e)}_renderDomNode(i,e){this.domNode.setWidth(e),this.domNode.setHeight(i),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(i){return this._shouldRender=this._onElementScrollSize(i.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(i.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(i.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(i,e){return e}_sliderPointerPosition(i){return i.pageY}_sliderOrthogonalPointerPosition(i){return i.pageX}_updateScrollbarSize(i){this.slider.setWidth(i)}writeScrollPosition(i,e){i.scrollTop=e}updateOptions(i){this.updateScrollbarSize(i.vertical===2?0:i.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(i.vertical),this._scrollByPage=i.scrollByPage}},iee=500,$M=50,see=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Xy=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,s=1,r=this._rear;do{let n=r===this._front?e:Math.pow(2,-s);if(e-=n,t+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(US){let t=Fr(e.browserEvent),s=pJ(t);this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,s){let r=null,n=new see(e,t,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(s+=.25),t){let r=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),c=Math.max(Math.min(r,o),1),u=Math.max(Math.min(n,l),1),d=Math.max(r,o),m=Math.max(n,l);d%c===0&&m%u===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Xy.INSTANCE=new Xy;var ree=Xy,nee=class extends GS{constructor(i,e,t){super(),this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new fe),this.onWillScroll=this._onWillScroll.event,this._options=aee(e),this._scrollable=t,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new tee(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new eee(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(i),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Eu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Eu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Eu(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 HS),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ua(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(i){this._verticalScrollbar.delegatePointerDown(i)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(i){this._scrollable.setScrollDimensions(i,!1)}updateClassName(i){this._options.className=i,en&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(i){typeof i.handleMouseWheel<"u"&&(this._options.handleMouseWheel=i.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof i.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=i.mouseWheelScrollSensitivity),typeof i.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=i.fastScrollSensitivity),typeof i.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=i.scrollPredominantAxis),typeof i.horizontal<"u"&&(this._options.horizontal=i.horizontal),typeof i.vertical<"u"&&(this._options.vertical=i.vertical),typeof i.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=i.horizontalScrollbarSize),typeof i.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=i.verticalScrollbarSize),typeof i.scrollByPage<"u"&&(this._options.scrollByPage=i.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(i){this._revealOnScroll=i}delegateScrollFromMouseWheelEvent(i){this._onMouseWheel(new AM(i))}_setListeningToMouseWheel(i){if(this._mouseWheelToDispose.length>0!==i&&(this._mouseWheelToDispose=Ua(this._mouseWheelToDispose),i)){let e=t=>{this._onMouseWheel(new AM(t))};this._mouseWheelToDispose.push(Qe(this._listenOnDomNode,ci.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(i){var r;if((r=i.browserEvent)!=null&&r.defaultPrevented)return;let e=ree.INSTANCE;e.acceptStandardWheelEvent(i);let t=!1;if(i.deltaY||i.deltaX){let n=i.deltaY*this._options.mouseWheelScrollSensitivity,o=i.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!en&&i.browserEvent&&i.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),i.browserEvent&&i.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let c=this._scrollable.getFutureScrollPosition(),u={};if(n){let d=$M*n,m=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(u,m)}if(o){let d=$M*o,m=c.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(u,m)}u=this._scrollable.validateScrollPosition(u),(c.scrollLeft!==u.scrollLeft||c.scrollTop!==u.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(u):this._scrollable.setScrollPositionNow(u),t=!0)}let s=t;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(i.preventDefault(),i.stopPropagation())}_onDidScroll(i){this._shouldRender=this._horizontalScrollbar.onDidScroll(i)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(i)||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 i=this._scrollable.getCurrentScrollPosition(),e=i.scrollTop>0,t=i.scrollLeft>0,s=t?" left":"",r=e?" top":"",n=t||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(i){this._mouseIsOver=!1,this._hide()}_onMouseOver(i){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(),iee)}},oee=class extends nee{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()}};function aee(i){let e={lazyRender:typeof i.lazyRender<"u"?i.lazyRender:!1,className:typeof i.className<"u"?i.className:"",useShadows:typeof i.useShadows<"u"?i.useShadows:!0,handleMouseWheel:typeof i.handleMouseWheel<"u"?i.handleMouseWheel:!0,flipAxes:typeof i.flipAxes<"u"?i.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof i.consumeMouseWheelIfScrollbarIsNeeded<"u"?i.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof i.alwaysConsumeMouseWheel<"u"?i.alwaysConsumeMouseWheel:!1,scrollYToX:typeof i.scrollYToX<"u"?i.scrollYToX:!1,mouseWheelScrollSensitivity:typeof i.mouseWheelScrollSensitivity<"u"?i.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof i.fastScrollSensitivity<"u"?i.fastScrollSensitivity:5,scrollPredominantAxis:typeof i.scrollPredominantAxis<"u"?i.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof i.mouseWheelSmoothScroll<"u"?i.mouseWheelSmoothScroll:!0,arrowSize:typeof i.arrowSize<"u"?i.arrowSize:11,listenOnDomNode:typeof i.listenOnDomNode<"u"?i.listenOnDomNode:null,horizontal:typeof i.horizontal<"u"?i.horizontal:1,horizontalScrollbarSize:typeof i.horizontalScrollbarSize<"u"?i.horizontalScrollbarSize:10,horizontalSliderSize:typeof i.horizontalSliderSize<"u"?i.horizontalSliderSize:0,horizontalHasArrows:typeof i.horizontalHasArrows<"u"?i.horizontalHasArrows:!1,vertical:typeof i.vertical<"u"?i.vertical:1,verticalScrollbarSize:typeof i.verticalScrollbarSize<"u"?i.verticalScrollbarSize:10,verticalHasArrows:typeof i.verticalHasArrows<"u"?i.verticalHasArrows:!1,verticalSliderSize:typeof i.verticalSliderSize<"u"?i.verticalSliderSize:0,scrollByPage:typeof i.scrollByPage<"u"?i.scrollByPage:!1};return e.horizontalSliderSize=typeof i.horizontalSliderSize<"u"?i.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof i.verticalSliderSize<"u"?i.verticalSliderSize:e.verticalScrollbarSize,en&&(e.className+=" mac"),e}var Vy=class extends Xe{constructor(e,t,s,r,n,o,l,c){super(),this._bufferService=s,this._optionsService=l,this._renderService=c,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let u=this._register(new YJ({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>FS(r.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{u.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new oee(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},u)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Di.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(xt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(xt(()=>this._styleElement.remove())),this._register(Di.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(`
98
- `)})),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(d=>this._handleScroll(d)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Vy=Lt([Oe(2,is),Oe(3,Un),Oe(4,NB),Oe(5,Dh),Oe(6,ss),Oe(7,Yn)],Vy);var Zy=class extends Xe{constructor(e,t,s,r,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=n,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(xt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Zy=Lt([Oe(1,is),Oe(2,Un),Oe(3,Mf),Oe(4,Yn)],Zy);var lee=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)}},Br={full:0,left:0,center:0,right:0},Co={full:0,left:0,center:0,right:0},Yc={full:0,left:0,center:0,right:0},Km=class extends Xe{constructor(e,t,s,r,n,o,l,c){var d;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=n,this._optionsService=o,this._themeService=l,this._coreBrowserService=c,this._colorZoneStore=new lee,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(),(d=this._viewportElement.parentElement)==null||d.insertBefore(this._canvas,this._viewportElement),this._register(xt(()=>{var m;return(m=this._canvas)==null?void 0:m.remove()}));let u=this._canvas.getContext("2d");if(u)this._ctx=u;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Co.full=this._canvas.width,Co.left=e,Co.center=t,Co.right=e,this._refreshDrawHeightConstants(),Yc.full=1,Yc.left=1,Yc.center=1+Co.left,Yc.right=1+Co.left+Co.center}_refreshDrawHeightConstants(){Br.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);Br.left=t,Br.center=t,Br.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Br.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(Yc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Br[e.position||"full"]/2),Co[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Br[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}))}};Km=Lt([Oe(2,is),Oe(3,Mf),Oe(4,Yn),Oe(5,ss),Oe(6,Dh),Oe(7,Un)],Km);var le;(i=>(i.NUL="\0",i.SOH="",i.STX="",i.ETX="",i.EOT="",i.ENQ="",i.ACK="",i.BEL="\x07",i.BS="\b",i.HT=" ",i.LF=`
99
- `,i.VT="\v",i.FF="\f",i.CR="\r",i.SO="",i.SI="",i.DLE="",i.DC1="",i.DC2="",i.DC3="",i.DC4="",i.NAK="",i.SYN="",i.ETB="",i.CAN="",i.EM="",i.SUB="",i.ESC="\x1B",i.FS="",i.GS="",i.RS="",i.US="",i.SP=" ",i.DEL=""))(le||(le={}));var sm;(i=>(i.PAD="€",i.HOP="",i.BPH="‚",i.NBH="ƒ",i.IND="„",i.NEL="…",i.SSA="†",i.ESA="‡",i.HTS="ˆ",i.HTJ="‰",i.VTS="Š",i.PLD="‹",i.PLU="Œ",i.RI="",i.SS2="Ž",i.SS3="",i.DCS="",i.PU1="‘",i.PU2="’",i.STS="“",i.CCH="”",i.MW="•",i.SPA="–",i.EPA="—",i.SOS="˜",i.SGCI="™",i.SCI="š",i.CSI="›",i.ST="œ",i.OSC="",i.PM="ž",i.APC="Ÿ"))(sm||(sm={}));var oD;(i=>i.ST=`${le.ESC}\\`)(oD||(oD={}));var jy=class{constructor(e,t,s,r,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=n,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(`${le.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,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=r+"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=n+"px",this._textarea.style.top=r+"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)}}};jy=Lt([Oe(2,is),Oe(3,ss),Oe(4,Ga),Oe(5,Yn)],jy);var ui=0,fi=0,di=0,Pt=0,BM={css:"#00000000",rgba:0},Ut;(i=>{function e(r,n,o,l){return l!==void 0?`#${ya(r)}${ya(n)}${ya(o)}${ya(l)}`:`#${ya(r)}${ya(n)}${ya(o)}`}i.toCss=e;function t(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}i.toRgba=t;function s(r,n,o,l){return{css:i.toCss(r,n,o,l),rgba:i.toRgba(r,n,o,l)}}i.toColor=s})(Ut||(Ut={}));var vt;(i=>{function e(c,u){if(Pt=(u.rgba&255)/255,Pt===1)return{css:u.css,rgba:u.rgba};let d=u.rgba>>24&255,m=u.rgba>>16&255,g=u.rgba>>8&255,_=c.rgba>>24&255,y=c.rgba>>16&255,b=c.rgba>>8&255;ui=_+Math.round((d-_)*Pt),fi=y+Math.round((m-y)*Pt),di=b+Math.round((g-b)*Pt);let x=Ut.toCss(ui,fi,di),w=Ut.toRgba(ui,fi,di);return{css:x,rgba:w}}i.blend=e;function t(c){return(c.rgba&255)===255}i.isOpaque=t;function s(c,u,d){let m=rm.ensureContrastRatio(c.rgba,u.rgba,d);if(m)return Ut.toColor(m>>24&255,m>>16&255,m>>8&255)}i.ensureContrastRatio=s;function r(c){let u=(c.rgba|255)>>>0;return[ui,fi,di]=rm.toChannels(u),{css:Ut.toCss(ui,fi,di),rgba:u}}i.opaque=r;function n(c,u){return Pt=Math.round(u*255),[ui,fi,di]=rm.toChannels(c.rgba),{css:Ut.toCss(ui,fi,di,Pt),rgba:Ut.toRgba(ui,fi,di,Pt)}}i.opacity=n;function o(c,u){return Pt=c.rgba&255,n(c,Pt*u/255)}i.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}i.toColorRGB=l})(vt||(vt={}));var Ct;(i=>{let e,t;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",t=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return ui=parseInt(r.slice(1,2).repeat(2),16),fi=parseInt(r.slice(2,3).repeat(2),16),di=parseInt(r.slice(3,4).repeat(2),16),Ut.toColor(ui,fi,di);case 5:return ui=parseInt(r.slice(1,2).repeat(2),16),fi=parseInt(r.slice(2,3).repeat(2),16),di=parseInt(r.slice(3,4).repeat(2),16),Pt=parseInt(r.slice(4,5).repeat(2),16),Ut.toColor(ui,fi,di,Pt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return ui=parseInt(n[1]),fi=parseInt(n[2]),di=parseInt(n[3]),Pt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ut.toColor(ui,fi,di,Pt);if(!e||!t)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=t,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[ui,fi,di,Pt]=e.getImageData(0,0,1,1).data,Pt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ut.toRgba(ui,fi,di,Pt),css:r}}i.toColor=s})(Ct||(Ct={}));var Yi;(i=>{function e(s){return t(s>>16&255,s>>8&255,s&255)}i.relativeLuminance=e;function t(s,r,n){let o=s/255,l=r/255,c=n/255,u=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+d*.7152+m*.0722}i.relativeLuminance2=t})(Yi||(Yi={}));var rm;(i=>{function e(o,l){if(Pt=(l&255)/255,Pt===1)return l;let c=l>>24&255,u=l>>16&255,d=l>>8&255,m=o>>24&255,g=o>>16&255,_=o>>8&255;return ui=m+Math.round((c-m)*Pt),fi=g+Math.round((u-g)*Pt),di=_+Math.round((d-_)*Pt),Ut.toRgba(ui,fi,di)}i.blend=e;function t(o,l,c){let u=Yi.relativeLuminance(o>>8),d=Yi.relativeLuminance(l>>8);if(Mn(u,d)<c){if(d<u){let _=s(o,l,c),y=Mn(u,Yi.relativeLuminance(_>>8));if(y<c){let b=r(o,l,c),x=Mn(u,Yi.relativeLuminance(b>>8));return y>x?_:b}return _}let m=r(o,l,c),g=Mn(u,Yi.relativeLuminance(m>>8));if(g<c){let _=s(o,l,c),y=Mn(u,Yi.relativeLuminance(_>>8));return g>y?m:_}return m}}i.ensureContrastRatio=t;function s(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));for(;b<c&&(g>0||_>0||y>0);)g-=Math.max(0,Math.ceil(g*.1)),_-=Math.max(0,Math.ceil(_*.1)),y-=Math.max(0,Math.ceil(y*.1)),b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.reduceLuminance=s;function r(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));for(;b<c&&(g<255||_<255||y<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}i.toChannels=n})(rm||(rm={}));function ya(i){let e=i.toString(16);return e.length<2?"0"+e:e}function Mn(i,e){return i<e?(e+.05)/(i+.05):(i+.05)/(e+.05)}var hee=class extends Af{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()]}},Jm=class{constructor(i){this._bufferService=i,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new lr}register(i){let e={id:this._nextCharacterJoinerId++,handler:i};return this._characterJoiners.push(e),e.id}deregister(i){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===i)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(i){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(i);if(!e||e.length===0)return[];let t=[],s=e.translateToString(!0),r=0,n=0,o=0,l=e.getFg(0),c=e.getBg(0);for(let u=0;u<e.getTrimmedLength();u++)if(e.loadCell(u,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(u-r>1){let d=this._getJoinedRanges(s,o,n,e,r);for(let m=0;m<d.length;m++)t.push(d[m])}r=u,o=n,l=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||No.length}if(this._bufferService.cols-r>1){let u=this._getJoinedRanges(s,o,n,e,r);for(let d=0;d<u.length;d++)t.push(u[d])}return t}_getJoinedRanges(i,e,t,s,r){let n=i.substring(e,t),o=[];try{o=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(n);for(let u=0;u<c.length;u++)Jm._mergeRanges(o,c[u])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(i,e,t){let s=0,r=!1,n=0,o=i[s];if(o){for(let l=t;l<this._bufferService.cols;l++){let c=e.getWidth(l),u=e.getString(l).length||No.length;if(c!==0){if(!r&&o[0]<=n&&(o[0]=l,r=!0),o[1]<=n){if(o[1]=l,o=i[++s],!o)break;o[0]<=n?(o[0]=l,r=!0):r=!1}n+=u}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(i,e){let t=!1;for(let s=0;s<i.length;s++){let r=i[s];if(t){if(e[1]<=r[0])return i[s-1][1]=e[1],i;if(e[1]<=r[1])return i[s-1][1]=Math.max(e[1],r[1]),i.splice(s,1),i;i.splice(s,1),s--}else{if(e[1]<=r[0])return i.splice(s,0,e),i;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),i;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),t=!0);continue}}return t?i[i.length-1][1]=e[1]:i.push(e),i}};Jm=Lt([Oe(0,is)],Jm);function cee(i){return 57508<=i&&i<=57558}function uee(i){return 9472<=i&&i<=9631}function fee(i){return cee(i)||uee(i)}function dee(){return{css:{canvas:Tp(),cell:Tp()},device:{canvas:Tp(),cell:Tp(),char:{width:0,height:0,left:0,top:0}}}}function Tp(){return{width:0,height:0}}var Iy=class{constructor(e,t,s,r,n,o,l){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=r,this._coreService=n,this._decorationService=o,this._themeService=l,this._workCell=new lr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,r,n,o,l,c,u,d,m){let g=[],_=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,b=e.getNoBgTrimmedLength();s&&b<o+1&&(b=o+1);let x,w=0,k="",C=0,A=0,P=0,E=0,$=!1,z=0,I=!1,se=0,F=0,R=[],L=d!==-1&&m!==-1;for(let N=0;N<b;N++){e.loadCell(N,this._workCell);let Z=this._workCell.getWidth();if(Z===0)continue;let Q=!1,X=N>=F,W=N,U=this._workCell;if(_.length>0&&N===_[0][0]&&X){let Pe=_.shift(),ln=this._isCellInSelection(Pe[0],t);for(C=Pe[0]+1;C<Pe[1];C++)X&&(X=ln===this._isCellInSelection(C,t));X&&(X=!s||o<Pe[0]||o>=Pe[1]),X?(Q=!0,U=new hee(this._workCell,e.translateToString(!0,Pe[0],Pe[1]),Pe[1]-Pe[0]),W=Pe[1]-1,Z=U.getWidth()):F=Pe[1]}let q=this._isCellInSelection(N,t),D=s&&N===o,G=L&&N>=d&&N<=m,ie=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Pe=>{ie=!0});let ce=U.getChars()||No;if(ce===" "&&(U.isUnderline()||U.isOverline())&&(ce=" "),se=Z*c-u.get(ce,U.isBold(),U.isItalic()),!x)x=this._document.createElement("span");else if(w&&(q&&I||!q&&!I&&U.bg===A)&&(q&&I&&y.selectionForeground||U.fg===P)&&U.extended.ext===E&&G===$&&se===z&&!D&&!Q&&!ie&&X){U.isInvisible()?k+=No:k+=ce,w++;continue}else w&&(x.textContent=k),x=this._document.createElement("span"),w=0,k="";if(A=U.bg,P=U.fg,E=U.extended.ext,$=G,z=se,I=q,Q&&o>=N&&o<=W&&(o=N),!this._coreService.isCursorHidden&&D&&this._coreService.isCursorInitialized){if(R.push("xterm-cursor"),this._coreBrowserService.isFocused)l&&R.push("xterm-cursor-blink"),R.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":R.push("xterm-cursor-outline");break;case"block":R.push("xterm-cursor-block");break;case"bar":R.push("xterm-cursor-bar");break;case"underline":R.push("xterm-cursor-underline");break}}if(U.isBold()&&R.push("xterm-bold"),U.isItalic()&&R.push("xterm-italic"),U.isDim()&&R.push("xterm-dim"),U.isInvisible()?k=No:k=U.getChars()||No,U.isUnderline()&&(R.push(`xterm-underline-${U.extended.underlineStyle}`),k===" "&&(k=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${Af.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let Pe=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&Pe<8&&(Pe+=8),x.style.textDecorationColor=y.ansi[Pe].css}U.isOverline()&&(R.push("xterm-overline"),k===" "&&(k=" ")),U.isStrikethrough()&&R.push("xterm-strikethrough"),G&&(x.style.textDecoration="underline");let he=U.getFgColor(),de=U.getFgColorMode(),ge=U.getBgColor(),Ae=U.getBgColorMode(),ye=!!U.isInverse();if(ye){let Pe=he;he=ge,ge=Pe;let ln=de;de=Ae,Ae=ln}let mt,Ft,Gt=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Pe=>{Pe.options.layer!=="top"&&Gt||(Pe.backgroundColorRGB&&(Ae=50331648,ge=Pe.backgroundColorRGB.rgba>>8&16777215,mt=Pe.backgroundColorRGB),Pe.foregroundColorRGB&&(de=50331648,he=Pe.foregroundColorRGB.rgba>>8&16777215,Ft=Pe.foregroundColorRGB),Gt=Pe.options.layer==="top")}),!Gt&&q&&(mt=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,ge=mt.rgba>>8&16777215,Ae=50331648,Gt=!0,y.selectionForeground&&(de=50331648,he=y.selectionForeground.rgba>>8&16777215,Ft=y.selectionForeground)),Gt&&R.push("xterm-decoration-top");let oi;switch(Ae){case 16777216:case 33554432:oi=y.ansi[ge],R.push(`xterm-bg-${ge}`);break;case 50331648:oi=Ut.toColor(ge>>16,ge>>8&255,ge&255),this._addStyle(x,`background-color:#${DM((ge>>>0).toString(16),"0",6)}`);break;case 0:default:ye?(oi=y.foreground,R.push("xterm-bg-257")):oi=y.background}switch(mt||U.isDim()&&(mt=vt.multiplyOpacity(oi,.5)),de){case 16777216:case 33554432:U.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(x,oi,y.ansi[he],U,mt,void 0)||R.push(`xterm-fg-${he}`);break;case 50331648:let Pe=Ut.toColor(he>>16&255,he>>8&255,he&255);this._applyMinimumContrast(x,oi,Pe,U,mt,Ft)||this._addStyle(x,`color:#${DM(he.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,oi,y.foreground,U,mt,Ft)||ye&&R.push("xterm-fg-257")}R.length&&(x.className=R.join(" "),R.length=0),!D&&!Q&&!ie&&X?w++:x.textContent=k,se!==this.defaultSpacing&&(x.style.letterSpacing=`${se}px`),g.push(x),N=W}return x&&w&&(x.textContent=k),g}_applyMinimumContrast(e,t,s,r,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||fee(r.getCode()))return!1;let l=this._getContrastCache(r),c;if(!n&&!o&&(c=l.getColor(t.rgba,s.rgba)),c===void 0){let u=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);c=vt.ensureContrastRatio(n||t,o||s,u),l.setColor((n||t).rgba,(o||s).rgba,c??null)}return c?(this._addStyle(e,`color:${c.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,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e<r[0]&&t<=r[1]:e<s[0]&&t>=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t<r[1]||s[1]===r[1]&&t===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&t===r[1]&&e<r[0]||s[1]<r[1]&&t===s[1]&&e>=s[0]}};Iy=Lt([Oe(1,ZB),Oe(2,ss),Oe(3,Un),Oe(4,Ga),Oe(5,Mf),Oe(6,Dh)],Iy);function DM(i,e,t){for(;i.length<t;)i=e+i;return i}var pee=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.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,r,n,o],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),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,r){e===this._font&&t===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,s){let r=0;if(!t&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let l=this._measure(e,0);return l>0&&(this._flat[r]=l),l}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let l=0;t&&(l|=1),s&&(l|=2),o=this._measure(e,l),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},mee=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,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,l=s[1]-n,c=Math.max(o,0),u=Math.min(l,e.rows-1);if(c>=e.rows||u<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=l,this.viewportCappedStartRow=c,this.viewportCappedEndRow=u,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}};function gee(){return new mee}var ov="xterm-dom-renderer-owner-",Hs="xterm-rows",Ap="xterm-fg-",zM="xterm-bg-",Hc="xterm-focus",Mp="xterm-selection",Oee=1,qy=class extends Xe{constructor(e,t,s,r,n,o,l,c,u,d,m,g,_,y){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=n,this._helperContainer=o,this._linkifier2=l,this._charSizeService=u,this._optionsService=d,this._bufferService=m,this._coreService=g,this._coreBrowserService=_,this._themeService=y,this._terminalClass=Oee++,this._rowElements=[],this._selectionRenderModel=gee(),this.onRequestRedraw=this._register(new fe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Hs),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(Mp),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=dee(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=c.createInstance(Iy,document),this._element.classList.add(ov+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(xt(()=>{this._element.classList.remove(ov+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new pee(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} .${Hs} 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} .${Hs} { 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} .${Hs} .xterm-dim { color: ${vt.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}`,r=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Hs}.${Hc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Hs}.${Hc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Hs}.${Hc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Mp} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Mp} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Mp} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,l]of e.ansi.entries())t+=`${this._terminalSelector} .${Ap}${o} { color: ${l.css}; }${this._terminalSelector} .${Ap}${o}.xterm-dim { color: ${vt.multiplyOpacity(l,.5).css}; }${this._terminalSelector} .${zM}${o} { background-color: ${l.css}; }`;t+=`${this._terminalSelector} .${Ap}257 { color: ${vt.opaque(e.background).css}; }${this._terminalSelector} .${Ap}257.xterm-dim { color: ${vt.multiplyOpacity(vt.opaque(e.background),.5).css}; }${this._terminalSelector} .${zM}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 r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Hc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Hc),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 r=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,l=this._selectionRenderModel.viewportCappedEndRow,c=this._document.createDocumentFragment();if(s){let u=e[0]>t[0];c.appendChild(this._createSelectionElement(o,u?t[0]:e[0],u?e[0]:t[0],l-o+1))}else{let u=r===o?e[0]:0,d=o===n?t[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(o,u,d));let m=l-o-1;if(c.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,m)),o!==l){let g=n===l?t[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(l,0,g))}}this._selectionContainer.appendChild(c)}_createSelectionElement(e,t,s,r=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,l=this.dimensions.css.cell.width*(s-t);return o+l>this.dimensions.css.canvas.width&&(l=this.dimensions.css.canvas.width-o),n.style.height=`${r*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${l}px`,n}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,r=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,l=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,c=this._optionsService.rawOptions.cursorInactiveStyle;for(let u=e;u<=t;u++){let d=u+s.ydisp,m=this._rowElements[u],g=s.lines.get(d);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,d,d===r,l,c,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${ov}${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,r,n,o){s<0&&(e=0),r<0&&(t=0);let l=this._bufferService.rows-1;s=Math.max(Math.min(s,l),0),r=Math.max(Math.min(r,l),0),n=Math.min(n,this._bufferService.cols);let c=this._bufferService.buffer,u=c.ybase+c.y,d=Math.min(c.x,n-1),m=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=s;y<=r;++y){let b=y+c.ydisp,x=this._rowElements[y],w=c.lines.get(b);if(!x||!w)break;x.replaceChildren(...this._rowFactory.createRow(w,b,b===u,g,_,d,m,this.dimensions.css.cell.width,this._widthCache,o?y===s?e:0:-1,o?(y===r?t:n)-1:-1))}}};qy=Lt([Oe(7,IS),Oe(8,xg),Oe(9,ss),Oe(10,is),Oe(11,Ga),Oe(12,Un),Oe(13,Dh)],qy);var Wy=class extends Xe{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new fe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new vee(this._optionsService))}catch{this._measureStrategy=this._register(new _ee(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())}};Wy=Lt([Oe(2,ss)],Wy);var aD=class extends Xe{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(i,e){i!==void 0&&i>0&&e!==void 0&&e>0&&(this._result.width=i,this._result.height=e)}},_ee=class extends aD{constructor(i,e,t){super(),this._document=i,this._parentElement=e,this._optionsService=t,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}},vee=class extends aD{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}},yee=class extends Xe{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 bee(this._window)),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new fe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Di.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Qe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Qe(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}},bee=class extends Xe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Th),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(xt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Qe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},See=class extends Xe{constructor(){super(),this.linkProviders=[],this._register(xt(()=>this.linkProviders.length=0))}registerLinkProvider(i){return this.linkProviders.push(i),{dispose:()=>{let e=this.linkProviders.indexOf(i);e!==-1&&this.linkProviders.splice(e,1)}}}};function KS(i,e,t){let s=t.getBoundingClientRect(),r=i.getComputedStyle(t),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-s.left-n,e.clientY-s.top-o]}function xee(i,e,t,s,r,n,o,l,c){if(!n)return;let u=KS(i,e,t);if(u)return u[0]=Math.ceil((u[0]+(c?o/2:0))/o),u[1]=Math.ceil(u[1]/l),u[0]=Math.min(Math.max(u[0],1),s+(c?1:0)),u[1]=Math.min(Math.max(u[1],1),r),u}var Uy=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,n){return xee(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=KS(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])}}};Uy=Lt([Oe(0,Yn),Oe(1,xg)],Uy);var wee=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=[]}},lD={};LK(lD,{getSafariVersion:()=>kee,isChromeOS:()=>fD,isFirefox:()=>hD,isIpad:()=>Tee,isIphone:()=>Aee,isLegacyEdge:()=>Cee,isLinux:()=>JS,isMac:()=>eg,isNode:()=>wg,isSafari:()=>cD,isWindows:()=>uD});var wg=typeof process<"u"&&"title"in process,Ef=wg?"node":navigator.userAgent,Pf=wg?"node":navigator.platform,hD=Ef.includes("Firefox"),Cee=Ef.includes("Edge"),cD=/^((?!chrome|android).)*safari/i.test(Ef);function kee(){if(!cD)return 0;let i=Ef.match(/Version\/(\d+)/);return i===null||i.length<2?0:parseInt(i[1])}var eg=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Pf),Tee=Pf==="iPad",Aee=Pf==="iPhone",uD=["Windows","Win16","Win32","WinCE"].includes(Pf),JS=Pf.indexOf("Linux")>=0,fD=/\bCrOS\b/.test(Ef),dD=class{constructor(){this._tasks=[],this._i=0}enqueue(i){this._tasks.push(i),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(i){this._idleCallback=void 0;let e=0,t=0,s=i.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),t=Math.max(e,t),r=i.timeRemaining(),t*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},Mee=class extends dD{_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())}}},Eee=class extends dD{_requestCallback(i){return requestIdleCallback(i)}_cancelCallback(i){cancelIdleCallback(i)}},tg=!wg&&"requestIdleCallback"in window?Eee:Mee,Pee=class{constructor(){this._queue=new tg}set(i){this._queue.clear(),this._queue.enqueue(i)}flush(){this._queue.flush()}},Yy=class extends Xe{constructor(e,t,s,r,n,o,l,c,u){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=n,this._coreBrowserService=c,this._renderer=this._register(new Th),this._pausedResizeTask=new Pee,this._observerDisposable=this._register(new Th),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 fe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new fe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new fe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new wee((d,m)=>this._renderRows(d,m),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Qee(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(xt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(l.onResize(()=>this._fullRefresh())),this._register(l.buffers.onBufferActivate(()=>{var d;return(d=this._renderer.value)==null?void 0:d.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(l.cols,l.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(l.buffer.y,l.buffer.y,!0))),this._register(u.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=xt(()=>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 r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Yy=Lt([Oe(2,ss),Oe(3,xg),Oe(4,Ga),Oe(5,Mf),Oe(6,is),Oe(7,Un),Oe(8,Dh)],Yy);var Qee=class{constructor(i,e,t){this._coreBrowserService=i,this._coreService=e,this._onTimeout=t,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(i,e){this._isBuffering?(this._start=Math.min(this._start,i),this._end=Math.max(this._end,e)):(this._start=i,this._end=e,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 i={start:this._start,end:this._end};return this._isBuffering=!1,i}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Ree(i,e,t,s){let r=t.buffer.x,n=t.buffer.y;if(!t.buffer.hasScrollback)return Bee(r,n,i,e,t,s)+Cg(n,e,t,s)+Dee(r,n,i,e,t,s);let o;if(n===e)return o=r>i?"D":"C",hf(Math.abs(r-i),lf(o,s));o=n>e?"D":"C";let l=Math.abs(n-e),c=$ee(n>e?i:r,t)+(l-1)*t.cols+1+Lee(n>e?r:i);return hf(c,lf(o,s))}function Lee(i,e){return i-1}function $ee(i,e){return e.cols-i}function Bee(i,e,t,s,r,n){return Cg(e,s,r,n).length===0?"":hf(mD(i,e,i,e-Ya(e,r),!1,r).length,lf("D",n))}function Cg(i,e,t,s){let r=i-Ya(i,t),n=e-Ya(e,t),o=Math.abs(r-n)-zee(i,e,t);return hf(o,lf(pD(i,e),s))}function Dee(i,e,t,s,r,n){let o;Cg(e,s,r,n).length>0?o=s-Ya(s,r):o=e;let l=s,c=Nee(i,e,t,s,r,n);return hf(mD(i,o,t,l,c==="C",r).length,lf(c,n))}function zee(i,e,t){var o;let s=0,r=i-Ya(i,t),n=e-Ya(e,t);for(let l=0;l<Math.abs(r-n);l++){let c=pD(i,e)==="A"?-1:1;(o=t.buffer.lines.get(r+c*l))!=null&&o.isWrapped&&s++}return s}function Ya(i,e){let t=0,s=e.buffer.lines.get(i),r=s==null?void 0:s.isWrapped;for(;r&&i>=0&&i<e.rows;)t++,s=e.buffer.lines.get(--i),r=s==null?void 0:s.isWrapped;return t}function Nee(i,e,t,s,r,n){let o;return Cg(t,s,r,n).length>0?o=s-Ya(s,r):o=e,i<t&&o<=s||i>=t&&o<s?"C":"D"}function pD(i,e){return i>e?"A":"B"}function mD(i,e,t,s,r,n){let o=i,l=e,c="";for(;(o!==t||l!==s)&&l>=0&&l<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(l,!1,i,o),o=0,i=0,l++):!r&&o<0&&(c+=n.buffer.translateBufferLineToString(l,!1,0,i+1),o=n.cols-1,i=o,l--);return c+n.buffer.translateBufferLineToString(l,!1,i,o)}function lf(i,e){let t=e?"O":"[";return le.ESC+t+i}function hf(i,e){i=Math.floor(i);let t="";for(let s=0;s<i;s++)t+=e;return t}var Xee=class{constructor(i){this._bufferService=i,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 i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let i=this.selectionStart,e=this.selectionEnd;return!i||!e?!1:i[1]>e[1]||i[1]===e[1]&&i[0]>e[0]}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function NM(i,e){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return e*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}var av=50,Vee=15,Zee=50,jee=500,Iee=" ",qee=new RegExp(Iee,"g"),Hy=class extends Xe{constructor(e,t,s,r,n,o,l,c,u){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=n,this._mouseService=o,this._optionsService=l,this._renderService=c,this._coreBrowserService=u,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new lr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new fe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new fe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new Xee(this._bufferService),this._activeSelectionMode=0,this._register(xt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.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,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let l=e[1];l<=t[1];l++){let c=s.translateBufferLineToString(l,!0,n,o);r.push(c)}}else{let n=e[1]===t[1]?t[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let l=s.lines.get(o),c=s.translateBufferLineToString(o,!0);l!=null&&l.isWrapped?r[r.length-1]+=c:r.push(c)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),l=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?r[r.length-1]+=l:r.push(l)}}return r.map(n=>n.replace(qee," ")).join(uD?`\r
104
+ `))}},QJ=class extends Error{constructor(i,e){super(i),this.name="ListenerLeakError",this.stack=e}},RJ=class extends Error{constructor(i,e){super(i),this.name="ListenerRefusalError",this.stack=e}},LJ=0,Cv=class{constructor(e){this.value=e,this.id=LJ++}},$J=2,BJ,fe=class{constructor(e){var t,s,r,n;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new EJ((e==null?void 0:e.onListenerError)??em,((s=this._options)==null?void 0:s.leakWarningThreshold)??MJ):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new AJ(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var e,t,s,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var l,c,u,d,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let g=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(g);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new RJ(`${g}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||em)(y),Xe.None}if(this._disposed)return Xe.None;t&&(e=e.bind(t));let r=new Cv(e),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=PJ.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Cv?(this._deliveryQueue??(this._deliveryQueue=new DJ),this._listeners=[this._listeners,r]):this._listeners.push(r):((u=(c=this._options)==null?void 0:c.onWillAddFirstListener)==null||u.call(c,this),this._listeners=r,(m=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||m.call(d,this)),this._size++;let o=xt(()=>{n==null||n(),this._removeListener(r)});return s instanceof Vo?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var n,o,l,c;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(c=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||c.call(l,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 r=this._deliveryQueue.current===this;if(this._size*$J<=t.length){let u=0;for(let d=0;d<t.length;d++)t[d]?t[u++]=t[d]:r&&(this._deliveryQueue.end--,u<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=u}}_deliver(e,t){var r;if(!e)return;let s=((r=this._options)==null?void 0:r.onListenerError)||em;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,s,r,n;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof Cv)this._deliver(this._listeners,e);else{let o=this._deliveryQueue;o.enqueue(this,e,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},DJ=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}},Ry=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new fe,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new fe,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};Ry.INSTANCE=new Ry;var US=Ry;function zJ(i,e,t){typeof e=="string"&&(e=i.matchMedia(e)),e.addEventListener("change",t)}US.INSTANCE.onDidChangeZoomLevel;function NJ(i){return US.INSTANCE.getZoomFactor(i)}US.INSTANCE.onDidChangeFullscreen;var zh=typeof navigator=="object"?navigator.userAgent:"",Ly=zh.indexOf("Firefox")>=0,XJ=zh.indexOf("AppleWebKit")>=0,YS=zh.indexOf("Chrome")>=0,VJ=!YS&&zh.indexOf("Safari")>=0;zh.indexOf("Electron/")>=0;zh.indexOf("Android")>=0;var kv=!1;if(typeof zn.matchMedia=="function"){let i=zn.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=zn.matchMedia("(display-mode: fullscreen)");kv=i.matches,zJ(zn,i,({matches:t})=>{kv&&e.matches||(kv=t)})}var ih="en",$y=!1,By=!1,tm=!1,iD=!1,kp,im=ih,FM=ih,ZJ,gr,Xa=globalThis,Ri,fP;typeof Xa.vscode<"u"&&typeof Xa.vscode.process<"u"?Ri=Xa.vscode.process:typeof process<"u"&&typeof((fP=process==null?void 0:process.versions)==null?void 0:fP.node)=="string"&&(Ri=process);var dP,jJ=typeof((dP=Ri==null?void 0:Ri.versions)==null?void 0:dP.electron)=="string",IJ=jJ&&(Ri==null?void 0:Ri.type)==="renderer",pP;if(typeof Ri=="object"){$y=Ri.platform==="win32",By=Ri.platform==="darwin",tm=Ri.platform==="linux",tm&&Ri.env.SNAP&&Ri.env.SNAP_REVISION,Ri.env.CI||Ri.env.BUILD_ARTIFACTSTAGINGDIRECTORY,kp=ih,im=ih;let i=Ri.env.VSCODE_NLS_CONFIG;if(i)try{let e=JSON.parse(i);kp=e.userLocale,FM=e.osLocale,im=e.resolvedLanguage||ih,ZJ=(pP=e.languagePack)==null?void 0:pP.translationsConfigFile}catch{}iD=!0}else typeof navigator=="object"&&!IJ?(gr=navigator.userAgent,$y=gr.indexOf("Windows")>=0,By=gr.indexOf("Macintosh")>=0,(gr.indexOf("Macintosh")>=0||gr.indexOf("iPad")>=0||gr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,tm=gr.indexOf("Linux")>=0,(gr==null?void 0:gr.indexOf("Mobi"))>=0,im=globalThis._VSCODE_NLS_LANGUAGE||ih,kp=navigator.language.toLowerCase(),FM=kp):console.error("Unable to resolve platform.");var sD=$y,en=By,qJ=tm,GM=iD,sn=gr,Co=im,WJ;(i=>{function e(){return Co}i.value=e;function t(){return Co.length===2?Co==="en":Co.length>=3?Co[0]==="e"&&Co[1]==="n"&&Co[2]==="-":!1}i.isDefaultVariant=t;function s(){return Co==="en"}i.isDefault=s})(WJ||(WJ={}));var UJ=typeof Xa.postMessage=="function"&&!Xa.importScripts;(()=>{if(UJ){let i=[];Xa.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let s=0,r=i.length;s<r;s++){let n=i[s];if(n.id===t.data.vscodeScheduleAsyncWork){i.splice(s,1),n.callback();return}}});let e=0;return t=>{let s=++e;i.push({id:s,callback:t}),Xa.postMessage({vscodeScheduleAsyncWork:s},"*")}}return i=>setTimeout(i)})();var YJ=!!(sn&&sn.indexOf("Chrome")>=0);sn&&sn.indexOf("Firefox")>=0;!YJ&&sn&&sn.indexOf("Safari")>=0;sn&&sn.indexOf("Edg/")>=0;sn&&sn.indexOf("Android")>=0;var Xl=typeof navigator=="object"?navigator:{};GM||document.queryCommandSupported&&document.queryCommandSupported("copy")||Xl&&Xl.clipboard&&Xl.clipboard.writeText,GM||Xl&&Xl.clipboard&&Xl.clipboard.readText;var HS=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}},Tv=new HS,KM=new HS,JM=new HS,HJ=new Array(230),rD;(i=>{function e(l){return Tv.keyCodeToStr(l)}i.toString=e;function t(l){return Tv.strToKeyCode(l)}i.fromString=t;function s(l){return KM.keyCodeToStr(l)}i.toUserSettingsUS=s;function r(l){return JM.keyCodeToStr(l)}i.toUserSettingsGeneral=r;function n(l){return KM.strToKeyCode(l)||JM.strToKeyCode(l)}i.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Tv.keyCodeToStr(l)}i.toElectronAccelerator=o})(rD||(rD={}));var FJ=class nD{constructor(e,t,s,r,n){this.ctrlKey=e,this.shiftKey=t,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(e){return e instanceof nD&&this.ctrlKey===e.ctrlKey&&this.shiftKey===e.shiftKey&&this.altKey===e.altKey&&this.metaKey===e.metaKey&&this.keyCode===e.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",t=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${t}${s}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new GJ([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},GJ=class{constructor(i){if(i.length===0)throw SJ("chords");this.chords=i}getHashCode(){let i="";for(let e=0,t=this.chords.length;e<t;e++)e!==0&&(i+=";"),i+=this.chords[e].getHashCode();return i}equals(i){if(i===null||this.chords.length!==i.chords.length)return!1;for(let e=0;e<this.chords.length;e++)if(!this.chords[e].equals(i.chords[e]))return!1;return!0}};function KJ(i){if(i.charCode){let t=String.fromCharCode(i.charCode).toUpperCase();return rD.fromString(t)}let e=i.keyCode;if(e===3)return 7;if(Ly)switch(e){case 59:return 85;case 60:if(qJ)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(en)return 57;break}else if(XJ&&(en&&e===93||!en&&e===92))return 57;return HJ[e]||0}var JJ=en?256:2048,eee=512,tee=1024,iee=en?2048:256,eE=class{constructor(i){var t;this._standardKeyboardEventBrand=!0;let e=i;this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=(t=e.getModifierState)==null?void 0:t.call(e,"AltGraph"),this.keyCode=KJ(e),this.code=e.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(i){return this._asKeybinding===i}_computeKeybinding(){let i=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(i=this.keyCode);let e=0;return this.ctrlKey&&(e|=JJ),this.altKey&&(e|=eee),this.shiftKey&&(e|=tee),this.metaKey&&(e|=iee),e|=i,e}_computeKeyCodeChord(){let i=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(i=this.keyCode),new FJ(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,i)}},tE=new WeakMap;function see(i){if(!i.parent||i.parent===i)return null;try{let e=i.location,t=i.parent.location;if(e.origin!=="null"&&t.origin!=="null"&&e.origin!==t.origin)return null}catch{return null}return i.parent}var ree=class{static getSameOriginWindowChain(i){let e=tE.get(i);if(!e){e=[],tE.set(i,e);let t=i,s;do s=see(t),s?e.push({window:new WeakRef(t),iframeElement:t.frameElement||null}):e.push({window:new WeakRef(t),iframeElement:null}),t=s;while(t)}return e.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(i,e){if(!e||i===e)return{top:0,left:0};let t=0,s=0,r=this.getSameOriginWindowChain(i);for(let n of r){let o=n.window.deref();if(t+=(o==null?void 0:o.scrollY)??0,s+=(o==null?void 0:o.scrollX)??0,o===e||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();t+=l.top,s+=l.left}return{top:t,left:s}}},Tp=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=ree.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},iE=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let r=!1;if(YS){let o=navigator.userAgent.match(/Chrome\/(\d+)/);r=(o?parseInt(o[1]):123)<=122}if(e){let o=e,l=e,c=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")r?this.deltaY=o.wheelDeltaY/(120*c):this.deltaY=o.wheelDeltaY/120;else if(typeof l.VERTICAL_AXIS<"u"&&l.axis===l.VERTICAL_AXIS)this.deltaY=-l.detail/3;else if(e.type==="wheel"){let u=e;u.deltaMode===u.DOM_DELTA_LINE?Ly&&!en?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")VJ&&sD?this.deltaX=-(o.wheelDeltaX/120):r?this.deltaX=o.wheelDeltaX/(120*c):this.deltaX=o.wheelDeltaX/120;else if(typeof l.HORIZONTAL_AXIS<"u"&&l.axis===l.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let u=e;u.deltaMode===u.DOM_DELTA_LINE?Ly&&!en?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*c):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},oD=Object.freeze(function(i,e){let t=setTimeout(i.bind(e),0);return{dispose(){clearTimeout(t)}}}),nee;(i=>{function e(t){return t===i.None||t===i.Cancelled||t instanceof oee?!0:!t||typeof t!="object"?!1:typeof t.isCancellationRequested=="boolean"&&typeof t.onCancellationRequested=="function"}i.isCancellationToken=e,i.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Di.None}),i.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:oD})})(nee||(nee={}));var oee=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?oD:(this._emitter||(this._emitter=new fe),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},FS=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 Ay("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ay("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},aee=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Ay("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},t);this.disposable=xt(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},lee;(i=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}i.settled=e;function t(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}i.withAsyncBody=t})(lee||(lee={}));var sE=class Fs{static fromArray(e){return new Fs(t=>{t.emitMany(e)})}static fromPromise(e){return new Fs(async t=>{t.emitMany(await e)})}static fromPromises(e){return new Fs(async t=>{await Promise.all(e.map(async s=>t.emitOne(await s)))})}static merge(e){return new Fs(async t=>{await Promise.all(e.map(async s=>{for await(let r of s)t.emitOne(r)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new fe,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Di.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var t;return(t=this._onReturn)==null||t.call(this),{done:!0,value:void 0}}}}static map(e,t){return new Fs(async s=>{for await(let r of e)s.emitOne(t(r))})}map(e){return Fs.map(this,e)}static filter(e,t){return new Fs(async s=>{for await(let r of e)t(r)&&s.emitOne(r)})}filter(e){return Fs.filter(this,e)}static coalesce(e){return Fs.filter(e,t=>!!t)}coalesce(){return Fs.coalesce(this)}static async toPromise(e){let t=[];for await(let s of e)t.push(s);return t}toPromise(){return Fs.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};sE.EMPTY=sE.fromArray([]);var{getWindow:Fr,getWindowId:hee,onDidRegisterWindow:cee}=(function(){let i=new Map,e={window:zn,disposables:new Vo};i.set(zn.vscodeWindowId,e);let t=new fe,s=new fe,r=new fe;function n(o,l){return(typeof o=="number"?i.get(o):void 0)??(l?e:void 0)}return{onDidRegisterWindow:t.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(i.has(o.vscodeWindowId))return Xe.None;let l=new Vo,c={window:o,disposables:l.add(new Vo)};return i.set(o.vscodeWindowId,c),l.add(xt(()=>{i.delete(o.vscodeWindowId),s.fire(o)})),l.add(Qe(o,ci.BEFORE_UNLOAD,()=>{r.fire(o)})),t.fire(c),l},getWindows(){return i.values()},getWindowsCount(){return i.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return i.has(o)},getWindowById:n,getWindow(o){var u;let l=o;if((u=l==null?void 0:l.ownerDocument)!=null&&u.defaultView)return l.ownerDocument.defaultView.window;let c=o;return c!=null&&c.view?c.view.window:zn},getDocument(o){return Fr(o).document}}})(),uee=class{constructor(e,t,s,r){this._node=e,this._type=t,this._handler=s,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Qe(i,e,t,s){return new uee(i,e,t,s)}var rE=function(i,e,t,s){return Qe(i,e,t,s)},GS,fee=class extends aee{constructor(i){super(),this.defaultTarget=i&&Fr(i)}cancelAndSet(i,e,t){return super.cancelAndSet(i,e,t??this.defaultTarget)}},nE=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){em(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let i=new Map,e=new Map,t=new Map,s=new Map,r=n=>{t.set(n,!1);let o=i.get(n)??[];for(e.set(n,o),i.set(n,[]),s.set(n,!0);o.length>0;)o.sort(nE.sort),o.shift().execute();s.set(n,!1)};GS=(n,o,l=0)=>{let c=hee(n),u=new nE(o,l),d=i.get(c);return d||(d=[],i.set(c,d)),d.push(u),t.get(c)||(t.set(c,!0),n.requestAnimationFrame(()=>r(c))),u}})();function dee(i){let e=i.getBoundingClientRect(),t=Fr(i);return{left:e.left+t.scrollX,top:e.top+t.scrollY,width:e.width,height:e.height}}var ci={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},pee=class{constructor(i){this.domNode=i,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(i){let e=us(i);this._maxWidth!==e&&(this._maxWidth=e,this.domNode.style.maxWidth=this._maxWidth)}setWidth(i){let e=us(i);this._width!==e&&(this._width=e,this.domNode.style.width=this._width)}setHeight(i){let e=us(i);this._height!==e&&(this._height=e,this.domNode.style.height=this._height)}setTop(i){let e=us(i);this._top!==e&&(this._top=e,this.domNode.style.top=this._top)}setLeft(i){let e=us(i);this._left!==e&&(this._left=e,this.domNode.style.left=this._left)}setBottom(i){let e=us(i);this._bottom!==e&&(this._bottom=e,this.domNode.style.bottom=this._bottom)}setRight(i){let e=us(i);this._right!==e&&(this._right=e,this.domNode.style.right=this._right)}setPaddingTop(i){let e=us(i);this._paddingTop!==e&&(this._paddingTop=e,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(i){let e=us(i);this._paddingLeft!==e&&(this._paddingLeft=e,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(i){let e=us(i);this._paddingBottom!==e&&(this._paddingBottom=e,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(i){let e=us(i);this._paddingRight!==e&&(this._paddingRight=e,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(i){this._fontFamily!==i&&(this._fontFamily=i,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(i){this._fontWeight!==i&&(this._fontWeight=i,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(i){let e=us(i);this._fontSize!==e&&(this._fontSize=e,this.domNode.style.fontSize=this._fontSize)}setFontStyle(i){this._fontStyle!==i&&(this._fontStyle=i,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(i){this._fontFeatureSettings!==i&&(this._fontFeatureSettings=i,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(i){this._fontVariationSettings!==i&&(this._fontVariationSettings=i,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(i){this._textDecoration!==i&&(this._textDecoration=i,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(i){let e=us(i);this._lineHeight!==e&&(this._lineHeight=e,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(i){let e=us(i);this._letterSpacing!==e&&(this._letterSpacing=e,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(i){this._className!==i&&(this._className=i,this.domNode.className=this._className)}toggleClassName(i,e){this.domNode.classList.toggle(i,e),this._className=this.domNode.className}setDisplay(i){this._display!==i&&(this._display=i,this.domNode.style.display=this._display)}setPosition(i){this._position!==i&&(this._position=i,this.domNode.style.position=this._position)}setVisibility(i){this._visibility!==i&&(this._visibility=i,this.domNode.style.visibility=this._visibility)}setColor(i){this._color!==i&&(this._color=i,this.domNode.style.color=this._color)}setBackgroundColor(i){this._backgroundColor!==i&&(this._backgroundColor=i,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(i){this._layerHint!==i&&(this._layerHint=i,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(i){this._boxShadow!==i&&(this._boxShadow=i,this.domNode.style.boxShadow=i)}setContain(i){this._contain!==i&&(this._contain=i,this.domNode.style.contain=this._contain)}setAttribute(i,e){this.domNode.setAttribute(i,e)}removeAttribute(i){this.domNode.removeAttribute(i)}appendChild(i){this.domNode.appendChild(i.domNode)}removeChild(i){this.domNode.removeChild(i.domNode)}};function us(i){return typeof i=="number"?`${i}px`:i}function Eu(i){return new pee(i)}var aD=class{constructor(){this._hooks=new Vo,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,r,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(xt(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=Fr(e)}this._hooks.add(Qe(o,ci.POINTER_MOVE,l=>{if(l.buttons!==s){this.stopMonitoring(!0);return}l.preventDefault(),this._pointerMoveCallback(l)})),this._hooks.add(Qe(o,ci.POINTER_UP,l=>this.stopMonitoring(!0)))}};function mee(i,e,t){let s=null,r=null;if(typeof t.value=="function"?(s="value",r=t.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof t.get=="function"&&(s="get",r=t.get),!r)throw new Error("not supported");let n=`$memoize$${e}`;t[s]=function(...o){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,o)}),this[n]}}var Vr;(i=>(i.Tap="-xterm-gesturetap",i.Change="-xterm-gesturechange",i.Start="-xterm-gesturestart",i.End="-xterm-gesturesend",i.Contextmenu="-xterm-gesturecontextmenu"))(Vr||(Vr={}));var uu=class Xi extends Xe{constructor(){super(),this.dispatched=!1,this.targets=new HM,this.ignoreTargets=new HM,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Di.runAndSubscribe(cee,({window:e,disposables:t})=>{t.add(Qe(e.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),t.add(Qe(e.document,"touchend",s=>this.onTouchEnd(e,s))),t.add(Qe(e.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:zn,disposables:this._store}))}static addTarget(e){if(!Xi.isTouchDevice())return Xe.None;Xi.INSTANCE||(Xi.INSTANCE=new Xi);let t=Xi.INSTANCE.targets.push(e);return xt(t)}static ignoreTarget(e){if(!Xi.isTouchDevice())return Xe.None;Xi.INSTANCE||(Xi.INSTANCE=new Xi);let t=Xi.INSTANCE.ignoreTargets.push(e);return xt(t)}static isTouchDevice(){return"ontouchstart"in zn||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=e.targetTouches.length;s<r;s++){let n=e.targetTouches.item(s);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:t,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[t],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let o=this.newGestureEvent(Vr.Start,n.target);o.pageX=n.pageX,o.pageY=n.pageY,this.dispatchEvent(o)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(e,t){let s=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,o=t.changedTouches.length;n<o;n++){let l=t.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let c=this.activeTouches[l.identifier],u=Date.now()-c.initialTimeStamp;if(u<Xi.HOLD_DELAY&&Math.abs(c.initialPageX-Qs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Qs(c.rollingPageY))<30){let d=this.newGestureEvent(Vr.Tap,c.initialTarget);d.pageX=Qs(c.rollingPageX),d.pageY=Qs(c.rollingPageY),this.dispatchEvent(d)}else if(u>=Xi.HOLD_DELAY&&Math.abs(c.initialPageX-Qs(c.rollingPageX))<30&&Math.abs(c.initialPageY-Qs(c.rollingPageY))<30){let d=this.newGestureEvent(Vr.Contextmenu,c.initialTarget);d.pageX=Qs(c.rollingPageX),d.pageY=Qs(c.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Qs(c.rollingPageX),m=Qs(c.rollingPageY),g=Qs(c.rollingTimestamps)-c.rollingTimestamps[0],_=d-c.rollingPageX[0],y=m-c.rollingPageY[0],b=[...this.targets].filter(x=>c.initialTarget instanceof Node&&x.contains(c.initialTarget));this.inertia(e,b,s,Math.abs(_)/g,_>0?1:-1,d,Math.abs(y)/g,y>0?1:-1,m)}this.dispatchEvent(this.newGestureEvent(Vr.End,c.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,t){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=t,s.tapCount=0,s}dispatchEvent(e){if(e.type===Vr.Tap){let t=new Date().getTime(),s=0;t-this._lastSetTapCountTime>Xi.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=t,e.tapCount=s}else(e.type===Vr.Change||e.type===Vr.Contextmenu)&&(this._lastSetTapCountTime=0);if(e.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(e.initialTarget))return;let t=[];for(let s of this.targets)if(s.contains(e.initialTarget)){let r=0,n=e.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;t.push([r,s])}t.sort((s,r)=>s[0]-r[0]);for(let[s,r]of t)r.dispatchEvent(e),this.dispatched=!0}}inertia(e,t,s,r,n,o,l,c,u){this.handle=GS(e,()=>{let d=Date.now(),m=d-s,g=0,_=0,y=!0;r+=Xi.SCROLL_FRICTION*m,l+=Xi.SCROLL_FRICTION*m,r>0&&(y=!1,g=n*r*m),l>0&&(y=!1,_=c*l*m);let b=this.newGestureEvent(Vr.Change);b.translationX=g,b.translationY=_,t.forEach(x=>x.dispatchEvent(b)),y||this.inertia(e,t,d,r,n,o+g,l,c,u+_)})}onTouchMove(e){let t=Date.now();for(let s=0,r=e.changedTouches.length;s<r;s++){let n=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let o=this.activeTouches[n.identifier],l=this.newGestureEvent(Vr.Change,o.initialTarget);l.translationX=n.pageX-Qs(o.rollingPageX),l.translationY=n.pageY-Qs(o.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),o.rollingPageX.length>3&&(o.rollingPageX.shift(),o.rollingPageY.shift(),o.rollingTimestamps.shift()),o.rollingPageX.push(n.pageX),o.rollingPageY.push(n.pageY),o.rollingTimestamps.push(t)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};uu.SCROLL_FRICTION=-.005,uu.HOLD_DELAY=700,uu.CLEAR_TAP_COUNT_TIME=400,Lt([mee],uu,"isTouchDevice",1);var gee=uu,KS=class extends Xe{onclick(e,t){this._register(Qe(e,ci.CLICK,s=>t(new Tp(Fr(e),s))))}onmousedown(e,t){this._register(Qe(e,ci.MOUSE_DOWN,s=>t(new Tp(Fr(e),s))))}onmouseover(e,t){this._register(Qe(e,ci.MOUSE_OVER,s=>t(new Tp(Fr(e),s))))}onmouseleave(e,t){this._register(Qe(e,ci.MOUSE_LEAVE,s=>t(new Tp(Fr(e),s))))}onkeydown(e,t){this._register(Qe(e,ci.KEY_DOWN,s=>t(new eE(s))))}onkeyup(e,t){this._register(Qe(e,ci.KEY_UP,s=>t(new eE(s))))}oninput(e,t){this._register(Qe(e,ci.INPUT,t))}onblur(e,t){this._register(Qe(e,ci.BLUR,t))}onfocus(e,t){this._register(Qe(e,ci.FOCUS,t))}onchange(e,t){this._register(Qe(e,ci.CHANGE,t))}ignoreGesture(e){return gee.ignoreTarget(e)}},oE=11,Oee=class extends KS{constructor(i){super(),this._onActivate=i.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=i.bgWidth+"px",this.bgDomNode.style.height=i.bgHeight+"px",typeof i.top<"u"&&(this.bgDomNode.style.top="0px"),typeof i.left<"u"&&(this.bgDomNode.style.left="0px"),typeof i.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof i.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=i.className,this.domNode.style.position="absolute",this.domNode.style.width=oE+"px",this.domNode.style.height=oE+"px",typeof i.top<"u"&&(this.domNode.style.top=i.top+"px"),typeof i.left<"u"&&(this.domNode.style.left=i.left+"px"),typeof i.bottom<"u"&&(this.domNode.style.bottom=i.bottom+"px"),typeof i.right<"u"&&(this.domNode.style.right=i.right+"px"),this._pointerMoveMonitor=this._register(new aD),this._register(rE(this.bgDomNode,ci.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(rE(this.domNode,ci.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new fee),this._pointerdownScheduleRepeatTimer=this._register(new FS)}_arrowPointerDown(i){if(!i.target||!(i.target instanceof Element))return;let e=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,Fr(i))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(e,200),this._pointerMoveMonitor.startMonitoring(i.target,i.pointerId,i.buttons,t=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),i.preventDefault()}},_ee=class Dy{constructor(e,t,s,r,n,o,l){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t=t|0,s=s|0,r=r|0,n=n|0,o=o|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,t<0&&(t=0),r+t>s&&(r=s-t),r<0&&(r=0),n<0&&(n=0),l+n>o&&(l=o-n),l<0&&(l=0),this.width=t,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=l}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(e,t){return new Dy(this._forceIntegerValues,typeof e.width<"u"?e.width:this.width,typeof e.scrollWidth<"u"?e.scrollWidth:this.scrollWidth,t?this.rawScrollLeft:this.scrollLeft,typeof e.height<"u"?e.height:this.height,typeof e.scrollHeight<"u"?e.scrollHeight:this.scrollHeight,t?this.rawScrollTop:this.scrollTop)}withScrollPosition(e){return new Dy(this._forceIntegerValues,this.width,this.scrollWidth,typeof e.scrollLeft<"u"?e.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof e.scrollTop<"u"?e.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let s=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,l=this.scrollHeight!==e.scrollHeight,c=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:l,scrollTopChanged:c}}},vee=class extends Xe{constructor(i){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._smoothScrollDuration=i.smoothScrollDuration,this._scheduleAtNextAnimationFrame=i.scheduleAtNextAnimationFrame,this._state=new _ee(i.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(i){this._smoothScrollDuration=i}validateScrollPosition(i){return this._state.withScrollPosition(i)}getScrollDimensions(){return this._state}setScrollDimensions(i,e){var s;let t=this._state.withScrollDimensions(i,e);this._setState(t,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(i){let e=this._state.withScrollPosition(i);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(e,!1)}setScrollPositionSmooth(i,e){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(i);if(this._smoothScrolling){i={scrollLeft:typeof i.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:i.scrollLeft,scrollTop:typeof i.scrollTop>"u"?this._smoothScrolling.to.scrollTop:i.scrollTop};let t=this._state.withScrollPosition(i);if(this._smoothScrolling.to.scrollLeft===t.scrollLeft&&this._smoothScrolling.to.scrollTop===t.scrollTop)return;let s;e?s=new lE(this._smoothScrolling.from,t,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,t,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let t=this._state.withScrollPosition(i);this._smoothScrolling=lE.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let i=this._smoothScrolling.tick(),e=this._state.withScrollPosition(i);if(this._setState(e,!0),!!this._smoothScrolling){if(i.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(i,e){let t=this._state;t.equals(i)||(this._state=i,this._onScroll.fire(this._state.createScrollEvent(t,e)))}},aE=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Av(i,e){let t=e-i;return function(s){return i+t*See(s)}}function yee(i,e,t){return function(s){return s<t?i(s/t):e((s-t)/(1-t))}}var lE=class zy{constructor(e,t,s,r){this.from=e,this.to=t,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,t,s){if(Math.abs(e-t)>2.5*s){let r,n;return e<t?(r=e+.75*s,n=t-.75*s):(r=e-.75*s,n=t+.75*s),yee(Av(e,r),Av(n,t),.33)}return Av(e,t)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let t=(e-this.startTime)/this.duration;if(t<1){let s=this.scrollLeft(t),r=this.scrollTop(t);return new aE(s,r,!1)}return new aE(this.to.scrollLeft,this.to.scrollTop,!0)}combine(e,t,s){return zy.start(e,t,s)}static start(e,t,s){s=s+10;let r=Date.now()-10;return new zy(e,t,r,s)}};function bee(i){return Math.pow(i,3)}function See(i){return 1-bee(1-i)}var xee=class extends Xe{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 FS)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},wee=140,lD=class extends KS{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 xee(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new aD),this._shouldRender=!0,this.domNode=Eu(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(Qe(this.domNode.domNode,ci.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Oee(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,r){this.slider=Eu(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 r=="number"&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Qe(this.slider.domNode,ci.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.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(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=r?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 n=dee(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let r=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),l=Math.abs(o-s);if(sD&&l>wee){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let c=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(c))},()=>{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()}},hD=class Ny{constructor(e,t,s,r,n,o){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Ny(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t?(this._visibleSize=t,this._refreshComputedValues(),!0):!1}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t?(this._scrollSize=t,this._refreshComputedValues(),!0):!1}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t?(this._scrollPosition=t,this._refreshComputedValues(),!0):!1}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,s,r,n){let o=Math.max(0,s-e),l=Math.max(0,o-2*t),c=r>0&&r>s;if(!c)return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let u=Math.round(Math.max(20,Math.floor(s*l/r))),d=(l-u)/(r-s),m=n*d;return{computedAvailableSize:Math.round(o),computedIsNeeded:c,computedSliderSize:Math.round(u),computedSliderRatio:d,computedSliderPosition:Math.round(m)}}_refreshComputedValues(){let e=Ny._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=e.computedAvailableSize,this._computedIsNeeded=e.computedIsNeeded,this._computedSliderSize=e.computedSliderSize,this._computedSliderRatio=e.computedSliderRatio,this._computedSliderPosition=e.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,s=this._scrollPosition;return t<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){if(!this._computedIsNeeded)return 0;let t=this._computedSliderPosition+e;return Math.round(t/this._computedSliderRatio)}},Cee=class extends lD{constructor(e,t,s){let r=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new hD(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,r.width,r.scrollWidth,n.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}},kee=class extends lD{constructor(i,e,t){let s=i.getScrollDimensions(),r=i.getCurrentScrollPosition();if(super({lazyRender:e.lazyRender,host:t,scrollbarState:new hD(e.verticalHasArrows?e.arrowSize:0,e.vertical===2?0:e.verticalScrollbarSize,0,s.height,s.scrollHeight,r.scrollTop),visibility:e.vertical,extraScrollbarClassName:"vertical",scrollable:i,scrollByPage:e.scrollByPage}),e.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((e.verticalScrollbarSize-e.verticalSliderSize)/2),e.verticalSliderSize,void 0)}_updateSlider(i,e){this.slider.setHeight(i),this.slider.setTop(e)}_renderDomNode(i,e){this.domNode.setWidth(e),this.domNode.setHeight(i),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(i){return this._shouldRender=this._onElementScrollSize(i.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(i.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(i.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(i,e){return e}_sliderPointerPosition(i){return i.pageY}_sliderOrthogonalPointerPosition(i){return i.pageX}_updateScrollbarSize(i){this.slider.setWidth(i)}writeScrollPosition(i,e){i.scrollTop=e}updateOptions(i){this.updateScrollbarSize(i.vertical===2?0:i.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(i.vertical),this._scrollByPage=i.scrollByPage}},Tee=500,hE=50,Aee=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Xy=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let e=1,t=0,s=1,r=this._rear;do{let n=r===this._front?e:Math.pow(2,-s);if(e-=n,t+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}while(!0);return t<=.5}acceptStandardWheelEvent(e){if(YS){let t=Fr(e.browserEvent),s=NJ(t);this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,t,s){let r=null,n=new Aee(e,t,s);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(e,t){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(e.deltaX)||!this._isAlmostInt(e.deltaY))&&(s+=.25),t){let r=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(t.deltaX),l=Math.abs(t.deltaY),c=Math.max(Math.min(r,o),1),u=Math.max(Math.min(n,l),1),d=Math.max(r,o),m=Math.max(n,l);d%c===0&&m%u===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};Xy.INSTANCE=new Xy;var Mee=Xy,Eee=class extends KS{constructor(i,e,t){super(),this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new fe),this.onWillScroll=this._onWillScroll.event,this._options=Qee(e),this._scrollable=t,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let s={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new kee(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Cee(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(i),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Eu(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Eu(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Eu(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 FS),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ua(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(i){this._verticalScrollbar.delegatePointerDown(i)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(i){this._scrollable.setScrollDimensions(i,!1)}updateClassName(i){this._options.className=i,en&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(i){typeof i.handleMouseWheel<"u"&&(this._options.handleMouseWheel=i.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof i.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=i.mouseWheelScrollSensitivity),typeof i.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=i.fastScrollSensitivity),typeof i.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=i.scrollPredominantAxis),typeof i.horizontal<"u"&&(this._options.horizontal=i.horizontal),typeof i.vertical<"u"&&(this._options.vertical=i.vertical),typeof i.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=i.horizontalScrollbarSize),typeof i.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=i.verticalScrollbarSize),typeof i.scrollByPage<"u"&&(this._options.scrollByPage=i.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(i){this._revealOnScroll=i}delegateScrollFromMouseWheelEvent(i){this._onMouseWheel(new iE(i))}_setListeningToMouseWheel(i){if(this._mouseWheelToDispose.length>0!==i&&(this._mouseWheelToDispose=Ua(this._mouseWheelToDispose),i)){let e=t=>{this._onMouseWheel(new iE(t))};this._mouseWheelToDispose.push(Qe(this._listenOnDomNode,ci.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(i){var r;if((r=i.browserEvent)!=null&&r.defaultPrevented)return;let e=Mee.INSTANCE;e.acceptStandardWheelEvent(i);let t=!1;if(i.deltaY||i.deltaX){let n=i.deltaY*this._options.mouseWheelScrollSensitivity,o=i.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&o+n===0?o=n=0:Math.abs(n)>=Math.abs(o)?o=0:n=0),this._options.flipAxes&&([n,o]=[o,n]);let l=!en&&i.browserEvent&&i.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!o&&(o=n,n=0),i.browserEvent&&i.browserEvent.altKey&&(o=o*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let c=this._scrollable.getFutureScrollPosition(),u={};if(n){let d=hE*n,m=c.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(u,m)}if(o){let d=hE*o,m=c.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(u,m)}u=this._scrollable.validateScrollPosition(u),(c.scrollLeft!==u.scrollLeft||c.scrollTop!==u.scrollTop)&&(this._options.mouseWheelSmoothScroll&&e.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(u):this._scrollable.setScrollPositionNow(u),t=!0)}let s=t;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(i.preventDefault(),i.stopPropagation())}_onDidScroll(i){this._shouldRender=this._horizontalScrollbar.onDidScroll(i)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(i)||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 i=this._scrollable.getCurrentScrollPosition(),e=i.scrollTop>0,t=i.scrollLeft>0,s=t?" left":"",r=e?" top":"",n=t||e?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(i){this._mouseIsOver=!1,this._hide()}_onMouseOver(i){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(),Tee)}},Pee=class extends Eee{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()}};function Qee(i){let e={lazyRender:typeof i.lazyRender<"u"?i.lazyRender:!1,className:typeof i.className<"u"?i.className:"",useShadows:typeof i.useShadows<"u"?i.useShadows:!0,handleMouseWheel:typeof i.handleMouseWheel<"u"?i.handleMouseWheel:!0,flipAxes:typeof i.flipAxes<"u"?i.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof i.consumeMouseWheelIfScrollbarIsNeeded<"u"?i.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof i.alwaysConsumeMouseWheel<"u"?i.alwaysConsumeMouseWheel:!1,scrollYToX:typeof i.scrollYToX<"u"?i.scrollYToX:!1,mouseWheelScrollSensitivity:typeof i.mouseWheelScrollSensitivity<"u"?i.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof i.fastScrollSensitivity<"u"?i.fastScrollSensitivity:5,scrollPredominantAxis:typeof i.scrollPredominantAxis<"u"?i.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof i.mouseWheelSmoothScroll<"u"?i.mouseWheelSmoothScroll:!0,arrowSize:typeof i.arrowSize<"u"?i.arrowSize:11,listenOnDomNode:typeof i.listenOnDomNode<"u"?i.listenOnDomNode:null,horizontal:typeof i.horizontal<"u"?i.horizontal:1,horizontalScrollbarSize:typeof i.horizontalScrollbarSize<"u"?i.horizontalScrollbarSize:10,horizontalSliderSize:typeof i.horizontalSliderSize<"u"?i.horizontalSliderSize:0,horizontalHasArrows:typeof i.horizontalHasArrows<"u"?i.horizontalHasArrows:!1,vertical:typeof i.vertical<"u"?i.vertical:1,verticalScrollbarSize:typeof i.verticalScrollbarSize<"u"?i.verticalScrollbarSize:10,verticalHasArrows:typeof i.verticalHasArrows<"u"?i.verticalHasArrows:!1,verticalSliderSize:typeof i.verticalSliderSize<"u"?i.verticalSliderSize:0,scrollByPage:typeof i.scrollByPage<"u"?i.scrollByPage:!1};return e.horizontalSliderSize=typeof i.horizontalSliderSize<"u"?i.horizontalSliderSize:e.horizontalScrollbarSize,e.verticalSliderSize=typeof i.verticalSliderSize<"u"?i.verticalSliderSize:e.verticalScrollbarSize,en&&(e.className+=" mac"),e}var Vy=class extends Xe{constructor(e,t,s,r,n,o,l,c){super(),this._bufferService=s,this._optionsService=l,this._renderService=c,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let u=this._register(new vee({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:d=>GS(r.window,d)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{u.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Pee(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},u)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(d=>{this._scrollableElement.updateOptions({handleMouseWheel:!(d&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Di.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(xt(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(xt(()=>this._styleElement.remove())),this._register(Di.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(`
105
+ `)})),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(d=>this._handleScroll(d)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Vy=Lt([Oe(2,is),Oe(3,Un),Oe(4,jB),Oe(5,Dh),Oe(6,ss),Oe(7,Yn)],Vy);var Zy=class extends Xe{constructor(e,t,s,r,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=r,this._renderService=n,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(xt(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var r;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((r=e==null?void 0:e.options)==null?void 0:r.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){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Zy=Lt([Oe(1,is),Oe(2,Un),Oe(3,Mf),Oe(4,Yn)],Zy);var Ree=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)}},Dr={full:0,left:0,center:0,right:0},ko={full:0,left:0,center:0,right:0},Hc={full:0,left:0,center:0,right:0},Km=class extends Xe{constructor(e,t,s,r,n,o,l,c){var d;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=r,this._renderService=n,this._optionsService=o,this._themeService=l,this._coreBrowserService=c,this._colorZoneStore=new Ree,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(),(d=this._viewportElement.parentElement)==null||d.insertBefore(this._canvas,this._viewportElement),this._register(xt(()=>{var m;return(m=this._canvas)==null?void 0:m.remove()}));let u=this._canvas.getContext("2d");if(u)this._ctx=u;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ko.full=this._canvas.width,ko.left=e,ko.center=t,ko.right=e,this._refreshDrawHeightConstants(),Hc.full=1,Hc.left=1,Hc.center=1+ko.left,Hc.right=1+ko.left+ko.center}_refreshDrawHeightConstants(){Dr.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);Dr.left=t,Dr.center=t,Dr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Dr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Dr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Dr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Dr.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(Hc[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Dr[e.position||"full"]/2),ko[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Dr[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}))}};Km=Lt([Oe(2,is),Oe(3,Mf),Oe(4,Yn),Oe(5,ss),Oe(6,Dh),Oe(7,Un)],Km);var le;(i=>(i.NUL="\0",i.SOH="",i.STX="",i.ETX="",i.EOT="",i.ENQ="",i.ACK="",i.BEL="\x07",i.BS="\b",i.HT=" ",i.LF=`
106
+ `,i.VT="\v",i.FF="\f",i.CR="\r",i.SO="",i.SI="",i.DLE="",i.DC1="",i.DC2="",i.DC3="",i.DC4="",i.NAK="",i.SYN="",i.ETB="",i.CAN="",i.EM="",i.SUB="",i.ESC="\x1B",i.FS="",i.GS="",i.RS="",i.US="",i.SP=" ",i.DEL=""))(le||(le={}));var sm;(i=>(i.PAD="€",i.HOP="",i.BPH="‚",i.NBH="ƒ",i.IND="„",i.NEL="…",i.SSA="†",i.ESA="‡",i.HTS="ˆ",i.HTJ="‰",i.VTS="Š",i.PLD="‹",i.PLU="Œ",i.RI="",i.SS2="Ž",i.SS3="",i.DCS="",i.PU1="‘",i.PU2="’",i.STS="“",i.CCH="”",i.MW="•",i.SPA="–",i.EPA="—",i.SOS="˜",i.SGCI="™",i.SCI="š",i.CSI="›",i.ST="œ",i.OSC="",i.PM="ž",i.APC="Ÿ"))(sm||(sm={}));var cD;(i=>i.ST=`${le.ESC}\\`)(cD||(cD={}));var jy=class{constructor(e,t,s,r,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=r,this._coreService=n,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(`${le.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,r=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=r+"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=n+"px",this._textarea.style.top=r+"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)}}};jy=Lt([Oe(2,is),Oe(3,ss),Oe(4,Ja),Oe(5,Yn)],jy);var ui=0,fi=0,di=0,Pt=0,cE={css:"#00000000",rgba:0},Ut;(i=>{function e(r,n,o,l){return l!==void 0?`#${ya(r)}${ya(n)}${ya(o)}${ya(l)}`:`#${ya(r)}${ya(n)}${ya(o)}`}i.toCss=e;function t(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}i.toRgba=t;function s(r,n,o,l){return{css:i.toCss(r,n,o,l),rgba:i.toRgba(r,n,o,l)}}i.toColor=s})(Ut||(Ut={}));var vt;(i=>{function e(c,u){if(Pt=(u.rgba&255)/255,Pt===1)return{css:u.css,rgba:u.rgba};let d=u.rgba>>24&255,m=u.rgba>>16&255,g=u.rgba>>8&255,_=c.rgba>>24&255,y=c.rgba>>16&255,b=c.rgba>>8&255;ui=_+Math.round((d-_)*Pt),fi=y+Math.round((m-y)*Pt),di=b+Math.round((g-b)*Pt);let x=Ut.toCss(ui,fi,di),w=Ut.toRgba(ui,fi,di);return{css:x,rgba:w}}i.blend=e;function t(c){return(c.rgba&255)===255}i.isOpaque=t;function s(c,u,d){let m=rm.ensureContrastRatio(c.rgba,u.rgba,d);if(m)return Ut.toColor(m>>24&255,m>>16&255,m>>8&255)}i.ensureContrastRatio=s;function r(c){let u=(c.rgba|255)>>>0;return[ui,fi,di]=rm.toChannels(u),{css:Ut.toCss(ui,fi,di),rgba:u}}i.opaque=r;function n(c,u){return Pt=Math.round(u*255),[ui,fi,di]=rm.toChannels(c.rgba),{css:Ut.toCss(ui,fi,di,Pt),rgba:Ut.toRgba(ui,fi,di,Pt)}}i.opacity=n;function o(c,u){return Pt=c.rgba&255,n(c,Pt*u/255)}i.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}i.toColorRGB=l})(vt||(vt={}));var Ct;(i=>{let e,t;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",t=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return ui=parseInt(r.slice(1,2).repeat(2),16),fi=parseInt(r.slice(2,3).repeat(2),16),di=parseInt(r.slice(3,4).repeat(2),16),Ut.toColor(ui,fi,di);case 5:return ui=parseInt(r.slice(1,2).repeat(2),16),fi=parseInt(r.slice(2,3).repeat(2),16),di=parseInt(r.slice(3,4).repeat(2),16),Pt=parseInt(r.slice(4,5).repeat(2),16),Ut.toColor(ui,fi,di,Pt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return ui=parseInt(n[1]),fi=parseInt(n[2]),di=parseInt(n[3]),Pt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ut.toColor(ui,fi,di,Pt);if(!e||!t)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=t,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[ui,fi,di,Pt]=e.getImageData(0,0,1,1).data,Pt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ut.toRgba(ui,fi,di,Pt),css:r}}i.toColor=s})(Ct||(Ct={}));var Yi;(i=>{function e(s){return t(s>>16&255,s>>8&255,s&255)}i.relativeLuminance=e;function t(s,r,n){let o=s/255,l=r/255,c=n/255,u=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+d*.7152+m*.0722}i.relativeLuminance2=t})(Yi||(Yi={}));var rm;(i=>{function e(o,l){if(Pt=(l&255)/255,Pt===1)return l;let c=l>>24&255,u=l>>16&255,d=l>>8&255,m=o>>24&255,g=o>>16&255,_=o>>8&255;return ui=m+Math.round((c-m)*Pt),fi=g+Math.round((u-g)*Pt),di=_+Math.round((d-_)*Pt),Ut.toRgba(ui,fi,di)}i.blend=e;function t(o,l,c){let u=Yi.relativeLuminance(o>>8),d=Yi.relativeLuminance(l>>8);if(Mn(u,d)<c){if(d<u){let _=s(o,l,c),y=Mn(u,Yi.relativeLuminance(_>>8));if(y<c){let b=r(o,l,c),x=Mn(u,Yi.relativeLuminance(b>>8));return y>x?_:b}return _}let m=r(o,l,c),g=Mn(u,Yi.relativeLuminance(m>>8));if(g<c){let _=s(o,l,c),y=Mn(u,Yi.relativeLuminance(_>>8));return g>y?m:_}return m}}i.ensureContrastRatio=t;function s(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));for(;b<c&&(g>0||_>0||y>0);)g-=Math.max(0,Math.ceil(g*.1)),_-=Math.max(0,Math.ceil(_*.1)),y-=Math.max(0,Math.ceil(y*.1)),b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.reduceLuminance=s;function r(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));for(;b<c&&(g<255||_<255||y<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),b=Mn(Yi.relativeLuminance2(g,_,y),Yi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}i.toChannels=n})(rm||(rm={}));function ya(i){let e=i.toString(16);return e.length<2?"0"+e:e}function Mn(i,e){return i<e?(e+.05)/(i+.05):(i+.05)/(e+.05)}var Lee=class extends Af{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()]}},Jm=class{constructor(i){this._bufferService=i,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new lr}register(i){let e={id:this._nextCharacterJoinerId++,handler:i};return this._characterJoiners.push(e),e.id}deregister(i){for(let e=0;e<this._characterJoiners.length;e++)if(this._characterJoiners[e].id===i)return this._characterJoiners.splice(e,1),!0;return!1}getJoinedCharacters(i){if(this._characterJoiners.length===0)return[];let e=this._bufferService.buffer.lines.get(i);if(!e||e.length===0)return[];let t=[],s=e.translateToString(!0),r=0,n=0,o=0,l=e.getFg(0),c=e.getBg(0);for(let u=0;u<e.getTrimmedLength();u++)if(e.loadCell(u,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==c){if(u-r>1){let d=this._getJoinedRanges(s,o,n,e,r);for(let m=0;m<d.length;m++)t.push(d[m])}r=u,o=n,l=this._workCell.fg,c=this._workCell.bg}n+=this._workCell.getChars().length||No.length}if(this._bufferService.cols-r>1){let u=this._getJoinedRanges(s,o,n,e,r);for(let d=0;d<u.length;d++)t.push(u[d])}return t}_getJoinedRanges(i,e,t,s,r){let n=i.substring(e,t),o=[];try{o=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let c=this._characterJoiners[l].handler(n);for(let u=0;u<c.length;u++)Jm._mergeRanges(o,c[u])}catch(c){console.error(c)}return this._stringRangesToCellRanges(o,s,r),o}_stringRangesToCellRanges(i,e,t){let s=0,r=!1,n=0,o=i[s];if(o){for(let l=t;l<this._bufferService.cols;l++){let c=e.getWidth(l),u=e.getString(l).length||No.length;if(c!==0){if(!r&&o[0]<=n&&(o[0]=l,r=!0),o[1]<=n){if(o[1]=l,o=i[++s],!o)break;o[0]<=n?(o[0]=l,r=!0):r=!1}n+=u}}o&&(o[1]=this._bufferService.cols)}}static _mergeRanges(i,e){let t=!1;for(let s=0;s<i.length;s++){let r=i[s];if(t){if(e[1]<=r[0])return i[s-1][1]=e[1],i;if(e[1]<=r[1])return i[s-1][1]=Math.max(e[1],r[1]),i.splice(s,1),i;i.splice(s,1),s--}else{if(e[1]<=r[0])return i.splice(s,0,e),i;if(e[1]<=r[1])return r[0]=Math.min(e[0],r[0]),i;e[0]<r[1]&&(r[0]=Math.min(e[0],r[0]),t=!0);continue}}return t?i[i.length-1][1]=e[1]:i.push(e),i}};Jm=Lt([Oe(0,is)],Jm);function $ee(i){return 57508<=i&&i<=57558}function Bee(i){return 9472<=i&&i<=9631}function Dee(i){return $ee(i)||Bee(i)}function zee(){return{css:{canvas:Ap(),cell:Ap()},device:{canvas:Ap(),cell:Ap(),char:{width:0,height:0,left:0,top:0}}}}function Ap(){return{width:0,height:0}}var Iy=class{constructor(e,t,s,r,n,o,l){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=r,this._coreService=n,this._decorationService=o,this._themeService=l,this._workCell=new lr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,r,n,o,l,c,u,d,m){let g=[],_=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,b=e.getNoBgTrimmedLength();s&&b<o+1&&(b=o+1);let x,w=0,k="",C=0,A=0,P=0,E=0,$=!1,z=0,I=!1,se=0,F=0,R=[],L=d!==-1&&m!==-1;for(let N=0;N<b;N++){e.loadCell(N,this._workCell);let Z=this._workCell.getWidth();if(Z===0)continue;let Q=!1,X=N>=F,W=N,U=this._workCell;if(_.length>0&&N===_[0][0]&&X){let Pe=_.shift(),ln=this._isCellInSelection(Pe[0],t);for(C=Pe[0]+1;C<Pe[1];C++)X&&(X=ln===this._isCellInSelection(C,t));X&&(X=!s||o<Pe[0]||o>=Pe[1]),X?(Q=!0,U=new Lee(this._workCell,e.translateToString(!0,Pe[0],Pe[1]),Pe[1]-Pe[0]),W=Pe[1]-1,Z=U.getWidth()):F=Pe[1]}let q=this._isCellInSelection(N,t),D=s&&N===o,G=L&&N>=d&&N<=m,ie=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Pe=>{ie=!0});let ce=U.getChars()||No;if(ce===" "&&(U.isUnderline()||U.isOverline())&&(ce=" "),se=Z*c-u.get(ce,U.isBold(),U.isItalic()),!x)x=this._document.createElement("span");else if(w&&(q&&I||!q&&!I&&U.bg===A)&&(q&&I&&y.selectionForeground||U.fg===P)&&U.extended.ext===E&&G===$&&se===z&&!D&&!Q&&!ie&&X){U.isInvisible()?k+=No:k+=ce,w++;continue}else w&&(x.textContent=k),x=this._document.createElement("span"),w=0,k="";if(A=U.bg,P=U.fg,E=U.extended.ext,$=G,z=se,I=q,Q&&o>=N&&o<=W&&(o=N),!this._coreService.isCursorHidden&&D&&this._coreService.isCursorInitialized){if(R.push("xterm-cursor"),this._coreBrowserService.isFocused)l&&R.push("xterm-cursor-blink"),R.push(r==="bar"?"xterm-cursor-bar":r==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":R.push("xterm-cursor-outline");break;case"block":R.push("xterm-cursor-block");break;case"bar":R.push("xterm-cursor-bar");break;case"underline":R.push("xterm-cursor-underline");break}}if(U.isBold()&&R.push("xterm-bold"),U.isItalic()&&R.push("xterm-italic"),U.isDim()&&R.push("xterm-dim"),U.isInvisible()?k=No:k=U.getChars()||No,U.isUnderline()&&(R.push(`xterm-underline-${U.extended.underlineStyle}`),k===" "&&(k=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())x.style.textDecorationColor=`rgb(${Af.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let Pe=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&Pe<8&&(Pe+=8),x.style.textDecorationColor=y.ansi[Pe].css}U.isOverline()&&(R.push("xterm-overline"),k===" "&&(k=" ")),U.isStrikethrough()&&R.push("xterm-strikethrough"),G&&(x.style.textDecoration="underline");let he=U.getFgColor(),de=U.getFgColorMode(),ge=U.getBgColor(),Ae=U.getBgColorMode(),ye=!!U.isInverse();if(ye){let Pe=he;he=ge,ge=Pe;let ln=de;de=Ae,Ae=ln}let mt,Ft,Gt=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,Pe=>{Pe.options.layer!=="top"&&Gt||(Pe.backgroundColorRGB&&(Ae=50331648,ge=Pe.backgroundColorRGB.rgba>>8&16777215,mt=Pe.backgroundColorRGB),Pe.foregroundColorRGB&&(de=50331648,he=Pe.foregroundColorRGB.rgba>>8&16777215,Ft=Pe.foregroundColorRGB),Gt=Pe.options.layer==="top")}),!Gt&&q&&(mt=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,ge=mt.rgba>>8&16777215,Ae=50331648,Gt=!0,y.selectionForeground&&(de=50331648,he=y.selectionForeground.rgba>>8&16777215,Ft=y.selectionForeground)),Gt&&R.push("xterm-decoration-top");let oi;switch(Ae){case 16777216:case 33554432:oi=y.ansi[ge],R.push(`xterm-bg-${ge}`);break;case 50331648:oi=Ut.toColor(ge>>16,ge>>8&255,ge&255),this._addStyle(x,`background-color:#${uE((ge>>>0).toString(16),"0",6)}`);break;case 0:default:ye?(oi=y.foreground,R.push("xterm-bg-257")):oi=y.background}switch(mt||U.isDim()&&(mt=vt.multiplyOpacity(oi,.5)),de){case 16777216:case 33554432:U.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(x,oi,y.ansi[he],U,mt,void 0)||R.push(`xterm-fg-${he}`);break;case 50331648:let Pe=Ut.toColor(he>>16&255,he>>8&255,he&255);this._applyMinimumContrast(x,oi,Pe,U,mt,Ft)||this._addStyle(x,`color:#${uE(he.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(x,oi,y.foreground,U,mt,Ft)||ye&&R.push("xterm-fg-257")}R.length&&(x.className=R.join(" "),R.length=0),!D&&!Q&&!ie&&X?w++:x.textContent=k,se!==this.defaultSpacing&&(x.style.letterSpacing=`${se}px`),g.push(x),N=W}return x&&w&&(x.textContent=k),g}_applyMinimumContrast(e,t,s,r,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||Dee(r.getCode()))return!1;let l=this._getContrastCache(r),c;if(!n&&!o&&(c=l.getColor(t.rgba,s.rgba)),c===void 0){let u=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);c=vt.ensureContrastRatio(n||t,o||s,u),l.setColor((n||t).rgba,(o||s).rgba,c??null)}return c?(this._addStyle(e,`color:${c.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,r=this._selectionEnd;return!s||!r?!1:this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&t>=s[1]&&e<r[0]&&t<=r[1]:e<s[0]&&t>=s[1]&&e>=r[0]&&t<=r[1]:t>s[1]&&t<r[1]||s[1]===r[1]&&t===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&t===r[1]&&e<r[0]||s[1]<r[1]&&t===s[1]&&e>=s[0]}};Iy=Lt([Oe(1,WB),Oe(2,ss),Oe(3,Un),Oe(4,Ja),Oe(5,Mf),Oe(6,Dh)],Iy);function uE(i,e,t){for(;i.length<t;)i=e+i;return i}var Nee=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 r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.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,r,n,o],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),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,r){e===this._font&&t===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,s){let r=0;if(!t&&!s&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let l=this._measure(e,0);return l>0&&(this._flat[r]=l),l}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let l=0;t&&(l|=1),s&&(l|=2),o=this._measure(e,l),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},Xee=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,r=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,l=s[1]-n,c=Math.max(o,0),u=Math.min(l,e.rows-1);if(c>=e.rows||u<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=l,this.viewportCappedStartRow=c,this.viewportCappedEndRow=u,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}};function Vee(){return new Xee}var Mv="xterm-dom-renderer-owner-",Hs="xterm-rows",Mp="xterm-fg-",fE="xterm-bg-",Fc="xterm-focus",Ep="xterm-selection",Zee=1,qy=class extends Xe{constructor(e,t,s,r,n,o,l,c,u,d,m,g,_,y){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=r,this._viewportElement=n,this._helperContainer=o,this._linkifier2=l,this._charSizeService=u,this._optionsService=d,this._bufferService=m,this._coreService=g,this._coreBrowserService=_,this._themeService=y,this._terminalClass=Zee++,this._rowElements=[],this._selectionRenderModel=Vee(),this.onRequestRedraw=this._register(new fe).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Hs),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(Ep),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=zee(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(b=>this._injectCss(b))),this._injectCss(this._themeService.colors),this._rowFactory=c.createInstance(Iy,document),this._element.classList.add(Mv+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(b=>this._handleLinkHover(b))),this._register(this._linkifier2.onHideLinkUnderline(b=>this._handleLinkLeave(b))),this._register(xt(()=>{this._element.classList.remove(Mv+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Nee(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} .${Hs} 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} .${Hs} { 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} .${Hs} .xterm-dim { color: ${vt.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}`,r=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Hs}.${Fc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Hs}.${Fc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Hs}.${Fc} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Hs} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Ep} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Ep} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Ep} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,l]of e.ansi.entries())t+=`${this._terminalSelector} .${Mp}${o} { color: ${l.css}; }${this._terminalSelector} .${Mp}${o}.xterm-dim { color: ${vt.multiplyOpacity(l,.5).css}; }${this._terminalSelector} .${fE}${o} { background-color: ${l.css}; }`;t+=`${this._terminalSelector} .${Mp}257 { color: ${vt.opaque(e.background).css}; }${this._terminalSelector} .${Mp}257.xterm-dim { color: ${vt.multiplyOpacity(vt.opaque(e.background),.5).css}; }${this._terminalSelector} .${fE}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 r=this._document.createElement("div");this._rowContainer.appendChild(r),this._rowElements.push(r)}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(Fc),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Fc),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 r=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,l=this._selectionRenderModel.viewportCappedEndRow,c=this._document.createDocumentFragment();if(s){let u=e[0]>t[0];c.appendChild(this._createSelectionElement(o,u?t[0]:e[0],u?e[0]:t[0],l-o+1))}else{let u=r===o?e[0]:0,d=o===n?t[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(o,u,d));let m=l-o-1;if(c.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,m)),o!==l){let g=n===l?t[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(l,0,g))}}this._selectionContainer.appendChild(c)}_createSelectionElement(e,t,s,r=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,l=this.dimensions.css.cell.width*(s-t);return o+l>this.dimensions.css.canvas.width&&(l=this.dimensions.css.canvas.width-o),n.style.height=`${r*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${l}px`,n}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,r=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,l=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,c=this._optionsService.rawOptions.cursorInactiveStyle;for(let u=e;u<=t;u++){let d=u+s.ydisp,m=this._rowElements[u],g=s.lines.get(d);if(!m||!g)break;m.replaceChildren(...this._rowFactory.createRow(g,d,d===r,l,c,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Mv}${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,r,n,o){s<0&&(e=0),r<0&&(t=0);let l=this._bufferService.rows-1;s=Math.max(Math.min(s,l),0),r=Math.max(Math.min(r,l),0),n=Math.min(n,this._bufferService.cols);let c=this._bufferService.buffer,u=c.ybase+c.y,d=Math.min(c.x,n-1),m=this._optionsService.rawOptions.cursorBlink,g=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let y=s;y<=r;++y){let b=y+c.ydisp,x=this._rowElements[y],w=c.lines.get(b);if(!x||!w)break;x.replaceChildren(...this._rowFactory.createRow(w,b,b===u,g,_,d,m,this.dimensions.css.cell.width,this._widthCache,o?y===s?e:0:-1,o?(y===r?t:n)-1:-1))}}};qy=Lt([Oe(7,qS),Oe(8,xg),Oe(9,ss),Oe(10,is),Oe(11,Ja),Oe(12,Un),Oe(13,Dh)],qy);var Wy=class extends Xe{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new fe),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Iee(this._optionsService))}catch{this._measureStrategy=this._register(new jee(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())}};Wy=Lt([Oe(2,ss)],Wy);var uD=class extends Xe{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(i,e){i!==void 0&&i>0&&e!==void 0&&e>0&&(this._result.width=i,this._result.height=e)}},jee=class extends uD{constructor(i,e,t){super(),this._document=i,this._parentElement=e,this._optionsService=t,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}},Iee=class extends uD{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}},qee=class extends Xe{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 Wee(this._window)),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new fe),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(r=>this._screenDprMonitor.setWindow(r))),this._register(Di.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Qe(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Qe(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}},Wee=class extends Xe{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Th),this._onDprChange=this._register(new fe),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(xt(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Qe(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Uee=class extends Xe{constructor(){super(),this.linkProviders=[],this._register(xt(()=>this.linkProviders.length=0))}registerLinkProvider(i){return this.linkProviders.push(i),{dispose:()=>{let e=this.linkProviders.indexOf(i);e!==-1&&this.linkProviders.splice(e,1)}}}};function JS(i,e,t){let s=t.getBoundingClientRect(),r=i.getComputedStyle(t),n=parseInt(r.getPropertyValue("padding-left")),o=parseInt(r.getPropertyValue("padding-top"));return[e.clientX-s.left-n,e.clientY-s.top-o]}function Yee(i,e,t,s,r,n,o,l,c){if(!n)return;let u=JS(i,e,t);if(u)return u[0]=Math.ceil((u[0]+(c?o/2:0))/o),u[1]=Math.ceil(u[1]/l),u[0]=Math.min(Math.max(u[0],1),s+(c?1:0)),u[1]=Math.min(Math.max(u[1],1),r),u}var Uy=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,r,n){return Yee(window,e,t,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=JS(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])}}};Uy=Lt([Oe(0,Yn),Oe(1,xg)],Uy);var Hee=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=[]}},fD={};nJ(fD,{getSafariVersion:()=>Gee,isChromeOS:()=>gD,isFirefox:()=>dD,isIpad:()=>Kee,isIphone:()=>Jee,isLegacyEdge:()=>Fee,isLinux:()=>ex,isMac:()=>eg,isNode:()=>wg,isSafari:()=>pD,isWindows:()=>mD});var wg=typeof process<"u"&&"title"in process,Ef=wg?"node":navigator.userAgent,Pf=wg?"node":navigator.platform,dD=Ef.includes("Firefox"),Fee=Ef.includes("Edge"),pD=/^((?!chrome|android).)*safari/i.test(Ef);function Gee(){if(!pD)return 0;let i=Ef.match(/Version\/(\d+)/);return i===null||i.length<2?0:parseInt(i[1])}var eg=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Pf),Kee=Pf==="iPad",Jee=Pf==="iPhone",mD=["Windows","Win16","Win32","WinCE"].includes(Pf),ex=Pf.indexOf("Linux")>=0,gD=/\bCrOS\b/.test(Ef),OD=class{constructor(){this._tasks=[],this._i=0}enqueue(i){this._tasks.push(i),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(i){this._idleCallback=void 0;let e=0,t=0,s=i.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),t=Math.max(e,t),r=i.timeRemaining(),t*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},ete=class extends OD{_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())}}},tte=class extends OD{_requestCallback(i){return requestIdleCallback(i)}_cancelCallback(i){cancelIdleCallback(i)}},tg=!wg&&"requestIdleCallback"in window?tte:ete,ite=class{constructor(){this._queue=new tg}set(i){this._queue.clear(),this._queue.enqueue(i)}flush(){this._queue.flush()}},Yy=class extends Xe{constructor(e,t,s,r,n,o,l,c,u){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=n,this._coreBrowserService=c,this._renderer=this._register(new Th),this._pausedResizeTask=new ite,this._observerDisposable=this._register(new Th),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 fe),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new fe),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new fe),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Hee((d,m)=>this._renderRows(d,m),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ste(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(xt(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(l.onResize(()=>this._fullRefresh())),this._register(l.buffers.onBufferActivate(()=>{var d;return(d=this._renderer.value)==null?void 0:d.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(l.cols,l.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(l.buffer.y,l.buffer.y,!0))),this._register(u.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(d=>this._registerIntersectionObserver(d,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(r=>this._handleIntersectionChange(r[r.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=xt(()=>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 r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.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(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var r;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(r=this._renderer.value)==null||r.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Yy=Lt([Oe(2,ss),Oe(3,xg),Oe(4,Ja),Oe(5,Mf),Oe(6,is),Oe(7,Un),Oe(8,Dh)],Yy);var ste=class{constructor(i,e,t){this._coreBrowserService=i,this._coreService=e,this._onTimeout=t,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(i,e){this._isBuffering?(this._start=Math.min(this._start,i),this._end=Math.max(this._end,e)):(this._start=i,this._end=e,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 i={start:this._start,end:this._end};return this._isBuffering=!1,i}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function rte(i,e,t,s){let r=t.buffer.x,n=t.buffer.y;if(!t.buffer.hasScrollback)return ate(r,n,i,e,t,s)+Cg(n,e,t,s)+lte(r,n,i,e,t,s);let o;if(n===e)return o=r>i?"D":"C",hf(Math.abs(r-i),lf(o,s));o=n>e?"D":"C";let l=Math.abs(n-e),c=ote(n>e?i:r,t)+(l-1)*t.cols+1+nte(n>e?r:i);return hf(c,lf(o,s))}function nte(i,e){return i-1}function ote(i,e){return e.cols-i}function ate(i,e,t,s,r,n){return Cg(e,s,r,n).length===0?"":hf(vD(i,e,i,e-Ya(e,r),!1,r).length,lf("D",n))}function Cg(i,e,t,s){let r=i-Ya(i,t),n=e-Ya(e,t),o=Math.abs(r-n)-hte(i,e,t);return hf(o,lf(_D(i,e),s))}function lte(i,e,t,s,r,n){let o;Cg(e,s,r,n).length>0?o=s-Ya(s,r):o=e;let l=s,c=cte(i,e,t,s,r,n);return hf(vD(i,o,t,l,c==="C",r).length,lf(c,n))}function hte(i,e,t){var o;let s=0,r=i-Ya(i,t),n=e-Ya(e,t);for(let l=0;l<Math.abs(r-n);l++){let c=_D(i,e)==="A"?-1:1;(o=t.buffer.lines.get(r+c*l))!=null&&o.isWrapped&&s++}return s}function Ya(i,e){let t=0,s=e.buffer.lines.get(i),r=s==null?void 0:s.isWrapped;for(;r&&i>=0&&i<e.rows;)t++,s=e.buffer.lines.get(--i),r=s==null?void 0:s.isWrapped;return t}function cte(i,e,t,s,r,n){let o;return Cg(t,s,r,n).length>0?o=s-Ya(s,r):o=e,i<t&&o<=s||i>=t&&o<s?"C":"D"}function _D(i,e){return i>e?"A":"B"}function vD(i,e,t,s,r,n){let o=i,l=e,c="";for(;(o!==t||l!==s)&&l>=0&&l<n.buffer.lines.length;)o+=r?1:-1,r&&o>n.cols-1?(c+=n.buffer.translateBufferLineToString(l,!1,i,o),o=0,i=0,l++):!r&&o<0&&(c+=n.buffer.translateBufferLineToString(l,!1,0,i+1),o=n.cols-1,i=o,l--);return c+n.buffer.translateBufferLineToString(l,!1,i,o)}function lf(i,e){let t=e?"O":"[";return le.ESC+t+i}function hf(i,e){i=Math.floor(i);let t="";for(let s=0;s<i;s++)t+=e;return t}var ute=class{constructor(i){this._bufferService=i,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 i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?i%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)-1]:[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[i,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let i=this.selectionStart[0]+this.selectionStartLength;return i>this._bufferService.cols?[i%this._bufferService.cols,this.selectionStart[1]+Math.floor(i/this._bufferService.cols)]:[Math.max(i,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let i=this.selectionStart,e=this.selectionEnd;return!i||!e?!1:i[1]>e[1]||i[1]===e[1]&&i[0]>e[0]}handleTrim(i){return this.selectionStart&&(this.selectionStart[1]-=i),this.selectionEnd&&(this.selectionEnd[1]-=i),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function dE(i,e){if(i.start.y>i.end.y)throw new Error(`Buffer range end (${i.end.x}, ${i.end.y}) cannot be before start (${i.start.x}, ${i.start.y})`);return e*(i.end.y-i.start.y)+(i.end.x-i.start.x+1)}var Ev=50,fte=15,dte=50,pte=500,mte=" ",gte=new RegExp(mte,"g"),Hy=class extends Xe{constructor(e,t,s,r,n,o,l,c,u){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=r,this._coreService=n,this._mouseService=o,this._optionsService=l,this._renderService=c,this._coreBrowserService=u,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new lr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new fe),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new fe),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new fe),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=d=>this._handleMouseMove(d),this._mouseUpListener=d=>this._handleMouseUp(d),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(d=>this._handleTrim(d)),this._register(this._bufferService.buffers.onBufferActivate(d=>this._handleBufferActivate(d))),this.enable(),this._model=new ute(this._bufferService),this._activeSelectionMode=0,this._register(xt(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(d=>{d.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,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let l=e[1];l<=t[1];l++){let c=s.translateBufferLineToString(l,!0,n,o);r.push(c)}}else{let n=e[1]===t[1]?t[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let l=s.lines.get(o),c=s.translateBufferLineToString(o,!0);l!=null&&l.isWrapped?r[r.length-1]+=c:r.push(c)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),l=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?r[r.length-1]+=l:r.push(l)}}return r.map(n=>n.replace(gte," ")).join(mD?`\r
100
107
  `:`
101
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),JS&&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,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_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){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=NM(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=KS(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,-av),av),t/=av,t/Math.abs(t)+Math.round(t*(Vee-1)))}shouldForceSelection(e){return eg?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(),Zee)}_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&&!(eg&&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 r=s.lines.get(this._model.selectionEnd[1]);r&&r.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<jee&&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 r=Ree(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!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 r=0;t>=r;r++){let n=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==r&&(s+=n-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,r=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let l=n.translateBufferLineToString(e[1],!1),c=this._convertViewportColToCharacterIndex(o,e[0]),u=c,d=e[0]-c,m=0,g=0,_=0,y=0;if(l.charAt(c)===" "){for(;c>0&&l.charAt(c-1)===" ";)c--;for(;u<l.length&&l.charAt(u+1)===" ";)u++}else{let w=e[0],k=e[0];o.getWidth(w)===0&&(m++,w--),o.getWidth(k)===2&&(g++,k++);let C=o.getString(k).length;for(C>1&&(y+=C-1,u+=C-1);w>0&&c>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(m++,w--):A>1&&(_+=A-1,c-=A-1),c--,w--}for(;k<o.length&&u+1<l.length&&!this._isCharWordSeparator(o.loadCell(k+1,this._workCell));){o.loadCell(k+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,k++):A>1&&(y+=A-1,u+=A-1),u++,k++}}u++;let b=c+d-m+_,x=Math.min(this._bufferService.cols,u-c+m+g-_-y);if(!(!t&&l.slice(c,u).trim()==="")){if(s&&b===0&&o.getCodePoint(0)!==32){let w=n.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 C=this._bufferService.cols-k.start;b-=C,x+=C}}}if(r&&b+x===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=n.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(x+=k.length)}}return{start:b,length:x}}}_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=NM(s,this._bufferService.cols)}};Hy=Lt([Oe(3,is),Oe(4,Ga),Oe(5,qS),Oe(6,ss),Oe(7,Yn),Oe(8,Un)],Hy);var XM=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={}}},VM=class{constructor(){this._color=new XM,this._css=new XM}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()}},ei=Object.freeze((()=>{let i=[Ct.toColor("#2e3436"),Ct.toColor("#cc0000"),Ct.toColor("#4e9a06"),Ct.toColor("#c4a000"),Ct.toColor("#3465a4"),Ct.toColor("#75507b"),Ct.toColor("#06989a"),Ct.toColor("#d3d7cf"),Ct.toColor("#555753"),Ct.toColor("#ef2929"),Ct.toColor("#8ae234"),Ct.toColor("#fce94f"),Ct.toColor("#729fcf"),Ct.toColor("#ad7fa8"),Ct.toColor("#34e2e2"),Ct.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let t=0;t<216;t++){let s=e[t/36%6|0],r=e[t/6%6|0],n=e[t%6];i.push({css:Ut.toCss(s,r,n),rgba:Ut.toRgba(s,r,n)})}for(let t=0;t<24;t++){let s=8+t*10;i.push({css:Ut.toCss(s,s,s),rgba:Ut.toRgba(s,s,s)})}return i})()),Ca=Ct.toColor("#ffffff"),fu=Ct.toColor("#000000"),ZM=Ct.toColor("#ffffff"),jM=fu,Fc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Wee=Ca,Fy=class extends Xe{constructor(e){super(),this._optionsService=e,this._contrastCache=new VM,this._halfContrastCache=new VM,this._onChangeColors=this._register(new fe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ca,background:fu,cursor:ZM,cursorAccent:jM,selectionForeground:void 0,selectionBackgroundTransparent:Fc,selectionBackgroundOpaque:vt.blend(fu,Fc),selectionInactiveBackgroundTransparent:Fc,selectionInactiveBackgroundOpaque:vt.blend(fu,Fc),scrollbarSliderBackground:vt.opacity(Ca,.2),scrollbarSliderHoverBackground:vt.opacity(Ca,.4),scrollbarSliderActiveBackground:vt.opacity(Ca,.5),overviewRulerBorder:Ca,ansi:ei.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=ot(e.foreground,Ca),t.background=ot(e.background,fu),t.cursor=vt.blend(t.background,ot(e.cursor,ZM)),t.cursorAccent=vt.blend(t.background,ot(e.cursorAccent,jM)),t.selectionBackgroundTransparent=ot(e.selectionBackground,Fc),t.selectionBackgroundOpaque=vt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ot(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=vt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ot(e.selectionForeground,BM):void 0,t.selectionForeground===BM&&(t.selectionForeground=void 0),vt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=vt.opacity(t.selectionBackgroundTransparent,.3)),vt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=vt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ot(e.scrollbarSliderBackground,vt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ot(e.scrollbarSliderHoverBackground,vt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ot(e.scrollbarSliderActiveBackground,vt.opacity(t.foreground,.5)),t.overviewRulerBorder=ot(e.overviewRulerBorder,Wee),t.ansi=ei.slice(),t.ansi[0]=ot(e.black,ei[0]),t.ansi[1]=ot(e.red,ei[1]),t.ansi[2]=ot(e.green,ei[2]),t.ansi[3]=ot(e.yellow,ei[3]),t.ansi[4]=ot(e.blue,ei[4]),t.ansi[5]=ot(e.magenta,ei[5]),t.ansi[6]=ot(e.cyan,ei[6]),t.ansi[7]=ot(e.white,ei[7]),t.ansi[8]=ot(e.brightBlack,ei[8]),t.ansi[9]=ot(e.brightRed,ei[9]),t.ansi[10]=ot(e.brightGreen,ei[10]),t.ansi[11]=ot(e.brightYellow,ei[11]),t.ansi[12]=ot(e.brightBlue,ei[12]),t.ansi[13]=ot(e.brightMagenta,ei[13]),t.ansi[14]=ot(e.brightCyan,ei[14]),t.ansi[15]=ot(e.brightWhite,ei[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)t.ansi[r+16]=ot(e.extendedAnsi[r],ei[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let 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()}}};Fy=Lt([Oe(0,ss)],Fy);function ot(i,e){if(i!==void 0)try{return Ct.toColor(i)}catch{}return e}var Uee=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)}},Yee=class{constructor(){this._services=new Uee,this._services.set(IS,this)}setService(i,e){this._services.set(i,e)}getService(i){return this._services.get(i)}createInstance(i,...e){let t=VK(i).sort((n,o)=>n.index-o.index),s=[];for(let n of t){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${i.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=t.length>0?t[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${i.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new i(...e,...s)}},Hee={trace:0,debug:1,info:2,warn:3,error:4,off:5},Fee="xterm.js: ",Gy=class extends Xe{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Hee[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?"":Fee)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Gy=Lt([Oe(0,ss)],Gy);var IM=class extends Xe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new fe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new fe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new fe),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 r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}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 n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ze=3,It=Object.freeze(new Af),Ep=0,lv=2,du=class gD{constructor(e,t,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ze);let r=t||lr.fromCharData([0,$B,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let t=this._data[e*ze+0],s=t&2097151;return[this._data[e*ze+1],t&2097152?this._combined[e]:s?$o(s):"",t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,t){this._data[e*ze+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*ze+0]=e|2097152|t[2]<<22):this._data[e*ze+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*ze+0]>>22}hasWidth(e){return this._data[e*ze+0]&12582912}getFg(e){return this._data[e*ze+1]}getBg(e){return this._data[e*ze+2]}hasContent(e){return this._data[e*ze+0]&4194303}getCodePoint(e){let t=this._data[e*ze+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*ze+0]&2097152}getString(e){let t=this._data[e*ze+0];return t&2097152?this._combined[e]:t&2097151?$o(t&2097151):""}isProtected(e){return this._data[e*ze+2]&536870912}loadCell(e,t){return Ep=e*ze,t.content=this._data[Ep+0],t.fg=this._data[Ep+1],t.bg=this._data[Ep+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*ze+0]=t.content,this._data[e*ze+1]=t.fg,this._data[e*ze+2]=t.bg}setCellFromCodepoint(e,t,s,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ze+0]=t|s<<22,this._data[e*ze+1]=r.fg,this._data[e*ze+2]=r.bg}addCodepointToCell(e,t,s){let r=this._data[e*ze+0];r&2097152?this._combined[e]+=$o(t):r&2097151?(this._combined[e]=$o(r&2097151)+$o(t),r&=-2097152,r|=2097152):r=t|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[e*ze+0]=r}insertCells(e,t,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),t<this.length-e){let r=new lr;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let n=0;n<t;++n)this.setCell(e+n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,t,s){if(e%=this.length,t<this.length-e){let r=new lr;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let n=this.length-t;n<this.length;++n)this.setCell(n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,t,s,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,s);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,s);e<t&&e<this.length;)this.setCell(e++,s)}resize(e,t){if(e===this.length)return this._data.length*4*lv<this._data.buffer.byteLength;let s=e*ze;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,t)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let l=parseInt(r[o],10);l>=e&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let l=parseInt(n[o],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,s*4*lv<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*lv<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let e=new gD(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let t in this._combined)e._combined[t]=this._combined[t];for(let t in this._extendedAttrs)e._extendedAttrs[t]=this._extendedAttrs[t];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ze+0]&4194303)return e+(this._data[e*ze+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ze+0]&4194303||this._data[e*ze+2]&50331648)return e+(this._data[e*ze+0]>>22);return 0}copyCellsFrom(e,t,s,r,n){let o=e._data;if(n)for(let c=r-1;c>=0;c--){for(let u=0;u<ze;u++)this._data[(s+c)*ze+u]=o[(t+c)*ze+u];o[(t+c)*ze+2]&268435456&&(this._extendedAttrs[s+c]=e._extendedAttrs[t+c])}else for(let c=0;c<r;c++){for(let u=0;u<ze;u++)this._data[(s+c)*ze+u]=o[(t+c)*ze+u];o[(t+c)*ze+2]&268435456&&(this._extendedAttrs[s+c]=e._extendedAttrs[t+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let u=parseInt(l[c],10);u>=t&&(this._combined[u-t+s]=e._combined[u])}}translateToString(e,t,s,r){t=t??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;t<s;){let o=this._data[t*ze+0],l=o&2097151,c=o&2097152?this._combined[t]:l?$o(l):No;if(n+=c,r)for(let u=0;u<c.length;++u)r.push(t);t+=o>>22||1}return r&&r.push(t),n}};function Gee(i,e,t,s,r,n){let o=[];for(let l=0;l<i.length-1;l++){let c=l,u=i.get(++c);if(!u.isWrapped)continue;let d=[i.get(l)];for(;c<i.length&&u.isWrapped;)d.push(u),u=i.get(++c);if(!n&&s>=l&&s<c){l+=d.length-1;continue}let m=0,g=cf(d,m,e),_=1,y=0;for(;_<d.length;){let x=cf(d,_,e),w=x-y,k=t-g,C=Math.min(w,k);d[m].copyCellsFrom(d[_],y,g,C,!1),g+=C,g===t&&(m++,g=0),y+=C,y===x&&(_++,y=0),g===0&&m!==0&&d[m-1].getWidth(t-1)===2&&(d[m].copyCellsFrom(d[m-1],t-1,g++,1,!1),d[m-1].setCell(t-1,r))}d[m].replaceCells(g,t,r);let b=0;for(let x=d.length-1;x>0&&(x>m||d[x].getTrimmedLength()===0);x--)b++;b>0&&(o.push(l+d.length-b),o.push(b)),l+=d.length-1}return o}function Kee(i,e){let t=[],s=0,r=e[s],n=0;for(let o=0;o<i.length;o++)if(r===o){let l=e[++s];i.onDeleteEmitter.fire({index:o-n,amount:l}),o+=l-1,n+=l,r=e[++s]}else t.push(o);return{layout:t,countRemoved:n}}function Jee(i,e){let t=[];for(let s=0;s<e.length;s++)t.push(i.get(e[s]));for(let s=0;s<t.length;s++)i.set(s,t[s]);i.length=e.length}function ete(i,e,t){let s=[],r=i.map((c,u)=>cf(i,u,e)).reduce((c,u)=>c+u),n=0,o=0,l=0;for(;l<r;){if(r-l<t){s.push(r-l);break}n+=t;let c=cf(i,o,e);n>c&&(n-=c,o++);let u=i[o].getWidth(n-1)===2;u&&n--;let d=u?t-1:t;s.push(d),l+=d}return s}function cf(i,e,t){if(e===i.length-1)return i[e].getTrimmedLength();let s=!i[e].hasContent(t-1)&&i[e].getWidth(t-1)===1,r=i[e+1].getWidth(0)===2;return s&&r?t-1:t}var OD=class _D{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=_D._nextId++,this._onDispose=this.register(new fe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ua(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};OD._nextId=1;var tte=OD,ni={},ka=ni.B;ni[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ni.A={"#":"£"};ni.B=void 0;ni[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ni.C=ni[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ni.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ni.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ni.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ni.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ni.E=ni[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ni.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ni.H=ni[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ni["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var qM=4294967295,WM=class{constructor(i,e,t){this._hasScrollback=i,this._optionsService=e,this._bufferService=t,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=It.clone(),this.savedCharset=ka,this.markers=[],this._nullCell=lr.fromCharData([0,$B,1,0]),this._whitespaceCell=lr.fromCharData([0,No,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new tg,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new IM(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(i){return i?(this._nullCell.fg=i.fg,this._nullCell.bg=i.bg,this._nullCell.extended=i.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Gm),this._nullCell}getWhitespaceCell(i){return i?(this._whitespaceCell.fg=i.fg,this._whitespaceCell.bg=i.bg,this._whitespaceCell.extended=i.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Gm),this._whitespaceCell}getBlankLine(i,e){return new du(this._bufferService.cols,this.getNullCell(i),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let i=this.ybase+this.y-this.ydisp;return i>=0&&i<this._rows}_getCorrectBufferLength(i){if(!this._hasScrollback)return i;let e=i+this._optionsService.rawOptions.scrollback;return e>qM?qM:e}fillViewportRows(i){if(this.lines.length===0){i===void 0&&(i=It);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(i))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new IM(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(i,e){let t=this.getNullCell(It),s=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<i)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(i,t);let n=0;if(this._rows<e)for(let o=this._rows;o<e;o++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new du(i,t)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new du(i,t)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,i-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,i-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(i,e),this._cols>i))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(i,t);this._cols=i,this._rows=e,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let i=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,i=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return i}get _isReflowEnabled(){let i=this._optionsService.rawOptions.windowsPty;return i&&i.buildNumber?this._hasScrollback&&i.backend==="conpty"&&i.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(i,e){this._cols!==i&&(i>this._cols?this._reflowLarger(i,e):this._reflowSmaller(i,e))}_reflowLarger(i,e){let t=this._optionsService.rawOptions.reflowCursorLine,s=Gee(this.lines,this._cols,i,this.ybase+this.y,this.getNullCell(It),t);if(s.length>0){let r=Kee(this.lines,s);Jee(this.lines,r.layout),this._reflowLargerAdjustViewport(i,e,r.countRemoved)}}_reflowLargerAdjustViewport(i,e,t){let s=this.getNullCell(It),r=t;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new du(i,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-t,0)}_reflowSmaller(i,e){let t=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(It),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=i)continue;let c=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),c.unshift(l);if(!t){let C=this.ybase+this.y;if(C>=o&&C<o+c.length)continue}let u=c[c.length-1].getTrimmedLength(),d=ete(c,this._cols,i),m=d.length-c.length,g;this.ybase===0&&this.y!==this.lines.length-1?g=Math.max(0,this.y-this.lines.maxLength+m):g=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let C=0;C<m;C++){let A=this.getBlankLine(It,!0);_.push(A)}_.length>0&&(r.push({start:o+c.length+n,newLines:_}),n+=_.length),c.push(..._);let y=d.length-1,b=d[y];b===0&&(y--,b=d[y]);let x=c.length-m-1,w=u;for(;x>=0;){let C=Math.min(w,b);if(c[y]===void 0)break;if(c[y].copyCellsFrom(c[x],w-C,b-C,C,!0),b-=C,b===0&&(y--,b=d[y]),w-=C,w===0){x--;let A=Math.max(x,0);w=cf(c,A,this._cols)}}for(let C=0;C<c.length;C++)d[C]<i&&c[C].setCell(d[C],s);let k=m-g;for(;k-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+e-1)}if(r.length>0){let o=[],l=[];for(let b=0;b<this.lines.length;b++)l.push(this.lines.get(b));let c=this.lines.length,u=c-1,d=0,m=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let g=0;for(let b=Math.min(this.lines.maxLength-1,c+n-1);b>=0;b--)if(m&&m.start>u+g){for(let x=m.newLines.length-1;x>=0;x--)this.lines.set(b--,m.newLines[x]);b++,o.push({index:u+1,amount:m.newLines.length}),g+=m.newLines.length,m=r[++d]}else this.lines.set(b,l[u--]);let _=0;for(let b=o.length-1;b>=0;b--)o[b].index+=_,this.lines.onInsertEmitter.fire(o[b]),_+=o[b].amount;let y=Math.max(0,c+n-this.lines.maxLength);y>0&&this.lines.onTrimEmitter.fire(y)}}translateBufferLineToString(i,e,t=0,s){let r=this.lines.get(i);return r?r.translateToString(e,t,s):""}getWrappedRangeForLine(i){let e=i,t=i;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;t+1<this.lines.length&&this.lines.get(t+1).isWrapped;)t++;return{first:e,last:t}}setupTabStops(i){for(i!=null?this.tabs[i]||(i=this.prevStop(i)):(this.tabs={},i=0);i<this._cols;i+=this._optionsService.rawOptions.tabStopWidth)this.tabs[i]=!0}prevStop(i){for(i==null&&(i=this.x);!this.tabs[--i]&&i>0;);return i>=this._cols?this._cols-1:i<0?0:i}nextStop(i){for(i==null&&(i=this.x);!this.tabs[++i]&&i<this._cols;);return i>=this._cols?this._cols-1:i<0?0:i}clearMarkers(i){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===i&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].dispose();this.markers.length=0,this._isClearing=!1}addMarker(i){let e=new tte(i);return this.markers.push(e),e.register(this.lines.onTrim(t=>{e.line-=t,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(t=>{e.line>=t.index&&(e.line+=t.amount)})),e.register(this.lines.onDelete(t=>{e.line>=t.index&&e.line<t.index+t.amount&&e.dispose(),e.line>t.index&&(e.line-=t.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(i){this._isClearing||this.markers.splice(this.markers.indexOf(i),1)}},ite=class extends Xe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new fe),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 WM(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new WM(!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)}},vD=2,yD=1,Ky=class extends Xe{constructor(i){super(),this.isUserScrolling=!1,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,vD),this.rows=Math.max(i.rawOptions.rows||0,yD),this.buffers=this._register(new ite(i,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(i,e){let t=this.cols!==i,s=this.rows!==e;this.cols=i,this.rows=e,this.buffers.resize(i,e),this._onResize.fire({cols:i,rows:e,colsChanged:t,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,e=!1){let t=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==i.fg||s.getBg(0)!==i.bg)&&(s=t.getBlankLine(i,e),this._cachedBlankLine=s),s.isWrapped=e;let r=t.ybase+t.scrollTop,n=t.ybase+t.scrollBottom;if(t.scrollTop===0){let o=t.lines.isFull;n===t.lines.length-1?o?t.lines.recycle().copyFrom(s):t.lines.push(s.clone()):t.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(t.ydisp=Math.max(t.ydisp-1,0)):(t.ybase++,this.isUserScrolling||t.ydisp++)}else{let o=n-r+1;t.lines.shiftElements(r+1,o-1,-1),t.lines.set(n,s.clone())}this.isUserScrolling||(t.ydisp=t.ybase),this._onScroll.fire(t.ydisp)}scrollLines(i,e){let t=this.buffer;if(i<0){if(t.ydisp===0)return;this.isUserScrolling=!0}else i+t.ydisp>=t.ybase&&(this.isUserScrolling=!1);let s=t.ydisp;t.ydisp=Math.max(Math.min(t.ydisp+i,t.ybase),0),s!==t.ydisp&&(e||this._onScroll.fire(t.ydisp))}};Ky=Lt([Oe(0,ss)],Ky);var Xl={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:eg,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},ste=["normal","bold","100","200","300","400","500","600","700","800","900"],rte=class extends Xe{constructor(e){super(),this._onOptionChange=this._register(new fe),this.onOptionChange=this._onOptionChange.event;let t={...Xl};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(xt(()=>{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 Xl))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in Xl))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Xl[e]),!nte(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Xl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=ste.includes(t)?t:Xl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function nte(i){return i==="block"||i==="underline"||i==="bar"}function pu(i,e=5){if(typeof i!="object")return i;let t=Array.isArray(i)?[]:{};for(let s in i)t[s]=e<=1?i[s]:i[s]&&pu(i[s],e-1);return t}var UM=Object.freeze({insertMode:!1}),YM=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Jy=class extends Xe{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 fe),this.onData=this._onData.event,this._onUserInput=this._register(new fe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new fe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=pu(UM),this.decPrivateModes=pu(YM)}reset(){this.modes=pu(UM),this.decPrivateModes=pu(YM)}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(r=>r.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))}};Jy=Lt([Oe(0,is),Oe(1,XB),Oe(2,ss)],Jy);var HM={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:i=>i.button===4||i.action!==1?!1:(i.ctrl=!1,i.alt=!1,i.shift=!1,!0)},VT200:{events:19,restrict:i=>i.action!==32},DRAG:{events:23,restrict:i=>!(i.action===32&&i.button===3)},ANY:{events:31,restrict:i=>!0}};function hv(i,e){let t=(i.ctrl?16:0)|(i.shift?4:0)|(i.alt?8:0);return i.button===4?(t|=64,t|=i.action):(t|=i.button&3,i.button&4&&(t|=64),i.button&8&&(t|=128),i.action===32?t|=32:i.action===0&&!e&&(t|=3)),t}var cv=String.fromCharCode,FM={DEFAULT:i=>{let e=[hv(i,!1)+32,i.col+32,i.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${cv(e[0])}${cv(e[1])}${cv(e[2])}`},SGR:i=>{let e=i.action===0&&i.button!==4?"m":"M";return`\x1B[<${hv(i,!0)};${i.col};${i.row}${e}`},SGR_PIXELS:i=>{let e=i.action===0&&i.button!==4?"m":"M";return`\x1B[<${hv(i,!0)};${i.x};${i.y}${e}`}},eb=class extends Xe{constructor(i,e,t){super(),this._bufferService=i,this._coreService=e,this._optionsService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new fe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(HM))this.addProtocol(s,HM[s]);for(let s of Object.keys(FM))this.addEncoding(s,FM[s]);this.reset()}addProtocol(i,e){this._protocols[i]=e}addEncoding(i,e){this._encodings[i]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(i){if(!this._protocols[i])throw new Error(`unknown protocol "${i}"`);this._activeProtocol=i,this._onProtocolChange.fire(this._protocols[i].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(i){if(!this._encodings[i])throw new Error(`unknown encoding "${i}"`);this._activeEncoding=i}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(i,e,t){if(i.deltaY===0||i.shiftKey||e===void 0||t===void 0)return 0;let s=e/t,r=this._applyScrollModifier(i.deltaY,i);return i.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(i.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):i.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(i,e){return e.altKey||e.ctrlKey||e.shiftKey?i*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:i*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(i){if(i.col<0||i.col>=this._bufferService.cols||i.row<0||i.row>=this._bufferService.rows||i.button===4&&i.action===32||i.button===3&&i.action!==32||i.button!==4&&(i.action===2||i.action===3)||(i.col++,i.row++,i.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,i,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(i))return!1;let e=this._encodings[this._activeEncoding](i);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=i,!0}explainEvents(i){return{down:!!(i&1),up:!!(i&2),drag:!!(i&4),move:!!(i&8),wheel:!!(i&16)}}_equalEvents(i,e,t){if(t){if(i.x!==e.x||i.y!==e.y)return!1}else if(i.col!==e.col||i.row!==e.row)return!1;return!(i.button!==e.button||i.action!==e.action||i.ctrl!==e.ctrl||i.alt!==e.alt||i.shift!==e.shift)}};eb=Lt([Oe(0,is),Oe(1,Ga),Oe(2,ss)],eb);var uv=[[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]],ote=[[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]],ti;function ate(i,e){let t=0,s=e.length-1,r;if(i<e[0][0]||i>e[s][1])return!1;for(;s>=t;)if(r=t+s>>1,i>e[r][1])t=r+1;else if(i<e[r][0])s=r-1;else return!0;return!1}var lte=class{constructor(){if(this.version="6",!ti){ti=new Uint8Array(65536),ti.fill(1),ti[0]=0,ti.fill(0,1,32),ti.fill(0,127,160),ti.fill(2,4352,4448),ti[9001]=2,ti[9002]=2,ti.fill(2,11904,42192),ti[12351]=1,ti.fill(2,44032,55204),ti.fill(2,63744,64256),ti.fill(2,65040,65050),ti.fill(2,65072,65136),ti.fill(2,65280,65377),ti.fill(2,65504,65511);for(let e=0;e<uv.length;++e)ti.fill(0,uv[e][0],uv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ti[e]:ate(e,ote)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let n=Ba.extractWidth(t);n===0?r=!1:n>s&&(s=n)}return Ba.createPropertyValue(0,s,r)}},Ba=class nm{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new fe,this.onChange=this._onChange.event;let e=new lte;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,s=!1){return(e&16777215)<<3|(t&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,s=0,r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return t+this.wcwidth(o);let u=e.charCodeAt(n);56320<=u&&u<=57343?o=(o-55296)*1024+u-56320+65536:t+=this.wcwidth(u)}let l=this.charProperties(o,s),c=nm.extractWidth(l);nm.extractShouldJoin(l)&&(c-=nm.extractWidth(s)),t+=c,s=l}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},hte=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function GM(i){var s;let e=(s=i.buffer.lines.get(i.buffer.ybase+i.buffer.y-1))==null?void 0:s.get(i.cols-1),t=i.buffer.lines.get(i.buffer.ybase+i.buffer.y);t&&e&&(t.isWrapped=e[3]!==0&&e[3]!==32)}var Gc=2147483647,cte=256,bD=class tb{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>cte)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let t=new tb;if(!e.length)return t;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let r=e[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)t.addSubParam(r[n]);else t.addParam(r)}return t}clone(){let e=new tb(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Gc?Gc:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>Gc?Gc:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-t>0?this._subParams.subarray(t,s):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-s>0&&(e[t]=this._subParams.slice(s,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[t-1];s[t-1]=~r?Math.min(r*10+e,Gc):e}},Kc=[],ute=class{constructor(){this._state=0,this._active=Kc,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 r=s.indexOf(t);r!==-1&&s.splice(r,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=Kc}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=Kc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Kc,!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",Sg(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].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 r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-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,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Kc,this._id=-1,this._state=0}}},Rs=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+=Sg(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}},Jc=[],fte=class{constructor(){this._handlers=Object.create(null),this._active=Jc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Jc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=Jc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Jc,!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",Sg(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Jc,this._ident=0}},mu=new bD;mu.addParam(0);var KM=class{constructor(i){this._handler=i,this._data="",this._params=mu,this._hitLimit=!1}hook(i){this._params=i.length>1||i.params[0]?i.clone():mu,this._data="",this._hitLimit=!1}put(i,e,t){this._hitLimit||(this._data+=Sg(i,e,t),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(i){let e=!1;if(this._hitLimit)e=!1;else if(i&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(t=>(this._params=mu,this._data="",this._hitLimit=!1,t));return this._params=mu,this._data="",this._hitLimit=!1,e}},dte=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|r}},Js=160,pte=(function(){let i=new dte(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),t=(l,c)=>e.slice(l,c),s=t(32,127),r=t(0,24);r.push(25),r.push.apply(r,t(28,32));let n=t(0,14),o;i.setDefault(1,0),i.addMany(s,0,2,0);for(o in n)i.addMany([24,26,153,154],o,3,0),i.addMany(t(128,144),o,3,0),i.addMany(t(144,152),o,3,0),i.add(156,o,0,0),i.add(27,o,11,1),i.add(157,o,4,8),i.addMany([152,158,159],o,0,7),i.add(155,o,11,3),i.add(144,o,11,9);return i.addMany(r,0,3,0),i.addMany(r,1,3,1),i.add(127,1,0,1),i.addMany(r,8,0,8),i.addMany(r,3,3,3),i.add(127,3,0,3),i.addMany(r,4,3,4),i.add(127,4,0,4),i.addMany(r,6,3,6),i.addMany(r,5,3,5),i.add(127,5,0,5),i.addMany(r,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(s,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(t(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(s,7,0,7),i.addMany(r,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(t(64,127),3,7,0),i.addMany(t(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(t(48,60),4,8,4),i.addMany(t(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(t(32,64),6,0,6),i.add(127,6,0,6),i.addMany(t(64,127),6,0,0),i.addMany(t(32,48),3,9,5),i.addMany(t(32,48),5,9,5),i.addMany(t(48,64),5,0,6),i.addMany(t(64,127),5,7,0),i.addMany(t(32,48),4,9,5),i.addMany(t(32,48),1,9,2),i.addMany(t(32,48),2,9,2),i.addMany(t(48,127),2,10,0),i.addMany(t(48,80),1,10,0),i.addMany(t(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(t(96,127),1,10,0),i.add(80,1,11,9),i.addMany(r,9,0,9),i.add(127,9,0,9),i.addMany(t(28,32),9,0,9),i.addMany(t(32,48),9,9,12),i.addMany(t(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(r,11,0,11),i.addMany(t(32,128),11,0,11),i.addMany(t(28,32),11,0,11),i.addMany(r,10,0,10),i.add(127,10,0,10),i.addMany(t(28,32),10,0,10),i.addMany(t(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(t(32,48),10,9,12),i.addMany(r,12,0,12),i.add(127,12,0,12),i.addMany(t(28,32),12,0,12),i.addMany(t(32,48),12,9,12),i.addMany(t(48,64),12,0,11),i.addMany(t(64,127),12,12,13),i.addMany(t(64,127),10,12,13),i.addMany(t(64,127),9,12,13),i.addMany(r,13,13,13),i.addMany(s,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(Js,0,2,0),i.add(Js,8,5,8),i.add(Js,6,0,6),i.add(Js,11,0,11),i.add(Js,13,13,13),i})(),mte=class extends Xe{constructor(e=pte){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 bD,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},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(xt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ute),this._dcsParser=this._register(new fte),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 n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);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 r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,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 r=this._escHandlers[s];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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 r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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,r,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=n}parse(e,t,s){let r=0,n=0,o=0,l;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 c=this._parseStack.handlers,u=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&u>-1){for(;u>=0&&(l=c[u](this._params),l!==!0);u--)if(l instanceof Promise)return this._parseStack.handlerPos=u,l}this._parseStack.handlers=[];break;case 4:if(s===!1&&u>-1){for(;u>=0&&(l=c[u](),l!==!0);u--)if(l instanceof Promise)return this._parseStack.handlerPos=u,l}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],l=this._dcsParser.unhook(r!==24&&r!==26,s),l)return l;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],l=this._oscParser.end(r!==24&&r!==26,s),l)return l;r===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 c=o;c<t;++c){switch(r=e[c],n=this._transitions.table[this.currentState<<8|(r<160?r:Js)],n>>4){case 2:for(let _=c+1;;++_){if(_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let u=this._csiHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(l=u[d](this._params),l!==!0);d--)if(l instanceof Promise)return this._preserveStack(3,u,d,n,c),l;d<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++c<t&&(r=e[c])>47&&r<60);c--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let m=this._escHandlers[this._collect<<8|r],g=m?m.length-1:-1;for(;g>=0&&(l=m[g](),l!==!0);g--)if(l instanceof Promise)return this._preserveStack(4,m,g,n,c),l;g<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let _=c+1;;++_)if(_>=t||(r=e[_])===24||r===26||r===27||r>127&&r<Js){this._dcsParser.put(e,c,_),c=_-1;break}break;case 14:if(l=this._dcsParser.unhook(r!==24&&r!==26),l)return this._preserveStack(6,[],0,n,c),l;r===27&&(n|=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 _=c+1;;_++)if(_>=t||(r=e[_])<32||r>127&&r<Js){this._oscParser.put(e,c,_),c=_-1;break}break;case 6:if(l=this._oscParser.end(r!==24&&r!==26),l)return this._preserveStack(5,[],0,n,c),l;r===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},gte=/^([\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})$/,Ote=/^[\da-f]+$/;function JM(i){if(!i)return;let e=i.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let t=gte.exec(e);if(t){let s=t[1]?15:t[4]?255:t[7]?4095:65535;return[Math.round(parseInt(t[1]||t[4]||t[7]||t[10],16)/s*255),Math.round(parseInt(t[2]||t[5]||t[8]||t[11],16)/s*255),Math.round(parseInt(t[3]||t[6]||t[9]||t[12],16)/s*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),Ote.exec(e)&&[3,6,9,12].includes(e.length))){let t=e.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(t*r,t*r+t),16);s[r]=t===1?n<<4:t===2?n:t===3?n>>4:n>>8}return s}}function fv(i,e){let t=i.toString(16),s=t.length<2?"0"+t:t;switch(e){case 4:return t[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function _te(i,e=16){let[t,s,r]=i;return`rgb:${fv(t,e)}/${fv(s,e)}/${fv(r,e)}`}var vte={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ko=131072,eE=10;function tE(i,e){if(i>24)return e.setWinLines||!1;switch(i){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var iE=5e3,sE=0,yte=class extends Xe{constructor(i,e,t,s,r,n,o,l,c=new mte){super(),this._bufferService=i,this._charsetService=e,this._coreService=t,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new NK,this._utf8Decoder=new XK,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=It.clone(),this._eraseAttrDataInternal=It.clone(),this._onRequestBell=this._register(new fe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new fe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new fe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new fe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new fe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new fe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new fe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new fe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new fe),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 ib(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(u=>this._activeBuffer=u.activeBuffer)),this._parser.setCsiHandlerFallback((u,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(u),params:d.toArray()})}),this._parser.setEscHandlerFallback(u=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(u)})}),this._parser.setExecuteHandlerFallback(u=>{this._logService.debug("Unknown EXECUTE code: ",{code:u})}),this._parser.setOscHandlerFallback((u,d,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:u,action:d,data:m})}),this._parser.setDcsHandlerFallback((u,d,m)=>{d==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(u),action:d,payload:m})}),this._parser.setPrintHandler((u,d,m)=>this.print(u,d,m)),this._parser.registerCsiHandler({final:"@"},u=>this.insertChars(u)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},u=>this.scrollLeft(u)),this._parser.registerCsiHandler({final:"A"},u=>this.cursorUp(u)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},u=>this.scrollRight(u)),this._parser.registerCsiHandler({final:"B"},u=>this.cursorDown(u)),this._parser.registerCsiHandler({final:"C"},u=>this.cursorForward(u)),this._parser.registerCsiHandler({final:"D"},u=>this.cursorBackward(u)),this._parser.registerCsiHandler({final:"E"},u=>this.cursorNextLine(u)),this._parser.registerCsiHandler({final:"F"},u=>this.cursorPrecedingLine(u)),this._parser.registerCsiHandler({final:"G"},u=>this.cursorCharAbsolute(u)),this._parser.registerCsiHandler({final:"H"},u=>this.cursorPosition(u)),this._parser.registerCsiHandler({final:"I"},u=>this.cursorForwardTab(u)),this._parser.registerCsiHandler({final:"J"},u=>this.eraseInDisplay(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},u=>this.eraseInDisplay(u,!0)),this._parser.registerCsiHandler({final:"K"},u=>this.eraseInLine(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},u=>this.eraseInLine(u,!0)),this._parser.registerCsiHandler({final:"L"},u=>this.insertLines(u)),this._parser.registerCsiHandler({final:"M"},u=>this.deleteLines(u)),this._parser.registerCsiHandler({final:"P"},u=>this.deleteChars(u)),this._parser.registerCsiHandler({final:"S"},u=>this.scrollUp(u)),this._parser.registerCsiHandler({final:"T"},u=>this.scrollDown(u)),this._parser.registerCsiHandler({final:"X"},u=>this.eraseChars(u)),this._parser.registerCsiHandler({final:"Z"},u=>this.cursorBackwardTab(u)),this._parser.registerCsiHandler({final:"`"},u=>this.charPosAbsolute(u)),this._parser.registerCsiHandler({final:"a"},u=>this.hPositionRelative(u)),this._parser.registerCsiHandler({final:"b"},u=>this.repeatPrecedingCharacter(u)),this._parser.registerCsiHandler({final:"c"},u=>this.sendDeviceAttributesPrimary(u)),this._parser.registerCsiHandler({prefix:">",final:"c"},u=>this.sendDeviceAttributesSecondary(u)),this._parser.registerCsiHandler({final:"d"},u=>this.linePosAbsolute(u)),this._parser.registerCsiHandler({final:"e"},u=>this.vPositionRelative(u)),this._parser.registerCsiHandler({final:"f"},u=>this.hVPosition(u)),this._parser.registerCsiHandler({final:"g"},u=>this.tabClear(u)),this._parser.registerCsiHandler({final:"h"},u=>this.setMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"h"},u=>this.setModePrivate(u)),this._parser.registerCsiHandler({final:"l"},u=>this.resetMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"l"},u=>this.resetModePrivate(u)),this._parser.registerCsiHandler({final:"m"},u=>this.charAttributes(u)),this._parser.registerCsiHandler({final:"n"},u=>this.deviceStatus(u)),this._parser.registerCsiHandler({prefix:"?",final:"n"},u=>this.deviceStatusPrivate(u)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},u=>this.softReset(u)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},u=>this.setCursorStyle(u)),this._parser.registerCsiHandler({final:"r"},u=>this.setScrollRegion(u)),this._parser.registerCsiHandler({final:"s"},u=>this.saveCursor(u)),this._parser.registerCsiHandler({final:"t"},u=>this.windowOptions(u)),this._parser.registerCsiHandler({final:"u"},u=>this.restoreCursor(u)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},u=>this.insertColumns(u)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},u=>this.deleteColumns(u)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},u=>this.selectProtected(u)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},u=>this.requestMode(u,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},u=>this.requestMode(u,!1)),this._parser.setExecuteHandler(le.BEL,()=>this.bell()),this._parser.setExecuteHandler(le.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(le.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(le.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(le.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(le.BS,()=>this.backspace()),this._parser.setExecuteHandler(le.HT,()=>this.tab()),this._parser.setExecuteHandler(le.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(le.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(sm.IND,()=>this.index()),this._parser.setExecuteHandler(sm.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(sm.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Rs(u=>(this.setTitle(u),this.setIconName(u),!0))),this._parser.registerOscHandler(1,new Rs(u=>this.setIconName(u))),this._parser.registerOscHandler(2,new Rs(u=>this.setTitle(u))),this._parser.registerOscHandler(4,new Rs(u=>this.setOrReportIndexedColor(u))),this._parser.registerOscHandler(8,new Rs(u=>this.setHyperlink(u))),this._parser.registerOscHandler(10,new Rs(u=>this.setOrReportFgColor(u))),this._parser.registerOscHandler(11,new Rs(u=>this.setOrReportBgColor(u))),this._parser.registerOscHandler(12,new Rs(u=>this.setOrReportCursorColor(u))),this._parser.registerOscHandler(104,new Rs(u=>this.restoreIndexedColor(u))),this._parser.registerOscHandler(110,new Rs(u=>this.restoreFgColor(u))),this._parser.registerOscHandler(111,new Rs(u=>this.restoreBgColor(u))),this._parser.registerOscHandler(112,new Rs(u=>this.restoreCursorColor(u))),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 u in ni)this._parser.registerEscHandler({intermediates:"(",final:u},()=>this.selectCharset("("+u)),this._parser.registerEscHandler({intermediates:")",final:u},()=>this.selectCharset(")"+u)),this._parser.registerEscHandler({intermediates:"*",final:u},()=>this.selectCharset("*"+u)),this._parser.registerEscHandler({intermediates:"+",final:u},()=>this.selectCharset("+"+u)),this._parser.registerEscHandler({intermediates:"-",final:u},()=>this.selectCharset("-"+u)),this._parser.registerEscHandler({intermediates:".",final:u},()=>this.selectCharset("."+u)),this._parser.registerEscHandler({intermediates:"/",final:u},()=>this.selectCharset("/"+u));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(u=>(this._logService.error("Parsing error: ",u),u)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new KM((u,d)=>this.requestStatusString(u,d)))}getAttrData(){return this._curAttrData}_preserveStack(i,e,t,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=i,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=t,this._parseStack.position=s}_logSlowResolvingAsync(i){this._logService.logLevel<=3&&Promise.race([i,new Promise((e,t)=>setTimeout(()=>t("#SLOW_TIMEOUT"),iE))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${iE} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(i,e){let t,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(t=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(t),t;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,i.length>ko&&(n=this._parseStack.position+ko)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof i=="string"?` "${i}"`:` "${Array.prototype.map.call(i,u=>String.fromCharCode(u)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof i=="string"?i.split("").map(u=>u.charCodeAt(0)):i),this._parseBuffer.length<i.length&&this._parseBuffer.length<ko&&(this._parseBuffer=new Uint32Array(Math.min(i.length,ko))),o||this._dirtyRowTracker.clearRange(),i.length>ko)for(let u=n;u<i.length;u+=ko){let d=u+ko<i.length?u+ko:i.length,m=typeof i=="string"?this._stringDecoder.decode(i.substring(u,d),this._parseBuffer):this._utf8Decoder.decode(i.subarray(u,d),this._parseBuffer);if(t=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,r,m,u),this._logSlowResolvingAsync(t),t}else if(!o){let u=typeof i=="string"?this._stringDecoder.decode(i,this._parseBuffer):this._utf8Decoder.decode(i,this._parseBuffer);if(t=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,r,u,0),this._logSlowResolvingAsync(t),t}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(i,e,t){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,u=this._coreService.modes.insertMode,d=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&t-e>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let g=this._parser.precedingJoinState;for(let _=e;_<t;++_){if(s=i[_],s<127&&n){let w=n[String.fromCharCode(s)];w&&(s=w.charCodeAt(0))}let y=this._unicodeService.charProperties(s,g);r=Ba.extractWidth(y);let b=Ba.extractShouldJoin(y),x=b?Ba.extractWidth(g):0;if(g=y,o&&this._onA11yChar.fire($o(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-x>l){if(c){let w=m,k=this._activeBuffer.x-x;for(this._activeBuffer.x=x,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&m instanceof du&&m.copyCellsFrom(w,k,0,x,!1);k<l;)w.setCellFromCodepoint(k++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(b&&this._activeBuffer.x){let w=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-w,s,r);for(let k=r-x;--k>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(u&&(m.insertCells(this._activeBuffer.x,r-x,this._activeBuffer.getNullCell(d)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,d)),m.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=g,this._activeBuffer.x<l&&t-e>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(i,e){return i.final==="t"&&!i.prefix&&!i.intermediates?this._parser.registerCsiHandler(i,t=>tE(t.params[0],this._optionsService.rawOptions.windowOptions)?e(t):!0):this._parser.registerCsiHandler(i,e)}registerDcsHandler(i,e){return this._parser.registerDcsHandler(i,new KM(e))}registerEscHandler(i,e){return this._parser.registerEscHandler(i,e)}registerOscHandler(i,e){return this._parser.registerOscHandler(i,new Rs(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var i;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&&((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&i.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 i=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-i),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(i=this._bufferService.cols-1){this._activeBuffer.x=Math.min(i,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(i,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=i,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=i,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(i,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+i,this._activeBuffer.y+e)}cursorUp(i){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,i.params[0]||1)):this._moveCursor(0,-(i.params[0]||1)),!0}cursorDown(i){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,i.params[0]||1)):this._moveCursor(0,i.params[0]||1),!0}cursorForward(i){return this._moveCursor(i.params[0]||1,0),!0}cursorBackward(i){return this._moveCursor(-(i.params[0]||1),0),!0}cursorNextLine(i){return this.cursorDown(i),this._activeBuffer.x=0,!0}cursorPrecedingLine(i){return this.cursorUp(i),this._activeBuffer.x=0,!0}cursorCharAbsolute(i){return this._setCursor((i.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(i){return this._setCursor(i.length>=2?(i.params[1]||1)-1:0,(i.params[0]||1)-1),!0}charPosAbsolute(i){return this._setCursor((i.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(i){return this._moveCursor(i.params[0]||1,0),!0}linePosAbsolute(i){return this._setCursor(this._activeBuffer.x,(i.params[0]||1)-1),!0}vPositionRelative(i){return this._moveCursor(0,i.params[0]||1),!0}hVPosition(i){return this.cursorPosition(i),!0}tabClear(i){let e=i.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(i){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=i.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(i){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=i.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(i){let e=i.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(i,e,t,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);n.replaceCells(e,t,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(i,e=!1){let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);t&&(t.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+i),t.isWrapped=!1)}eraseInDisplay(i,e=!1){var s;this._restrictCursor(this._bufferService.cols);let t;switch(i.params[0]){case 0:for(t=this._activeBuffer.y,this._dirtyRowTracker.markDirty(t),this._eraseInBufferLine(t++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);t<this._bufferService.rows;t++)this._resetBufferLine(t,e);this._dirtyRowTracker.markDirty(t);break;case 1:for(t=this._activeBuffer.y,this._dirtyRowTracker.markDirty(t),this._eraseInBufferLine(t,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(t=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,t-1);t--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t))!=null&&s.getTrimmedLength()););for(;t>=0;t--)this._bufferService.scroll(this._eraseAttrData())}else{for(t=this._bufferService.rows,this._dirtyRowTracker.markDirty(t-1);t--;)this._resetBufferLine(t,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(i,e=!1){switch(this._restrictCursor(this._bufferService.cols),i.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(i){this._restrictCursor();let e=i.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(t,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(i){this._restrictCursor();let e=i.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;e--;)this._activeBuffer.lines.splice(t,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(i){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,i.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(i){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,i.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(i){let e=i.params[0]||1;for(;e--;)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(i){let e=i.params[0]||1;for(;e--;)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(It));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(i){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(i.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(i){let e=this._parser.precedingJoinState;if(!e)return!0;let t=i.params[0]||1,s=Ba.extractWidth(e),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*t),l=0;for(let u=0;u<n.length;){let d=n.codePointAt(u)||0;o[l++]=d,u+=d>65535?2:1}let c=l;for(let u=1;u<t;++u)o.copyWithin(c,0,l),c+=l;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(i){return i.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(le.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(le.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(i){return i.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(le.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(le.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(i.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(le.ESC+"[>83;40003;0c")),!0}_is(i){return(this._optionsService.rawOptions.termName+"").indexOf(i)===0}setMode(i){for(let e=0;e<i.length;e++)switch(i.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(i){for(let e=0;e<i.length;e++)switch(i.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ka),this._charsetService.setgCharset(1,ka),this._charsetService.setgCharset(2,ka),this._charsetService.setgCharset(3,ka);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(i){for(let e=0;e<i.length;e++)switch(i.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(i){for(let e=0;e<i.length;e++)switch(i.params[e]){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(),i.params[e]===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(i,e){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(t={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:u,alt:d}=l,m=this._optionsService.rawOptions,g=(b,x)=>(o.triggerDataEvent(`${le.ESC}[${e?"":"?"}${b};${x}$y`),!0),_=b=>b?1:2,y=i.params[0];return e?y===2?g(y,4):y===4?g(y,_(o.modes.insertMode)):y===12?g(y,3):y===20?g(y,_(m.convertEol)):g(y,0):y===1?g(y,_(s.applicationCursorKeys)):y===3?g(y,m.windowOptions.setWinLines?c===80?2:c===132?1:0:0):y===6?g(y,_(s.origin)):y===7?g(y,_(s.wraparound)):y===8?g(y,3):y===9?g(y,_(r==="X10")):y===12?g(y,_(m.cursorBlink)):y===25?g(y,_(!o.isCursorHidden)):y===45?g(y,_(s.reverseWraparound)):y===66?g(y,_(s.applicationKeypad)):y===67?g(y,4):y===1e3?g(y,_(r==="VT200")):y===1002?g(y,_(r==="DRAG")):y===1003?g(y,_(r==="ANY")):y===1004?g(y,_(s.sendFocus)):y===1005?g(y,4):y===1006?g(y,_(n==="SGR")):y===1015?g(y,4):y===1016?g(y,_(n==="SGR_PIXELS")):y===1048?g(y,1):y===47||y===1047||y===1049?g(y,_(u===d)):y===2004?g(y,_(s.bracketedPasteMode)):y===2026?g(y,_(s.synchronizedOutput)):g(y,0)}_updateAttrColor(i,e,t,s,r){return e===2?(i|=50331648,i&=-16777216,i|=Af.fromColorRGB([t,s,r])):e===5&&(i&=-50331904,i|=33554432|t&255),i}_extractColor(i,e,t){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=i.params[e+n],i.hasSubParams(e+n)){let o=i.getSubParams(e+n),l=0;do s[1]===5&&(r=1),s[n+l+1+r]=o[l];while(++l<o.length&&l+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+e<i.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:t.fg=this._updateAttrColor(t.fg,s[1],s[3],s[4],s[5]);break;case 48:t.bg=this._updateAttrColor(t.bg,s[1],s[3],s[4],s[5]);break;case 58:t.extended=t.extended.clone(),t.extended.underlineColor=this._updateAttrColor(t.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(i,e){e.extended=e.extended.clone(),(!~i||i>5)&&(i=1),e.extended.underlineStyle=i,e.fg|=268435456,i===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(i){i.fg=It.fg,i.bg=It.bg,i.extended=i.extended.clone(),i.extended.underlineStyle=0,i.extended.underlineColor&=-67108864,i.updateExtended()}charAttributes(i){if(i.length===1&&i.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=i.length,t,s=this._curAttrData;for(let r=0;r<e;r++)t=i.params[r],t>=30&&t<=37?(s.fg&=-50331904,s.fg|=16777216|t-30):t>=40&&t<=47?(s.bg&=-50331904,s.bg|=16777216|t-40):t>=90&&t<=97?(s.fg&=-50331904,s.fg|=16777216|t-90|8):t>=100&&t<=107?(s.bg&=-50331904,s.bg|=16777216|t-100|8):t===0?this._processSGR0(s):t===1?s.fg|=134217728:t===3?s.bg|=67108864:t===4?(s.fg|=268435456,this._processUnderline(i.hasSubParams(r)?i.getSubParams(r)[0]:1,s)):t===5?s.fg|=536870912:t===7?s.fg|=67108864:t===8?s.fg|=1073741824:t===9?s.fg|=2147483648:t===2?s.bg|=134217728:t===21?this._processUnderline(2,s):t===22?(s.fg&=-134217729,s.bg&=-134217729):t===23?s.bg&=-67108865:t===24?(s.fg&=-268435457,this._processUnderline(0,s)):t===25?s.fg&=-536870913:t===27?s.fg&=-67108865:t===28?s.fg&=-1073741825:t===29?s.fg&=2147483647:t===39?(s.fg&=-67108864,s.fg|=It.fg&16777215):t===49?(s.bg&=-67108864,s.bg|=It.bg&16777215):t===38||t===48||t===58?r+=this._extractColor(i,r,s):t===53?s.bg|=1073741824:t===55?s.bg&=-1073741825:t===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):t===100?(s.fg&=-67108864,s.fg|=It.fg&16777215,s.bg&=-67108864,s.bg|=It.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",t);return!0}deviceStatus(i){switch(i.params[0]){case 5:this._coreService.triggerDataEvent(`${le.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${le.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(i){switch(i.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${le.ESC}[?${e};${t}R`);break}return!0}softReset(i){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=It.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(i){let e=i.length===0?1:i.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){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 t=e%2===1;this._coreService.decPrivateModes.cursorBlink=t}return!0}setScrollRegion(i){let e=i.params[0]||1,t;return(i.length<2||(t=i.params[1])>this._bufferService.rows||t===0)&&(t=this._bufferService.rows),t>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=t-1,this._setCursor(0,0)),!0}windowOptions(i){if(!tE(i.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=i.length>1?i.params[1]:0;switch(i.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${le.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>eE&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>eE&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(i){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(i){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(i){return this._windowTitle=i,this._onTitleChange.fire(i),!0}setIconName(i){return this._iconName=i,!0}setOrReportIndexedColor(i){let e=[],t=i.split(";");for(;t.length>1;){let s=t.shift(),r=t.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(rE(n))if(r==="?")e.push({type:0,index:n});else{let o=JM(r);o&&e.push({type:1,index:n,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(i){let e=i.indexOf(";");if(e===-1)return!0;let t=i.slice(0,e).trim(),s=i.slice(e+1);return s?this._createHyperlink(t,s):t.trim()?!1:this._finishHyperlink()}_createHyperlink(i,e){this._getCurrentLinkId()&&this._finishHyperlink();let t=i.split(":"),s,r=t.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=t[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(i,e){let t=i.split(";");for(let s=0;s<t.length&&!(e>=this._specialColors.length);++s,++e)if(t[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=JM(t[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(i){return this._setOrReportSpecialColor(i,0)}setOrReportBgColor(i){return this._setOrReportSpecialColor(i,1)}setOrReportCursorColor(i){return this._setOrReportSpecialColor(i,2)}restoreIndexedColor(i){if(!i)return this._onColor.fire([{type:2}]),!0;let e=[],t=i.split(";");for(let s=0;s<t.length;++s)if(/^\d+$/.exec(t[s])){let r=parseInt(t[s]);rE(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(i){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(i){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(i){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,ka),!0}selectCharset(i){return i.length!==2?(this.selectDefaultCharset(),!0):(i[0]==="/"||this._charsetService.setgCharset(vte[i[0]],ni[i[1]]||ka),!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 i=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,i,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=It.clone(),this._eraseAttrDataInternal=It.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(i){return this._charsetService.setgLevel(i),!0}screenAlignmentPattern(){let i=new lr;i.content=1<<22|69,i.fg=this._curAttrData.fg,i.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let t=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(t);s&&(s.fill(i),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(i,e){let t=o=>(this._coreService.triggerDataEvent(`${le.ESC}${o}${le.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return t(i==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:i==='"p'?'P1$r61;1"p':i==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:i==="m"?"P1$r0m":i===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(i,e){this._dirtyRowTracker.markRangeDirty(i,e)}},ib=class{constructor(i){this._bufferService=i,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(i){i<this.start?this.start=i:i>this.end&&(this.end=i)}markRangeDirty(i,e){i>e&&(sE=i,i=e,e=sE),i<this.start&&(this.start=i),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ib=Lt([Oe(0,is)],ib);function rE(i){return 0<=i&&i<256}var bte=5e7,nE=12,Ste=50,xte=class extends Xe{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 fe),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 r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>bte)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 r=this._writeBuffer[this._bufferOffset],n=this._action(r,t);if(n){let l=c=>performance.now()-s>=nE?setTimeout(()=>this._innerWrite(0,c)):this._innerWrite(s,c);n.catch(c=>(queueMicrotask(()=>{throw c}),Promise.resolve(!1))).then(l);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=nE)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ste&&(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()}},sb=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 c=t.addMarker(t.ybase+t.y),u={data:e,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._dataByLinkId.set(u.id,u),u.id}let s=e,r=this._getEntryIdKey(s),n=this._entriesWithId.get(r);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),l={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(l,o)),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let 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)))}};sb=Lt([Oe(0,is)],sb);var oE=!1,wte=class extends Xe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Th),this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onData=this._register(new fe),this.onData=this._onData.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new fe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new fe),this._instantiationService=new Yee,this.optionsService=this._register(new rte(e)),this._instantiationService.setService(ss,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ky)),this._instantiationService.setService(is,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Gy)),this._instantiationService.setService(XB,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Jy)),this._instantiationService.setService(Ga,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(eb)),this._instantiationService.setService(NB,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ba)),this._instantiationService.setService(IK,this.unicodeService),this._charsetService=this._instantiationService.createInstance(hte),this._instantiationService.setService(jK,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(sb),this._instantiationService.setService(VB,this._oscLinkService),this._inputHandler=this._register(new yte(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Di.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Di.forward(this._bufferService.onResize,this._onResize)),this._register(Di.forward(this.coreService.onData,this._onData)),this._register(Di.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 xte((t,s)=>this._inputHandler.parse(t,s))),this._register(Di.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new fe),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!oE&&(this._logService.warn("writeSync is unreliable and will be removed soon."),oE=!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,vD),t=Math.max(t,yD),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(GM.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(GM(this._bufferService),!1))),this._windowsWrappingHeuristics.value=xt(()=>{for(let t of e)t.dispose()})}}},Cte={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function kte(i,e,t,s){var o;let r={type:0,cancel:!1,key:void 0},n=(i.shiftKey?1:0)|(i.altKey?2:0)|(i.ctrlKey?4:0)|(i.metaKey?8:0);switch(i.keyCode){case 0:i.key==="UIKeyInputUpArrow"?e?r.key=le.ESC+"OA":r.key=le.ESC+"[A":i.key==="UIKeyInputLeftArrow"?e?r.key=le.ESC+"OD":r.key=le.ESC+"[D":i.key==="UIKeyInputRightArrow"?e?r.key=le.ESC+"OC":r.key=le.ESC+"[C":i.key==="UIKeyInputDownArrow"&&(e?r.key=le.ESC+"OB":r.key=le.ESC+"[B");break;case 8:r.key=i.ctrlKey?"\b":le.DEL,i.altKey&&(r.key=le.ESC+r.key);break;case 9:if(i.shiftKey){r.key=le.ESC+"[Z";break}r.key=le.HT,r.cancel=!0;break;case 13:r.key=i.altKey?le.ESC+le.CR:le.CR,r.cancel=!0;break;case 27:r.key=le.ESC,i.altKey&&(r.key=le.ESC+le.ESC),r.cancel=!0;break;case 37:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"D":e?r.key=le.ESC+"OD":r.key=le.ESC+"[D";break;case 39:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"C":e?r.key=le.ESC+"OC":r.key=le.ESC+"[C";break;case 38:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"A":e?r.key=le.ESC+"OA":r.key=le.ESC+"[A";break;case 40:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"B":e?r.key=le.ESC+"OB":r.key=le.ESC+"[B";break;case 45:!i.shiftKey&&!i.ctrlKey&&(r.key=le.ESC+"[2~");break;case 46:n?r.key=le.ESC+"[3;"+(n+1)+"~":r.key=le.ESC+"[3~";break;case 36:n?r.key=le.ESC+"[1;"+(n+1)+"H":e?r.key=le.ESC+"OH":r.key=le.ESC+"[H";break;case 35:n?r.key=le.ESC+"[1;"+(n+1)+"F":e?r.key=le.ESC+"OF":r.key=le.ESC+"[F";break;case 33:i.shiftKey?r.type=2:i.ctrlKey?r.key=le.ESC+"[5;"+(n+1)+"~":r.key=le.ESC+"[5~";break;case 34:i.shiftKey?r.type=3:i.ctrlKey?r.key=le.ESC+"[6;"+(n+1)+"~":r.key=le.ESC+"[6~";break;case 112:n?r.key=le.ESC+"[1;"+(n+1)+"P":r.key=le.ESC+"OP";break;case 113:n?r.key=le.ESC+"[1;"+(n+1)+"Q":r.key=le.ESC+"OQ";break;case 114:n?r.key=le.ESC+"[1;"+(n+1)+"R":r.key=le.ESC+"OR";break;case 115:n?r.key=le.ESC+"[1;"+(n+1)+"S":r.key=le.ESC+"OS";break;case 116:n?r.key=le.ESC+"[15;"+(n+1)+"~":r.key=le.ESC+"[15~";break;case 117:n?r.key=le.ESC+"[17;"+(n+1)+"~":r.key=le.ESC+"[17~";break;case 118:n?r.key=le.ESC+"[18;"+(n+1)+"~":r.key=le.ESC+"[18~";break;case 119:n?r.key=le.ESC+"[19;"+(n+1)+"~":r.key=le.ESC+"[19~";break;case 120:n?r.key=le.ESC+"[20;"+(n+1)+"~":r.key=le.ESC+"[20~";break;case 121:n?r.key=le.ESC+"[21;"+(n+1)+"~":r.key=le.ESC+"[21~";break;case 122:n?r.key=le.ESC+"[23;"+(n+1)+"~":r.key=le.ESC+"[23~";break;case 123:n?r.key=le.ESC+"[24;"+(n+1)+"~":r.key=le.ESC+"[24~";break;default:if(i.ctrlKey&&!i.shiftKey&&!i.altKey&&!i.metaKey)i.keyCode>=65&&i.keyCode<=90?r.key=String.fromCharCode(i.keyCode-64):i.keyCode===32?r.key=le.NUL:i.keyCode>=51&&i.keyCode<=55?r.key=String.fromCharCode(i.keyCode-51+27):i.keyCode===56?r.key=le.DEL:i.keyCode===219?r.key=le.ESC:i.keyCode===220?r.key=le.FS:i.keyCode===221&&(r.key=le.GS);else if((!t||s)&&i.altKey&&!i.metaKey){let l=(o=Cte[i.keyCode])==null?void 0:o[i.shiftKey?1:0];if(l)r.key=le.ESC+l;else if(i.keyCode>=65&&i.keyCode<=90){let c=i.ctrlKey?i.keyCode-64:i.keyCode+32,u=String.fromCharCode(c);i.shiftKey&&(u=u.toUpperCase()),r.key=le.ESC+u}else if(i.keyCode===32)r.key=le.ESC+(i.ctrlKey?le.NUL:" ");else if(i.key==="Dead"&&i.code.startsWith("Key")){let c=i.code.slice(3,4);i.shiftKey||(c=c.toLowerCase()),r.key=le.ESC+c,r.cancel=!0}}else t&&!i.altKey&&!i.ctrlKey&&!i.shiftKey&&i.metaKey?i.keyCode===65&&(r.type=1):i.key&&!i.ctrlKey&&!i.altKey&&!i.metaKey&&i.keyCode>=48&&i.key.length===1?r.key=i.key:i.key&&i.ctrlKey&&(i.key==="_"&&(r.key=le.US),i.key==="@"&&(r.key=le.NUL));break}return r}var Dt=0,Tte=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new tg,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new tg,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((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<r.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[n]=e[t],t++):r[n]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Dt=this._search(t),Dt===-1)||this._getKey(this._array[Dt])!==t)return!1;do if(this._array[Dt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Dt),!0;while(++Dt<this._array.length&&this._getKey(this._array[Dt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),r=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[r++]=this._array[n];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&&(Dt=this._search(e),!(Dt<0||Dt>=this._array.length)&&this._getKey(this._array[Dt])===e))do yield this._array[Dt];while(++Dt<this._array.length&&this._getKey(this._array[Dt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Dt=this._search(e),!(Dt<0||Dt>=this._array.length)&&this._getKey(this._array[Dt])===e))do t(this._array[Dt]);while(++Dt<this._array.length&&this._getKey(this._array[Dt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let r=t+s>>1,n=this._getKey(this._array[r]);if(n>e)s=r-1;else if(n<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},dv=0,aE=0,Ate=class extends Xe{constructor(){super(),this._decorations=new Tte(i=>i==null?void 0:i.marker.line),this._onDecorationRegistered=this._register(new fe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new fe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(xt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(i){if(i.marker.isDisposed)return;let e=new Mte(i);if(e){let t=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),t.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let i of this._decorations.values())i.dispose();this._decorations.clear()}*getDecorationsAtCell(i,e,t){let s=0,r=0;for(let n of this._decorations.getKeyIterator(e))s=n.options.x??0,r=s+(n.options.width??1),i>=s&&i<r&&(!t||(n.options.layer??"bottom")===t)&&(yield n)}forEachDecorationAtCell(i,e,t,s){this._decorations.forEachByKey(e,r=>{dv=r.options.x??0,aE=dv+(r.options.width??1),i>=dv&&i<aE&&(!t||(r.options.layer??"bottom")===t)&&s(r)})}},Mte=class extends Vo{constructor(i){super(),this.options=i,this.onRenderEmitter=this.add(new fe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new fe),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=i.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ct.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ct.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Ete=1e3,Pte=class{constructor(e,t=Ete){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 r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=r-this._lastRefreshMs,o=this._debounceThresholdMS-n;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)}},lE=20,ig=class extends Xe{constructor(i,e,t,s){super(),this._terminal=i,this._coreBrowserService=t,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Pte(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
102
- `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Qe(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(xt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(i){for(let e=0;e<i;e++)this._handleChar(" ")}_handleChar(i){this._liveRegionLineCount<lE+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==i&&(this._charsToAnnounce+=i):this._charsToAnnounce+=i,i===`
103
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===lE+1&&(this._liveRegion.textContent+=xy.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(i){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(i)||this._charsToConsume.push(i)}_refreshRows(i,e){this._liveRegionDebouncer.refresh(i,e,this._terminal.rows)}_renderRows(i,e){let t=this._terminal.buffer,s=t.lines.length.toString();for(let r=i;r<=e;r++){let n=t.lines.get(t.ydisp+r),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(t.ydisp+r+1).toString(),u=this._rowElements[r];u&&(l.length===0?(u.textContent=" ",this._rowColumns.set(u,[0,1])):(u.textContent=l,this._rowColumns.set(u,o)),u.setAttribute("aria-posinset",c),u.setAttribute("aria-setsize",s),this._alignRowWidth(u))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(i,e){let t=i.target,s=this._rowElements[e===0?1:this._rowElements.length-2],r=t.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||i.relatedTarget!==s)return;let o,l;if(e===0?(o=t,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=t,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===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(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),i.preventDefault(),i.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let i=this._coreBrowserService.mainDocument.getSelection();if(!i)return;if(i.isCollapsed){this._rowContainer.contains(i.anchorNode)&&this._terminal.clearSelection();return}if(!i.anchorNode||!i.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:i.anchorNode,offset:i.anchorOffset},t={node:i.focusNode,offset:i.focusOffset};if((e.node.compareDocumentPosition(t.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===t.node&&e.offset>t.offset)&&([e,t]=[t,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let s=this._rowElements.slice(-1)[0];if(t.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(t={node:s,offset:((l=s.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(t.node))return;let r=({node:c,offset:u})=>{let d=c instanceof Text?c.parentNode:c,m=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let g=this._rowColumns.get(d);if(!g)return console.warn("columns is null. Race condition?"),null;let _=u<g.length?g[u]:g.slice(-1)[0]+1;return _>=this._terminal.cols&&(++m,_=0),{row:m,column:_}},n=r(e),o=r(t);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(i){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let i=this._coreBrowserService.mainDocument.createElement("div");return i.setAttribute("role","listitem"),i.tabIndex=-1,this._refreshRowDimensions(i),i}_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 i=0;i<this._terminal.rows;i++)this._refreshRowDimensions(this._rowElements[i]),this._alignRowWidth(this._rowElements[i])}}_refreshRowDimensions(i){i.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(i){var r,n;i.style.transform="";let e=i.getBoundingClientRect().width,t=(n=(r=this._rowColumns.get(i))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!t)return;let s=t*this._renderService.dimensions.css.cell.width;i.style.transform=`scaleX(${s/e})`}};ig=Lt([Oe(1,IS),Oe(2,Un),Oe(3,Yn)],ig);var rb=class extends Xe{constructor(i,e,t,s,r){super(),this._element=i,this._mouseService=e,this._renderService=t,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new fe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new fe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(xt(()=>{var n;Ua(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Qe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Qe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Qe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Qe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(i){this._lastMouseEvent=i;let e=this._positionFromMouseEvent(i,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let t=i.composedPath();for(let s=0;s<t.length;s++){let r=t[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(i){if(this._activeLine!==i.y||this._wasResized){this._clearCurrentLink(),this._askForLink(i,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,i)||(this._clearCurrentLink(),this._askForLink(i,!0))}_askForLink(i,e){var s,r;(!this._activeProviderReplies||!e)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=i.y);let t=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())e?(r=this._activeProviderReplies)!=null&&r.get(n)&&(t=this._checkLinkProviderResult(n,i,t)):o.provideLinks(i.y,l=>{var u,d;if(this._isMouseOut)return;let c=l==null?void 0:l.map(m=>({link:m}));(u=this._activeProviderReplies)==null||u.set(n,c),t=this._checkLinkProviderResult(n,i,t),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(i.y,this._activeProviderReplies)})}_removeIntersectingLinks(i,e){let t=new Set;for(let s=0;s<e.size;s++){let r=e.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],l=o.link.range.start.y<i?0:o.link.range.start.x,c=o.link.range.end.y>i?this._bufferService.cols:o.link.range.end.x;for(let u=l;u<=c;u++){if(t.has(u)){r.splice(n--,1);break}t.add(u)}}}}_checkLinkProviderResult(i,e,t){var n;if(!this._activeProviderReplies)return t;let s=this._activeProviderReplies.get(i),r=!1;for(let o=0;o<i;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(l=>this._linkAtPosition(l.link,e));o&&(t=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!t)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(c=>this._linkAtPosition(c.link,e));if(l){t=!0,this._handleNewLink(l);break}}return t}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(i){if(!this._currentLink)return;let e=this._positionFromMouseEvent(i,this._element,this._mouseService);e&&this._mouseDownLink&&Qte(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(i,this._currentLink.link.text)}_clearCurrentLink(i,e){!this._currentLink||!this._lastMouseEvent||(!i||!e||this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ua(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(i){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(i.link,e)&&(this._currentLink=i,this._currentLink.state={decorations:{underline:i.link.decorations===void 0?!0:i.link.decorations.underline,pointerCursor:i.link.decorations===void 0?!0:i.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,i.link,this._lastMouseEvent),i.link.decorations={},Object.defineProperties(i.link.decorations,{pointerCursor:{get:()=>{var t,s;return(s=(t=this._currentLink)==null?void 0:t.state)==null?void 0:s.decorations.pointerCursor},set:t=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==t&&(this._currentLink.state.decorations.pointerCursor=t,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",t))}},underline:{get:()=>{var t,s;return(s=(t=this._currentLink)==null?void 0:t.state)==null?void 0:s.decorations.underline},set:t=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(i.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(t=>{if(!this._currentLink)return;let s=t.start===0?0:t.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+t.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(i,e,t){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&i.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(t,e.text)}_fireUnderlineEvent(i,e){let t=i.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(t.start.x-1,t.start.y-s-1,t.end.x,t.end.y-s-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(i,e,t){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&i.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(t,e.text)}_linkAtPosition(i,e){let t=i.range.start.y*this._bufferService.cols+i.range.start.x,s=i.range.end.y*this._bufferService.cols+i.range.end.x,r=e.y*this._bufferService.cols+e.x;return t<=r&&r<=s}_positionFromMouseEvent(i,e,t){let s=t.getCoords(i,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(i,e,t,s,r){return{x1:i,y1:e,x2:t,y2:s,cols:this._bufferService.cols,fg:r}}};rb=Lt([Oe(1,qS),Oe(2,Yn),Oe(3,is),Oe(4,jB)],rb);function Qte(i,e){return i.text===e.text&&i.range.start.x===e.range.start.x&&i.range.start.y===e.range.start.y&&i.range.end.x===e.range.end.x&&i.range.end.y===e.range.end.y}var Rte=class extends wte{constructor(e={}){super(e),this._linkifier=this._register(new Th),this.browser=lD,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Th),this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new fe),this.onKey=this._onKey.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new fe),this.onBell=this._onBell.event,this._onFocus=this._register(new fe),this._onBlur=this._register(new fe),this._onA11yCharEmitter=this._register(new fe),this._onA11yTabEmitter=this._register(new fe),this._onWillOpen=this._register(new fe),this._setup(),this._decorationService=this._instantiationService.createInstance(Ate),this._instantiationService.setService(Mf,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(See),this._instantiationService.setService(jB,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Cy)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Di.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Di.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Di.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Di.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(xt(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.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,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let n=vt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${le.ESC}]${r};${_te(n)}${oD.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ut.toColor(...t.color));else{let o=s;this._themeService.modifyColors(l=>l[o]=Ut.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(ig,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(le.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(le.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),r=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,l=this.buffer.y*this._renderService.dimensions.css.cell.height,c=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=c+"px",this.textarea.style.top=l+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Qe(this.element,"copy",t=>{this.hasSelection()&&DK(t,this._selectionService)}));let e=t=>zK(t,this.textarea,this.coreService,this.optionsService);this._register(Qe(this.textarea,"paste",e)),this._register(Qe(this.element,"paste",e)),hD?this._register(Qe(this.element,"mousedown",t=>{t.button===2&&_M(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Qe(this.element,"contextmenu",t=>{_M(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),JS&&this._register(Qe(this.element,"auxclick",t=>{t.button===1&&LB(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Qe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Qe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Qe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Qe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Qe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Qe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Qe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;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"),((n=this.element)==null?void 0:n.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(Qe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),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",Sy.get()),fD||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(yee,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Un,this._coreBrowserService),this._register(Qe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Qe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wy,this._document,this._helperContainer),this._instantiationService.setService(xg,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fy),this._instantiationService.setService(Dh,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Jm),this._instantiationService.setService(ZB,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Yy,this.rows,this.screenElement)),this._instantiationService.setService(Yn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(jy,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Uy),this._instantiationService.setService(qS,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(rb,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(Vy,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Hy,this.element,this.screenElement,r)),this._instantiationService.setService(WK,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Di.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Zy,this.screenElement)),this._register(Qe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(ig,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Km,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Km,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qy,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var d,m,g,_,y;let l=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!l)return!1;let c,u;switch(o.overrideType||o.type){case"mousemove":u=32,o.buttons===void 0?(c=3,o.button!==void 0&&(c=o.button<3?o.button:3)):c=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":u=0,c=o.button<3?o.button:3;break;case"mousedown":u=1,c=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let b=o.deltaY;if(b===0||e.coreMouseService.consumeWheelEvent(o,(_=(g=(m=(d=e._renderService)==null?void 0:d.dimensions)==null?void 0:m.device)==null?void 0:g.cell)==null?void 0:_.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;u=b<0?0:1,c=4;break;default:return!1}return u===void 0||c===void 0||c>4?!1:e.coreMouseService.triggerMouseEvent({col:l.col,row:l.row,x:l.x,y:l.y,button:c,action:u,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.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?r.mousemove||(t.addEventListener("mousemove",n.mousemove),r.mousemove=n.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),r.wheel=n.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Qe(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(Qe(t,"wheel",o=>{var l,c,u,d,m;if(!r.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,(d=(u=(c=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:c.device)==null?void 0:u.cell)==null?void 0:d.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return this.cancel(o,!0);let g=le.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){RB(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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.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=kte(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),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===le.ETX||s.key===le.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)&&(Lte(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.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(It));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(le.ESC+"[I"):this.coreService.triggerDataEvent(le.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(`${le.ESC}[4;${s};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${le.ESC}[6;${n};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Lte(i){return i.keyCode===16||i.keyCode===17||i.keyCode===18}var $te=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)}},Bte=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 lr)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},hE=class{constructor(i,e){this._buffer=i,this.type=e}init(i){return this._buffer=i,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(i){let e=this._buffer.lines.get(i);if(e)return new Bte(e)}getNullCell(){return new lr}},Dte=class extends Xe{constructor(i){super(),this._core=i,this._onBufferChange=this._register(new fe),this.onBufferChange=this._onBufferChange.event,this._normal=new hE(this._core.buffers.normal,"normal"),this._alternate=new hE(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)}},zte=class{constructor(i){this._core=i}registerCsiHandler(i,e){return this._core.registerCsiHandler(i,t=>e(t.toArray()))}addCsiHandler(i,e){return this.registerCsiHandler(i,e)}registerDcsHandler(i,e){return this._core.registerDcsHandler(i,(t,s)=>e(t,s.toArray()))}addDcsHandler(i,e){return this.registerDcsHandler(i,e)}registerEscHandler(i,e){return this._core.registerEscHandler(i,e)}addEscHandler(i,e){return this.registerEscHandler(i,e)}registerOscHandler(i,e){return this._core.registerOscHandler(i,e)}addOscHandler(i,e){return this.registerOscHandler(i,e)}},Nte=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}},Xte=["cols","rows"],Dr=0,Vte=class extends Xe{constructor(i){super(),this._core=this._register(new Rte(i)),this._addonManager=this._register(new $te),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],t=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(i){if(Xte.includes(i))throw new Error(`Option "${i}" 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 zte(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Nte(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 Dte(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let i=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:i.applicationCursorKeys,applicationKeypadMode:i.applicationKeypad,bracketedPasteMode:i.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:i.origin,reverseWraparoundMode:i.reverseWraparound,sendFocusMode:i.sendFocus,synchronizedOutputMode:i.synchronizedOutput,wraparoundMode:i.wraparound}}get options(){return this._publicOptions}set options(i){for(let e in i)this._publicOptions[e]=i[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(i,e=!0){this._core.input(i,e)}resize(i,e){this._verifyIntegers(i,e),this._core.resize(i,e)}open(i){this._core.open(i)}attachCustomKeyEventHandler(i){this._core.attachCustomKeyEventHandler(i)}attachCustomWheelEventHandler(i){this._core.attachCustomWheelEventHandler(i)}registerLinkProvider(i){return this._core.registerLinkProvider(i)}registerCharacterJoiner(i){return this._checkProposedApi(),this._core.registerCharacterJoiner(i)}deregisterCharacterJoiner(i){this._checkProposedApi(),this._core.deregisterCharacterJoiner(i)}registerMarker(i=0){return this._verifyIntegers(i),this._core.registerMarker(i)}registerDecoration(i){return this._checkProposedApi(),this._verifyPositiveIntegers(i.x??0,i.width??0,i.height??0),this._core.registerDecoration(i)}hasSelection(){return this._core.hasSelection()}select(i,e,t){this._verifyIntegers(i,e,t),this._core.select(i,e,t)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(i,e){this._verifyIntegers(i,e),this._core.selectLines(i,e)}dispose(){super.dispose()}scrollLines(i){this._verifyIntegers(i),this._core.scrollLines(i)}scrollPages(i){this._verifyIntegers(i),this._core.scrollPages(i)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(i){this._verifyIntegers(i),this._core.scrollToLine(i)}clear(){this._core.clear()}write(i,e){this._core.write(i,e)}writeln(i,e){this._core.write(i),this._core.write(`\r
104
- `,e)}paste(i){this._core.paste(i)}refresh(i,e){this._verifyIntegers(i,e),this._core.refresh(i,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(i){this._addonManager.loadAddon(this,i)}static get strings(){return{get promptLabel(){return Sy.get()},set promptLabel(i){Sy.set(i)},get tooMuchOutput(){return xy.get()},set tooMuchOutput(i){xy.set(i)}}}_verifyIntegers(...i){for(Dr of i)if(Dr===1/0||isNaN(Dr)||Dr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...i){for(Dr of i)if(Dr&&(Dr===1/0||isNaN(Dr)||Dr%1!==0||Dr<0))throw new Error("This API only accepts positive integers")}};/**
108
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),ex&&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,r=this._model.finalSelectionEnd;return!s||!r||!t?!1:this._areCoordsInSelection(t,s,r)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!s||!r?!1:this._areCoordsInSelection([e,t],s,r)}_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){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=dE(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=JS(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,-Ev),Ev),t/=Ev,t/Math.abs(t)+Math.round(t*(fte-1)))}shouldForceSelection(e){return eg?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(),dte)}_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&&!(eg&&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 r=s.lines.get(this._model.selectionEnd[1]);r&&r.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<pte&&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 r=rte(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!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 r=0;t>=r;r++){let n=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==r&&(s+=n-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,r=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let l=n.translateBufferLineToString(e[1],!1),c=this._convertViewportColToCharacterIndex(o,e[0]),u=c,d=e[0]-c,m=0,g=0,_=0,y=0;if(l.charAt(c)===" "){for(;c>0&&l.charAt(c-1)===" ";)c--;for(;u<l.length&&l.charAt(u+1)===" ";)u++}else{let w=e[0],k=e[0];o.getWidth(w)===0&&(m++,w--),o.getWidth(k)===2&&(g++,k++);let C=o.getString(k).length;for(C>1&&(y+=C-1,u+=C-1);w>0&&c>0&&!this._isCharWordSeparator(o.loadCell(w-1,this._workCell));){o.loadCell(w-1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===0?(m++,w--):A>1&&(_+=A-1,c-=A-1),c--,w--}for(;k<o.length&&u+1<l.length&&!this._isCharWordSeparator(o.loadCell(k+1,this._workCell));){o.loadCell(k+1,this._workCell);let A=this._workCell.getChars().length;this._workCell.getWidth()===2?(g++,k++):A>1&&(y+=A-1,u+=A-1),u++,k++}}u++;let b=c+d-m+_,x=Math.min(this._bufferService.cols,u-c+m+g-_-y);if(!(!t&&l.slice(c,u).trim()==="")){if(s&&b===0&&o.getCodePoint(0)!==32){let w=n.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 C=this._bufferService.cols-k.start;b-=C,x+=C}}}if(r&&b+x===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let w=n.lines.get(e[1]+1);if(w!=null&&w.isWrapped&&w.getCodePoint(0)!==32){let k=this._getWordAt([0,e[1]+1],!1,!1,!0);k&&(x+=k.length)}}return{start:b,length:x}}}_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=dE(s,this._bufferService.cols)}};Hy=Lt([Oe(3,is),Oe(4,Ja),Oe(5,WS),Oe(6,ss),Oe(7,Yn),Oe(8,Un)],Hy);var pE=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={}}},mE=class{constructor(){this._color=new pE,this._css=new pE}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()}},ei=Object.freeze((()=>{let i=[Ct.toColor("#2e3436"),Ct.toColor("#cc0000"),Ct.toColor("#4e9a06"),Ct.toColor("#c4a000"),Ct.toColor("#3465a4"),Ct.toColor("#75507b"),Ct.toColor("#06989a"),Ct.toColor("#d3d7cf"),Ct.toColor("#555753"),Ct.toColor("#ef2929"),Ct.toColor("#8ae234"),Ct.toColor("#fce94f"),Ct.toColor("#729fcf"),Ct.toColor("#ad7fa8"),Ct.toColor("#34e2e2"),Ct.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let t=0;t<216;t++){let s=e[t/36%6|0],r=e[t/6%6|0],n=e[t%6];i.push({css:Ut.toCss(s,r,n),rgba:Ut.toRgba(s,r,n)})}for(let t=0;t<24;t++){let s=8+t*10;i.push({css:Ut.toCss(s,s,s),rgba:Ut.toRgba(s,s,s)})}return i})()),Ca=Ct.toColor("#ffffff"),fu=Ct.toColor("#000000"),gE=Ct.toColor("#ffffff"),OE=fu,Gc={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},Ote=Ca,Fy=class extends Xe{constructor(e){super(),this._optionsService=e,this._contrastCache=new mE,this._halfContrastCache=new mE,this._onChangeColors=this._register(new fe),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Ca,background:fu,cursor:gE,cursorAccent:OE,selectionForeground:void 0,selectionBackgroundTransparent:Gc,selectionBackgroundOpaque:vt.blend(fu,Gc),selectionInactiveBackgroundTransparent:Gc,selectionInactiveBackgroundOpaque:vt.blend(fu,Gc),scrollbarSliderBackground:vt.opacity(Ca,.2),scrollbarSliderHoverBackground:vt.opacity(Ca,.4),scrollbarSliderActiveBackground:vt.opacity(Ca,.5),overviewRulerBorder:Ca,ansi:ei.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=ot(e.foreground,Ca),t.background=ot(e.background,fu),t.cursor=vt.blend(t.background,ot(e.cursor,gE)),t.cursorAccent=vt.blend(t.background,ot(e.cursorAccent,OE)),t.selectionBackgroundTransparent=ot(e.selectionBackground,Gc),t.selectionBackgroundOpaque=vt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ot(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=vt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ot(e.selectionForeground,cE):void 0,t.selectionForeground===cE&&(t.selectionForeground=void 0),vt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=vt.opacity(t.selectionBackgroundTransparent,.3)),vt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=vt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ot(e.scrollbarSliderBackground,vt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ot(e.scrollbarSliderHoverBackground,vt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ot(e.scrollbarSliderActiveBackground,vt.opacity(t.foreground,.5)),t.overviewRulerBorder=ot(e.overviewRulerBorder,Ote),t.ansi=ei.slice(),t.ansi[0]=ot(e.black,ei[0]),t.ansi[1]=ot(e.red,ei[1]),t.ansi[2]=ot(e.green,ei[2]),t.ansi[3]=ot(e.yellow,ei[3]),t.ansi[4]=ot(e.blue,ei[4]),t.ansi[5]=ot(e.magenta,ei[5]),t.ansi[6]=ot(e.cyan,ei[6]),t.ansi[7]=ot(e.white,ei[7]),t.ansi[8]=ot(e.brightBlack,ei[8]),t.ansi[9]=ot(e.brightRed,ei[9]),t.ansi[10]=ot(e.brightGreen,ei[10]),t.ansi[11]=ot(e.brightYellow,ei[11]),t.ansi[12]=ot(e.brightBlue,ei[12]),t.ansi[13]=ot(e.brightMagenta,ei[13]),t.ansi[14]=ot(e.brightCyan,ei[14]),t.ansi[15]=ot(e.brightWhite,ei[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)t.ansi[r+16]=ot(e.extendedAnsi[r],ei[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let 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()}}};Fy=Lt([Oe(0,ss)],Fy);function ot(i,e){if(i!==void 0)try{return Ct.toColor(i)}catch{}return e}var _te=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)}},vte=class{constructor(){this._services=new _te,this._services.set(qS,this)}setService(i,e){this._services.set(i,e)}getService(i){return this._services.get(i)}createInstance(i,...e){let t=fJ(i).sort((n,o)=>n.index-o.index),s=[];for(let n of t){let o=this._services.get(n.id);if(!o)throw new Error(`[createInstance] ${i.name} depends on UNKNOWN service ${n.id._id}.`);s.push(o)}let r=t.length>0?t[0].index:e.length;if(e.length!==r)throw new Error(`[createInstance] First service dependency of ${i.name} at position ${r+1} conflicts with ${e.length} static arguments`);return new i(...e,...s)}},yte={trace:0,debug:1,info:2,warn:3,error:4,off:5},bte="xterm.js: ",Gy=class extends Xe{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=yte[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?"":bte)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Gy=Lt([Oe(0,ss)],Gy);var _E=class extends Xe{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new fe),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new fe),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new fe),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 r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+s.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<s.length;r++)this._array[this._getCyclicIndex(e+r)]=s[r];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let r=this._length+s.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}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 n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let r=e+t+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ze=3,It=Object.freeze(new Af),Pp=0,Pv=2,du=class yD{constructor(e,t,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*ze);let r=t||lr.fromCharData([0,NB,1,0]);for(let n=0;n<e;++n)this.setCell(n,r);this.length=e}get(e){let t=this._data[e*ze+0],s=t&2097151;return[this._data[e*ze+1],t&2097152?this._combined[e]:s?$o(s):"",t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,t){this._data[e*ze+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*ze+0]=e|2097152|t[2]<<22):this._data[e*ze+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*ze+0]>>22}hasWidth(e){return this._data[e*ze+0]&12582912}getFg(e){return this._data[e*ze+1]}getBg(e){return this._data[e*ze+2]}hasContent(e){return this._data[e*ze+0]&4194303}getCodePoint(e){let t=this._data[e*ze+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*ze+0]&2097152}getString(e){let t=this._data[e*ze+0];return t&2097152?this._combined[e]:t&2097151?$o(t&2097151):""}isProtected(e){return this._data[e*ze+2]&536870912}loadCell(e,t){return Pp=e*ze,t.content=this._data[Pp+0],t.fg=this._data[Pp+1],t.bg=this._data[Pp+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*ze+0]=t.content,this._data[e*ze+1]=t.fg,this._data[e*ze+2]=t.bg}setCellFromCodepoint(e,t,s,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*ze+0]=t|s<<22,this._data[e*ze+1]=r.fg,this._data[e*ze+2]=r.bg}addCodepointToCell(e,t,s){let r=this._data[e*ze+0];r&2097152?this._combined[e]+=$o(t):r&2097151?(this._combined[e]=$o(r&2097151)+$o(t),r&=-2097152,r|=2097152):r=t|1<<22,s&&(r&=-12582913,r|=s<<22),this._data[e*ze+0]=r}insertCells(e,t,s){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),t<this.length-e){let r=new lr;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let n=0;n<t;++n)this.setCell(e+n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,t,s){if(e%=this.length,t<this.length-e){let r=new lr;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let n=this.length-t;n<this.length;++n)this.setCell(n,s)}else for(let r=e;r<this.length;++r)this.setCell(r,s);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,t,s,r=!1){if(r){for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,s);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,s),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,s);e<t&&e<this.length;)this.setCell(e++,s)}resize(e,t){if(e===this.length)return this._data.length*4*Pv<this._data.buffer.byteLength;let s=e*ze;if(e>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let r=new Uint32Array(s);r.set(this._data),this._data=r}for(let r=this.length;r<e;++r)this.setCell(r,t)}else{this._data=this._data.subarray(0,s);let r=Object.keys(this._combined);for(let o=0;o<r.length;o++){let l=parseInt(r[o],10);l>=e&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let o=0;o<n.length;o++){let l=parseInt(n[o],10);l>=e&&delete this._extendedAttrs[l]}}return this.length=e,s*4*Pv<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Pv<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,e);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,e)}copyFrom(e){this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let e=new yD(0);e._data=new Uint32Array(this._data),e.length=this.length;for(let t in this._combined)e._combined[t]=this._combined[t];for(let t in this._extendedAttrs)e._extendedAttrs[t]=this._extendedAttrs[t];return e.isWrapped=this.isWrapped,e}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ze+0]&4194303)return e+(this._data[e*ze+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*ze+0]&4194303||this._data[e*ze+2]&50331648)return e+(this._data[e*ze+0]>>22);return 0}copyCellsFrom(e,t,s,r,n){let o=e._data;if(n)for(let c=r-1;c>=0;c--){for(let u=0;u<ze;u++)this._data[(s+c)*ze+u]=o[(t+c)*ze+u];o[(t+c)*ze+2]&268435456&&(this._extendedAttrs[s+c]=e._extendedAttrs[t+c])}else for(let c=0;c<r;c++){for(let u=0;u<ze;u++)this._data[(s+c)*ze+u]=o[(t+c)*ze+u];o[(t+c)*ze+2]&268435456&&(this._extendedAttrs[s+c]=e._extendedAttrs[t+c])}let l=Object.keys(e._combined);for(let c=0;c<l.length;c++){let u=parseInt(l[c],10);u>=t&&(this._combined[u-t+s]=e._combined[u])}}translateToString(e,t,s,r){t=t??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;t<s;){let o=this._data[t*ze+0],l=o&2097151,c=o&2097152?this._combined[t]:l?$o(l):No;if(n+=c,r)for(let u=0;u<c.length;++u)r.push(t);t+=o>>22||1}return r&&r.push(t),n}};function Ste(i,e,t,s,r,n){let o=[];for(let l=0;l<i.length-1;l++){let c=l,u=i.get(++c);if(!u.isWrapped)continue;let d=[i.get(l)];for(;c<i.length&&u.isWrapped;)d.push(u),u=i.get(++c);if(!n&&s>=l&&s<c){l+=d.length-1;continue}let m=0,g=cf(d,m,e),_=1,y=0;for(;_<d.length;){let x=cf(d,_,e),w=x-y,k=t-g,C=Math.min(w,k);d[m].copyCellsFrom(d[_],y,g,C,!1),g+=C,g===t&&(m++,g=0),y+=C,y===x&&(_++,y=0),g===0&&m!==0&&d[m-1].getWidth(t-1)===2&&(d[m].copyCellsFrom(d[m-1],t-1,g++,1,!1),d[m-1].setCell(t-1,r))}d[m].replaceCells(g,t,r);let b=0;for(let x=d.length-1;x>0&&(x>m||d[x].getTrimmedLength()===0);x--)b++;b>0&&(o.push(l+d.length-b),o.push(b)),l+=d.length-1}return o}function xte(i,e){let t=[],s=0,r=e[s],n=0;for(let o=0;o<i.length;o++)if(r===o){let l=e[++s];i.onDeleteEmitter.fire({index:o-n,amount:l}),o+=l-1,n+=l,r=e[++s]}else t.push(o);return{layout:t,countRemoved:n}}function wte(i,e){let t=[];for(let s=0;s<e.length;s++)t.push(i.get(e[s]));for(let s=0;s<t.length;s++)i.set(s,t[s]);i.length=e.length}function Cte(i,e,t){let s=[],r=i.map((c,u)=>cf(i,u,e)).reduce((c,u)=>c+u),n=0,o=0,l=0;for(;l<r;){if(r-l<t){s.push(r-l);break}n+=t;let c=cf(i,o,e);n>c&&(n-=c,o++);let u=i[o].getWidth(n-1)===2;u&&n--;let d=u?t-1:t;s.push(d),l+=d}return s}function cf(i,e,t){if(e===i.length-1)return i[e].getTrimmedLength();let s=!i[e].hasContent(t-1)&&i[e].getWidth(t-1)===1,r=i[e+1].getWidth(0)===2;return s&&r?t-1:t}var bD=class SD{constructor(e){this.line=e,this.isDisposed=!1,this._disposables=[],this._id=SD._nextId++,this._onDispose=this.register(new fe),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ua(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};bD._nextId=1;var kte=bD,ni={},ka=ni.B;ni[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ni.A={"#":"£"};ni.B=void 0;ni[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ni.C=ni[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ni.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ni.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ni.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ni.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ni.E=ni[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ni.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ni.H=ni[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ni["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var vE=4294967295,yE=class{constructor(i,e,t){this._hasScrollback=i,this._optionsService=e,this._bufferService=t,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=It.clone(),this.savedCharset=ka,this.markers=[],this._nullCell=lr.fromCharData([0,NB,1,0]),this._whitespaceCell=lr.fromCharData([0,No,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new tg,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new _E(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(i){return i?(this._nullCell.fg=i.fg,this._nullCell.bg=i.bg,this._nullCell.extended=i.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Gm),this._nullCell}getWhitespaceCell(i){return i?(this._whitespaceCell.fg=i.fg,this._whitespaceCell.bg=i.bg,this._whitespaceCell.extended=i.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Gm),this._whitespaceCell}getBlankLine(i,e){return new du(this._bufferService.cols,this.getNullCell(i),e)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let i=this.ybase+this.y-this.ydisp;return i>=0&&i<this._rows}_getCorrectBufferLength(i){if(!this._hasScrollback)return i;let e=i+this._optionsService.rawOptions.scrollback;return e>vE?vE:e}fillViewportRows(i){if(this.lines.length===0){i===void 0&&(i=It);let e=this._rows;for(;e--;)this.lines.push(this.getBlankLine(i))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new _E(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(i,e){let t=this.getNullCell(It),s=0,r=this._getCorrectBufferLength(e);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<i)for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(i,t);let n=0;if(this._rows<e)for(let o=this._rows;o<e;o++)this.lines.length<e+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new du(i,t)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new du(i,t)));else for(let o=this._rows;o>e;o--)this.lines.length>e+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let o=this.lines.length-r;o>0&&(this.lines.trimStart(o),this.ybase=Math.max(this.ybase-o,0),this.ydisp=Math.max(this.ydisp-o,0),this.savedY=Math.max(this.savedY-o,0)),this.lines.maxLength=r}this.x=Math.min(this.x,i-1),this.y=Math.min(this.y,e-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,i-1),this.scrollTop=0}if(this.scrollBottom=e-1,this._isReflowEnabled&&(this._reflow(i,e),this._cols>i))for(let n=0;n<this.lines.length;n++)s+=+this.lines.get(n).resize(i,t);this._cols=i,this._rows=e,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let i=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,i=!1);let e=0;for(;this._memoryCleanupPosition<this.lines.length;)if(e+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),e>100)return!0;return i}get _isReflowEnabled(){let i=this._optionsService.rawOptions.windowsPty;return i&&i.buildNumber?this._hasScrollback&&i.backend==="conpty"&&i.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(i,e){this._cols!==i&&(i>this._cols?this._reflowLarger(i,e):this._reflowSmaller(i,e))}_reflowLarger(i,e){let t=this._optionsService.rawOptions.reflowCursorLine,s=Ste(this.lines,this._cols,i,this.ybase+this.y,this.getNullCell(It),t);if(s.length>0){let r=xte(this.lines,s);wte(this.lines,r.layout),this._reflowLargerAdjustViewport(i,e,r.countRemoved)}}_reflowLargerAdjustViewport(i,e,t){let s=this.getNullCell(It),r=t;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<e&&this.lines.push(new du(i,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-t,0)}_reflowSmaller(i,e){let t=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(It),r=[],n=0;for(let o=this.lines.length-1;o>=0;o--){let l=this.lines.get(o);if(!l||!l.isWrapped&&l.getTrimmedLength()<=i)continue;let c=[l];for(;l.isWrapped&&o>0;)l=this.lines.get(--o),c.unshift(l);if(!t){let C=this.ybase+this.y;if(C>=o&&C<o+c.length)continue}let u=c[c.length-1].getTrimmedLength(),d=Cte(c,this._cols,i),m=d.length-c.length,g;this.ybase===0&&this.y!==this.lines.length-1?g=Math.max(0,this.y-this.lines.maxLength+m):g=Math.max(0,this.lines.length-this.lines.maxLength+m);let _=[];for(let C=0;C<m;C++){let A=this.getBlankLine(It,!0);_.push(A)}_.length>0&&(r.push({start:o+c.length+n,newLines:_}),n+=_.length),c.push(..._);let y=d.length-1,b=d[y];b===0&&(y--,b=d[y]);let x=c.length-m-1,w=u;for(;x>=0;){let C=Math.min(w,b);if(c[y]===void 0)break;if(c[y].copyCellsFrom(c[x],w-C,b-C,C,!0),b-=C,b===0&&(y--,b=d[y]),w-=C,w===0){x--;let A=Math.max(x,0);w=cf(c,A,this._cols)}}for(let C=0;C<c.length;C++)d[C]<i&&c[C].setCell(d[C],s);let k=m-g;for(;k-- >0;)this.ybase===0?this.y<e-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-e&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+m,this.ybase+e-1)}if(r.length>0){let o=[],l=[];for(let b=0;b<this.lines.length;b++)l.push(this.lines.get(b));let c=this.lines.length,u=c-1,d=0,m=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let g=0;for(let b=Math.min(this.lines.maxLength-1,c+n-1);b>=0;b--)if(m&&m.start>u+g){for(let x=m.newLines.length-1;x>=0;x--)this.lines.set(b--,m.newLines[x]);b++,o.push({index:u+1,amount:m.newLines.length}),g+=m.newLines.length,m=r[++d]}else this.lines.set(b,l[u--]);let _=0;for(let b=o.length-1;b>=0;b--)o[b].index+=_,this.lines.onInsertEmitter.fire(o[b]),_+=o[b].amount;let y=Math.max(0,c+n-this.lines.maxLength);y>0&&this.lines.onTrimEmitter.fire(y)}}translateBufferLineToString(i,e,t=0,s){let r=this.lines.get(i);return r?r.translateToString(e,t,s):""}getWrappedRangeForLine(i){let e=i,t=i;for(;e>0&&this.lines.get(e).isWrapped;)e--;for(;t+1<this.lines.length&&this.lines.get(t+1).isWrapped;)t++;return{first:e,last:t}}setupTabStops(i){for(i!=null?this.tabs[i]||(i=this.prevStop(i)):(this.tabs={},i=0);i<this._cols;i+=this._optionsService.rawOptions.tabStopWidth)this.tabs[i]=!0}prevStop(i){for(i==null&&(i=this.x);!this.tabs[--i]&&i>0;);return i>=this._cols?this._cols-1:i<0?0:i}nextStop(i){for(i==null&&(i=this.x);!this.tabs[++i]&&i<this._cols;);return i>=this._cols?this._cols-1:i<0?0:i}clearMarkers(i){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].line===i&&(this.markers[e].dispose(),this.markers.splice(e--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].dispose();this.markers.length=0,this._isClearing=!1}addMarker(i){let e=new kte(i);return this.markers.push(e),e.register(this.lines.onTrim(t=>{e.line-=t,e.line<0&&e.dispose()})),e.register(this.lines.onInsert(t=>{e.line>=t.index&&(e.line+=t.amount)})),e.register(this.lines.onDelete(t=>{e.line>=t.index&&e.line<t.index+t.amount&&e.dispose(),e.line>t.index&&(e.line-=t.amount)})),e.register(e.onDispose(()=>this._removeMarker(e))),e}_removeMarker(i){this._isClearing||this.markers.splice(this.markers.indexOf(i),1)}},Tte=class extends Xe{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new fe),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 yE(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new yE(!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)}},xD=2,wD=1,Ky=class extends Xe{constructor(i){super(),this.isUserScrolling=!1,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this.cols=Math.max(i.rawOptions.cols||0,xD),this.rows=Math.max(i.rawOptions.rows||0,wD),this.buffers=this._register(new Tte(i,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(i,e){let t=this.cols!==i,s=this.rows!==e;this.cols=i,this.rows=e,this.buffers.resize(i,e),this._onResize.fire({cols:i,rows:e,colsChanged:t,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(i,e=!1){let t=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==i.fg||s.getBg(0)!==i.bg)&&(s=t.getBlankLine(i,e),this._cachedBlankLine=s),s.isWrapped=e;let r=t.ybase+t.scrollTop,n=t.ybase+t.scrollBottom;if(t.scrollTop===0){let o=t.lines.isFull;n===t.lines.length-1?o?t.lines.recycle().copyFrom(s):t.lines.push(s.clone()):t.lines.splice(n+1,0,s.clone()),o?this.isUserScrolling&&(t.ydisp=Math.max(t.ydisp-1,0)):(t.ybase++,this.isUserScrolling||t.ydisp++)}else{let o=n-r+1;t.lines.shiftElements(r+1,o-1,-1),t.lines.set(n,s.clone())}this.isUserScrolling||(t.ydisp=t.ybase),this._onScroll.fire(t.ydisp)}scrollLines(i,e){let t=this.buffer;if(i<0){if(t.ydisp===0)return;this.isUserScrolling=!0}else i+t.ydisp>=t.ybase&&(this.isUserScrolling=!1);let s=t.ydisp;t.ydisp=Math.max(Math.min(t.ydisp+i,t.ybase),0),s!==t.ydisp&&(e||this._onScroll.fire(t.ydisp))}};Ky=Lt([Oe(0,ss)],Ky);var Vl={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:eg,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Ate=["normal","bold","100","200","300","400","500","600","700","800","900"],Mte=class extends Xe{constructor(e){super(),this._onOptionChange=this._register(new fe),this.onOptionChange=this._onOptionChange.event;let t={...Vl};for(let s in e)if(s in t)try{let r=e[s];t[s]=this._sanitizeAndValidateOption(s,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(xt(()=>{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 Vl))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,r)=>{if(!(s in Vl))throw new Error(`No option with key "${s}"`);r=this._sanitizeAndValidateOption(s,r),this.rawOptions[s]!==r&&(this.rawOptions[s]=r,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Vl[e]),!Ete(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Vl[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=Ate.includes(t)?t:Vl[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function Ete(i){return i==="block"||i==="underline"||i==="bar"}function pu(i,e=5){if(typeof i!="object")return i;let t=Array.isArray(i)?[]:{};for(let s in i)t[s]=e<=1?i[s]:i[s]&&pu(i[s],e-1);return t}var bE=Object.freeze({insertMode:!1}),SE=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Jy=class extends Xe{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 fe),this.onData=this._onData.event,this._onUserInput=this._register(new fe),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new fe),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=pu(bE),this.decPrivateModes=pu(SE)}reset(){this.modes=pu(bE),this.decPrivateModes=pu(SE)}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(r=>r.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))}};Jy=Lt([Oe(0,is),Oe(1,IB),Oe(2,ss)],Jy);var xE={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:i=>i.button===4||i.action!==1?!1:(i.ctrl=!1,i.alt=!1,i.shift=!1,!0)},VT200:{events:19,restrict:i=>i.action!==32},DRAG:{events:23,restrict:i=>!(i.action===32&&i.button===3)},ANY:{events:31,restrict:i=>!0}};function Qv(i,e){let t=(i.ctrl?16:0)|(i.shift?4:0)|(i.alt?8:0);return i.button===4?(t|=64,t|=i.action):(t|=i.button&3,i.button&4&&(t|=64),i.button&8&&(t|=128),i.action===32?t|=32:i.action===0&&!e&&(t|=3)),t}var Rv=String.fromCharCode,wE={DEFAULT:i=>{let e=[Qv(i,!1)+32,i.col+32,i.row+32];return e[0]>255||e[1]>255||e[2]>255?"":`\x1B[M${Rv(e[0])}${Rv(e[1])}${Rv(e[2])}`},SGR:i=>{let e=i.action===0&&i.button!==4?"m":"M";return`\x1B[<${Qv(i,!0)};${i.col};${i.row}${e}`},SGR_PIXELS:i=>{let e=i.action===0&&i.button!==4?"m":"M";return`\x1B[<${Qv(i,!0)};${i.x};${i.y}${e}`}},eb=class extends Xe{constructor(i,e,t){super(),this._bufferService=i,this._coreService=e,this._optionsService=t,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new fe),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(xE))this.addProtocol(s,xE[s]);for(let s of Object.keys(wE))this.addEncoding(s,wE[s]);this.reset()}addProtocol(i,e){this._protocols[i]=e}addEncoding(i,e){this._encodings[i]=e}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(i){if(!this._protocols[i])throw new Error(`unknown protocol "${i}"`);this._activeProtocol=i,this._onProtocolChange.fire(this._protocols[i].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(i){if(!this._encodings[i])throw new Error(`unknown encoding "${i}"`);this._activeEncoding=i}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(i,e,t){if(i.deltaY===0||i.shiftKey||e===void 0||t===void 0)return 0;let s=e/t,r=this._applyScrollModifier(i.deltaY,i);return i.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=s+0,Math.abs(i.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):i.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(i,e){return e.altKey||e.ctrlKey||e.shiftKey?i*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:i*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(i){if(i.col<0||i.col>=this._bufferService.cols||i.row<0||i.row>=this._bufferService.rows||i.button===4&&i.action===32||i.button===3&&i.action!==32||i.button!==4&&(i.action===2||i.action===3)||(i.col++,i.row++,i.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,i,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(i))return!1;let e=this._encodings[this._activeEncoding](i);return e&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(e):this._coreService.triggerDataEvent(e,!0)),this._lastEvent=i,!0}explainEvents(i){return{down:!!(i&1),up:!!(i&2),drag:!!(i&4),move:!!(i&8),wheel:!!(i&16)}}_equalEvents(i,e,t){if(t){if(i.x!==e.x||i.y!==e.y)return!1}else if(i.col!==e.col||i.row!==e.row)return!1;return!(i.button!==e.button||i.action!==e.action||i.ctrl!==e.ctrl||i.alt!==e.alt||i.shift!==e.shift)}};eb=Lt([Oe(0,is),Oe(1,Ja),Oe(2,ss)],eb);var Lv=[[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]],Pte=[[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]],ti;function Qte(i,e){let t=0,s=e.length-1,r;if(i<e[0][0]||i>e[s][1])return!1;for(;s>=t;)if(r=t+s>>1,i>e[r][1])t=r+1;else if(i<e[r][0])s=r-1;else return!0;return!1}var Rte=class{constructor(){if(this.version="6",!ti){ti=new Uint8Array(65536),ti.fill(1),ti[0]=0,ti.fill(0,1,32),ti.fill(0,127,160),ti.fill(2,4352,4448),ti[9001]=2,ti[9002]=2,ti.fill(2,11904,42192),ti[12351]=1,ti.fill(2,44032,55204),ti.fill(2,63744,64256),ti.fill(2,65040,65050),ti.fill(2,65072,65136),ti.fill(2,65280,65377),ti.fill(2,65504,65511);for(let e=0;e<Lv.length;++e)ti.fill(0,Lv[e][0],Lv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ti[e]:Qte(e,Pte)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),r=s===0&&t!==0;if(r){let n=Ba.extractWidth(t);n===0?r=!1:n>s&&(s=n)}return Ba.createPropertyValue(0,s,r)}},Ba=class nm{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new fe,this.onChange=this._onChange.event;let e=new Rte;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(e&1)!==0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,s=!1){return(e&16777215)<<3|(t&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw new Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(e){let t=0,s=0,r=e.length;for(let n=0;n<r;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=r)return t+this.wcwidth(o);let u=e.charCodeAt(n);56320<=u&&u<=57343?o=(o-55296)*1024+u-56320+65536:t+=this.wcwidth(u)}let l=this.charProperties(o,s),c=nm.extractWidth(l);nm.extractShouldJoin(l)&&(c-=nm.extractWidth(s)),t+=c,s=l}return t}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},Lte=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function CE(i){var s;let e=(s=i.buffer.lines.get(i.buffer.ybase+i.buffer.y-1))==null?void 0:s.get(i.cols-1),t=i.buffer.lines.get(i.buffer.ybase+i.buffer.y);t&&e&&(t.isWrapped=e[3]!==0&&e[3]!==32)}var Kc=2147483647,$te=256,CD=class tb{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>$te)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(e){let t=new tb;if(!e.length)return t;for(let s=Array.isArray(e[0])?1:0;s<e.length;++s){let r=e[s];if(Array.isArray(r))for(let n=0;n<r.length;++n)t.addSubParam(r[n]);else t.addParam(r)}return t}clone(){let e=new tb(this.maxLength,this.maxSubParamsLength);return e.params.set(this.params),e.length=this.length,e._subParams.set(this._subParams),e._subParamsLength=this._subParamsLength,e._subParamsIdx.set(this._subParamsIdx),e._rejectDigits=this._rejectDigits,e._rejectSubDigits=this._rejectSubDigits,e._digitIsSub=this._digitIsSub,e}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>Kc?Kc:e}addSubParam(e){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>Kc?Kc:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,s=this._subParamsIdx[e]&255;return s-t>0?this._subParams.subarray(t,s):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let s=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-s>0&&(e[t]=this._subParams.slice(s,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[t-1];s[t-1]=~r?Math.min(r*10+e,Kc):e}},Jc=[],Bte=class{constructor(){this._state=0,this._active=Jc,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 r=s.indexOf(t);r!==-1&&s.splice(r,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=Jc}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=Jc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Jc,!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",Sg(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].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 r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-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,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].end(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=Jc,this._id=-1,this._state=0}}},Rs=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+=Sg(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}},eu=[],Dte=class{constructor(){this._handlers=Object.create(null),this._active=eu,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=eu}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let r=s.indexOf(t);r!==-1&&s.splice(r,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=eu,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||eu,!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",Sg(e,t,s));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;r>=0&&(s=this._active[r].unhook(e),s!==!0);r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if(s=this._active[r].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}this._active=eu,this._ident=0}},mu=new CD;mu.addParam(0);var kE=class{constructor(i){this._handler=i,this._data="",this._params=mu,this._hitLimit=!1}hook(i){this._params=i.length>1||i.params[0]?i.clone():mu,this._data="",this._hitLimit=!1}put(i,e,t){this._hitLimit||(this._data+=Sg(i,e,t),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(i){let e=!1;if(this._hitLimit)e=!1;else if(i&&(e=this._handler(this._data,this._params),e instanceof Promise))return e.then(t=>(this._params=mu,this._data="",this._hitLimit=!1,t));return this._params=mu,this._data="",this._hitLimit=!1,e}},zte=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,r){this.table[t<<8|e]=s<<4|r}addMany(e,t,s,r){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|r}},Js=160,Nte=(function(){let i=new zte(4095),e=Array.apply(null,Array(256)).map((l,c)=>c),t=(l,c)=>e.slice(l,c),s=t(32,127),r=t(0,24);r.push(25),r.push.apply(r,t(28,32));let n=t(0,14),o;i.setDefault(1,0),i.addMany(s,0,2,0);for(o in n)i.addMany([24,26,153,154],o,3,0),i.addMany(t(128,144),o,3,0),i.addMany(t(144,152),o,3,0),i.add(156,o,0,0),i.add(27,o,11,1),i.add(157,o,4,8),i.addMany([152,158,159],o,0,7),i.add(155,o,11,3),i.add(144,o,11,9);return i.addMany(r,0,3,0),i.addMany(r,1,3,1),i.add(127,1,0,1),i.addMany(r,8,0,8),i.addMany(r,3,3,3),i.add(127,3,0,3),i.addMany(r,4,3,4),i.add(127,4,0,4),i.addMany(r,6,3,6),i.addMany(r,5,3,5),i.add(127,5,0,5),i.addMany(r,2,3,2),i.add(127,2,0,2),i.add(93,1,4,8),i.addMany(s,8,5,8),i.add(127,8,5,8),i.addMany([156,27,24,26,7],8,6,0),i.addMany(t(28,32),8,0,8),i.addMany([88,94,95],1,0,7),i.addMany(s,7,0,7),i.addMany(r,7,0,7),i.add(156,7,0,0),i.add(127,7,0,7),i.add(91,1,11,3),i.addMany(t(64,127),3,7,0),i.addMany(t(48,60),3,8,4),i.addMany([60,61,62,63],3,9,4),i.addMany(t(48,60),4,8,4),i.addMany(t(64,127),4,7,0),i.addMany([60,61,62,63],4,0,6),i.addMany(t(32,64),6,0,6),i.add(127,6,0,6),i.addMany(t(64,127),6,0,0),i.addMany(t(32,48),3,9,5),i.addMany(t(32,48),5,9,5),i.addMany(t(48,64),5,0,6),i.addMany(t(64,127),5,7,0),i.addMany(t(32,48),4,9,5),i.addMany(t(32,48),1,9,2),i.addMany(t(32,48),2,9,2),i.addMany(t(48,127),2,10,0),i.addMany(t(48,80),1,10,0),i.addMany(t(81,88),1,10,0),i.addMany([89,90,92],1,10,0),i.addMany(t(96,127),1,10,0),i.add(80,1,11,9),i.addMany(r,9,0,9),i.add(127,9,0,9),i.addMany(t(28,32),9,0,9),i.addMany(t(32,48),9,9,12),i.addMany(t(48,60),9,8,10),i.addMany([60,61,62,63],9,9,10),i.addMany(r,11,0,11),i.addMany(t(32,128),11,0,11),i.addMany(t(28,32),11,0,11),i.addMany(r,10,0,10),i.add(127,10,0,10),i.addMany(t(28,32),10,0,10),i.addMany(t(48,60),10,8,10),i.addMany([60,61,62,63],10,0,11),i.addMany(t(32,48),10,9,12),i.addMany(r,12,0,12),i.add(127,12,0,12),i.addMany(t(28,32),12,0,12),i.addMany(t(32,48),12,9,12),i.addMany(t(48,64),12,0,11),i.addMany(t(64,127),12,12,13),i.addMany(t(64,127),10,12,13),i.addMany(t(64,127),9,12,13),i.addMany(r,13,13,13),i.addMany(s,13,13,13),i.add(127,13,0,13),i.addMany([27,156,24,26],13,14,0),i.add(Js,0,2,0),i.add(Js,8,5,8),i.add(Js,6,0,6),i.add(Js,11,0,11),i.add(Js,13,13,13),i})(),Xte=class extends Xe{constructor(e=Nte){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 CD,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,r)=>{},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(xt(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Bte),this._dcsParser=this._register(new Dte),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 n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);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 r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=r,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 r=this._escHandlers[s];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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 r=this._csiHandlers[s];return r.push(t),{dispose:()=>{let n=r.indexOf(t);n!==-1&&r.splice(n,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,r,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=n}parse(e,t,s){let r=0,n=0,o=0,l;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 c=this._parseStack.handlers,u=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&u>-1){for(;u>=0&&(l=c[u](this._params),l!==!0);u--)if(l instanceof Promise)return this._parseStack.handlerPos=u,l}this._parseStack.handlers=[];break;case 4:if(s===!1&&u>-1){for(;u>=0&&(l=c[u](),l!==!0);u--)if(l instanceof Promise)return this._parseStack.handlerPos=u,l}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],l=this._dcsParser.unhook(r!==24&&r!==26,s),l)return l;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],l=this._oscParser.end(r!==24&&r!==26,s),l)return l;r===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 c=o;c<t;++c){switch(r=e[c],n=this._transitions.table[this.currentState<<8|(r<160?r:Js)],n>>4){case 2:for(let _=c+1;;++_){if(_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}if(++_>=t||(r=e[_])<32||r>126&&r<Js){this._printHandler(e,c,_),c=_-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let u=this._csiHandlers[this._collect<<8|r],d=u?u.length-1:-1;for(;d>=0&&(l=u[d](this._params),l!==!0);d--)if(l instanceof Promise)return this._preserveStack(3,u,d,n,c),l;d<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++c<t&&(r=e[c])>47&&r<60);c--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let m=this._escHandlers[this._collect<<8|r],g=m?m.length-1:-1;for(;g>=0&&(l=m[g](),l!==!0);g--)if(l instanceof Promise)return this._preserveStack(4,m,g,n,c),l;g<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let _=c+1;;++_)if(_>=t||(r=e[_])===24||r===26||r===27||r>127&&r<Js){this._dcsParser.put(e,c,_),c=_-1;break}break;case 14:if(l=this._dcsParser.unhook(r!==24&&r!==26),l)return this._preserveStack(6,[],0,n,c),l;r===27&&(n|=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 _=c+1;;_++)if(_>=t||(r=e[_])<32||r>127&&r<Js){this._oscParser.put(e,c,_),c=_-1;break}break;case 6:if(l=this._oscParser.end(r!==24&&r!==26),l)return this._preserveStack(5,[],0,n,c),l;r===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},Vte=/^([\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})$/,Zte=/^[\da-f]+$/;function TE(i){if(!i)return;let e=i.toLowerCase();if(e.indexOf("rgb:")===0){e=e.slice(4);let t=Vte.exec(e);if(t){let s=t[1]?15:t[4]?255:t[7]?4095:65535;return[Math.round(parseInt(t[1]||t[4]||t[7]||t[10],16)/s*255),Math.round(parseInt(t[2]||t[5]||t[8]||t[11],16)/s*255),Math.round(parseInt(t[3]||t[6]||t[9]||t[12],16)/s*255)]}}else if(e.indexOf("#")===0&&(e=e.slice(1),Zte.exec(e)&&[3,6,9,12].includes(e.length))){let t=e.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(e.slice(t*r,t*r+t),16);s[r]=t===1?n<<4:t===2?n:t===3?n>>4:n>>8}return s}}function $v(i,e){let t=i.toString(16),s=t.length<2?"0"+t:t;switch(e){case 4:return t[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function jte(i,e=16){let[t,s,r]=i;return`rgb:${$v(t,e)}/${$v(s,e)}/${$v(r,e)}`}var Ite={"(":0,")":1,"*":2,"+":3,"-":1,".":2},To=131072,AE=10;function ME(i,e){if(i>24)return e.setWinLines||!1;switch(i){case 1:return!!e.restoreWin;case 2:return!!e.minimizeWin;case 3:return!!e.setWinPosition;case 4:return!!e.setWinSizePixels;case 5:return!!e.raiseWin;case 6:return!!e.lowerWin;case 7:return!!e.refreshWin;case 8:return!!e.setWinSizeChars;case 9:return!!e.maximizeWin;case 10:return!!e.fullscreenWin;case 11:return!!e.getWinState;case 13:return!!e.getWinPosition;case 14:return!!e.getWinSizePixels;case 15:return!!e.getScreenSizePixels;case 16:return!!e.getCellSizePixels;case 18:return!!e.getWinSizeChars;case 19:return!!e.getScreenSizeChars;case 20:return!!e.getIconTitle;case 21:return!!e.getWinTitle;case 22:return!!e.pushTitle;case 23:return!!e.popTitle;case 24:return!!e.setWinLines}return!1}var EE=5e3,PE=0,qte=class extends Xe{constructor(i,e,t,s,r,n,o,l,c=new Xte){super(),this._bufferService=i,this._charsetService=e,this._coreService=t,this._logService=s,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=o,this._unicodeService=l,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new cJ,this._utf8Decoder=new uJ,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=It.clone(),this._eraseAttrDataInternal=It.clone(),this._onRequestBell=this._register(new fe),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new fe),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new fe),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new fe),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new fe),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new fe),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new fe),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new fe),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new fe),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new fe),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 ib(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(u=>this._activeBuffer=u.activeBuffer)),this._parser.setCsiHandlerFallback((u,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(u),params:d.toArray()})}),this._parser.setEscHandlerFallback(u=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(u)})}),this._parser.setExecuteHandlerFallback(u=>{this._logService.debug("Unknown EXECUTE code: ",{code:u})}),this._parser.setOscHandlerFallback((u,d,m)=>{this._logService.debug("Unknown OSC code: ",{identifier:u,action:d,data:m})}),this._parser.setDcsHandlerFallback((u,d,m)=>{d==="HOOK"&&(m=m.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(u),action:d,payload:m})}),this._parser.setPrintHandler((u,d,m)=>this.print(u,d,m)),this._parser.registerCsiHandler({final:"@"},u=>this.insertChars(u)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},u=>this.scrollLeft(u)),this._parser.registerCsiHandler({final:"A"},u=>this.cursorUp(u)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},u=>this.scrollRight(u)),this._parser.registerCsiHandler({final:"B"},u=>this.cursorDown(u)),this._parser.registerCsiHandler({final:"C"},u=>this.cursorForward(u)),this._parser.registerCsiHandler({final:"D"},u=>this.cursorBackward(u)),this._parser.registerCsiHandler({final:"E"},u=>this.cursorNextLine(u)),this._parser.registerCsiHandler({final:"F"},u=>this.cursorPrecedingLine(u)),this._parser.registerCsiHandler({final:"G"},u=>this.cursorCharAbsolute(u)),this._parser.registerCsiHandler({final:"H"},u=>this.cursorPosition(u)),this._parser.registerCsiHandler({final:"I"},u=>this.cursorForwardTab(u)),this._parser.registerCsiHandler({final:"J"},u=>this.eraseInDisplay(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},u=>this.eraseInDisplay(u,!0)),this._parser.registerCsiHandler({final:"K"},u=>this.eraseInLine(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},u=>this.eraseInLine(u,!0)),this._parser.registerCsiHandler({final:"L"},u=>this.insertLines(u)),this._parser.registerCsiHandler({final:"M"},u=>this.deleteLines(u)),this._parser.registerCsiHandler({final:"P"},u=>this.deleteChars(u)),this._parser.registerCsiHandler({final:"S"},u=>this.scrollUp(u)),this._parser.registerCsiHandler({final:"T"},u=>this.scrollDown(u)),this._parser.registerCsiHandler({final:"X"},u=>this.eraseChars(u)),this._parser.registerCsiHandler({final:"Z"},u=>this.cursorBackwardTab(u)),this._parser.registerCsiHandler({final:"`"},u=>this.charPosAbsolute(u)),this._parser.registerCsiHandler({final:"a"},u=>this.hPositionRelative(u)),this._parser.registerCsiHandler({final:"b"},u=>this.repeatPrecedingCharacter(u)),this._parser.registerCsiHandler({final:"c"},u=>this.sendDeviceAttributesPrimary(u)),this._parser.registerCsiHandler({prefix:">",final:"c"},u=>this.sendDeviceAttributesSecondary(u)),this._parser.registerCsiHandler({final:"d"},u=>this.linePosAbsolute(u)),this._parser.registerCsiHandler({final:"e"},u=>this.vPositionRelative(u)),this._parser.registerCsiHandler({final:"f"},u=>this.hVPosition(u)),this._parser.registerCsiHandler({final:"g"},u=>this.tabClear(u)),this._parser.registerCsiHandler({final:"h"},u=>this.setMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"h"},u=>this.setModePrivate(u)),this._parser.registerCsiHandler({final:"l"},u=>this.resetMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"l"},u=>this.resetModePrivate(u)),this._parser.registerCsiHandler({final:"m"},u=>this.charAttributes(u)),this._parser.registerCsiHandler({final:"n"},u=>this.deviceStatus(u)),this._parser.registerCsiHandler({prefix:"?",final:"n"},u=>this.deviceStatusPrivate(u)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},u=>this.softReset(u)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},u=>this.setCursorStyle(u)),this._parser.registerCsiHandler({final:"r"},u=>this.setScrollRegion(u)),this._parser.registerCsiHandler({final:"s"},u=>this.saveCursor(u)),this._parser.registerCsiHandler({final:"t"},u=>this.windowOptions(u)),this._parser.registerCsiHandler({final:"u"},u=>this.restoreCursor(u)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},u=>this.insertColumns(u)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},u=>this.deleteColumns(u)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},u=>this.selectProtected(u)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},u=>this.requestMode(u,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},u=>this.requestMode(u,!1)),this._parser.setExecuteHandler(le.BEL,()=>this.bell()),this._parser.setExecuteHandler(le.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(le.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(le.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(le.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(le.BS,()=>this.backspace()),this._parser.setExecuteHandler(le.HT,()=>this.tab()),this._parser.setExecuteHandler(le.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(le.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(sm.IND,()=>this.index()),this._parser.setExecuteHandler(sm.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(sm.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Rs(u=>(this.setTitle(u),this.setIconName(u),!0))),this._parser.registerOscHandler(1,new Rs(u=>this.setIconName(u))),this._parser.registerOscHandler(2,new Rs(u=>this.setTitle(u))),this._parser.registerOscHandler(4,new Rs(u=>this.setOrReportIndexedColor(u))),this._parser.registerOscHandler(8,new Rs(u=>this.setHyperlink(u))),this._parser.registerOscHandler(10,new Rs(u=>this.setOrReportFgColor(u))),this._parser.registerOscHandler(11,new Rs(u=>this.setOrReportBgColor(u))),this._parser.registerOscHandler(12,new Rs(u=>this.setOrReportCursorColor(u))),this._parser.registerOscHandler(104,new Rs(u=>this.restoreIndexedColor(u))),this._parser.registerOscHandler(110,new Rs(u=>this.restoreFgColor(u))),this._parser.registerOscHandler(111,new Rs(u=>this.restoreBgColor(u))),this._parser.registerOscHandler(112,new Rs(u=>this.restoreCursorColor(u))),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 u in ni)this._parser.registerEscHandler({intermediates:"(",final:u},()=>this.selectCharset("("+u)),this._parser.registerEscHandler({intermediates:")",final:u},()=>this.selectCharset(")"+u)),this._parser.registerEscHandler({intermediates:"*",final:u},()=>this.selectCharset("*"+u)),this._parser.registerEscHandler({intermediates:"+",final:u},()=>this.selectCharset("+"+u)),this._parser.registerEscHandler({intermediates:"-",final:u},()=>this.selectCharset("-"+u)),this._parser.registerEscHandler({intermediates:".",final:u},()=>this.selectCharset("."+u)),this._parser.registerEscHandler({intermediates:"/",final:u},()=>this.selectCharset("/"+u));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(u=>(this._logService.error("Parsing error: ",u),u)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new kE((u,d)=>this.requestStatusString(u,d)))}getAttrData(){return this._curAttrData}_preserveStack(i,e,t,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=i,this._parseStack.cursorStartY=e,this._parseStack.decodedLength=t,this._parseStack.position=s}_logSlowResolvingAsync(i){this._logService.logLevel<=3&&Promise.race([i,new Promise((e,t)=>setTimeout(()=>t("#SLOW_TIMEOUT"),EE))]).catch(e=>{if(e!=="#SLOW_TIMEOUT")throw e;console.warn(`async parser handler taking longer than ${EE} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(i,e){let t,s=this._activeBuffer.x,r=this._activeBuffer.y,n=0,o=this._parseStack.paused;if(o){if(t=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,e))return this._logSlowResolvingAsync(t),t;s=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,i.length>To&&(n=this._parseStack.position+To)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof i=="string"?` "${i}"`:` "${Array.prototype.map.call(i,u=>String.fromCharCode(u)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof i=="string"?i.split("").map(u=>u.charCodeAt(0)):i),this._parseBuffer.length<i.length&&this._parseBuffer.length<To&&(this._parseBuffer=new Uint32Array(Math.min(i.length,To))),o||this._dirtyRowTracker.clearRange(),i.length>To)for(let u=n;u<i.length;u+=To){let d=u+To<i.length?u+To:i.length,m=typeof i=="string"?this._stringDecoder.decode(i.substring(u,d),this._parseBuffer):this._utf8Decoder.decode(i.subarray(u,d),this._parseBuffer);if(t=this._parser.parse(this._parseBuffer,m))return this._preserveStack(s,r,m,u),this._logSlowResolvingAsync(t),t}else if(!o){let u=typeof i=="string"?this._stringDecoder.decode(i,this._parseBuffer):this._utf8Decoder.decode(i,this._parseBuffer);if(t=this._parser.parse(this._parseBuffer,u))return this._preserveStack(s,r,u,0),this._logSlowResolvingAsync(t),t}(this._activeBuffer.x!==s||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(i,e,t){let s,r,n=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,u=this._coreService.modes.insertMode,d=this._curAttrData,m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&t-e>0&&m.getWidth(this._activeBuffer.x-1)===2&&m.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let g=this._parser.precedingJoinState;for(let _=e;_<t;++_){if(s=i[_],s<127&&n){let w=n[String.fromCharCode(s)];w&&(s=w.charCodeAt(0))}let y=this._unicodeService.charProperties(s,g);r=Ba.extractWidth(y);let b=Ba.extractShouldJoin(y),x=b?Ba.extractWidth(g):0;if(g=y,o&&this._onA11yChar.fire($o(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-x>l){if(c){let w=m,k=this._activeBuffer.x-x;for(this._activeBuffer.x=x,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),m=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&m instanceof du&&m.copyCellsFrom(w,k,0,x,!1);k<l;)w.setCellFromCodepoint(k++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(b&&this._activeBuffer.x){let w=m.getWidth(this._activeBuffer.x-1)?1:2;m.addCodepointToCell(this._activeBuffer.x-w,s,r);for(let k=r-x;--k>=0;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(u&&(m.insertCells(this._activeBuffer.x,r-x,this._activeBuffer.getNullCell(d)),m.getWidth(l-1)===2&&m.setCellFromCodepoint(l-1,0,1,d)),m.setCellFromCodepoint(this._activeBuffer.x++,s,r,d),r>0)for(;--r;)m.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=g,this._activeBuffer.x<l&&t-e>0&&m.getWidth(this._activeBuffer.x)===0&&!m.hasContent(this._activeBuffer.x)&&m.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(i,e){return i.final==="t"&&!i.prefix&&!i.intermediates?this._parser.registerCsiHandler(i,t=>ME(t.params[0],this._optionsService.rawOptions.windowOptions)?e(t):!0):this._parser.registerCsiHandler(i,e)}registerDcsHandler(i,e){return this._parser.registerDcsHandler(i,new kE(e))}registerEscHandler(i,e){return this._parser.registerEscHandler(i,e)}registerOscHandler(i,e){return this._parser.registerOscHandler(i,new Rs(e))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var i;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&&((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&i.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 i=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-i),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(i=this._bufferService.cols-1){this._activeBuffer.x=Math.min(i,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(i,e){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=i,this._activeBuffer.y=this._activeBuffer.scrollTop+e):(this._activeBuffer.x=i,this._activeBuffer.y=e),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(i,e){this._restrictCursor(),this._setCursor(this._activeBuffer.x+i,this._activeBuffer.y+e)}cursorUp(i){let e=this._activeBuffer.y-this._activeBuffer.scrollTop;return e>=0?this._moveCursor(0,-Math.min(e,i.params[0]||1)):this._moveCursor(0,-(i.params[0]||1)),!0}cursorDown(i){let e=this._activeBuffer.scrollBottom-this._activeBuffer.y;return e>=0?this._moveCursor(0,Math.min(e,i.params[0]||1)):this._moveCursor(0,i.params[0]||1),!0}cursorForward(i){return this._moveCursor(i.params[0]||1,0),!0}cursorBackward(i){return this._moveCursor(-(i.params[0]||1),0),!0}cursorNextLine(i){return this.cursorDown(i),this._activeBuffer.x=0,!0}cursorPrecedingLine(i){return this.cursorUp(i),this._activeBuffer.x=0,!0}cursorCharAbsolute(i){return this._setCursor((i.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(i){return this._setCursor(i.length>=2?(i.params[1]||1)-1:0,(i.params[0]||1)-1),!0}charPosAbsolute(i){return this._setCursor((i.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(i){return this._moveCursor(i.params[0]||1,0),!0}linePosAbsolute(i){return this._setCursor(this._activeBuffer.x,(i.params[0]||1)-1),!0}vPositionRelative(i){return this._moveCursor(0,i.params[0]||1),!0}hVPosition(i){return this.cursorPosition(i),!0}tabClear(i){let e=i.params[0];return e===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:e===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(i){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=i.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(i){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=i.params[0]||1;for(;e--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(i){let e=i.params[0];return e===1&&(this._curAttrData.bg|=536870912),(e===2||e===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(i,e,t,s=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);n.replaceCells(e,t,this._activeBuffer.getNullCell(this._eraseAttrData()),r),s&&(n.isWrapped=!1)}_resetBufferLine(i,e=!1){let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);t&&(t.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),e),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+i),t.isWrapped=!1)}eraseInDisplay(i,e=!1){var s;this._restrictCursor(this._bufferService.cols);let t;switch(i.params[0]){case 0:for(t=this._activeBuffer.y,this._dirtyRowTracker.markDirty(t),this._eraseInBufferLine(t++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);t<this._bufferService.rows;t++)this._resetBufferLine(t,e);this._dirtyRowTracker.markDirty(t);break;case 1:for(t=this._activeBuffer.y,this._dirtyRowTracker.markDirty(t),this._eraseInBufferLine(t,0,this._activeBuffer.x+1,!0,e),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(t+1).isWrapped=!1);t--;)this._resetBufferLine(t,e);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(t=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,t-1);t--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t))!=null&&s.getTrimmedLength()););for(;t>=0;t--)this._bufferService.scroll(this._eraseAttrData())}else{for(t=this._bufferService.rows,this._dirtyRowTracker.markDirty(t-1);t--;)this._resetBufferLine(t,e);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(i,e=!1){switch(this._restrictCursor(this._bufferService.cols),i.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,e);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,e);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,e);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(i){this._restrictCursor();let e=i.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;e--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(t,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(i){this._restrictCursor();let e=i.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;e--;)this._activeBuffer.lines.splice(t,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(i){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.insertCells(this._activeBuffer.x,i.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(i){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.deleteCells(this._activeBuffer.x,i.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(i){let e=i.params[0]||1;for(;e--;)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(i){let e=i.params[0]||1;for(;e--;)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(It));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(0,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.insertCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(i){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let e=i.params[0]||1;for(let t=this._activeBuffer.scrollTop;t<=this._activeBuffer.scrollBottom;++t){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+t);s.deleteCells(this._activeBuffer.x,e,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(i){this._restrictCursor();let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return e&&(e.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(i.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(i){let e=this._parser.precedingJoinState;if(!e)return!0;let t=i.params[0]||1,s=Ba.extractWidth(e),r=this._activeBuffer.x-s,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),o=new Uint32Array(n.length*t),l=0;for(let u=0;u<n.length;){let d=n.codePointAt(u)||0;o[l++]=d,u+=d>65535?2:1}let c=l;for(let u=1;u<t;++u)o.copyWithin(c,0,l),c+=l;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(i){return i.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(le.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(le.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(i){return i.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(le.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(le.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(i.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(le.ESC+"[>83;40003;0c")),!0}_is(i){return(this._optionsService.rawOptions.termName+"").indexOf(i)===0}setMode(i){for(let e=0;e<i.length;e++)switch(i.params[e]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(i){for(let e=0;e<i.length;e++)switch(i.params[e]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ka),this._charsetService.setgCharset(1,ka),this._charsetService.setgCharset(2,ka),this._charsetService.setgCharset(3,ka);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(i){for(let e=0;e<i.length;e++)switch(i.params[e]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(i){for(let e=0;e<i.length;e++)switch(i.params[e]){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(),i.params[e]===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(i,e){(b=>(b[b.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",b[b.SET=1]="SET",b[b.RESET=2]="RESET",b[b.PERMANENTLY_SET=3]="PERMANENTLY_SET",b[b.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(t={}));let s=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,o=this._coreService,{buffers:l,cols:c}=this._bufferService,{active:u,alt:d}=l,m=this._optionsService.rawOptions,g=(b,x)=>(o.triggerDataEvent(`${le.ESC}[${e?"":"?"}${b};${x}$y`),!0),_=b=>b?1:2,y=i.params[0];return e?y===2?g(y,4):y===4?g(y,_(o.modes.insertMode)):y===12?g(y,3):y===20?g(y,_(m.convertEol)):g(y,0):y===1?g(y,_(s.applicationCursorKeys)):y===3?g(y,m.windowOptions.setWinLines?c===80?2:c===132?1:0:0):y===6?g(y,_(s.origin)):y===7?g(y,_(s.wraparound)):y===8?g(y,3):y===9?g(y,_(r==="X10")):y===12?g(y,_(m.cursorBlink)):y===25?g(y,_(!o.isCursorHidden)):y===45?g(y,_(s.reverseWraparound)):y===66?g(y,_(s.applicationKeypad)):y===67?g(y,4):y===1e3?g(y,_(r==="VT200")):y===1002?g(y,_(r==="DRAG")):y===1003?g(y,_(r==="ANY")):y===1004?g(y,_(s.sendFocus)):y===1005?g(y,4):y===1006?g(y,_(n==="SGR")):y===1015?g(y,4):y===1016?g(y,_(n==="SGR_PIXELS")):y===1048?g(y,1):y===47||y===1047||y===1049?g(y,_(u===d)):y===2004?g(y,_(s.bracketedPasteMode)):y===2026?g(y,_(s.synchronizedOutput)):g(y,0)}_updateAttrColor(i,e,t,s,r){return e===2?(i|=50331648,i&=-16777216,i|=Af.fromColorRGB([t,s,r])):e===5&&(i&=-50331904,i|=33554432|t&255),i}_extractColor(i,e,t){let s=[0,0,-1,0,0,0],r=0,n=0;do{if(s[n+r]=i.params[e+n],i.hasSubParams(e+n)){let o=i.getSubParams(e+n),l=0;do s[1]===5&&(r=1),s[n+l+1+r]=o[l];while(++l<o.length&&l+n+1+r<s.length);break}if(s[1]===5&&n+r>=2||s[1]===2&&n+r>=5)break;s[1]&&(r=1)}while(++n+e<i.length&&n+r<s.length);for(let o=2;o<s.length;++o)s[o]===-1&&(s[o]=0);switch(s[0]){case 38:t.fg=this._updateAttrColor(t.fg,s[1],s[3],s[4],s[5]);break;case 48:t.bg=this._updateAttrColor(t.bg,s[1],s[3],s[4],s[5]);break;case 58:t.extended=t.extended.clone(),t.extended.underlineColor=this._updateAttrColor(t.extended.underlineColor,s[1],s[3],s[4],s[5])}return n}_processUnderline(i,e){e.extended=e.extended.clone(),(!~i||i>5)&&(i=1),e.extended.underlineStyle=i,e.fg|=268435456,i===0&&(e.fg&=-268435457),e.updateExtended()}_processSGR0(i){i.fg=It.fg,i.bg=It.bg,i.extended=i.extended.clone(),i.extended.underlineStyle=0,i.extended.underlineColor&=-67108864,i.updateExtended()}charAttributes(i){if(i.length===1&&i.params[0]===0)return this._processSGR0(this._curAttrData),!0;let e=i.length,t,s=this._curAttrData;for(let r=0;r<e;r++)t=i.params[r],t>=30&&t<=37?(s.fg&=-50331904,s.fg|=16777216|t-30):t>=40&&t<=47?(s.bg&=-50331904,s.bg|=16777216|t-40):t>=90&&t<=97?(s.fg&=-50331904,s.fg|=16777216|t-90|8):t>=100&&t<=107?(s.bg&=-50331904,s.bg|=16777216|t-100|8):t===0?this._processSGR0(s):t===1?s.fg|=134217728:t===3?s.bg|=67108864:t===4?(s.fg|=268435456,this._processUnderline(i.hasSubParams(r)?i.getSubParams(r)[0]:1,s)):t===5?s.fg|=536870912:t===7?s.fg|=67108864:t===8?s.fg|=1073741824:t===9?s.fg|=2147483648:t===2?s.bg|=134217728:t===21?this._processUnderline(2,s):t===22?(s.fg&=-134217729,s.bg&=-134217729):t===23?s.bg&=-67108865:t===24?(s.fg&=-268435457,this._processUnderline(0,s)):t===25?s.fg&=-536870913:t===27?s.fg&=-67108865:t===28?s.fg&=-1073741825:t===29?s.fg&=2147483647:t===39?(s.fg&=-67108864,s.fg|=It.fg&16777215):t===49?(s.bg&=-67108864,s.bg|=It.bg&16777215):t===38||t===48||t===58?r+=this._extractColor(i,r,s):t===53?s.bg|=1073741824:t===55?s.bg&=-1073741825:t===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):t===100?(s.fg&=-67108864,s.fg|=It.fg&16777215,s.bg&=-67108864,s.bg|=It.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",t);return!0}deviceStatus(i){switch(i.params[0]){case 5:this._coreService.triggerDataEvent(`${le.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${le.ESC}[${e};${t}R`);break}return!0}deviceStatusPrivate(i){switch(i.params[0]){case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${le.ESC}[?${e};${t}R`);break}return!0}softReset(i){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=It.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(i){let e=i.length===0?1:i.params[0];if(e===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(e){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 t=e%2===1;this._coreService.decPrivateModes.cursorBlink=t}return!0}setScrollRegion(i){let e=i.params[0]||1,t;return(i.length<2||(t=i.params[1])>this._bufferService.rows||t===0)&&(t=this._bufferService.rows),t>e&&(this._activeBuffer.scrollTop=e-1,this._activeBuffer.scrollBottom=t-1,this._setCursor(0,0)),!0}windowOptions(i){if(!ME(i.params[0],this._optionsService.rawOptions.windowOptions))return!0;let e=i.length>1?i.params[1]:0;switch(i.params[0]){case 14:e!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${le.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(e===0||e===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>AE&&this._windowTitleStack.shift()),(e===0||e===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>AE&&this._iconNameStack.shift());break;case 23:(e===0||e===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(e===0||e===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(i){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(i){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(i){return this._windowTitle=i,this._onTitleChange.fire(i),!0}setIconName(i){return this._iconName=i,!0}setOrReportIndexedColor(i){let e=[],t=i.split(";");for(;t.length>1;){let s=t.shift(),r=t.shift();if(/^\d+$/.exec(s)){let n=parseInt(s);if(QE(n))if(r==="?")e.push({type:0,index:n});else{let o=TE(r);o&&e.push({type:1,index:n,color:o})}}}return e.length&&this._onColor.fire(e),!0}setHyperlink(i){let e=i.indexOf(";");if(e===-1)return!0;let t=i.slice(0,e).trim(),s=i.slice(e+1);return s?this._createHyperlink(t,s):t.trim()?!1:this._finishHyperlink()}_createHyperlink(i,e){this._getCurrentLinkId()&&this._finishHyperlink();let t=i.split(":"),s,r=t.findIndex(n=>n.startsWith("id="));return r!==-1&&(s=t[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:e}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(i,e){let t=i.split(";");for(let s=0;s<t.length&&!(e>=this._specialColors.length);++s,++e)if(t[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[e]}]);else{let r=TE(t[s]);r&&this._onColor.fire([{type:1,index:this._specialColors[e],color:r}])}return!0}setOrReportFgColor(i){return this._setOrReportSpecialColor(i,0)}setOrReportBgColor(i){return this._setOrReportSpecialColor(i,1)}setOrReportCursorColor(i){return this._setOrReportSpecialColor(i,2)}restoreIndexedColor(i){if(!i)return this._onColor.fire([{type:2}]),!0;let e=[],t=i.split(";");for(let s=0;s<t.length;++s)if(/^\d+$/.exec(t[s])){let r=parseInt(t[s]);QE(r)&&e.push({type:2,index:r})}return e.length&&this._onColor.fire(e),!0}restoreFgColor(i){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(i){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(i){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,ka),!0}selectCharset(i){return i.length!==2?(this.selectDefaultCharset(),!0):(i[0]==="/"||this._charsetService.setgCharset(Ite[i[0]],ni[i[1]]||ka),!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 i=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,i,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=It.clone(),this._eraseAttrDataInternal=It.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(i){return this._charsetService.setgLevel(i),!0}screenAlignmentPattern(){let i=new lr;i.content=1<<22|69,i.fg=this._curAttrData.fg,i.bg=this._curAttrData.bg,this._setCursor(0,0);for(let e=0;e<this._bufferService.rows;++e){let t=this._activeBuffer.ybase+this._activeBuffer.y+e,s=this._activeBuffer.lines.get(t);s&&(s.fill(i),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(i,e){let t=o=>(this._coreService.triggerDataEvent(`${le.ESC}${o}${le.ESC}\\`),!0),s=this._bufferService.buffer,r=this._optionsService.rawOptions;return t(i==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:i==='"p'?'P1$r61;1"p':i==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:i==="m"?"P1$r0m":i===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(i,e){this._dirtyRowTracker.markRangeDirty(i,e)}},ib=class{constructor(i){this._bufferService=i,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(i){i<this.start?this.start=i:i>this.end&&(this.end=i)}markRangeDirty(i,e){i>e&&(PE=i,i=e,e=PE),i<this.start&&(this.start=i),e>this.end&&(this.end=e)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};ib=Lt([Oe(0,is)],ib);function QE(i){return 0<=i&&i<256}var Wte=5e7,RE=12,Ute=50,Yte=class extends Xe{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 fe),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 r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Wte)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 r=this._writeBuffer[this._bufferOffset],n=this._action(r,t);if(n){let l=c=>performance.now()-s>=RE?setTimeout(()=>this._innerWrite(0,c)):this._innerWrite(s,c);n.catch(c=>(queueMicrotask(()=>{throw c}),Promise.resolve(!1))).then(l);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-s>=RE)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Ute&&(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()}},sb=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 c=t.addMarker(t.ybase+t.y),u={data:e,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(u,c)),this._dataByLinkId.set(u.id,u),u.id}let s=e,r=this._getEntryIdKey(s),n=this._entriesWithId.get(r);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),l={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(l,o)),this._entriesWithId.set(l.key,l),this._dataByLinkId.set(l.id,l),l.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);s.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(s,r))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let 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)))}};sb=Lt([Oe(0,is)],sb);var LE=!1,Hte=class extends Xe{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Th),this._onBinary=this._register(new fe),this.onBinary=this._onBinary.event,this._onData=this._register(new fe),this.onData=this._onData.event,this._onLineFeed=this._register(new fe),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new fe),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new fe),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new fe),this._instantiationService=new vte,this.optionsService=this._register(new Mte(e)),this._instantiationService.setService(ss,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ky)),this._instantiationService.setService(is,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Gy)),this._instantiationService.setService(IB,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Jy)),this._instantiationService.setService(Ja,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(eb)),this._instantiationService.setService(jB,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ba)),this._instantiationService.setService(mJ,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Lte),this._instantiationService.setService(pJ,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(sb),this._instantiationService.setService(qB,this._oscLinkService),this._inputHandler=this._register(new qte(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Di.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Di.forward(this._bufferService.onResize,this._onResize)),this._register(Di.forward(this.coreService.onData,this._onData)),this._register(Di.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 Yte((t,s)=>this._inputHandler.parse(t,s))),this._register(Di.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new fe),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!LE&&(this._logService.warn("writeSync is unreliable and will be removed soon."),LE=!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,xD),t=Math.max(t,wD),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(CE.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(CE(this._bufferService),!1))),this._windowsWrappingHeuristics.value=xt(()=>{for(let t of e)t.dispose()})}}},Fte={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function Gte(i,e,t,s){var o;let r={type:0,cancel:!1,key:void 0},n=(i.shiftKey?1:0)|(i.altKey?2:0)|(i.ctrlKey?4:0)|(i.metaKey?8:0);switch(i.keyCode){case 0:i.key==="UIKeyInputUpArrow"?e?r.key=le.ESC+"OA":r.key=le.ESC+"[A":i.key==="UIKeyInputLeftArrow"?e?r.key=le.ESC+"OD":r.key=le.ESC+"[D":i.key==="UIKeyInputRightArrow"?e?r.key=le.ESC+"OC":r.key=le.ESC+"[C":i.key==="UIKeyInputDownArrow"&&(e?r.key=le.ESC+"OB":r.key=le.ESC+"[B");break;case 8:r.key=i.ctrlKey?"\b":le.DEL,i.altKey&&(r.key=le.ESC+r.key);break;case 9:if(i.shiftKey){r.key=le.ESC+"[Z";break}r.key=le.HT,r.cancel=!0;break;case 13:r.key=i.altKey?le.ESC+le.CR:le.CR,r.cancel=!0;break;case 27:r.key=le.ESC,i.altKey&&(r.key=le.ESC+le.ESC),r.cancel=!0;break;case 37:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"D":e?r.key=le.ESC+"OD":r.key=le.ESC+"[D";break;case 39:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"C":e?r.key=le.ESC+"OC":r.key=le.ESC+"[C";break;case 38:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"A":e?r.key=le.ESC+"OA":r.key=le.ESC+"[A";break;case 40:if(i.metaKey)break;n?r.key=le.ESC+"[1;"+(n+1)+"B":e?r.key=le.ESC+"OB":r.key=le.ESC+"[B";break;case 45:!i.shiftKey&&!i.ctrlKey&&(r.key=le.ESC+"[2~");break;case 46:n?r.key=le.ESC+"[3;"+(n+1)+"~":r.key=le.ESC+"[3~";break;case 36:n?r.key=le.ESC+"[1;"+(n+1)+"H":e?r.key=le.ESC+"OH":r.key=le.ESC+"[H";break;case 35:n?r.key=le.ESC+"[1;"+(n+1)+"F":e?r.key=le.ESC+"OF":r.key=le.ESC+"[F";break;case 33:i.shiftKey?r.type=2:i.ctrlKey?r.key=le.ESC+"[5;"+(n+1)+"~":r.key=le.ESC+"[5~";break;case 34:i.shiftKey?r.type=3:i.ctrlKey?r.key=le.ESC+"[6;"+(n+1)+"~":r.key=le.ESC+"[6~";break;case 112:n?r.key=le.ESC+"[1;"+(n+1)+"P":r.key=le.ESC+"OP";break;case 113:n?r.key=le.ESC+"[1;"+(n+1)+"Q":r.key=le.ESC+"OQ";break;case 114:n?r.key=le.ESC+"[1;"+(n+1)+"R":r.key=le.ESC+"OR";break;case 115:n?r.key=le.ESC+"[1;"+(n+1)+"S":r.key=le.ESC+"OS";break;case 116:n?r.key=le.ESC+"[15;"+(n+1)+"~":r.key=le.ESC+"[15~";break;case 117:n?r.key=le.ESC+"[17;"+(n+1)+"~":r.key=le.ESC+"[17~";break;case 118:n?r.key=le.ESC+"[18;"+(n+1)+"~":r.key=le.ESC+"[18~";break;case 119:n?r.key=le.ESC+"[19;"+(n+1)+"~":r.key=le.ESC+"[19~";break;case 120:n?r.key=le.ESC+"[20;"+(n+1)+"~":r.key=le.ESC+"[20~";break;case 121:n?r.key=le.ESC+"[21;"+(n+1)+"~":r.key=le.ESC+"[21~";break;case 122:n?r.key=le.ESC+"[23;"+(n+1)+"~":r.key=le.ESC+"[23~";break;case 123:n?r.key=le.ESC+"[24;"+(n+1)+"~":r.key=le.ESC+"[24~";break;default:if(i.ctrlKey&&!i.shiftKey&&!i.altKey&&!i.metaKey)i.keyCode>=65&&i.keyCode<=90?r.key=String.fromCharCode(i.keyCode-64):i.keyCode===32?r.key=le.NUL:i.keyCode>=51&&i.keyCode<=55?r.key=String.fromCharCode(i.keyCode-51+27):i.keyCode===56?r.key=le.DEL:i.keyCode===219?r.key=le.ESC:i.keyCode===220?r.key=le.FS:i.keyCode===221&&(r.key=le.GS);else if((!t||s)&&i.altKey&&!i.metaKey){let l=(o=Fte[i.keyCode])==null?void 0:o[i.shiftKey?1:0];if(l)r.key=le.ESC+l;else if(i.keyCode>=65&&i.keyCode<=90){let c=i.ctrlKey?i.keyCode-64:i.keyCode+32,u=String.fromCharCode(c);i.shiftKey&&(u=u.toUpperCase()),r.key=le.ESC+u}else if(i.keyCode===32)r.key=le.ESC+(i.ctrlKey?le.NUL:" ");else if(i.key==="Dead"&&i.code.startsWith("Key")){let c=i.code.slice(3,4);i.shiftKey||(c=c.toLowerCase()),r.key=le.ESC+c,r.cancel=!0}}else t&&!i.altKey&&!i.ctrlKey&&!i.shiftKey&&i.metaKey?i.keyCode===65&&(r.type=1):i.key&&!i.ctrlKey&&!i.altKey&&!i.metaKey&&i.keyCode>=48&&i.key.length===1?r.key=i.key:i.key&&i.ctrlKey&&(i.key==="_"&&(r.key=le.US),i.key==="@"&&(r.key=le.NUL));break}return r}var Dt=0,Kte=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new tg,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new tg,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((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,r=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<r.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(r[n]=e[t],t++):r[n]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Dt=this._search(t),Dt===-1)||this._getKey(this._array[Dt])!==t)return!1;do if(this._array[Dt]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Dt),!0;while(++Dt<this._array.length&&this._getKey(this._array[Dt])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),r=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[r++]=this._array[n];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&&(Dt=this._search(e),!(Dt<0||Dt>=this._array.length)&&this._getKey(this._array[Dt])===e))do yield this._array[Dt];while(++Dt<this._array.length&&this._getKey(this._array[Dt])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Dt=this._search(e),!(Dt<0||Dt>=this._array.length)&&this._getKey(this._array[Dt])===e))do t(this._array[Dt]);while(++Dt<this._array.length&&this._getKey(this._array[Dt])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let r=t+s>>1,n=this._getKey(this._array[r]);if(n>e)s=r-1;else if(n<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Bv=0,$E=0,Jte=class extends Xe{constructor(){super(),this._decorations=new Kte(i=>i==null?void 0:i.marker.line),this._onDecorationRegistered=this._register(new fe),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new fe),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(xt(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(i){if(i.marker.isDisposed)return;let e=new eie(i);if(e){let t=e.marker.onDispose(()=>e.dispose()),s=e.onDispose(()=>{s.dispose(),e&&(this._decorations.delete(e)&&this._onDecorationRemoved.fire(e),t.dispose())});this._decorations.insert(e),this._onDecorationRegistered.fire(e)}return e}reset(){for(let i of this._decorations.values())i.dispose();this._decorations.clear()}*getDecorationsAtCell(i,e,t){let s=0,r=0;for(let n of this._decorations.getKeyIterator(e))s=n.options.x??0,r=s+(n.options.width??1),i>=s&&i<r&&(!t||(n.options.layer??"bottom")===t)&&(yield n)}forEachDecorationAtCell(i,e,t,s){this._decorations.forEachByKey(e,r=>{Bv=r.options.x??0,$E=Bv+(r.options.width??1),i>=Bv&&i<$E&&(!t||(r.options.layer??"bottom")===t)&&s(r)})}},eie=class extends Vo{constructor(i){super(),this.options=i,this.onRenderEmitter=this.add(new fe),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new fe),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=i.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Ct.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Ct.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},tie=1e3,iie=class{constructor(e,t=tie){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 r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=r-this._lastRefreshMs,o=this._debounceThresholdMS-n;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)}},BE=20,ig=class extends Xe{constructor(i,e,t,s){super(),this._terminal=i,this._coreBrowserService=t,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new iie(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
109
+ `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Qe(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(xt(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(i){for(let e=0;e<i;e++)this._handleChar(" ")}_handleChar(i){this._liveRegionLineCount<BE+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==i&&(this._charsToAnnounce+=i):this._charsToAnnounce+=i,i===`
110
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===BE+1&&(this._liveRegion.textContent+=xy.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(i){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(i)||this._charsToConsume.push(i)}_refreshRows(i,e){this._liveRegionDebouncer.refresh(i,e,this._terminal.rows)}_renderRows(i,e){let t=this._terminal.buffer,s=t.lines.length.toString();for(let r=i;r<=e;r++){let n=t.lines.get(t.ydisp+r),o=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,o))||"",c=(t.ydisp+r+1).toString(),u=this._rowElements[r];u&&(l.length===0?(u.textContent=" ",this._rowColumns.set(u,[0,1])):(u.textContent=l,this._rowColumns.set(u,o)),u.setAttribute("aria-posinset",c),u.setAttribute("aria-setsize",s),this._alignRowWidth(u))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(i,e){let t=i.target,s=this._rowElements[e===0?1:this._rowElements.length-2],r=t.getAttribute("aria-posinset"),n=e===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||i.relatedTarget!==s)return;let o,l;if(e===0?(o=t,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(o=this._rowElements.shift(),l=t,this._rowContainer.removeChild(o)),o.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),e===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(e===0?-1:1),this._rowElements[e===0?1:this._rowElements.length-2].focus(),i.preventDefault(),i.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let i=this._coreBrowserService.mainDocument.getSelection();if(!i)return;if(i.isCollapsed){this._rowContainer.contains(i.anchorNode)&&this._terminal.clearSelection();return}if(!i.anchorNode||!i.focusNode){console.error("anchorNode and/or focusNode are null");return}let e={node:i.anchorNode,offset:i.anchorOffset},t={node:i.focusNode,offset:i.focusOffset};if((e.node.compareDocumentPosition(t.node)&Node.DOCUMENT_POSITION_PRECEDING||e.node===t.node&&e.offset>t.offset)&&([e,t]=[t,e]),e.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(e={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(e.node))return;let s=this._rowElements.slice(-1)[0];if(t.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(t={node:s,offset:((l=s.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(t.node))return;let r=({node:c,offset:u})=>{let d=c instanceof Text?c.parentNode:c,m=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(m))return console.warn("row is invalid. Race condition?"),null;let g=this._rowColumns.get(d);if(!g)return console.warn("columns is null. Race condition?"),null;let _=u<g.length?g[u]:g.slice(-1)[0]+1;return _>=this._terminal.cols&&(++m,_=0),{row:m,column:_}},n=r(e),o=r(t);if(!(!n||!o)){if(n.row>o.row||n.row===o.row&&n.column>=o.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(o.row-n.row)*this._terminal.cols-n.column+o.column)}}_handleResize(i){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let i=this._coreBrowserService.mainDocument.createElement("div");return i.setAttribute("role","listitem"),i.tabIndex=-1,this._refreshRowDimensions(i),i}_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 i=0;i<this._terminal.rows;i++)this._refreshRowDimensions(this._rowElements[i]),this._alignRowWidth(this._rowElements[i])}}_refreshRowDimensions(i){i.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(i){var r,n;i.style.transform="";let e=i.getBoundingClientRect().width,t=(n=(r=this._rowColumns.get(i))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!t)return;let s=t*this._renderService.dimensions.css.cell.width;i.style.transform=`scaleX(${s/e})`}};ig=Lt([Oe(1,qS),Oe(2,Un),Oe(3,Yn)],ig);var rb=class extends Xe{constructor(i,e,t,s,r){super(),this._element=i,this._mouseService=e,this._renderService=t,this._bufferService=s,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new fe),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new fe),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(xt(()=>{var n;Ua(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Qe(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Qe(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Qe(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Qe(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(i){this._lastMouseEvent=i;let e=this._positionFromMouseEvent(i,this._element,this._mouseService);if(!e)return;this._isMouseOut=!1;let t=i.composedPath();for(let s=0;s<t.length;s++){let r=t[s];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||e.x!==this._lastBufferCell.x||e.y!==this._lastBufferCell.y)&&(this._handleHover(e),this._lastBufferCell=e)}_handleHover(i){if(this._activeLine!==i.y||this._wasResized){this._clearCurrentLink(),this._askForLink(i,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,i)||(this._clearCurrentLink(),this._askForLink(i,!0))}_askForLink(i,e){var s,r;(!this._activeProviderReplies||!e)&&((s=this._activeProviderReplies)==null||s.forEach(n=>{n==null||n.forEach(o=>{o.link.dispose&&o.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=i.y);let t=!1;for(let[n,o]of this._linkProviderService.linkProviders.entries())e?(r=this._activeProviderReplies)!=null&&r.get(n)&&(t=this._checkLinkProviderResult(n,i,t)):o.provideLinks(i.y,l=>{var u,d;if(this._isMouseOut)return;let c=l==null?void 0:l.map(m=>({link:m}));(u=this._activeProviderReplies)==null||u.set(n,c),t=this._checkLinkProviderResult(n,i,t),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(i.y,this._activeProviderReplies)})}_removeIntersectingLinks(i,e){let t=new Set;for(let s=0;s<e.size;s++){let r=e.get(s);if(r)for(let n=0;n<r.length;n++){let o=r[n],l=o.link.range.start.y<i?0:o.link.range.start.x,c=o.link.range.end.y>i?this._bufferService.cols:o.link.range.end.x;for(let u=l;u<=c;u++){if(t.has(u)){r.splice(n--,1);break}t.add(u)}}}}_checkLinkProviderResult(i,e,t){var n;if(!this._activeProviderReplies)return t;let s=this._activeProviderReplies.get(i),r=!1;for(let o=0;o<i;o++)(!this._activeProviderReplies.has(o)||this._activeProviderReplies.get(o))&&(r=!0);if(!r&&s){let o=s.find(l=>this._linkAtPosition(l.link,e));o&&(t=!0,this._handleNewLink(o))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!t)for(let o=0;o<this._activeProviderReplies.size;o++){let l=(n=this._activeProviderReplies.get(o))==null?void 0:n.find(c=>this._linkAtPosition(c.link,e));if(l){t=!0,this._handleNewLink(l);break}}return t}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(i){if(!this._currentLink)return;let e=this._positionFromMouseEvent(i,this._element,this._mouseService);e&&this._mouseDownLink&&sie(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,e)&&this._currentLink.link.activate(i,this._currentLink.link.text)}_clearCurrentLink(i,e){!this._currentLink||!this._lastMouseEvent||(!i||!e||this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=e)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ua(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(i){if(!this._lastMouseEvent)return;let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._linkAtPosition(i.link,e)&&(this._currentLink=i,this._currentLink.state={decorations:{underline:i.link.decorations===void 0?!0:i.link.decorations.underline,pointerCursor:i.link.decorations===void 0?!0:i.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,i.link,this._lastMouseEvent),i.link.decorations={},Object.defineProperties(i.link.decorations,{pointerCursor:{get:()=>{var t,s;return(s=(t=this._currentLink)==null?void 0:t.state)==null?void 0:s.decorations.pointerCursor},set:t=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==t&&(this._currentLink.state.decorations.pointerCursor=t,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",t))}},underline:{get:()=>{var t,s;return(s=(t=this._currentLink)==null?void 0:t.state)==null?void 0:s.decorations.underline},set:t=>{var s,r,n;(s=this._currentLink)!=null&&s.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(i.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(t=>{if(!this._currentLink)return;let s=t.start===0?0:t.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+t.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(s,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(i,e,t){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!0),this._currentLink.state.decorations.pointerCursor&&i.classList.add("xterm-cursor-pointer")),e.hover&&e.hover(t,e.text)}_fireUnderlineEvent(i,e){let t=i.range,s=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(t.start.x-1,t.start.y-s-1,t.end.x,t.end.y-s-1,void 0);(e?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(i,e,t){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(e,!1),this._currentLink.state.decorations.pointerCursor&&i.classList.remove("xterm-cursor-pointer")),e.leave&&e.leave(t,e.text)}_linkAtPosition(i,e){let t=i.range.start.y*this._bufferService.cols+i.range.start.x,s=i.range.end.y*this._bufferService.cols+i.range.end.x,r=e.y*this._bufferService.cols+e.x;return t<=r&&r<=s}_positionFromMouseEvent(i,e,t){let s=t.getCoords(i,e,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(i,e,t,s,r){return{x1:i,y1:e,x2:t,y2:s,cols:this._bufferService.cols,fg:r}}};rb=Lt([Oe(1,WS),Oe(2,Yn),Oe(3,is),Oe(4,UB)],rb);function sie(i,e){return i.text===e.text&&i.range.start.x===e.range.start.x&&i.range.start.y===e.range.start.y&&i.range.end.x===e.range.end.x&&i.range.end.y===e.range.end.y}var rie=class extends Hte{constructor(e={}){super(e),this._linkifier=this._register(new Th),this.browser=fD,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Th),this._onCursorMove=this._register(new fe),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new fe),this.onKey=this._onKey.event,this._onRender=this._register(new fe),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new fe),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new fe),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new fe),this.onBell=this._onBell.event,this._onFocus=this._register(new fe),this._onBlur=this._register(new fe),this._onA11yCharEmitter=this._register(new fe),this._onA11yTabEmitter=this._register(new fe),this._onWillOpen=this._register(new fe),this._setup(),this._decorationService=this._instantiationService.createInstance(Jte),this._instantiationService.setService(Mf,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Uee),this._instantiationService.setService(UB,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Cy)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Di.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Di.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Di.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Di.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(xt(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.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,r="";switch(t.index){case 256:s="foreground",r="10";break;case 257:s="background",r="11";break;case 258:s="cursor",r="12";break;default:s="ansi",r="4;"+t.index}switch(t.type){case 0:let n=vt.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${le.ESC}]${r};${jte(n)}${cD.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=Ut.toColor(...t.color));else{let o=s;this._themeService.modifyColors(l=>l[o]=Ut.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(ig,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(le.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(le.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),r=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,l=this.buffer.y*this._renderService.dimensions.css.cell.height,c=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=c+"px",this.textarea.style.top=l+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Qe(this.element,"copy",t=>{this.hasSelection()&&lJ(t,this._selectionService)}));let e=t=>hJ(t,this.textarea,this.coreService,this.optionsService);this._register(Qe(this.textarea,"paste",e)),this._register(Qe(this.element,"paste",e)),dD?this._register(Qe(this.element,"mousedown",t=>{t.button===2&&WM(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Qe(this.element,"contextmenu",t=>{WM(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),ex&&this._register(Qe(this.element,"auxclick",t=>{t.button===1&&zB(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Qe(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Qe(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Qe(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Qe(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Qe(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Qe(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Qe(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;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"),((n=this.element)==null?void 0:n.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(Qe(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),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",Sy.get()),gD||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(qee,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Un,this._coreBrowserService),this._register(Qe(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Qe(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Wy,this._document,this._helperContainer),this._instantiationService.setService(xg,this._charSizeService),this._themeService=this._instantiationService.createInstance(Fy),this._instantiationService.setService(Dh,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Jm),this._instantiationService.setService(WB,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Yy,this.rows,this.screenElement)),this._instantiationService.setService(Yn,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(jy,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Uy),this._instantiationService.setService(WS,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(rb,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(Vy,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Hy,this.element,this.screenElement,r)),this._instantiationService.setService(OJ,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Di.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Zy,this.screenElement)),this._register(Qe(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),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(ig,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Km,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Km,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(qy,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var d,m,g,_,y;let l=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!l)return!1;let c,u;switch(o.overrideType||o.type){case"mousemove":u=32,o.buttons===void 0?(c=3,o.button!==void 0&&(c=o.button<3?o.button:3)):c=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":u=0,c=o.button<3?o.button:3;break;case"mousedown":u=1,c=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let b=o.deltaY;if(b===0||e.coreMouseService.consumeWheelEvent(o,(_=(g=(m=(d=e._renderService)==null?void 0:d.dimensions)==null?void 0:m.device)==null?void 0:g.cell)==null?void 0:_.height,(y=e._coreBrowserService)==null?void 0:y.dpr)===0)return!1;u=b<0?0:1,c=4;break;default:return!1}return u===void 0||c===void 0||c>4?!1:e.coreMouseService.triggerMouseEvent({col:l.col,row:l.row,x:l.x,y:l.y,button:c,action:u,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.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?r.mousemove||(t.addEventListener("mousemove",n.mousemove),r.mousemove=n.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),o&16?r.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),r.wheel=n.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),o&2?r.mouseup||(r.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),o&4?r.mousedrag||(r.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Qe(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(o)})),this._register(Qe(t,"wheel",o=>{var l,c,u,d,m;if(!r.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,(d=(u=(c=(l=e._renderService)==null?void 0:l.dimensions)==null?void 0:c.device)==null?void 0:u.cell)==null?void 0:d.height,(m=e._coreBrowserService)==null?void 0:m.dpr)===0)return this.cancel(o,!0);let g=le.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(g,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){DB(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(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.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=Gte(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let r=this.rows-1;return this.scrollLines(s.type===2?-r:r),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===le.ETX||s.key===le.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)&&(nie(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.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(It));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(le.ESC+"[I"):this.coreService.triggerDataEvent(le.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(`${le.ESC}[4;${s};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${le.ESC}[6;${n};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function nie(i){return i.keyCode===16||i.keyCode===17||i.keyCode===18}var oie=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)}},aie=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 lr)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},DE=class{constructor(i,e){this._buffer=i,this.type=e}init(i){return this._buffer=i,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(i){let e=this._buffer.lines.get(i);if(e)return new aie(e)}getNullCell(){return new lr}},lie=class extends Xe{constructor(i){super(),this._core=i,this._onBufferChange=this._register(new fe),this.onBufferChange=this._onBufferChange.event,this._normal=new DE(this._core.buffers.normal,"normal"),this._alternate=new DE(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)}},hie=class{constructor(i){this._core=i}registerCsiHandler(i,e){return this._core.registerCsiHandler(i,t=>e(t.toArray()))}addCsiHandler(i,e){return this.registerCsiHandler(i,e)}registerDcsHandler(i,e){return this._core.registerDcsHandler(i,(t,s)=>e(t,s.toArray()))}addDcsHandler(i,e){return this.registerDcsHandler(i,e)}registerEscHandler(i,e){return this._core.registerEscHandler(i,e)}addEscHandler(i,e){return this.registerEscHandler(i,e)}registerOscHandler(i,e){return this._core.registerOscHandler(i,e)}addOscHandler(i,e){return this.registerOscHandler(i,e)}},cie=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}},uie=["cols","rows"],zr=0,fie=class extends Xe{constructor(i){super(),this._core=this._register(new rie(i)),this._addonManager=this._register(new oie),this._publicOptions={...this._core.options};let e=s=>this._core.options[s],t=(s,r)=>{this._checkReadonlyOptions(s),this._core.options[s]=r};for(let s in this._core.options){let r={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this._publicOptions,s,r)}}_checkReadonlyOptions(i){if(uie.includes(i))throw new Error(`Option "${i}" 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 hie(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new cie(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 lie(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let i=this._core.coreService.decPrivateModes,e="none";switch(this._core.coreMouseService.activeProtocol){case"X10":e="x10";break;case"VT200":e="vt200";break;case"DRAG":e="drag";break;case"ANY":e="any";break}return{applicationCursorKeysMode:i.applicationCursorKeys,applicationKeypadMode:i.applicationKeypad,bracketedPasteMode:i.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:e,originMode:i.origin,reverseWraparoundMode:i.reverseWraparound,sendFocusMode:i.sendFocus,synchronizedOutputMode:i.synchronizedOutput,wraparoundMode:i.wraparound}}get options(){return this._publicOptions}set options(i){for(let e in i)this._publicOptions[e]=i[e]}blur(){this._core.blur()}focus(){this._core.focus()}input(i,e=!0){this._core.input(i,e)}resize(i,e){this._verifyIntegers(i,e),this._core.resize(i,e)}open(i){this._core.open(i)}attachCustomKeyEventHandler(i){this._core.attachCustomKeyEventHandler(i)}attachCustomWheelEventHandler(i){this._core.attachCustomWheelEventHandler(i)}registerLinkProvider(i){return this._core.registerLinkProvider(i)}registerCharacterJoiner(i){return this._checkProposedApi(),this._core.registerCharacterJoiner(i)}deregisterCharacterJoiner(i){this._checkProposedApi(),this._core.deregisterCharacterJoiner(i)}registerMarker(i=0){return this._verifyIntegers(i),this._core.registerMarker(i)}registerDecoration(i){return this._checkProposedApi(),this._verifyPositiveIntegers(i.x??0,i.width??0,i.height??0),this._core.registerDecoration(i)}hasSelection(){return this._core.hasSelection()}select(i,e,t){this._verifyIntegers(i,e,t),this._core.select(i,e,t)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(i,e){this._verifyIntegers(i,e),this._core.selectLines(i,e)}dispose(){super.dispose()}scrollLines(i){this._verifyIntegers(i),this._core.scrollLines(i)}scrollPages(i){this._verifyIntegers(i),this._core.scrollPages(i)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(i){this._verifyIntegers(i),this._core.scrollToLine(i)}clear(){this._core.clear()}write(i,e){this._core.write(i,e)}writeln(i,e){this._core.write(i),this._core.write(`\r
111
+ `,e)}paste(i){this._core.paste(i)}refresh(i,e){this._verifyIntegers(i,e),this._core.refresh(i,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(i){this._addonManager.loadAddon(this,i)}static get strings(){return{get promptLabel(){return Sy.get()},set promptLabel(i){Sy.set(i)},get tooMuchOutput(){return xy.get()},set tooMuchOutput(i){xy.set(i)}}}_verifyIntegers(...i){for(zr of i)if(zr===1/0||isNaN(zr)||zr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...i){for(zr of i)if(zr&&(zr===1/0||isNaN(zr)||zr%1!==0||zr<0))throw new Error("This API only accepts positive integers")}};/**
105
112
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
106
113
  * @license MIT
107
114
  *
@@ -112,7 +119,7 @@ WARNING: This link could potentially be dangerous`)){let t=window.open();if(t){t
112
119
  * Fabrice Bellard's javascript vt100 for jslinux:
113
120
  * http://bellard.org/jslinux/
114
121
  * Copyright (c) 2011 Fabrice Bellard
115
- */var Zte=2,jte=1,Ite=class{activate(i){this._terminal=i}dispose(){}fit(){let i=this.proposeDimensions();if(!i||!this._terminal||isNaN(i.cols)||isNaN(i.rows))return;let e=this._terminal._core;(this._terminal.rows!==i.rows||this._terminal.cols!==i.cols)&&(e._renderService.clear(),this._terminal.resize(i.cols,i.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let i=this._terminal._core._renderService.dimensions;if(i.css.cell.width===0||i.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,t=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(t.getPropertyValue("height")),r=Math.max(0,parseInt(t.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=o.top+o.bottom,c=o.right+o.left,u=s-l,d=r-c-e;return{cols:Math.max(Zte,Math.floor(d/i.css.cell.width)),rows:Math.max(jte,Math.floor(u/i.css.cell.height))}}};/**
122
+ */var die=2,pie=1,mie=class{activate(i){this._terminal=i}dispose(){}fit(){let i=this.proposeDimensions();if(!i||!this._terminal||isNaN(i.cols)||isNaN(i.rows))return;let e=this._terminal._core;(this._terminal.rows!==i.rows||this._terminal.cols!==i.cols)&&(e._renderService.clear(),this._terminal.resize(i.cols,i.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let i=this._terminal._core._renderService.dimensions;if(i.css.cell.width===0||i.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,t=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(t.getPropertyValue("height")),r=Math.max(0,parseInt(t.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),o={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=o.top+o.bottom,c=o.right+o.left,u=s-l,d=r-c-e;return{cols:Math.max(die,Math.floor(d/i.css.cell.width)),rows:Math.max(pie,Math.floor(u/i.css.cell.height))}}};/**
116
123
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
117
124
  * @license MIT
118
125
  *
@@ -123,13 +130,13 @@ WARNING: This link could potentially be dangerous`)){let t=window.open();if(t){t
123
130
  * Fabrice Bellard's javascript vt100 for jslinux:
124
131
  * http://bellard.org/jslinux/
125
132
  * Copyright (c) 2011 Fabrice Bellard
126
- */var qte=(i,e,t,s)=>{for(var r=e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=o(r)||r);return r},Wte=(i,e)=>(t,s)=>e(t,s,i),Ute=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(i){setTimeout(()=>{throw i.stack?cE.isErrorNoTelemetry(i)?new cE(i.message+`
133
+ */var gie=(i,e,t,s)=>{for(var r=e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=o(r)||r);return r},Oie=(i,e)=>(t,s)=>e(t,s,i),_ie=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(i){setTimeout(()=>{throw i.stack?zE.isErrorNoTelemetry(i)?new zE(i.message+`
127
134
 
128
135
  `+i.stack):new Error(i.message+`
129
136
 
130
- `+i.stack):i},0)}}addListener(i){return this.listeners.push(i),()=>{this._removeListener(i)}}emit(i){this.listeners.forEach(e=>{e(i)})}_removeListener(i){this.listeners.splice(this.listeners.indexOf(i),1)}setUnexpectedErrorHandler(i){this.unexpectedErrorHandler=i}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(i){this.unexpectedErrorHandler(i),this.emit(i)}onUnexpectedExternalError(i){this.unexpectedErrorHandler(i)}},Yte=new Ute;function pv(i){Hte(i)||Yte.onUnexpectedError(i)}var nb="Canceled";function Hte(i){return i instanceof Fte?!0:i instanceof Error&&i.name===nb&&i.message===nb}var Fte=class extends Error{constructor(){super(nb),this.name=this.message}},cE=class ob extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof ob)return e;let t=new ob;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Gte;(i=>{function e(n){return n<0}i.isLessThan=e;function t(n){return n<=0}i.isLessThanOrEqual=t;function s(n){return n>0}i.isGreaterThan=s;function r(n){return n===0}i.isNeitherLessOrGreaterThan=r,i.greaterThan=1,i.lessThan=-1,i.neitherLessOrGreaterThan=0})(Gte||(Gte={}));function Kte(i,e){let t=this,s=!1,r;return function(){return s||(s=!0,e||(r=i.apply(t,arguments))),r}}var SD;(i=>{function e(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}i.is=e;let t=Object.freeze([]);function s(){return t}i.empty=s;function*r(A){yield A}i.single=r;function n(A){return e(A)?A:r(A)}i.wrap=n;function o(A){return A||t}i.from=o;function*l(A){for(let P=A.length-1;P>=0;P--)yield A[P]}i.reverse=l;function c(A){return!A||A[Symbol.iterator]().next().done===!0}i.isEmpty=c;function u(A){return A[Symbol.iterator]().next().value}i.first=u;function d(A,P){let E=0;for(let $ of A)if(P($,E++))return!0;return!1}i.some=d;function m(A,P){for(let E of A)if(P(E))return E}i.find=m;function*g(A,P){for(let E of A)P(E)&&(yield E)}i.filter=g;function*_(A,P){let E=0;for(let $ of A)yield P($,E++)}i.map=_;function*y(A,P){let E=0;for(let $ of A)yield*P($,E++)}i.flatMap=y;function*b(...A){for(let P of A)yield*P}i.concat=b;function x(A,P,E){let $=E;for(let z of A)$=P($,z);return $}i.reduce=x;function*w(A,P,E=A.length){for(P<0&&(P+=A.length),E<0?E+=A.length:E>A.length&&(E=A.length);P<E;P++)yield A[P]}i.slice=w;function k(A,P=Number.POSITIVE_INFINITY){let E=[];if(P===0)return[E,A];let $=A[Symbol.iterator]();for(let z=0;z<P;z++){let I=$.next();if(I.done)return[E,i.empty()];E.push(I.value)}return[E,{[Symbol.iterator](){return $}}]}i.consume=k;async function C(A){let P=[];for await(let E of A)P.push(E);return Promise.resolve(P)}i.asyncToArray=C})(SD||(SD={}));function xD(i){if(SD.is(i)){let e=[];for(let t of i)if(t)try{t.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(i)?[]:i}else if(i)return i.dispose(),i}function wD(...i){return ji(()=>xD(i))}function ji(i){return{dispose:Kte(()=>{i()})}}var CD=class kD{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{xD(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?kD.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};CD.DISABLE_DISPOSED_WARNING=!1;var ph=CD,Cr=class{constructor(){this._store=new ph,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Cr.None=Object.freeze({dispose(){}});var eu=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(i){var e;this._isDisposed||i===this._value||((e=this._value)==null||e.dispose(),this._value=i)}clear(){this.value=void 0}dispose(){var i;this._isDisposed=!0,(i=this._value)==null||i.dispose(),this._value=void 0}clearAndLeak(){let i=this._value;return this._value=void 0,i}},ex=typeof process<"u"&&"title"in process,kg=ex?"node":navigator.userAgent,Jte=ex?"node":navigator.platform,eie=kg.includes("Firefox"),tie=kg.includes("Edge"),TD=/^((?!chrome|android).)*safari/i.test(kg);function iie(){if(!TD)return 0;let i=kg.match(/Version\/(\d+)/);return i===null||i.length<2?0:parseInt(i[1])}Jte.indexOf("Linux")>=0;var sie="",pi=0,mi=0,gi=0,Qt=0,Gs={css:"#00000000",rgba:0},Ki;(i=>{function e(r,n,o,l){return l!==void 0?`#${ba(r)}${ba(n)}${ba(o)}${ba(l)}`:`#${ba(r)}${ba(n)}${ba(o)}`}i.toCss=e;function t(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}i.toRgba=t;function s(r,n,o,l){return{css:i.toCss(r,n,o,l),rgba:i.toRgba(r,n,o,l)}}i.toColor=s})(Ki||(Ki={}));var gu;(i=>{function e(c,u){if(Qt=(u.rgba&255)/255,Qt===1)return{css:u.css,rgba:u.rgba};let d=u.rgba>>24&255,m=u.rgba>>16&255,g=u.rgba>>8&255,_=c.rgba>>24&255,y=c.rgba>>16&255,b=c.rgba>>8&255;pi=_+Math.round((d-_)*Qt),mi=y+Math.round((m-y)*Qt),gi=b+Math.round((g-b)*Qt);let x=Ki.toCss(pi,mi,gi),w=Ki.toRgba(pi,mi,gi);return{css:x,rgba:w}}i.blend=e;function t(c){return(c.rgba&255)===255}i.isOpaque=t;function s(c,u,d){let m=Va.ensureContrastRatio(c.rgba,u.rgba,d);if(m)return Ki.toColor(m>>24&255,m>>16&255,m>>8&255)}i.ensureContrastRatio=s;function r(c){let u=(c.rgba|255)>>>0;return[pi,mi,gi]=Va.toChannels(u),{css:Ki.toCss(pi,mi,gi),rgba:u}}i.opaque=r;function n(c,u){return Qt=Math.round(u*255),[pi,mi,gi]=Va.toChannels(c.rgba),{css:Ki.toCss(pi,mi,gi,Qt),rgba:Ki.toRgba(pi,mi,gi,Qt)}}i.opacity=n;function o(c,u){return Qt=c.rgba&255,n(c,Qt*u/255)}i.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}i.toColorRGB=l})(gu||(gu={}));var rie;(i=>{let e,t;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",t=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return pi=parseInt(r.slice(1,2).repeat(2),16),mi=parseInt(r.slice(2,3).repeat(2),16),gi=parseInt(r.slice(3,4).repeat(2),16),Ki.toColor(pi,mi,gi);case 5:return pi=parseInt(r.slice(1,2).repeat(2),16),mi=parseInt(r.slice(2,3).repeat(2),16),gi=parseInt(r.slice(3,4).repeat(2),16),Qt=parseInt(r.slice(4,5).repeat(2),16),Ki.toColor(pi,mi,gi,Qt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return pi=parseInt(n[1]),mi=parseInt(n[2]),gi=parseInt(n[3]),Qt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ki.toColor(pi,mi,gi,Qt);if(!e||!t)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=t,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[pi,mi,gi,Qt]=e.getImageData(0,0,1,1).data,Qt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ki.toRgba(pi,mi,gi,Qt),css:r}}i.toColor=s})(rie||(rie={}));var Hi;(i=>{function e(s){return t(s>>16&255,s>>8&255,s&255)}i.relativeLuminance=e;function t(s,r,n){let o=s/255,l=r/255,c=n/255,u=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+d*.7152+m*.0722}i.relativeLuminance2=t})(Hi||(Hi={}));var Va;(i=>{function e(o,l){if(Qt=(l&255)/255,Qt===1)return l;let c=l>>24&255,u=l>>16&255,d=l>>8&255,m=o>>24&255,g=o>>16&255,_=o>>8&255;return pi=m+Math.round((c-m)*Qt),mi=g+Math.round((u-g)*Qt),gi=_+Math.round((d-_)*Qt),Ki.toRgba(pi,mi,gi)}i.blend=e;function t(o,l,c){let u=Hi.relativeLuminance(o>>8),d=Hi.relativeLuminance(l>>8);if(En(u,d)<c){if(d<u){let _=s(o,l,c),y=En(u,Hi.relativeLuminance(_>>8));if(y<c){let b=r(o,l,c),x=En(u,Hi.relativeLuminance(b>>8));return y>x?_:b}return _}let m=r(o,l,c),g=En(u,Hi.relativeLuminance(m>>8));if(g<c){let _=s(o,l,c),y=En(u,Hi.relativeLuminance(_>>8));return g>y?m:_}return m}}i.ensureContrastRatio=t;function s(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));for(;b<c&&(g>0||_>0||y>0);)g-=Math.max(0,Math.ceil(g*.1)),_-=Math.max(0,Math.ceil(_*.1)),y-=Math.max(0,Math.ceil(y*.1)),b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.reduceLuminance=s;function r(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));for(;b<c&&(g<255||_<255||y<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}i.toChannels=n})(Va||(Va={}));function ba(i){let e=i.toString(16);return e.length<2?"0"+e:e}function En(i,e){return i<e?(e+.05)/(i+.05):(i+.05)/(e+.05)}function Wt(i){if(!i)throw new Error("value must not be falsy");return i}function tx(i){return 57508<=i&&i<=57558}function nie(i){return 57520<=i&&i<=57527}function oie(i){return 57344<=i&&i<=63743}function aie(i){return 9472<=i&&i<=9631}function lie(i){return i>=128512&&i<=128591||i>=127744&&i<=128511||i>=128640&&i<=128767||i>=9728&&i<=9983||i>=9984&&i<=10175||i>=65024&&i<=65039||i>=129280&&i<=129535||i>=127462&&i<=127487}function hie(i,e,t,s){return e===1&&t>Math.ceil(s*1.5)&&i!==void 0&&i>255&&!lie(i)&&!tx(i)&&!oie(i)}function AD(i){return tx(i)||aie(i)}function cie(){return{css:{canvas:Pp(),cell:Pp()},device:{canvas:Pp(),cell:Pp(),char:{width:0,height:0,left:0,top:0}}}}function Pp(){return{width:0,height:0}}function uie(i,e,t=0){return(i-(Math.round(e)*2-t))%(Math.round(e)*2)}var Mi=0,hi=0,zr=!1,Pn=!1,Qp=!1,fs,mv=0,fie=class{constructor(i,e,t,s,r,n){this._terminal=i,this._optionService=e,this._selectionRenderModel=t,this._decorationService=s,this._coreBrowserService=r,this._themeService=n,this.result={fg:0,bg:0,ext:0}}resolve(i,e,t,s){if(this.result.bg=i.bg,this.result.fg=i.fg,this.result.ext=i.bg&268435456?i.extended.ext:0,hi=0,Mi=0,Pn=!1,zr=!1,Qp=!1,fs=this._themeService.colors,mv=0,i.getCode()!==0&&i.extended.underlineStyle===4){let r=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));mv=e*s%(Math.round(r)*2)}if(this._decorationService.forEachDecorationAtCell(e,t,"bottom",r=>{r.backgroundColorRGB&&(hi=r.backgroundColorRGB.rgba>>8&16777215,Pn=!0),r.foregroundColorRGB&&(Mi=r.foregroundColorRGB.rgba>>8&16777215,zr=!0)}),Qp=this._selectionRenderModel.isCellSelected(this._terminal,e,t),Qp){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:hi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:hi=(this.result.fg&16777215)<<8|255;break;case 0:default:hi=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:hi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:hi=(this.result.bg&16777215)<<8|255;break}hi=Va.blend(hi,(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else hi=(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Pn=!0,fs.selectionForeground&&(Mi=fs.selectionForeground.rgba>>8&16777215,zr=!0),AD(i.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)Mi=(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Mi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Mi=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Mi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Mi=(this.result.fg&16777215)<<8|255;break;case 0:default:Mi=this._themeService.colors.foreground.rgba}Mi=Va.blend(Mi,(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}zr=!0}}this._decorationService.forEachDecorationAtCell(e,t,"top",r=>{r.backgroundColorRGB&&(hi=r.backgroundColorRGB.rgba>>8&16777215,Pn=!0),r.foregroundColorRGB&&(Mi=r.foregroundColorRGB.rgba>>8&16777215,zr=!0)}),Pn&&(Qp?hi=i.bg&-16777216&-134217729|hi|50331648:hi=i.bg&-16777216|hi|50331648),zr&&(Mi=i.fg&-16777216&-67108865|Mi|50331648),this.result.fg&67108864&&(Pn&&!zr&&((this.result.bg&50331648)===0?Mi=this.result.fg&-134217728|fs.background.rgba>>8&16777215&16777215|50331648:Mi=this.result.fg&-134217728|this.result.bg&67108863,zr=!0),!Pn&&zr&&((this.result.fg&50331648)===0?hi=this.result.bg&-67108864|fs.foreground.rgba>>8&16777215&16777215|50331648:hi=this.result.bg&-67108864|this.result.fg&67108863,Pn=!0)),fs=void 0,this.result.bg=Pn?hi:this.result.bg,this.result.fg=zr?Mi:this.result.fg,this.result.ext&=536870911,this.result.ext|=mv<<29&3758096384}},die=.5,MD=eie||tie?"bottom":"ideographic",pie={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},mie={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},gie={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(i,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(i,e)=>`M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1`},"╒":{1:(i,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(i,e)=>`M${.5-i},1 L${.5-i},.5 L1,.5 M${.5+i},.5 L${.5+i},1`},"╔":{1:(i,e)=>`M1,${.5-e} L${.5-i},${.5-e} L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1`},"╕":{1:(i,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(i,e)=>`M${.5+i},1 L${.5+i},.5 L0,.5 M${.5-i},.5 L${.5-i},1`},"╗":{1:(i,e)=>`M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M0,${.5-e} L${.5+i},${.5-e} L${.5+i},1`},"╘":{1:(i,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(i,e)=>`M1,.5 L${.5-i},.5 L${.5-i},0 M${.5+i},.5 L${.5+i},0`},"╚":{1:(i,e)=>`M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0 M1,${.5+e} L${.5-i},${.5+e} L${.5-i},0`},"╛":{1:(i,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(i,e)=>`M0,.5 L${.5+i},.5 L${.5+i},0 M${.5-i},.5 L${.5-i},0`},"╝":{1:(i,e)=>`M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0 M0,${.5+e} L${.5+i},${.5+e} L${.5+i},0`},"╞":{1:(i,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(i,e)=>`M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1 M${.5+i},.5 L1,.5`},"╠":{1:(i,e)=>`M${.5-i},0 L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1 M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0`},"╡":{1:(i,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(i,e)=>`M0,.5 L${.5-i},.5 M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1`},"╣":{1:(i,e)=>`M${.5+i},0 L${.5+i},1 M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0`},"╤":{1:(i,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(i,e)=>`M0,.5 L1,.5 M${.5-i},.5 L${.5-i},1 M${.5+i},.5 L${.5+i},1`},"╦":{1:(i,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1`},"╧":{1:(i,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(i,e)=>`M0,.5 L1,.5 M${.5-i},.5 L${.5-i},0 M${.5+i},.5 L${.5+i},0`},"╩":{1:(i,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0 M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0`},"╪":{1:(i,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(i,e)=>`M0,.5 L1,.5 M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1`},"╬":{1:(i,e)=>`M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1 M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0 M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(i,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(i,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(i,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(i,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},uf={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};uf[""]=uf[""];uf[""]=uf[""];function Oie(i,e,t,s,r,n,o,l){let c=pie[e];if(c)return _ie(i,c,t,s,r,n),!0;let u=mie[e];if(u)return vie(i,u,t,s,r,n),!0;let d=gie[e];if(d)return yie(i,d,t,s,r,n,l),!0;let m=uf[e];return m?(bie(i,m,t,s,r,n,o,l),!0):!1}function _ie(i,e,t,s,r,n){for(let o=0;o<e.length;o++){let l=e[o],c=r/8,u=n/8;i.fillRect(t+l.x*c,s+l.y*u,l.w*c,l.h*u)}}var uE=new Map;function vie(i,e,t,s,r,n){let o=uE.get(e);o||(o=new Map,uE.set(e,o));let l=i.fillStyle;if(typeof l!="string")throw new Error(`Unexpected fillStyle type "${l}"`);let c=o.get(l);if(!c){let u=e[0].length,d=e.length,m=i.canvas.ownerDocument.createElement("canvas");m.width=u,m.height=d;let g=Wt(m.getContext("2d")),_=new ImageData(u,d),y,b,x,w;if(l.startsWith("#"))y=parseInt(l.slice(1,3),16),b=parseInt(l.slice(3,5),16),x=parseInt(l.slice(5,7),16),w=l.length>7&&parseInt(l.slice(7,9),16)||1;else if(l.startsWith("rgba"))[y,b,x,w]=l.substring(5,l.length-1).split(",").map(k=>parseFloat(k));else throw new Error(`Unexpected fillStyle color format "${l}" when drawing pattern glyph`);for(let k=0;k<d;k++)for(let C=0;C<u;C++)_.data[(k*u+C)*4]=y,_.data[(k*u+C)*4+1]=b,_.data[(k*u+C)*4+2]=x,_.data[(k*u+C)*4+3]=e[k][C]*(w*255);g.putImageData(_,0,0),c=Wt(i.createPattern(m,null)),o.set(l,c)}i.fillStyle=c,i.fillRect(t,s,r,n)}function yie(i,e,t,s,r,n,o){i.strokeStyle=i.fillStyle;for(let[l,c]of Object.entries(e)){i.beginPath(),i.lineWidth=o*Number.parseInt(l);let u;if(typeof c=="function"){let d=.15/n*r;u=c(.15,d)}else u=c;for(let d of u.split(" ")){let m=d[0],g=ED[m];if(!g){console.error(`Could not find drawing instructions for "${m}"`);continue}let _=d.substring(1).split(",");!_[0]||!_[1]||g(i,PD(_,r,n,t,s,!0,o))}i.stroke(),i.closePath()}}function bie(i,e,t,s,r,n,o,l){let c=new Path2D;c.rect(t,s,r,n),i.clip(c),i.beginPath();let u=o/12;i.lineWidth=l*u;for(let d of e.d.split(" ")){let m=d[0],g=ED[m];if(!g){console.error(`Could not find drawing instructions for "${m}"`);continue}let _=d.substring(1).split(",");!_[0]||!_[1]||g(i,PD(_,r,n,t,s,!1,l,(e.leftPadding??0)*(u/2),(e.rightPadding??0)*(u/2)))}e.type===1?(i.strokeStyle=i.fillStyle,i.stroke()):i.fill(),i.closePath()}function fE(i,e,t=0){return Math.max(Math.min(i,e),t)}var ED={C:(i,e)=>i.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(i,e)=>i.lineTo(e[0],e[1]),M:(i,e)=>i.moveTo(e[0],e[1])};function PD(i,e,t,s,r,n,o,l=0,c=0){let u=i.map(d=>parseFloat(d)||parseInt(d));if(u.length<2)throw new Error("Too few arguments for instruction");for(let d=0;d<u.length;d+=2)u[d]*=e-l*o-c*o,n&&u[d]!==0&&(u[d]=fE(Math.round(u[d]+.5)-.5,e,0)),u[d]+=s+l*o;for(let d=1;d<u.length;d+=2)u[d]*=t,n&&u[d]!==0&&(u[d]=fE(Math.round(u[d]+.5)-.5,t,0)),u[d]+=r;return u}var dE=class{constructor(){this._data={}}set(i,e,t){this._data[i]||(this._data[i]={}),this._data[i][e]=t}get(i,e){return this._data[i]?this._data[i][e]:void 0}clear(){this._data={}}},pE=class{constructor(){this._data=new dE}set(i,e,t,s,r){this._data.get(i,e)||this._data.set(i,e,new dE),this._data.get(i,e).set(t,s,r)}get(i,e,t,s){var r;return(r=this._data.get(i,e))==null?void 0:r.get(t,s)}clear(){this._data.clear()}},QD=class{constructor(){this._tasks=[],this._i=0}enqueue(i){this._tasks.push(i),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(i){this._idleCallback=void 0;let e=0,t=0,s=i.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),t=Math.max(e,t),r=i.timeRemaining(),t*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},Sie=class extends QD{_requestCallback(i){return setTimeout(()=>i(this._createDeadline(16)))}_cancelCallback(i){clearTimeout(i)}_createDeadline(i){let e=performance.now()+i;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},xie=class extends QD{_requestCallback(i){return requestIdleCallback(i)}_cancelCallback(i){cancelIdleCallback(i)}},wie=!ex&&"requestIdleCallback"in window?xie:Sie,sh=class RD{constructor(){this.fg=0,this.bg=0,this.extended=new LD}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new RD;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},LD=class $D{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new $D(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Cie=globalThis.performance&&typeof globalThis.performance.now=="function",kie=class BD{static create(e){return new BD(e)}constructor(e){this._now=Cie&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Nn;(i=>{i.None=()=>Cr.None;function e(R,L){return m(R,()=>{},0,void 0,!0,void 0,L)}i.defer=e;function t(R){return(L,N=null,Z)=>{let Q=!1,X;return X=R(W=>{if(!Q)return X?X.dispose():Q=!0,L.call(N,W)},null,Z),Q&&X.dispose(),X}}i.once=t;function s(R,L,N){return u((Z,Q=null,X)=>R(W=>Z.call(Q,L(W)),null,X),N)}i.map=s;function r(R,L,N){return u((Z,Q=null,X)=>R(W=>{L(W),Z.call(Q,W)},null,X),N)}i.forEach=r;function n(R,L,N){return u((Z,Q=null,X)=>R(W=>L(W)&&Z.call(Q,W),null,X),N)}i.filter=n;function o(R){return R}i.signal=o;function l(...R){return(L,N=null,Z)=>{let Q=wD(...R.map(X=>X(W=>L.call(N,W))));return d(Q,Z)}}i.any=l;function c(R,L,N,Z){let Q=N;return s(R,X=>(Q=L(Q,X),Q),Z)}i.reduce=c;function u(R,L){let N,Z={onWillAddFirstListener(){N=R(Q.fire,Q)},onDidRemoveLastListener(){N==null||N.dispose()}},Q=new yt(Z);return L==null||L.add(Q),Q.event}function d(R,L){return L instanceof Array?L.push(R):L&&L.add(R),R}function m(R,L,N=100,Z=!1,Q=!1,X,W){let U,q,D,G=0,ie,ce={leakWarningThreshold:X,onWillAddFirstListener(){U=R(de=>{G++,q=L(q,de),Z&&!D&&(he.fire(q),q=void 0),ie=()=>{let ge=q;q=void 0,D=void 0,(!Z||G>1)&&he.fire(ge),G=0},typeof N=="number"?(clearTimeout(D),D=setTimeout(ie,N)):D===void 0&&(D=0,queueMicrotask(ie))})},onWillRemoveListener(){Q&&G>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,U.dispose()}},he=new yt(ce);return W==null||W.add(he),he.event}i.debounce=m;function g(R,L=0,N){return i.debounce(R,(Z,Q)=>Z?(Z.push(Q),Z):[Q],L,void 0,!0,void 0,N)}i.accumulate=g;function _(R,L=(Z,Q)=>Z===Q,N){let Z=!0,Q;return n(R,X=>{let W=Z||!L(X,Q);return Z=!1,Q=X,W},N)}i.latch=_;function y(R,L,N){return[i.filter(R,L,N),i.filter(R,Z=>!L(Z),N)]}i.split=y;function b(R,L=!1,N=[],Z){let Q=N.slice(),X=R(q=>{Q?Q.push(q):U.fire(q)});Z&&Z.add(X);let W=()=>{Q==null||Q.forEach(q=>U.fire(q)),Q=null},U=new yt({onWillAddFirstListener(){X||(X=R(q=>U.fire(q)),Z&&Z.add(X))},onDidAddFirstListener(){Q&&(L?setTimeout(W):W())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return Z&&Z.add(U),U.event}i.buffer=b;function x(R,L){return(N,Z,Q)=>{let X=L(new k);return R(function(W){let U=X.evaluate(W);U!==w&&N.call(Z,U)},void 0,Q)}}i.chain=x;let w=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(N=>(L(N),N)),this}filter(L){return this.steps.push(N=>L(N)?N:w),this}reduce(L,N){let Z=N;return this.steps.push(Q=>(Z=L(Z,Q),Z)),this}latch(L=(N,Z)=>N===Z){let N=!0,Z;return this.steps.push(Q=>{let X=N||!L(Q,Z);return N=!1,Z=Q,X?Q:w}),this}evaluate(L){for(let N of this.steps)if(L=N(L),L===w)break;return L}}function C(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.on(L,Z),X=()=>R.removeListener(L,Z),W=new yt({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromNodeEventEmitter=C;function A(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.addEventListener(L,Z),X=()=>R.removeEventListener(L,Z),W=new yt({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromDOMEventEmitter=A;function P(R){return new Promise(L=>t(R)(L))}i.toPromise=P;function E(R){let L=new yt;return R.then(N=>{L.fire(N)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}i.fromPromise=E;function $(R,L){return R(N=>L.fire(N))}i.forward=$;function z(R,L,N){return L(N),R(Z=>L(Z))}i.runAndSubscribe=z;class I{constructor(L,N){this._observable=L,this._counter=0,this._hasChanged=!1;let Z={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new yt(Z),N&&N.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,N){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function se(R,L){return new I(R,L).emitter.event}i.fromObservable=se;function F(R){return(L,N,Z)=>{let Q=0,X=!1,W={beginUpdate(){Q++},endUpdate(){Q--,Q===0&&(R.reportChanges(),X&&(X=!1,L.call(N)))},handlePossibleChange(){},handleChange(){X=!0}};R.addObserver(W),R.reportChanges();let U={dispose(){R.removeObserver(W)}};return Z instanceof ph?Z.add(U):Array.isArray(Z)&&Z.push(U),U}}i.fromObservableLight=F})(Nn||(Nn={}));var ab=class lb{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${lb._idPool++}`,lb.all.add(this)}start(e){this._stopWatch=new kie,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};ab.all=new Set,ab._idPool=0;var Tie=ab,Aie=-1,DD=class zD{constructor(e,t,s=(zD._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=t,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,t){let s=this.threshold;if(s<=0||t<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let c=new Pie(l,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[s,r]of this._stacks)(!e||t<r)&&(e=[s,r],t=r);return e}};DD._idPool=1;var Mie=DD,Eie=class ND{constructor(e){this.value=e}static create(){let e=new Error;return new ND(e.stack??"")}print(){console.warn(this.value.split(`
137
+ `+i.stack):i},0)}}addListener(i){return this.listeners.push(i),()=>{this._removeListener(i)}}emit(i){this.listeners.forEach(e=>{e(i)})}_removeListener(i){this.listeners.splice(this.listeners.indexOf(i),1)}setUnexpectedErrorHandler(i){this.unexpectedErrorHandler=i}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(i){this.unexpectedErrorHandler(i),this.emit(i)}onUnexpectedExternalError(i){this.unexpectedErrorHandler(i)}},vie=new _ie;function Dv(i){yie(i)||vie.onUnexpectedError(i)}var nb="Canceled";function yie(i){return i instanceof bie?!0:i instanceof Error&&i.name===nb&&i.message===nb}var bie=class extends Error{constructor(){super(nb),this.name=this.message}},zE=class ob extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(e){if(e instanceof ob)return e;let t=new ob;return t.message=e.message,t.stack=e.stack,t}static isErrorNoTelemetry(e){return e.name==="CodeExpectedError"}},Sie;(i=>{function e(n){return n<0}i.isLessThan=e;function t(n){return n<=0}i.isLessThanOrEqual=t;function s(n){return n>0}i.isGreaterThan=s;function r(n){return n===0}i.isNeitherLessOrGreaterThan=r,i.greaterThan=1,i.lessThan=-1,i.neitherLessOrGreaterThan=0})(Sie||(Sie={}));function xie(i,e){let t=this,s=!1,r;return function(){return s||(s=!0,e||(r=i.apply(t,arguments))),r}}var kD;(i=>{function e(A){return A&&typeof A=="object"&&typeof A[Symbol.iterator]=="function"}i.is=e;let t=Object.freeze([]);function s(){return t}i.empty=s;function*r(A){yield A}i.single=r;function n(A){return e(A)?A:r(A)}i.wrap=n;function o(A){return A||t}i.from=o;function*l(A){for(let P=A.length-1;P>=0;P--)yield A[P]}i.reverse=l;function c(A){return!A||A[Symbol.iterator]().next().done===!0}i.isEmpty=c;function u(A){return A[Symbol.iterator]().next().value}i.first=u;function d(A,P){let E=0;for(let $ of A)if(P($,E++))return!0;return!1}i.some=d;function m(A,P){for(let E of A)if(P(E))return E}i.find=m;function*g(A,P){for(let E of A)P(E)&&(yield E)}i.filter=g;function*_(A,P){let E=0;for(let $ of A)yield P($,E++)}i.map=_;function*y(A,P){let E=0;for(let $ of A)yield*P($,E++)}i.flatMap=y;function*b(...A){for(let P of A)yield*P}i.concat=b;function x(A,P,E){let $=E;for(let z of A)$=P($,z);return $}i.reduce=x;function*w(A,P,E=A.length){for(P<0&&(P+=A.length),E<0?E+=A.length:E>A.length&&(E=A.length);P<E;P++)yield A[P]}i.slice=w;function k(A,P=Number.POSITIVE_INFINITY){let E=[];if(P===0)return[E,A];let $=A[Symbol.iterator]();for(let z=0;z<P;z++){let I=$.next();if(I.done)return[E,i.empty()];E.push(I.value)}return[E,{[Symbol.iterator](){return $}}]}i.consume=k;async function C(A){let P=[];for await(let E of A)P.push(E);return Promise.resolve(P)}i.asyncToArray=C})(kD||(kD={}));function TD(i){if(kD.is(i)){let e=[];for(let t of i)if(t)try{t.dispose()}catch(s){e.push(s)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"Encountered errors while disposing of store");return Array.isArray(i)?[]:i}else if(i)return i.dispose(),i}function AD(...i){return ji(()=>TD(i))}function ji(i){return{dispose:xie(()=>{i()})}}var MD=class ED{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{TD(this._toDispose)}finally{this._toDispose.clear()}}add(e){if(!e)return e;if(e===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?ED.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(e),e}delete(e){if(e){if(e===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),void 0)}};MD.DISABLE_DISPOSED_WARNING=!1;var ph=MD,Cr=class{constructor(){this._store=new ph,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Cr.None=Object.freeze({dispose(){}});var tu=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(i){var e;this._isDisposed||i===this._value||((e=this._value)==null||e.dispose(),this._value=i)}clear(){this.value=void 0}dispose(){var i;this._isDisposed=!0,(i=this._value)==null||i.dispose(),this._value=void 0}clearAndLeak(){let i=this._value;return this._value=void 0,i}},tx=typeof process<"u"&&"title"in process,kg=tx?"node":navigator.userAgent,wie=tx?"node":navigator.platform,Cie=kg.includes("Firefox"),kie=kg.includes("Edge"),PD=/^((?!chrome|android).)*safari/i.test(kg);function Tie(){if(!PD)return 0;let i=kg.match(/Version\/(\d+)/);return i===null||i.length<2?0:parseInt(i[1])}wie.indexOf("Linux")>=0;var Aie="",pi=0,mi=0,gi=0,Qt=0,Gs={css:"#00000000",rgba:0},Ki;(i=>{function e(r,n,o,l){return l!==void 0?`#${ba(r)}${ba(n)}${ba(o)}${ba(l)}`:`#${ba(r)}${ba(n)}${ba(o)}`}i.toCss=e;function t(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}i.toRgba=t;function s(r,n,o,l){return{css:i.toCss(r,n,o,l),rgba:i.toRgba(r,n,o,l)}}i.toColor=s})(Ki||(Ki={}));var gu;(i=>{function e(c,u){if(Qt=(u.rgba&255)/255,Qt===1)return{css:u.css,rgba:u.rgba};let d=u.rgba>>24&255,m=u.rgba>>16&255,g=u.rgba>>8&255,_=c.rgba>>24&255,y=c.rgba>>16&255,b=c.rgba>>8&255;pi=_+Math.round((d-_)*Qt),mi=y+Math.round((m-y)*Qt),gi=b+Math.round((g-b)*Qt);let x=Ki.toCss(pi,mi,gi),w=Ki.toRgba(pi,mi,gi);return{css:x,rgba:w}}i.blend=e;function t(c){return(c.rgba&255)===255}i.isOpaque=t;function s(c,u,d){let m=Va.ensureContrastRatio(c.rgba,u.rgba,d);if(m)return Ki.toColor(m>>24&255,m>>16&255,m>>8&255)}i.ensureContrastRatio=s;function r(c){let u=(c.rgba|255)>>>0;return[pi,mi,gi]=Va.toChannels(u),{css:Ki.toCss(pi,mi,gi),rgba:u}}i.opaque=r;function n(c,u){return Qt=Math.round(u*255),[pi,mi,gi]=Va.toChannels(c.rgba),{css:Ki.toCss(pi,mi,gi,Qt),rgba:Ki.toRgba(pi,mi,gi,Qt)}}i.opacity=n;function o(c,u){return Qt=c.rgba&255,n(c,Qt*u/255)}i.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}i.toColorRGB=l})(gu||(gu={}));var Mie;(i=>{let e,t;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",t=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return pi=parseInt(r.slice(1,2).repeat(2),16),mi=parseInt(r.slice(2,3).repeat(2),16),gi=parseInt(r.slice(3,4).repeat(2),16),Ki.toColor(pi,mi,gi);case 5:return pi=parseInt(r.slice(1,2).repeat(2),16),mi=parseInt(r.slice(2,3).repeat(2),16),gi=parseInt(r.slice(3,4).repeat(2),16),Qt=parseInt(r.slice(4,5).repeat(2),16),Ki.toColor(pi,mi,gi,Qt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return pi=parseInt(n[1]),mi=parseInt(n[2]),gi=parseInt(n[3]),Qt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ki.toColor(pi,mi,gi,Qt);if(!e||!t)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=t,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[pi,mi,gi,Qt]=e.getImageData(0,0,1,1).data,Qt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ki.toRgba(pi,mi,gi,Qt),css:r}}i.toColor=s})(Mie||(Mie={}));var Hi;(i=>{function e(s){return t(s>>16&255,s>>8&255,s&255)}i.relativeLuminance=e;function t(s,r,n){let o=s/255,l=r/255,c=n/255,u=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+d*.7152+m*.0722}i.relativeLuminance2=t})(Hi||(Hi={}));var Va;(i=>{function e(o,l){if(Qt=(l&255)/255,Qt===1)return l;let c=l>>24&255,u=l>>16&255,d=l>>8&255,m=o>>24&255,g=o>>16&255,_=o>>8&255;return pi=m+Math.round((c-m)*Qt),mi=g+Math.round((u-g)*Qt),gi=_+Math.round((d-_)*Qt),Ki.toRgba(pi,mi,gi)}i.blend=e;function t(o,l,c){let u=Hi.relativeLuminance(o>>8),d=Hi.relativeLuminance(l>>8);if(En(u,d)<c){if(d<u){let _=s(o,l,c),y=En(u,Hi.relativeLuminance(_>>8));if(y<c){let b=r(o,l,c),x=En(u,Hi.relativeLuminance(b>>8));return y>x?_:b}return _}let m=r(o,l,c),g=En(u,Hi.relativeLuminance(m>>8));if(g<c){let _=s(o,l,c),y=En(u,Hi.relativeLuminance(_>>8));return g>y?m:_}return m}}i.ensureContrastRatio=t;function s(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));for(;b<c&&(g>0||_>0||y>0);)g-=Math.max(0,Math.ceil(g*.1)),_-=Math.max(0,Math.ceil(_*.1)),y-=Math.max(0,Math.ceil(y*.1)),b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.reduceLuminance=s;function r(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));for(;b<c&&(g<255||_<255||y<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),b=En(Hi.relativeLuminance2(g,_,y),Hi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}i.toChannels=n})(Va||(Va={}));function ba(i){let e=i.toString(16);return e.length<2?"0"+e:e}function En(i,e){return i<e?(e+.05)/(i+.05):(i+.05)/(e+.05)}function Wt(i){if(!i)throw new Error("value must not be falsy");return i}function ix(i){return 57508<=i&&i<=57558}function Eie(i){return 57520<=i&&i<=57527}function Pie(i){return 57344<=i&&i<=63743}function Qie(i){return 9472<=i&&i<=9631}function Rie(i){return i>=128512&&i<=128591||i>=127744&&i<=128511||i>=128640&&i<=128767||i>=9728&&i<=9983||i>=9984&&i<=10175||i>=65024&&i<=65039||i>=129280&&i<=129535||i>=127462&&i<=127487}function Lie(i,e,t,s){return e===1&&t>Math.ceil(s*1.5)&&i!==void 0&&i>255&&!Rie(i)&&!ix(i)&&!Pie(i)}function QD(i){return ix(i)||Qie(i)}function $ie(){return{css:{canvas:Qp(),cell:Qp()},device:{canvas:Qp(),cell:Qp(),char:{width:0,height:0,left:0,top:0}}}}function Qp(){return{width:0,height:0}}function Bie(i,e,t=0){return(i-(Math.round(e)*2-t))%(Math.round(e)*2)}var Mi=0,hi=0,Nr=!1,Pn=!1,Rp=!1,fs,zv=0,Die=class{constructor(i,e,t,s,r,n){this._terminal=i,this._optionService=e,this._selectionRenderModel=t,this._decorationService=s,this._coreBrowserService=r,this._themeService=n,this.result={fg:0,bg:0,ext:0}}resolve(i,e,t,s){if(this.result.bg=i.bg,this.result.fg=i.fg,this.result.ext=i.bg&268435456?i.extended.ext:0,hi=0,Mi=0,Pn=!1,Nr=!1,Rp=!1,fs=this._themeService.colors,zv=0,i.getCode()!==0&&i.extended.underlineStyle===4){let r=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));zv=e*s%(Math.round(r)*2)}if(this._decorationService.forEachDecorationAtCell(e,t,"bottom",r=>{r.backgroundColorRGB&&(hi=r.backgroundColorRGB.rgba>>8&16777215,Pn=!0),r.foregroundColorRGB&&(Mi=r.foregroundColorRGB.rgba>>8&16777215,Nr=!0)}),Rp=this._selectionRenderModel.isCellSelected(this._terminal,e,t),Rp){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:hi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:hi=(this.result.fg&16777215)<<8|255;break;case 0:default:hi=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:hi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:hi=(this.result.bg&16777215)<<8|255;break}hi=Va.blend(hi,(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else hi=(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Pn=!0,fs.selectionForeground&&(Mi=fs.selectionForeground.rgba>>8&16777215,Nr=!0),QD(i.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)Mi=(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Mi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Mi=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:Mi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Mi=(this.result.fg&16777215)<<8|255;break;case 0:default:Mi=this._themeService.colors.foreground.rgba}Mi=Va.blend(Mi,(this._coreBrowserService.isFocused?fs.selectionBackgroundOpaque:fs.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Nr=!0}}this._decorationService.forEachDecorationAtCell(e,t,"top",r=>{r.backgroundColorRGB&&(hi=r.backgroundColorRGB.rgba>>8&16777215,Pn=!0),r.foregroundColorRGB&&(Mi=r.foregroundColorRGB.rgba>>8&16777215,Nr=!0)}),Pn&&(Rp?hi=i.bg&-16777216&-134217729|hi|50331648:hi=i.bg&-16777216|hi|50331648),Nr&&(Mi=i.fg&-16777216&-67108865|Mi|50331648),this.result.fg&67108864&&(Pn&&!Nr&&((this.result.bg&50331648)===0?Mi=this.result.fg&-134217728|fs.background.rgba>>8&16777215&16777215|50331648:Mi=this.result.fg&-134217728|this.result.bg&67108863,Nr=!0),!Pn&&Nr&&((this.result.fg&50331648)===0?hi=this.result.bg&-67108864|fs.foreground.rgba>>8&16777215&16777215|50331648:hi=this.result.bg&-67108864|this.result.fg&67108863,Pn=!0)),fs=void 0,this.result.bg=Pn?hi:this.result.bg,this.result.fg=Nr?Mi:this.result.fg,this.result.ext&=536870911,this.result.ext|=zv<<29&3758096384}},zie=.5,RD=Cie||kie?"bottom":"ideographic",Nie={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Xie={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Vie={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(i,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"║":{1:(i,e)=>`M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1`},"╒":{1:(i,e)=>`M.5,1 L.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╓":{1:(i,e)=>`M${.5-i},1 L${.5-i},.5 L1,.5 M${.5+i},.5 L${.5+i},1`},"╔":{1:(i,e)=>`M1,${.5-e} L${.5-i},${.5-e} L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1`},"╕":{1:(i,e)=>`M0,${.5-e} L.5,${.5-e} L.5,1 M0,${.5+e} L.5,${.5+e}`},"╖":{1:(i,e)=>`M${.5+i},1 L${.5+i},.5 L0,.5 M${.5-i},.5 L${.5-i},1`},"╗":{1:(i,e)=>`M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M0,${.5-e} L${.5+i},${.5-e} L${.5+i},1`},"╘":{1:(i,e)=>`M.5,0 L.5,${.5+e} L1,${.5+e} M.5,${.5-e} L1,${.5-e}`},"╙":{1:(i,e)=>`M1,.5 L${.5-i},.5 L${.5-i},0 M${.5+i},.5 L${.5+i},0`},"╚":{1:(i,e)=>`M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0 M1,${.5+e} L${.5-i},${.5+e} L${.5-i},0`},"╛":{1:(i,e)=>`M0,${.5+e} L.5,${.5+e} L.5,0 M0,${.5-e} L.5,${.5-e}`},"╜":{1:(i,e)=>`M0,.5 L${.5+i},.5 L${.5+i},0 M${.5-i},.5 L${.5-i},0`},"╝":{1:(i,e)=>`M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0 M0,${.5+e} L${.5+i},${.5+e} L${.5+i},0`},"╞":{1:(i,e)=>`M.5,0 L.5,1 M.5,${.5-e} L1,${.5-e} M.5,${.5+e} L1,${.5+e}`},"╟":{1:(i,e)=>`M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1 M${.5+i},.5 L1,.5`},"╠":{1:(i,e)=>`M${.5-i},0 L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1 M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0`},"╡":{1:(i,e)=>`M.5,0 L.5,1 M0,${.5-e} L.5,${.5-e} M0,${.5+e} L.5,${.5+e}`},"╢":{1:(i,e)=>`M0,.5 L${.5-i},.5 M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1`},"╣":{1:(i,e)=>`M${.5+i},0 L${.5+i},1 M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0`},"╤":{1:(i,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e} M.5,${.5+e} L.5,1`},"╥":{1:(i,e)=>`M0,.5 L1,.5 M${.5-i},.5 L${.5-i},1 M${.5+i},.5 L${.5+i},1`},"╦":{1:(i,e)=>`M0,${.5-e} L1,${.5-e} M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1`},"╧":{1:(i,e)=>`M.5,0 L.5,${.5-e} M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╨":{1:(i,e)=>`M0,.5 L1,.5 M${.5-i},.5 L${.5-i},0 M${.5+i},.5 L${.5+i},0`},"╩":{1:(i,e)=>`M0,${.5+e} L1,${.5+e} M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0 M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0`},"╪":{1:(i,e)=>`M.5,0 L.5,1 M0,${.5-e} L1,${.5-e} M0,${.5+e} L1,${.5+e}`},"╫":{1:(i,e)=>`M0,.5 L1,.5 M${.5-i},0 L${.5-i},1 M${.5+i},0 L${.5+i},1`},"╬":{1:(i,e)=>`M0,${.5+e} L${.5-i},${.5+e} L${.5-i},1 M1,${.5+e} L${.5+i},${.5+e} L${.5+i},1 M0,${.5-e} L${.5-i},${.5-e} L${.5-i},0 M1,${.5-e} L${.5+i},${.5-e} L${.5+i},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(i,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,1,.5`},"╮":{1:(i,e)=>`M.5,1 L.5,${.5+e/.15*.5} C.5,${.5+e/.15*.5},.5,.5,0,.5`},"╯":{1:(i,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,0,.5`},"╰":{1:(i,e)=>`M.5,0 L.5,${.5-e/.15*.5} C.5,${.5-e/.15*.5},.5,.5,1,.5`}},uf={"":{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0},"":{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0},"":{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0},"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}};uf[""]=uf[""];uf[""]=uf[""];function Zie(i,e,t,s,r,n,o,l){let c=Nie[e];if(c)return jie(i,c,t,s,r,n),!0;let u=Xie[e];if(u)return Iie(i,u,t,s,r,n),!0;let d=Vie[e];if(d)return qie(i,d,t,s,r,n,l),!0;let m=uf[e];return m?(Wie(i,m,t,s,r,n,o,l),!0):!1}function jie(i,e,t,s,r,n){for(let o=0;o<e.length;o++){let l=e[o],c=r/8,u=n/8;i.fillRect(t+l.x*c,s+l.y*u,l.w*c,l.h*u)}}var NE=new Map;function Iie(i,e,t,s,r,n){let o=NE.get(e);o||(o=new Map,NE.set(e,o));let l=i.fillStyle;if(typeof l!="string")throw new Error(`Unexpected fillStyle type "${l}"`);let c=o.get(l);if(!c){let u=e[0].length,d=e.length,m=i.canvas.ownerDocument.createElement("canvas");m.width=u,m.height=d;let g=Wt(m.getContext("2d")),_=new ImageData(u,d),y,b,x,w;if(l.startsWith("#"))y=parseInt(l.slice(1,3),16),b=parseInt(l.slice(3,5),16),x=parseInt(l.slice(5,7),16),w=l.length>7&&parseInt(l.slice(7,9),16)||1;else if(l.startsWith("rgba"))[y,b,x,w]=l.substring(5,l.length-1).split(",").map(k=>parseFloat(k));else throw new Error(`Unexpected fillStyle color format "${l}" when drawing pattern glyph`);for(let k=0;k<d;k++)for(let C=0;C<u;C++)_.data[(k*u+C)*4]=y,_.data[(k*u+C)*4+1]=b,_.data[(k*u+C)*4+2]=x,_.data[(k*u+C)*4+3]=e[k][C]*(w*255);g.putImageData(_,0,0),c=Wt(i.createPattern(m,null)),o.set(l,c)}i.fillStyle=c,i.fillRect(t,s,r,n)}function qie(i,e,t,s,r,n,o){i.strokeStyle=i.fillStyle;for(let[l,c]of Object.entries(e)){i.beginPath(),i.lineWidth=o*Number.parseInt(l);let u;if(typeof c=="function"){let d=.15/n*r;u=c(.15,d)}else u=c;for(let d of u.split(" ")){let m=d[0],g=LD[m];if(!g){console.error(`Could not find drawing instructions for "${m}"`);continue}let _=d.substring(1).split(",");!_[0]||!_[1]||g(i,$D(_,r,n,t,s,!0,o))}i.stroke(),i.closePath()}}function Wie(i,e,t,s,r,n,o,l){let c=new Path2D;c.rect(t,s,r,n),i.clip(c),i.beginPath();let u=o/12;i.lineWidth=l*u;for(let d of e.d.split(" ")){let m=d[0],g=LD[m];if(!g){console.error(`Could not find drawing instructions for "${m}"`);continue}let _=d.substring(1).split(",");!_[0]||!_[1]||g(i,$D(_,r,n,t,s,!1,l,(e.leftPadding??0)*(u/2),(e.rightPadding??0)*(u/2)))}e.type===1?(i.strokeStyle=i.fillStyle,i.stroke()):i.fill(),i.closePath()}function XE(i,e,t=0){return Math.max(Math.min(i,e),t)}var LD={C:(i,e)=>i.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]),L:(i,e)=>i.lineTo(e[0],e[1]),M:(i,e)=>i.moveTo(e[0],e[1])};function $D(i,e,t,s,r,n,o,l=0,c=0){let u=i.map(d=>parseFloat(d)||parseInt(d));if(u.length<2)throw new Error("Too few arguments for instruction");for(let d=0;d<u.length;d+=2)u[d]*=e-l*o-c*o,n&&u[d]!==0&&(u[d]=XE(Math.round(u[d]+.5)-.5,e,0)),u[d]+=s+l*o;for(let d=1;d<u.length;d+=2)u[d]*=t,n&&u[d]!==0&&(u[d]=XE(Math.round(u[d]+.5)-.5,t,0)),u[d]+=r;return u}var VE=class{constructor(){this._data={}}set(i,e,t){this._data[i]||(this._data[i]={}),this._data[i][e]=t}get(i,e){return this._data[i]?this._data[i][e]:void 0}clear(){this._data={}}},ZE=class{constructor(){this._data=new VE}set(i,e,t,s,r){this._data.get(i,e)||this._data.set(i,e,new VE),this._data.get(i,e).set(t,s,r)}get(i,e,t,s){var r;return(r=this._data.get(i,e))==null?void 0:r.get(t,s)}clear(){this._data.clear()}},BD=class{constructor(){this._tasks=[],this._i=0}enqueue(i){this._tasks.push(i),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(i){this._idleCallback=void 0;let e=0,t=0,s=i.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(e=performance.now(),this._tasks[this._i]()||this._i++,e=Math.max(1,performance.now()-e),t=Math.max(e,t),r=i.timeRemaining(),t*1.5>r){s-e<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-e))}ms`),this._start();return}s=r}this.clear()}},Uie=class extends BD{_requestCallback(i){return setTimeout(()=>i(this._createDeadline(16)))}_cancelCallback(i){clearTimeout(i)}_createDeadline(i){let e=performance.now()+i;return{timeRemaining:()=>Math.max(0,e-performance.now())}}},Yie=class extends BD{_requestCallback(i){return requestIdleCallback(i)}_cancelCallback(i){cancelIdleCallback(i)}},Hie=!tx&&"requestIdleCallback"in window?Yie:Uie,sh=class DD{constructor(){this.fg=0,this.bg=0,this.extended=new zD}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let e=new DD;return e.fg=this.fg,e.bg=this.bg,e.extended=this.extended.clone(),e}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}},zD=class ND{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new ND(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Fie=globalThis.performance&&typeof globalThis.performance.now=="function",Gie=class XD{static create(e){return new XD(e)}constructor(e){this._now=Fie&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Nn;(i=>{i.None=()=>Cr.None;function e(R,L){return m(R,()=>{},0,void 0,!0,void 0,L)}i.defer=e;function t(R){return(L,N=null,Z)=>{let Q=!1,X;return X=R(W=>{if(!Q)return X?X.dispose():Q=!0,L.call(N,W)},null,Z),Q&&X.dispose(),X}}i.once=t;function s(R,L,N){return u((Z,Q=null,X)=>R(W=>Z.call(Q,L(W)),null,X),N)}i.map=s;function r(R,L,N){return u((Z,Q=null,X)=>R(W=>{L(W),Z.call(Q,W)},null,X),N)}i.forEach=r;function n(R,L,N){return u((Z,Q=null,X)=>R(W=>L(W)&&Z.call(Q,W),null,X),N)}i.filter=n;function o(R){return R}i.signal=o;function l(...R){return(L,N=null,Z)=>{let Q=AD(...R.map(X=>X(W=>L.call(N,W))));return d(Q,Z)}}i.any=l;function c(R,L,N,Z){let Q=N;return s(R,X=>(Q=L(Q,X),Q),Z)}i.reduce=c;function u(R,L){let N,Z={onWillAddFirstListener(){N=R(Q.fire,Q)},onDidRemoveLastListener(){N==null||N.dispose()}},Q=new yt(Z);return L==null||L.add(Q),Q.event}function d(R,L){return L instanceof Array?L.push(R):L&&L.add(R),R}function m(R,L,N=100,Z=!1,Q=!1,X,W){let U,q,D,G=0,ie,ce={leakWarningThreshold:X,onWillAddFirstListener(){U=R(de=>{G++,q=L(q,de),Z&&!D&&(he.fire(q),q=void 0),ie=()=>{let ge=q;q=void 0,D=void 0,(!Z||G>1)&&he.fire(ge),G=0},typeof N=="number"?(clearTimeout(D),D=setTimeout(ie,N)):D===void 0&&(D=0,queueMicrotask(ie))})},onWillRemoveListener(){Q&&G>0&&(ie==null||ie())},onDidRemoveLastListener(){ie=void 0,U.dispose()}},he=new yt(ce);return W==null||W.add(he),he.event}i.debounce=m;function g(R,L=0,N){return i.debounce(R,(Z,Q)=>Z?(Z.push(Q),Z):[Q],L,void 0,!0,void 0,N)}i.accumulate=g;function _(R,L=(Z,Q)=>Z===Q,N){let Z=!0,Q;return n(R,X=>{let W=Z||!L(X,Q);return Z=!1,Q=X,W},N)}i.latch=_;function y(R,L,N){return[i.filter(R,L,N),i.filter(R,Z=>!L(Z),N)]}i.split=y;function b(R,L=!1,N=[],Z){let Q=N.slice(),X=R(q=>{Q?Q.push(q):U.fire(q)});Z&&Z.add(X);let W=()=>{Q==null||Q.forEach(q=>U.fire(q)),Q=null},U=new yt({onWillAddFirstListener(){X||(X=R(q=>U.fire(q)),Z&&Z.add(X))},onDidAddFirstListener(){Q&&(L?setTimeout(W):W())},onDidRemoveLastListener(){X&&X.dispose(),X=null}});return Z&&Z.add(U),U.event}i.buffer=b;function x(R,L){return(N,Z,Q)=>{let X=L(new k);return R(function(W){let U=X.evaluate(W);U!==w&&N.call(Z,U)},void 0,Q)}}i.chain=x;let w=Symbol("HaltChainable");class k{constructor(){this.steps=[]}map(L){return this.steps.push(L),this}forEach(L){return this.steps.push(N=>(L(N),N)),this}filter(L){return this.steps.push(N=>L(N)?N:w),this}reduce(L,N){let Z=N;return this.steps.push(Q=>(Z=L(Z,Q),Z)),this}latch(L=(N,Z)=>N===Z){let N=!0,Z;return this.steps.push(Q=>{let X=N||!L(Q,Z);return N=!1,Z=Q,X?Q:w}),this}evaluate(L){for(let N of this.steps)if(L=N(L),L===w)break;return L}}function C(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.on(L,Z),X=()=>R.removeListener(L,Z),W=new yt({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromNodeEventEmitter=C;function A(R,L,N=Z=>Z){let Z=(...U)=>W.fire(N(...U)),Q=()=>R.addEventListener(L,Z),X=()=>R.removeEventListener(L,Z),W=new yt({onWillAddFirstListener:Q,onDidRemoveLastListener:X});return W.event}i.fromDOMEventEmitter=A;function P(R){return new Promise(L=>t(R)(L))}i.toPromise=P;function E(R){let L=new yt;return R.then(N=>{L.fire(N)},()=>{L.fire(void 0)}).finally(()=>{L.dispose()}),L.event}i.fromPromise=E;function $(R,L){return R(N=>L.fire(N))}i.forward=$;function z(R,L,N){return L(N),R(Z=>L(Z))}i.runAndSubscribe=z;class I{constructor(L,N){this._observable=L,this._counter=0,this._hasChanged=!1;let Z={onWillAddFirstListener:()=>{L.addObserver(this)},onDidRemoveLastListener:()=>{L.removeObserver(this)}};this.emitter=new yt(Z),N&&N.add(this.emitter)}beginUpdate(L){this._counter++}handlePossibleChange(L){}handleChange(L,N){this._hasChanged=!0}endUpdate(L){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function se(R,L){return new I(R,L).emitter.event}i.fromObservable=se;function F(R){return(L,N,Z)=>{let Q=0,X=!1,W={beginUpdate(){Q++},endUpdate(){Q--,Q===0&&(R.reportChanges(),X&&(X=!1,L.call(N)))},handlePossibleChange(){},handleChange(){X=!0}};R.addObserver(W),R.reportChanges();let U={dispose(){R.removeObserver(W)}};return Z instanceof ph?Z.add(U):Array.isArray(Z)&&Z.push(U),U}}i.fromObservableLight=F})(Nn||(Nn={}));var ab=class lb{constructor(e){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${e}_${lb._idPool++}`,lb.all.add(this)}start(e){this._stopWatch=new Gie,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};ab.all=new Set,ab._idPool=0;var Kie=ab,Jie=-1,VD=class ZD{constructor(e,t,s=(ZD._idPool++).toString(16).padStart(3,"0")){this._errorHandler=e,this.threshold=t,this.name=s,this._warnCountdown=0}dispose(){var e;(e=this._stacks)==null||e.clear()}check(e,t){let s=this.threshold;if(s<=0||t<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[n,o]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${t} listeners already. MOST frequent listener (${o}):`;console.warn(l),console.warn(n);let c=new ise(l,n);this._errorHandler(c)}return()=>{let n=this._stacks.get(e.value)||0;this._stacks.set(e.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[s,r]of this._stacks)(!e||t<r)&&(e=[s,r],t=r);return e}};VD._idPool=1;var ese=VD,tse=class jD{constructor(e){this.value=e}static create(){let e=new Error;return new jD(e.stack??"")}print(){console.warn(this.value.split(`
131
138
  `).slice(2).join(`
132
- `))}},Pie=class extends Error{constructor(i,e){super(i),this.name="ListenerLeakError",this.stack=e}},Qie=class extends Error{constructor(i,e){super(i),this.name="ListenerRefusalError",this.stack=e}},Rie=0,gv=class{constructor(i){this.value=i,this.id=Rie++}},Lie=2,$ie,yt=class{constructor(e){var t,s,r,n;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new Mie((e==null?void 0:e.onListenerError)??pv,((s=this._options)==null?void 0:s.leakWarningThreshold)??Aie):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Tie(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var e,t,s,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var l,c,u,d,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let g=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(g);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new Qie(`${g}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||pv)(y),Cr.None}if(this._disposed)return Cr.None;t&&(e=e.bind(t));let r=new gv(e),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Eie.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof gv?(this._deliveryQueue??(this._deliveryQueue=new Bie),this._listeners=[this._listeners,r]):this._listeners.push(r):((u=(c=this._options)==null?void 0:c.onWillAddFirstListener)==null||u.call(c,this),this._listeners=r,(m=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||m.call(d,this)),this._size++;let o=ji(()=>{n==null||n(),this._removeListener(r)});return s instanceof ph?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var n,o,l,c;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(c=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||c.call(l,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 r=this._deliveryQueue.current===this;if(this._size*Lie<=t.length){let u=0;for(let d=0;d<t.length;d++)t[d]?t[u++]=t[d]:r&&(this._deliveryQueue.end--,u<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=u}}_deliver(e,t){var r;if(!e)return;let s=((r=this._options)==null?void 0:r.onListenerError)||pv;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,s,r,n;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof gv)this._deliver(this._listeners,e);else{let o=this._deliveryQueue;o.enqueue(this,e,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},Bie=class{constructor(){this.i=-1,this.end=0}enqueue(i,e,t){this.i=0,this.end=t,this.current=i,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},mE={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},tu=2,iu,Po=class Ul{constructor(e,t,s){this._document=e,this._config=t,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new pE,this._cacheMapCombined=new pE,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new sh,this._textureSize=512,this._onAddTextureAtlasCanvas=new yt,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new yt,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=XD(e,this._config.deviceCellWidth*4+tu*2,this._config.deviceCellHeight+tu*2),this._tmpCtx=Wt(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new wie;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let s=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,s)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Ul.maxAtlasPages&&this._pages.length>=Math.max(4,Ul.maxAtlasPages)){let t=this._pages.filter(u=>u.canvas.width*2<=(Ul.maxTextureSize||4096)).sort((u,d)=>d.canvas.width!==u.canvas.width?d.canvas.width-u.canvas.width:d.percentageUsed-u.percentageUsed),s=-1,r=0;for(let u=0;u<t.length;u++)if(t[u].canvas.width!==r)s=u,r=t[u].canvas.width;else if(u-s===3)break;let n=t.slice(s,s+4),o=n.map(u=>u.glyphs[0].texturePage).sort((u,d)=>u>d?1:-1),l=this.pages.length-n.length,c=this._mergePages(n,l);c.version++;for(let u=o.length-1;u>=0;u--)this._deletePage(o[u]);this.pages.push(c),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(c.canvas)}let e=new Ov(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,t){let s=e[0].canvas.width*2,r=new Ov(this._document,s,e);for(let[n,o]of e.entries()){let l=n*o.canvas.width%s,c=Math.floor(n/2)*o.canvas.height;r.ctx.drawImage(o.canvas,l,c);for(let d of o.glyphs)d.texturePage=t,d.sizeClipSpace.x=d.size.x/s,d.sizeClipSpace.y=d.size.y/s,d.texturePosition.x+=l,d.texturePosition.y+=c,d.texturePositionClipSpace.x=d.texturePosition.x/s,d.texturePositionClipSpace.y=d.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(o.canvas);let u=this._activePages.indexOf(o);u!==-1&&this._activePages.splice(u,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let s=this._pages[t];for(let r of s.glyphs)r.texturePage--;s.version++}}getRasterizedGlyphCombinedChar(e,t,s,r,n,o){return this._getFromCacheMap(this._cacheMapCombined,e,t,s,r,n,o)}getRasterizedGlyph(e,t,s,r,n,o){return this._getFromCacheMap(this._cacheMap,e,t,s,r,n,o)}_getFromCacheMap(e,t,s,r,n,o,l){return iu=e.get(t,s,r,n),iu||(iu=this._drawToCache(t,s,r,n,o,l),e.set(t,s,r,n,iu)),iu}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,s,r){if(this._config.allowTransparency)return Gs;let n;switch(e){case 16777216:case 33554432:n=this._getColorFromAnsiIndex(t);break;case 50331648:let o=sh.toColorRGB(t);n=Ki.toColor(o[0],o[1],o[2]);break;case 0:default:s?n=gu.opaque(this._config.colors.foreground):n=this._config.colors.background;break}return this._config.allowTransparency||(n=gu.opaque(n)),n}_getForegroundColor(e,t,s,r,n,o,l,c,u,d){let m=this._getMinimumContrastColor(e,t,s,r,n,o,l,u,c,d);if(m)return m;let g;switch(n){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&u&&o<8&&(o+=8),g=this._getColorFromAnsiIndex(o);break;case 50331648:let _=sh.toColorRGB(o);g=Ki.toColor(_[0],_[1],_[2]);break;case 0:default:l?g=this._config.colors.background:g=this._config.colors.foreground}return this._config.allowTransparency&&(g=gu.opaque(g)),c&&(g=gu.multiplyOpacity(g,die)),g}_resolveBackgroundRgba(e,t,s){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;case 0:default:return s?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,s,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;case 0:default:return s?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,s,r,n,o,l,c,u,d){if(this._config.minimumContrastRatio===1||d)return;let m=this._getContrastCache(u),g=m.getColor(e,r);if(g!==void 0)return g||void 0;let _=this._resolveBackgroundRgba(t,s,l),y=this._resolveForegroundRgba(n,o,l,c),b=Va.ensureContrastRatio(_,y,this._config.minimumContrastRatio/(u?2:1));if(!b){m.setColor(e,r,null);return}let x=Ki.toColor(b>>24&255,b>>16&255,b>>8&255);return m.setColor(e,r,x),x}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,t,s,r,n,o){let l=typeof e=="number"?String.fromCharCode(e):e;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(l.length,2)+tu*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<c&&(this._tmpCanvas.width=c);let u=Math.min(this._config.deviceCellHeight+tu*4,this._textureSize);if(this._tmpCanvas.height<u&&(this._tmpCanvas.height=u),this._tmpCtx.save(),this._workAttributeData.fg=s,this._workAttributeData.bg=t,this._workAttributeData.extended.ext=r,!!this._workAttributeData.isInvisible())return mE;let d=!!this._workAttributeData.isBold(),m=!!this._workAttributeData.isInverse(),g=!!this._workAttributeData.isDim(),_=!!this._workAttributeData.isItalic(),y=!!this._workAttributeData.isUnderline(),b=!!this._workAttributeData.isStrikethrough(),x=!!this._workAttributeData.isOverline(),w=this._workAttributeData.getFgColor(),k=this._workAttributeData.getFgColorMode(),C=this._workAttributeData.getBgColor(),A=this._workAttributeData.getBgColorMode();if(m){let q=w;w=C,C=q;let D=k;k=A,A=D}let P=this._getBackgroundColor(A,C,m,g);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=P.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let E=d?this._config.fontWeightBold:this._config.fontWeight,$=_?"italic":"";this._tmpCtx.font=`${$} ${E} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=MD;let z=l.length===1&&tx(l.charCodeAt(0)),I=l.length===1&&nie(l.charCodeAt(0)),se=this._getForegroundColor(t,A,C,s,k,w,m,g,d,AD(l.charCodeAt(0)));this._tmpCtx.fillStyle=se.css;let F=I?0:tu*2,R=!1;this._config.customGlyphs!==!1&&(R=Oie(this._tmpCtx,l,F,F,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let L=!z,N;if(typeof e=="number"?N=this._unicodeService.wcwidth(e):N=this._unicodeService.getStringCellWidth(e),y){this._tmpCtx.save();let q=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),D=q%2===1?.5:0;if(this._tmpCtx.lineWidth=q,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())L=!1,this._tmpCtx.strokeStyle=`rgb(${sh.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{L=!1;let ge=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&ge<8&&(ge+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(ge).css}this._tmpCtx.beginPath();let G=F,ie=Math.ceil(F+this._config.deviceCharHeight)-D-(n?q*2:0),ce=ie+q,he=ie+q*2,de=this._workAttributeData.getUnderlineVariantOffset();for(let ge=0;ge<N;ge++){this._tmpCtx.save();let Ae=G+ge*this._config.deviceCellWidth,ye=G+(ge+1)*this._config.deviceCellWidth,mt=Ae+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(ye,ie),this._tmpCtx.moveTo(Ae,he),this._tmpCtx.lineTo(ye,he);break;case 3:let Ft=q<=1?he:Math.ceil(F+this._config.deviceCharHeight-q/2)-D,Gt=q<=1?ie:Math.ceil(F+this._config.deviceCharHeight+q/2)-D,oi=new Path2D;oi.rect(Ae,ie,this._config.deviceCellWidth,he-ie),this._tmpCtx.clip(oi),this._tmpCtx.moveTo(Ae-this._config.deviceCellWidth/2,ce),this._tmpCtx.bezierCurveTo(Ae-this._config.deviceCellWidth/2,Gt,Ae,Gt,Ae,ce),this._tmpCtx.bezierCurveTo(Ae,Ft,mt,Ft,mt,ce),this._tmpCtx.bezierCurveTo(mt,Gt,ye,Gt,ye,ce),this._tmpCtx.bezierCurveTo(ye,Ft,ye+this._config.deviceCellWidth/2,Ft,ye+this._config.deviceCellWidth/2,ce);break;case 4:let Pe=de===0?0:de>=q?q*2-de:q-de;de>=q||Pe===0?(this._tmpCtx.setLineDash([Math.round(q),Math.round(q)]),this._tmpCtx.moveTo(Ae+Pe,ie),this._tmpCtx.lineTo(ye,ie)):(this._tmpCtx.setLineDash([Math.round(q),Math.round(q)]),this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(Ae+Pe,ie),this._tmpCtx.moveTo(Ae+Pe+q,ie),this._tmpCtx.lineTo(ye,ie)),de=uie(ye-Ae,q,de);break;case 5:let ln=.6,Xh=.3,Vh=ye-Ae,Zh=Math.floor(ln*Vh),el=Math.floor(Xh*Vh),jh=Vh-Zh-el;this._tmpCtx.setLineDash([Zh,el,jh]),this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(ye,ie);break;case 1:default:this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(ye,ie);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!R&&this._config.fontSize>=12&&!this._config.allowTransparency&&l!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let ge=this._tmpCtx.measureText(l);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in ge&&ge.actualBoundingBoxDescent>0){this._tmpCtx.save();let Ae=new Path2D;Ae.rect(G,ie-Math.ceil(q/2),this._config.deviceCellWidth*N,he-ie+Math.ceil(q/2)),this._tmpCtx.clip(Ae),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=P.css,this._tmpCtx.strokeText(l,F,F+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(x){let q=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),D=q%2===1?.5:0;this._tmpCtx.lineWidth=q,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(F,F+D),this._tmpCtx.lineTo(F+this._config.deviceCharWidth*N,F+D),this._tmpCtx.stroke()}if(R||this._tmpCtx.fillText(l,F,F+this._config.deviceCharHeight),l==="_"&&!this._config.allowTransparency){let q=_v(this._tmpCtx.getImageData(F,F,this._config.deviceCellWidth,this._config.deviceCellHeight),P,se,L);if(q)for(let D=1;D<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=P.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(l,F,F+this._config.deviceCharHeight-D),q=_v(this._tmpCtx.getImageData(F,F,this._config.deviceCellWidth,this._config.deviceCellHeight),P,se,L),!!q);D++);}if(b){let q=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),D=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=q,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(F,F+Math.floor(this._config.deviceCharHeight/2)-D),this._tmpCtx.lineTo(F+this._config.deviceCharWidth*N,F+Math.floor(this._config.deviceCharHeight/2)-D),this._tmpCtx.stroke()}this._tmpCtx.restore();let Z=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),Q;if(this._config.allowTransparency?Q=Die(Z):Q=_v(Z,P,se,L),Q)return mE;let X=this._findGlyphBoundingBox(Z,this._workBoundingBox,c,I,R,F),W,U;for(;;){if(this._activePages.length===0){let q=this._createNewPage();W=q,U=q.currentRow,U.height=X.size.y;break}W=this._activePages[this._activePages.length-1],U=W.currentRow;for(let q of this._activePages)X.size.y<=q.currentRow.height&&(W=q,U=q.currentRow);for(let q=this._activePages.length-1;q>=0;q--)for(let D of this._activePages[q].fixedRows)D.height<=U.height&&X.size.y<=D.height&&(W=this._activePages[q],U=D);if(X.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Ov(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),W=this._overflowSizePage,U=this._overflowSizePage.currentRow,U.x+X.size.x>=W.canvas.width&&(U.x=0,U.y+=U.height,U.height=0);break}if(U.y+X.size.y>=W.canvas.height||U.height>X.size.y+2){let q=!1;if(W.currentRow.y+W.currentRow.height+X.size.y>=W.canvas.height){let D;for(let G of this._activePages)if(G.currentRow.y+G.currentRow.height+X.size.y<G.canvas.height){D=G;break}if(D)W=D;else if(Ul.maxAtlasPages&&this._pages.length>=Ul.maxAtlasPages&&U.y+X.size.y<=W.canvas.height&&U.height>=X.size.y&&U.x+X.size.x<=W.canvas.width)q=!0;else{let G=this._createNewPage();W=G,U=G.currentRow,U.height=X.size.y,q=!0}}q||(W.currentRow.height>0&&W.fixedRows.push(W.currentRow),U={x:0,y:W.currentRow.y+W.currentRow.height,height:X.size.y},W.fixedRows.push(U),W.currentRow={x:0,y:U.y+U.height,height:0})}if(U.x+X.size.x<=W.canvas.width)break;U===W.currentRow?(U.x=0,U.y+=U.height,U.height=0):W.fixedRows.splice(W.fixedRows.indexOf(U),1)}return X.texturePage=this._pages.indexOf(W),X.texturePosition.x=U.x,X.texturePosition.y=U.y,X.texturePositionClipSpace.x=U.x/W.canvas.width,X.texturePositionClipSpace.y=U.y/W.canvas.height,X.sizeClipSpace.x/=W.canvas.width,X.sizeClipSpace.y/=W.canvas.height,U.height=Math.max(U.height,X.size.y),U.x+=X.size.x,W.ctx.putImageData(Z,X.texturePosition.x-this._workBoundingBox.left,X.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,X.size.x,X.size.y),W.addGlyph(X),W.version++,X}_findGlyphBoundingBox(e,t,s,r,n,o){t.top=0;let l=r?this._config.deviceCellHeight:this._tmpCanvas.height,c=r?this._config.deviceCellWidth:s,u=!1;for(let d=0;d<l;d++){for(let m=0;m<c;m++){let g=d*this._tmpCanvas.width*4+m*4+3;if(e.data[g]!==0){t.top=d,u=!0;break}}if(u)break}t.left=0,u=!1;for(let d=0;d<o+c;d++){for(let m=0;m<l;m++){let g=m*this._tmpCanvas.width*4+d*4+3;if(e.data[g]!==0){t.left=d,u=!0;break}}if(u)break}t.right=c,u=!1;for(let d=o+c-1;d>=o;d--){for(let m=0;m<l;m++){let g=m*this._tmpCanvas.width*4+d*4+3;if(e.data[g]!==0){t.right=d,u=!0;break}}if(u)break}t.bottom=l,u=!1;for(let d=l-1;d>=0;d--){for(let m=0;m<c;m++){let g=d*this._tmpCanvas.width*4+m*4+3;if(e.data[g]!==0){t.bottom=d,u=!0;break}}if(u)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+o+(r||n?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+o+(r||n?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Ov=class{constructor(i,e,t){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],t)for(let s of t)this._glyphs.push(...s.glyphs),this._usedPixels+=s._usedPixels;this.canvas=XD(i,e,e),this.ctx=Wt(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(i){this._glyphs.push(i),this._usedPixels+=i.size.x*i.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function _v(i,e,t,s){let r=e.rgba>>>24,n=e.rgba>>>16&255,o=e.rgba>>>8&255,l=t.rgba>>>24,c=t.rgba>>>16&255,u=t.rgba>>>8&255,d=Math.floor((Math.abs(r-l)+Math.abs(n-c)+Math.abs(o-u))/12),m=!0;for(let g=0;g<i.data.length;g+=4)i.data[g]===r&&i.data[g+1]===n&&i.data[g+2]===o||s&&Math.abs(i.data[g]-r)+Math.abs(i.data[g+1]-n)+Math.abs(i.data[g+2]-o)<d?i.data[g+3]=0:m=!1;return m}function Die(i){for(let e=0;e<i.data.length;e+=4)if(i.data[e+3]>0)return!1;return!0}function XD(i,e,t){let s=i.createElement("canvas");return s.width=e,s.height=t,s}function zie(i,e,t,s,r,n,o,l){let c={foreground:n.foreground,background:n.background,cursor:Gs,cursorAccent:Gs,selectionForeground:Gs,selectionBackgroundTransparent:Gs,selectionBackgroundOpaque:Gs,selectionInactiveBackgroundTransparent:Gs,selectionInactiveBackgroundOpaque:Gs,overviewRulerBorder:Gs,scrollbarSliderBackground:Gs,scrollbarSliderHoverBackground:Gs,scrollbarSliderActiveBackground:Gs,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:r.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:l,letterSpacing:r.letterSpacing,lineHeight:r.lineHeight,deviceCellWidth:i,deviceCellHeight:e,deviceCharWidth:t,deviceCharHeight:s,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,drawBoldTextInBrightColors:r.drawBoldTextInBrightColors,minimumContrastRatio:r.minimumContrastRatio,colors:c}}function gE(i,e){for(let t=0;t<i.colors.ansi.length;t++)if(i.colors.ansi[t].rgba!==e.colors.ansi[t].rgba)return!1;return i.devicePixelRatio===e.devicePixelRatio&&i.customGlyphs===e.customGlyphs&&i.lineHeight===e.lineHeight&&i.letterSpacing===e.letterSpacing&&i.fontFamily===e.fontFamily&&i.fontSize===e.fontSize&&i.fontWeight===e.fontWeight&&i.fontWeightBold===e.fontWeightBold&&i.allowTransparency===e.allowTransparency&&i.deviceCharWidth===e.deviceCharWidth&&i.deviceCharHeight===e.deviceCharHeight&&i.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&i.minimumContrastRatio===e.minimumContrastRatio&&i.colors.foreground.rgba===e.colors.foreground.rgba&&i.colors.background.rgba===e.colors.background.rgba}function Nie(i){return(i&50331648)===16777216||(i&50331648)===33554432}var er=[];function VD(i,e,t,s,r,n,o,l,c){let u=zie(s,r,n,o,e,t,l,c);for(let g=0;g<er.length;g++){let _=er[g],y=_.ownedBy.indexOf(i);if(y>=0){if(gE(_.config,u))return _.atlas;_.ownedBy.length===1?(_.atlas.dispose(),er.splice(g,1)):_.ownedBy.splice(y,1);break}}for(let g=0;g<er.length;g++){let _=er[g];if(gE(_.config,u))return _.ownedBy.push(i),_.atlas}let d=i._core,m={atlas:new Po(document,u,d.unicodeService),config:u,ownedBy:[i]};return er.push(m),m.atlas}function OE(i){for(let e=0;e<er.length;e++){let t=er[e].ownedBy.indexOf(i);if(t!==-1){er[e].ownedBy.length===1?(er[e].atlas.dispose(),er.splice(e,1)):er[e].ownedBy.splice(t,1);break}}}var Rp=600,Xie=class{constructor(i,e){this._renderCallback=i,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(i=Rp){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Rp-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Rp-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Rp)},i)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function _E(i,e,t){let s=new e.ResizeObserver(r=>{let n=r.find(c=>c.target===i);if(!n)return;if(!("devicePixelContentBoxSize"in n)){s==null||s.disconnect(),s=void 0;return}let o=n.devicePixelContentBoxSize[0].inlineSize,l=n.devicePixelContentBoxSize[0].blockSize;o>0&&l>0&&t(o,l)});try{s.observe(i,{box:["device-pixel-content-box"]})}catch{s.disconnect(),s=void 0}return ji(()=>s==null?void 0:s.disconnect())}function Vie(i){return i>65535?(i-=65536,String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)}var vE=class ZD extends sh{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new LD,this.combinedData=""}static fromCharData(e){let t=new ZD;return t.setFromCharData(e),t}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Vie(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},jD=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function ID(i,e,t){let s=Wt(i.createProgram());if(i.attachShader(s,Wt(yE(i,i.VERTEX_SHADER,e))),i.attachShader(s,Wt(yE(i,i.FRAGMENT_SHADER,t))),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS))return s;console.error(i.getProgramInfoLog(s)),i.deleteProgram(s)}function yE(i,e,t){let s=Wt(i.createShader(e));if(i.shaderSource(s,t),i.compileShader(s),i.getShaderParameter(s,i.COMPILE_STATUS))return s;console.error(i.getShaderInfoLog(s)),i.deleteShader(s)}function Zie(i,e){let t=Math.min(i.length*2,e),s=new Float32Array(t);for(let r=0;r<i.length;r++)s[r]=i[r];return s}var jie=class{constructor(i){this.texture=i,this.version=-1}},Iie=`#version 300 es
139
+ `))}},ise=class extends Error{constructor(i,e){super(i),this.name="ListenerLeakError",this.stack=e}},sse=class extends Error{constructor(i,e){super(i),this.name="ListenerRefusalError",this.stack=e}},rse=0,Nv=class{constructor(i){this.value=i,this.id=rse++}},nse=2,ose,yt=class{constructor(e){var t,s,r,n;this._size=0,this._options=e,this._leakageMon=(t=this._options)!=null&&t.leakWarningThreshold?new ese((e==null?void 0:e.onListenerError)??Dv,((s=this._options)==null?void 0:s.leakWarningThreshold)??Jie):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Kie(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var e,t,s,r;this._disposed||(this._disposed=!0,((e=this._deliveryQueue)==null?void 0:e.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(t=this._options)==null?void 0:t.onDidRemoveLastListener)==null||s.call(t),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(e,t,s)=>{var l,c,u,d,m;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let g=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(g);let _=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new sse(`${g}. HINT: Stack shows most frequent listener (${_[1]}-times)`,_[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Dv)(y),Cr.None}if(this._disposed)return Cr.None;t&&(e=e.bind(t));let r=new Nv(e),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=tse.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Nv?(this._deliveryQueue??(this._deliveryQueue=new ase),this._listeners=[this._listeners,r]):this._listeners.push(r):((u=(c=this._options)==null?void 0:c.onWillAddFirstListener)==null||u.call(c,this),this._listeners=r,(m=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||m.call(d,this)),this._size++;let o=ji(()=>{n==null||n(),this._removeListener(r)});return s instanceof ph?s.add(o):Array.isArray(s)&&s.push(o),o}),this._event}_removeListener(e){var n,o,l,c;if((o=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||o.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(c=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||c.call(l,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 r=this._deliveryQueue.current===this;if(this._size*nse<=t.length){let u=0;for(let d=0;d<t.length;d++)t[d]?t[u++]=t[d]:r&&(this._deliveryQueue.end--,u<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=u}}_deliver(e,t){var r;if(!e)return;let s=((r=this._options)==null?void 0:r.onListenerError)||Dv;if(!s){e.value(t);return}try{e.value(t)}catch(n){s(n)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){var t,s,r,n;if((t=this._deliveryQueue)!=null&&t.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof Nv)this._deliver(this._listeners,e);else{let o=this._deliveryQueue;o.enqueue(this,e,this._listeners.length),this._deliverQueue(o)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},ase=class{constructor(){this.i=-1,this.end=0}enqueue(i,e,t){this.i=0,this.end=t,this.current=i,this.value=e}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},jE={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},iu=2,su,Po=class Ul{constructor(e,t,s){this._document=e,this._config=t,this._unicodeService=s,this._didWarmUp=!1,this._cacheMap=new ZE,this._cacheMapCombined=new ZE,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new sh,this._textureSize=512,this._onAddTextureAtlasCanvas=new yt,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new yt,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=ID(e,this._config.deviceCellWidth*4+iu*2,this._config.deviceCellHeight+iu*2),this._tmpCtx=Wt(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let e=new Hie;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let s=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,s)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(Ul.maxAtlasPages&&this._pages.length>=Math.max(4,Ul.maxAtlasPages)){let t=this._pages.filter(u=>u.canvas.width*2<=(Ul.maxTextureSize||4096)).sort((u,d)=>d.canvas.width!==u.canvas.width?d.canvas.width-u.canvas.width:d.percentageUsed-u.percentageUsed),s=-1,r=0;for(let u=0;u<t.length;u++)if(t[u].canvas.width!==r)s=u,r=t[u].canvas.width;else if(u-s===3)break;let n=t.slice(s,s+4),o=n.map(u=>u.glyphs[0].texturePage).sort((u,d)=>u>d?1:-1),l=this.pages.length-n.length,c=this._mergePages(n,l);c.version++;for(let u=o.length-1;u>=0;u--)this._deletePage(o[u]);this.pages.push(c),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(c.canvas)}let e=new Xv(this._document,this._textureSize);return this._pages.push(e),this._activePages.push(e),this._onAddTextureAtlasCanvas.fire(e.canvas),e}_mergePages(e,t){let s=e[0].canvas.width*2,r=new Xv(this._document,s,e);for(let[n,o]of e.entries()){let l=n*o.canvas.width%s,c=Math.floor(n/2)*o.canvas.height;r.ctx.drawImage(o.canvas,l,c);for(let d of o.glyphs)d.texturePage=t,d.sizeClipSpace.x=d.size.x/s,d.sizeClipSpace.y=d.size.y/s,d.texturePosition.x+=l,d.texturePosition.y+=c,d.texturePositionClipSpace.x=d.texturePosition.x/s,d.texturePositionClipSpace.y=d.texturePosition.y/s;this._onRemoveTextureAtlasCanvas.fire(o.canvas);let u=this._activePages.indexOf(o);u!==-1&&this._activePages.splice(u,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t<this._pages.length;t++){let s=this._pages[t];for(let r of s.glyphs)r.texturePage--;s.version++}}getRasterizedGlyphCombinedChar(e,t,s,r,n,o){return this._getFromCacheMap(this._cacheMapCombined,e,t,s,r,n,o)}getRasterizedGlyph(e,t,s,r,n,o){return this._getFromCacheMap(this._cacheMap,e,t,s,r,n,o)}_getFromCacheMap(e,t,s,r,n,o,l){return su=e.get(t,s,r,n),su||(su=this._drawToCache(t,s,r,n,o,l),e.set(t,s,r,n,su)),su}_getColorFromAnsiIndex(e){if(e>=this._config.colors.ansi.length)throw new Error("No color found for idx "+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,s,r){if(this._config.allowTransparency)return Gs;let n;switch(e){case 16777216:case 33554432:n=this._getColorFromAnsiIndex(t);break;case 50331648:let o=sh.toColorRGB(t);n=Ki.toColor(o[0],o[1],o[2]);break;case 0:default:s?n=gu.opaque(this._config.colors.foreground):n=this._config.colors.background;break}return this._config.allowTransparency||(n=gu.opaque(n)),n}_getForegroundColor(e,t,s,r,n,o,l,c,u,d){let m=this._getMinimumContrastColor(e,t,s,r,n,o,l,u,c,d);if(m)return m;let g;switch(n){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&u&&o<8&&(o+=8),g=this._getColorFromAnsiIndex(o);break;case 50331648:let _=sh.toColorRGB(o);g=Ki.toColor(_[0],_[1],_[2]);break;case 0:default:l?g=this._config.colors.background:g=this._config.colors.foreground}return this._config.allowTransparency&&(g=gu.opaque(g)),c&&(g=gu.multiplyOpacity(g,zie)),g}_resolveBackgroundRgba(e,t,s){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;case 0:default:return s?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,s,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;case 0:default:return s?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,s,r,n,o,l,c,u,d){if(this._config.minimumContrastRatio===1||d)return;let m=this._getContrastCache(u),g=m.getColor(e,r);if(g!==void 0)return g||void 0;let _=this._resolveBackgroundRgba(t,s,l),y=this._resolveForegroundRgba(n,o,l,c),b=Va.ensureContrastRatio(_,y,this._config.minimumContrastRatio/(u?2:1));if(!b){m.setColor(e,r,null);return}let x=Ki.toColor(b>>24&255,b>>16&255,b>>8&255);return m.setColor(e,r,x),x}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(e,t,s,r,n,o){let l=typeof e=="number"?String.fromCharCode(e):e;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display="none",o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(l.length,2)+iu*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<c&&(this._tmpCanvas.width=c);let u=Math.min(this._config.deviceCellHeight+iu*4,this._textureSize);if(this._tmpCanvas.height<u&&(this._tmpCanvas.height=u),this._tmpCtx.save(),this._workAttributeData.fg=s,this._workAttributeData.bg=t,this._workAttributeData.extended.ext=r,!!this._workAttributeData.isInvisible())return jE;let d=!!this._workAttributeData.isBold(),m=!!this._workAttributeData.isInverse(),g=!!this._workAttributeData.isDim(),_=!!this._workAttributeData.isItalic(),y=!!this._workAttributeData.isUnderline(),b=!!this._workAttributeData.isStrikethrough(),x=!!this._workAttributeData.isOverline(),w=this._workAttributeData.getFgColor(),k=this._workAttributeData.getFgColorMode(),C=this._workAttributeData.getBgColor(),A=this._workAttributeData.getBgColorMode();if(m){let q=w;w=C,C=q;let D=k;k=A,A=D}let P=this._getBackgroundColor(A,C,m,g);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=P.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let E=d?this._config.fontWeightBold:this._config.fontWeight,$=_?"italic":"";this._tmpCtx.font=`${$} ${E} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=RD;let z=l.length===1&&ix(l.charCodeAt(0)),I=l.length===1&&Eie(l.charCodeAt(0)),se=this._getForegroundColor(t,A,C,s,k,w,m,g,d,QD(l.charCodeAt(0)));this._tmpCtx.fillStyle=se.css;let F=I?0:iu*2,R=!1;this._config.customGlyphs!==!1&&(R=Zie(this._tmpCtx,l,F,F,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let L=!z,N;if(typeof e=="number"?N=this._unicodeService.wcwidth(e):N=this._unicodeService.getStringCellWidth(e),y){this._tmpCtx.save();let q=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),D=q%2===1?.5:0;if(this._tmpCtx.lineWidth=q,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())L=!1,this._tmpCtx.strokeStyle=`rgb(${sh.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{L=!1;let ge=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&ge<8&&(ge+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(ge).css}this._tmpCtx.beginPath();let G=F,ie=Math.ceil(F+this._config.deviceCharHeight)-D-(n?q*2:0),ce=ie+q,he=ie+q*2,de=this._workAttributeData.getUnderlineVariantOffset();for(let ge=0;ge<N;ge++){this._tmpCtx.save();let Ae=G+ge*this._config.deviceCellWidth,ye=G+(ge+1)*this._config.deviceCellWidth,mt=Ae+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(ye,ie),this._tmpCtx.moveTo(Ae,he),this._tmpCtx.lineTo(ye,he);break;case 3:let Ft=q<=1?he:Math.ceil(F+this._config.deviceCharHeight-q/2)-D,Gt=q<=1?ie:Math.ceil(F+this._config.deviceCharHeight+q/2)-D,oi=new Path2D;oi.rect(Ae,ie,this._config.deviceCellWidth,he-ie),this._tmpCtx.clip(oi),this._tmpCtx.moveTo(Ae-this._config.deviceCellWidth/2,ce),this._tmpCtx.bezierCurveTo(Ae-this._config.deviceCellWidth/2,Gt,Ae,Gt,Ae,ce),this._tmpCtx.bezierCurveTo(Ae,Ft,mt,Ft,mt,ce),this._tmpCtx.bezierCurveTo(mt,Gt,ye,Gt,ye,ce),this._tmpCtx.bezierCurveTo(ye,Ft,ye+this._config.deviceCellWidth/2,Ft,ye+this._config.deviceCellWidth/2,ce);break;case 4:let Pe=de===0?0:de>=q?q*2-de:q-de;de>=q||Pe===0?(this._tmpCtx.setLineDash([Math.round(q),Math.round(q)]),this._tmpCtx.moveTo(Ae+Pe,ie),this._tmpCtx.lineTo(ye,ie)):(this._tmpCtx.setLineDash([Math.round(q),Math.round(q)]),this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(Ae+Pe,ie),this._tmpCtx.moveTo(Ae+Pe+q,ie),this._tmpCtx.lineTo(ye,ie)),de=Bie(ye-Ae,q,de);break;case 5:let ln=.6,Xh=.3,Vh=ye-Ae,Zh=Math.floor(ln*Vh),el=Math.floor(Xh*Vh),jh=Vh-Zh-el;this._tmpCtx.setLineDash([Zh,el,jh]),this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(ye,ie);break;case 1:default:this._tmpCtx.moveTo(Ae,ie),this._tmpCtx.lineTo(ye,ie);break}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!R&&this._config.fontSize>=12&&!this._config.allowTransparency&&l!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let ge=this._tmpCtx.measureText(l);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in ge&&ge.actualBoundingBoxDescent>0){this._tmpCtx.save();let Ae=new Path2D;Ae.rect(G,ie-Math.ceil(q/2),this._config.deviceCellWidth*N,he-ie+Math.ceil(q/2)),this._tmpCtx.clip(Ae),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=P.css,this._tmpCtx.strokeText(l,F,F+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(x){let q=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),D=q%2===1?.5:0;this._tmpCtx.lineWidth=q,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(F,F+D),this._tmpCtx.lineTo(F+this._config.deviceCharWidth*N,F+D),this._tmpCtx.stroke()}if(R||this._tmpCtx.fillText(l,F,F+this._config.deviceCharHeight),l==="_"&&!this._config.allowTransparency){let q=Vv(this._tmpCtx.getImageData(F,F,this._config.deviceCellWidth,this._config.deviceCellHeight),P,se,L);if(q)for(let D=1;D<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=P.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(l,F,F+this._config.deviceCharHeight-D),q=Vv(this._tmpCtx.getImageData(F,F,this._config.deviceCellWidth,this._config.deviceCellHeight),P,se,L),!!q);D++);}if(b){let q=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),D=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=q,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(F,F+Math.floor(this._config.deviceCharHeight/2)-D),this._tmpCtx.lineTo(F+this._config.deviceCharWidth*N,F+Math.floor(this._config.deviceCharHeight/2)-D),this._tmpCtx.stroke()}this._tmpCtx.restore();let Z=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),Q;if(this._config.allowTransparency?Q=lse(Z):Q=Vv(Z,P,se,L),Q)return jE;let X=this._findGlyphBoundingBox(Z,this._workBoundingBox,c,I,R,F),W,U;for(;;){if(this._activePages.length===0){let q=this._createNewPage();W=q,U=q.currentRow,U.height=X.size.y;break}W=this._activePages[this._activePages.length-1],U=W.currentRow;for(let q of this._activePages)X.size.y<=q.currentRow.height&&(W=q,U=q.currentRow);for(let q=this._activePages.length-1;q>=0;q--)for(let D of this._activePages[q].fixedRows)D.height<=U.height&&X.size.y<=D.height&&(W=this._activePages[q],U=D);if(X.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Xv(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),W=this._overflowSizePage,U=this._overflowSizePage.currentRow,U.x+X.size.x>=W.canvas.width&&(U.x=0,U.y+=U.height,U.height=0);break}if(U.y+X.size.y>=W.canvas.height||U.height>X.size.y+2){let q=!1;if(W.currentRow.y+W.currentRow.height+X.size.y>=W.canvas.height){let D;for(let G of this._activePages)if(G.currentRow.y+G.currentRow.height+X.size.y<G.canvas.height){D=G;break}if(D)W=D;else if(Ul.maxAtlasPages&&this._pages.length>=Ul.maxAtlasPages&&U.y+X.size.y<=W.canvas.height&&U.height>=X.size.y&&U.x+X.size.x<=W.canvas.width)q=!0;else{let G=this._createNewPage();W=G,U=G.currentRow,U.height=X.size.y,q=!0}}q||(W.currentRow.height>0&&W.fixedRows.push(W.currentRow),U={x:0,y:W.currentRow.y+W.currentRow.height,height:X.size.y},W.fixedRows.push(U),W.currentRow={x:0,y:U.y+U.height,height:0})}if(U.x+X.size.x<=W.canvas.width)break;U===W.currentRow?(U.x=0,U.y+=U.height,U.height=0):W.fixedRows.splice(W.fixedRows.indexOf(U),1)}return X.texturePage=this._pages.indexOf(W),X.texturePosition.x=U.x,X.texturePosition.y=U.y,X.texturePositionClipSpace.x=U.x/W.canvas.width,X.texturePositionClipSpace.y=U.y/W.canvas.height,X.sizeClipSpace.x/=W.canvas.width,X.sizeClipSpace.y/=W.canvas.height,U.height=Math.max(U.height,X.size.y),U.x+=X.size.x,W.ctx.putImageData(Z,X.texturePosition.x-this._workBoundingBox.left,X.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,X.size.x,X.size.y),W.addGlyph(X),W.version++,X}_findGlyphBoundingBox(e,t,s,r,n,o){t.top=0;let l=r?this._config.deviceCellHeight:this._tmpCanvas.height,c=r?this._config.deviceCellWidth:s,u=!1;for(let d=0;d<l;d++){for(let m=0;m<c;m++){let g=d*this._tmpCanvas.width*4+m*4+3;if(e.data[g]!==0){t.top=d,u=!0;break}}if(u)break}t.left=0,u=!1;for(let d=0;d<o+c;d++){for(let m=0;m<l;m++){let g=m*this._tmpCanvas.width*4+d*4+3;if(e.data[g]!==0){t.left=d,u=!0;break}}if(u)break}t.right=c,u=!1;for(let d=o+c-1;d>=o;d--){for(let m=0;m<l;m++){let g=m*this._tmpCanvas.width*4+d*4+3;if(e.data[g]!==0){t.right=d,u=!0;break}}if(u)break}t.bottom=l,u=!1;for(let d=l-1;d>=0;d--){for(let m=0;m<c;m++){let g=d*this._tmpCanvas.width*4+m*4+3;if(e.data[g]!==0){t.bottom=d,u=!0;break}}if(u)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:t.right-t.left+1,y:t.bottom-t.top+1},sizeClipSpace:{x:t.right-t.left+1,y:t.bottom-t.top+1},offset:{x:-t.left+o+(r||n?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-t.top+o+(r||n?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},Xv=class{constructor(i,e,t){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],t)for(let s of t)this._glyphs.push(...s.glyphs),this._usedPixels+=s._usedPixels;this.canvas=ID(i,e,e),this.ctx=Wt(this.canvas.getContext("2d",{alpha:!0}))}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(i){this._glyphs.push(i),this._usedPixels+=i.size.x*i.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}};function Vv(i,e,t,s){let r=e.rgba>>>24,n=e.rgba>>>16&255,o=e.rgba>>>8&255,l=t.rgba>>>24,c=t.rgba>>>16&255,u=t.rgba>>>8&255,d=Math.floor((Math.abs(r-l)+Math.abs(n-c)+Math.abs(o-u))/12),m=!0;for(let g=0;g<i.data.length;g+=4)i.data[g]===r&&i.data[g+1]===n&&i.data[g+2]===o||s&&Math.abs(i.data[g]-r)+Math.abs(i.data[g+1]-n)+Math.abs(i.data[g+2]-o)<d?i.data[g+3]=0:m=!1;return m}function lse(i){for(let e=0;e<i.data.length;e+=4)if(i.data[e+3]>0)return!1;return!0}function ID(i,e,t){let s=i.createElement("canvas");return s.width=e,s.height=t,s}function hse(i,e,t,s,r,n,o,l){let c={foreground:n.foreground,background:n.background,cursor:Gs,cursorAccent:Gs,selectionForeground:Gs,selectionBackgroundTransparent:Gs,selectionBackgroundOpaque:Gs,selectionInactiveBackgroundTransparent:Gs,selectionInactiveBackgroundOpaque:Gs,overviewRulerBorder:Gs,scrollbarSliderBackground:Gs,scrollbarSliderHoverBackground:Gs,scrollbarSliderActiveBackground:Gs,ansi:n.ansi.slice(),contrastCache:n.contrastCache,halfContrastCache:n.halfContrastCache};return{customGlyphs:r.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:l,letterSpacing:r.letterSpacing,lineHeight:r.lineHeight,deviceCellWidth:i,deviceCellHeight:e,deviceCharWidth:t,deviceCharHeight:s,fontFamily:r.fontFamily,fontSize:r.fontSize,fontWeight:r.fontWeight,fontWeightBold:r.fontWeightBold,allowTransparency:r.allowTransparency,drawBoldTextInBrightColors:r.drawBoldTextInBrightColors,minimumContrastRatio:r.minimumContrastRatio,colors:c}}function IE(i,e){for(let t=0;t<i.colors.ansi.length;t++)if(i.colors.ansi[t].rgba!==e.colors.ansi[t].rgba)return!1;return i.devicePixelRatio===e.devicePixelRatio&&i.customGlyphs===e.customGlyphs&&i.lineHeight===e.lineHeight&&i.letterSpacing===e.letterSpacing&&i.fontFamily===e.fontFamily&&i.fontSize===e.fontSize&&i.fontWeight===e.fontWeight&&i.fontWeightBold===e.fontWeightBold&&i.allowTransparency===e.allowTransparency&&i.deviceCharWidth===e.deviceCharWidth&&i.deviceCharHeight===e.deviceCharHeight&&i.drawBoldTextInBrightColors===e.drawBoldTextInBrightColors&&i.minimumContrastRatio===e.minimumContrastRatio&&i.colors.foreground.rgba===e.colors.foreground.rgba&&i.colors.background.rgba===e.colors.background.rgba}function cse(i){return(i&50331648)===16777216||(i&50331648)===33554432}var er=[];function qD(i,e,t,s,r,n,o,l,c){let u=hse(s,r,n,o,e,t,l,c);for(let g=0;g<er.length;g++){let _=er[g],y=_.ownedBy.indexOf(i);if(y>=0){if(IE(_.config,u))return _.atlas;_.ownedBy.length===1?(_.atlas.dispose(),er.splice(g,1)):_.ownedBy.splice(y,1);break}}for(let g=0;g<er.length;g++){let _=er[g];if(IE(_.config,u))return _.ownedBy.push(i),_.atlas}let d=i._core,m={atlas:new Po(document,u,d.unicodeService),config:u,ownedBy:[i]};return er.push(m),m.atlas}function qE(i){for(let e=0;e<er.length;e++){let t=er[e].ownedBy.indexOf(i);if(t!==-1){er[e].ownedBy.length===1?(er[e].atlas.dispose(),er.splice(e,1)):er[e].ownedBy.splice(t,1);break}}}var Lp=600,use=class{constructor(i,e){this._renderCallback=i,this._coreBrowserService=e,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(i=Lp){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Lp-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Lp-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Lp)},i)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function WE(i,e,t){let s=new e.ResizeObserver(r=>{let n=r.find(c=>c.target===i);if(!n)return;if(!("devicePixelContentBoxSize"in n)){s==null||s.disconnect(),s=void 0;return}let o=n.devicePixelContentBoxSize[0].inlineSize,l=n.devicePixelContentBoxSize[0].blockSize;o>0&&l>0&&t(o,l)});try{s.observe(i,{box:["device-pixel-content-box"]})}catch{s.disconnect(),s=void 0}return ji(()=>s==null?void 0:s.disconnect())}function fse(i){return i>65535?(i-=65536,String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):String.fromCharCode(i)}var UE=class WD extends sh{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new zD,this.combinedData=""}static fromCharData(e){let t=new WD;return t.setFromCharData(e),t}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?fse(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},UD=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function YD(i,e,t){let s=Wt(i.createProgram());if(i.attachShader(s,Wt(YE(i,i.VERTEX_SHADER,e))),i.attachShader(s,Wt(YE(i,i.FRAGMENT_SHADER,t))),i.linkProgram(s),i.getProgramParameter(s,i.LINK_STATUS))return s;console.error(i.getProgramInfoLog(s)),i.deleteProgram(s)}function YE(i,e,t){let s=Wt(i.createShader(e));if(i.shaderSource(s,t),i.compileShader(s),i.getShaderParameter(s,i.COMPILE_STATUS))return s;console.error(i.getShaderInfoLog(s)),i.deleteShader(s)}function dse(i,e){let t=Math.min(i.length*2,e),s=new Float32Array(t);for(let r=0;r<i.length;r++)s[r]=i[r];return s}var pse=class{constructor(i){this.texture=i,this.version=-1}},mse=`#version 300 es
133
140
  layout (location = 0) in vec2 a_unitquad;
134
141
  layout (location = 1) in vec2 a_cellpos;
135
142
  layout (location = 2) in vec2 a_offset;
@@ -149,7 +156,7 @@ void main() {
149
156
  gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
150
157
  v_texpage = int(a_texpage);
151
158
  v_texcoord = a_texcoord + a_unitquad * a_texsize;
152
- }`;function qie(i){let e="";for(let t=1;t<i;t++)e+=` else if (v_texpage == ${t}) { outColor = texture(u_texture[${t}], v_texcoord); }`;return`#version 300 es
159
+ }`;function gse(i){let e="";for(let t=1;t<i;t++)e+=` else if (v_texpage == ${t}) { outColor = texture(u_texture[${t}], v_texcoord); }`;return`#version 300 es
153
160
  precision lowp float;
154
161
 
155
162
  in vec2 v_texcoord;
@@ -163,7 +170,7 @@ void main() {
163
170
  if (v_texpage == 0) {
164
171
  outColor = texture(u_texture[0], v_texcoord);
165
172
  } ${e}
166
- }`}var Qo=11,Vl=Qo*Float32Array.BYTES_PER_ELEMENT,Wie=2,Mt=0,_t,vv=0,su=0,Uie=class extends Cr{constructor(i,e,t,s){super(),this._terminal=i,this._gl=e,this._dimensions=t,this._optionsService=s,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let r=this._gl;Po.maxAtlasPages===void 0&&(Po.maxAtlasPages=Math.min(32,Wt(r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS))),Po.maxTextureSize=Wt(r.getParameter(r.MAX_TEXTURE_SIZE))),this._program=Wt(ID(r,Iie,qie(Po.maxAtlasPages))),this._register(ji(()=>r.deleteProgram(this._program))),this._projectionLocation=Wt(r.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Wt(r.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Wt(r.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(ji(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let l=new Uint8Array([0,1,2,3]),c=r.createBuffer();this._register(ji(()=>r.deleteBuffer(c))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,c),r.bufferData(r.ELEMENT_ARRAY_BUFFER,l,r.STATIC_DRAW),this._attributesBuffer=Wt(r.createBuffer()),this._register(ji(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,2,r.FLOAT,!1,Vl,0),r.vertexAttribDivisor(2,1),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,r.FLOAT,!1,Vl,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(3,1),r.enableVertexAttribArray(4),r.vertexAttribPointer(4,1,r.FLOAT,!1,Vl,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(4,1),r.enableVertexAttribArray(5),r.vertexAttribPointer(5,2,r.FLOAT,!1,Vl,5*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(5,1),r.enableVertexAttribArray(6),r.vertexAttribPointer(6,2,r.FLOAT,!1,Vl,7*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(6,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,Vl,9*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.useProgram(this._program);let u=new Int32Array(Po.maxAtlasPages);for(let d=0;d<Po.maxAtlasPages;d++)u[d]=d;r.uniform1iv(this._textureLocation,u),r.uniformMatrix4fv(this._projectionLocation,!1,jD),this._atlasTextures=[];for(let d=0;d<Po.maxAtlasPages;d++){let m=new jie(Wt(r.createTexture()));this._register(ji(()=>r.deleteTexture(m.texture))),r.activeTexture(r.TEXTURE0+d),r.bindTexture(r.TEXTURE_2D,m.texture),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[d]=m}r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(i,e,t,s,r,n,o,l,c){this._updateCell(this._vertices.attributes,i,e,t,s,r,n,o,l,c)}_updateCell(i,e,t,s,r,n,o,l,c,u){if(Mt=(t*this._terminal.cols+e)*Qo,s===0||s===void 0){i.fill(0,Mt,Mt+Qo-1-Wie);return}this._atlas&&(l&&l.length>1?_t=this._atlas.getRasterizedGlyphCombinedChar(l,r,n,o,!1,this._terminal.element):_t=this._atlas.getRasterizedGlyph(s,r,n,o,!1,this._terminal.element),vv=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),r!==u&&_t.offset.x>vv?(su=_t.offset.x-vv,i[Mt]=-(_t.offset.x-su)+this._dimensions.device.char.left,i[Mt+1]=-_t.offset.y+this._dimensions.device.char.top,i[Mt+2]=(_t.size.x-su)/this._dimensions.device.canvas.width,i[Mt+3]=_t.size.y/this._dimensions.device.canvas.height,i[Mt+4]=_t.texturePage,i[Mt+5]=_t.texturePositionClipSpace.x+su/this._atlas.pages[_t.texturePage].canvas.width,i[Mt+6]=_t.texturePositionClipSpace.y,i[Mt+7]=_t.sizeClipSpace.x-su/this._atlas.pages[_t.texturePage].canvas.width,i[Mt+8]=_t.sizeClipSpace.y):(i[Mt]=-_t.offset.x+this._dimensions.device.char.left,i[Mt+1]=-_t.offset.y+this._dimensions.device.char.top,i[Mt+2]=_t.size.x/this._dimensions.device.canvas.width,i[Mt+3]=_t.size.y/this._dimensions.device.canvas.height,i[Mt+4]=_t.texturePage,i[Mt+5]=_t.texturePositionClipSpace.x,i[Mt+6]=_t.texturePositionClipSpace.y,i[Mt+7]=_t.sizeClipSpace.x,i[Mt+8]=_t.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&hie(s,c,_t.size.x,this._dimensions.device.cell.width)&&(i[Mt+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let i=this._terminal,e=i.cols*i.rows*Qo;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let t=0;for(;t<this._vertices.attributesBuffers.length;t++)this._vertices.count!==e?this._vertices.attributesBuffers[t]=new Float32Array(e):this._vertices.attributesBuffers[t].fill(0);this._vertices.count=e,t=0;for(let s=0;s<i.rows;s++)for(let r=0;r<i.cols;r++)this._vertices.attributes[t+9]=r/i.cols,this._vertices.attributes[t+10]=s/i.rows,t+=Qo}handleResize(){let i=this._gl;i.useProgram(this._program),i.viewport(0,0,i.canvas.width,i.canvas.height),i.uniform2f(this._resolutionLocation,i.canvas.width,i.canvas.height),this.clear()}render(i){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let t=this._vertices.attributesBuffers[this._activeBuffer],s=0;for(let r=0;r<i.lineLengths.length;r++){let n=r*this._terminal.cols*Qo,o=this._vertices.attributes.subarray(n,n+i.lineLengths[r]*Qo);t.set(o,s),s+=o.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.subarray(0,s),e.STREAM_DRAW);for(let r=0;r<this._atlas.pages.length;r++)this._atlas.pages[r].version!==this._atlasTextures[r].version&&this._bindAtlasPageTexture(e,this._atlas,r);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,s/Qo)}setAtlas(i){this._atlas=i;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(i,e,t){i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,this._atlasTextures[t].texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e.pages[t].canvas),i.generateMipmap(i.TEXTURE_2D),this._atlasTextures[t].version=e.pages[t].version}setDimensions(i){this._dimensions=i}},Yie=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(i,e,t,s=!1){if(this.selectionStart=e,this.selectionEnd=t,!e||!t||e[0]===t[0]&&e[1]===t[1]){this.clear();return}let r=i.buffers.active.ydisp,n=e[1]-r,o=t[1]-r,l=Math.max(n,0),c=Math.min(o,i.rows-1);if(l>=i.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=t[0]}isCellSelected(i,e,t){return this.hasSelection?(t-=i.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&t>=this.viewportCappedStartRow&&e<this.endCol&&t<=this.viewportCappedEndRow:e<this.startCol&&t>=this.viewportCappedStartRow&&e>=this.endCol&&t<=this.viewportCappedEndRow:t>this.viewportStartRow&&t<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&t===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&t===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&t===this.viewportStartRow&&e>=this.startCol):!1}};function Hie(){return new Yie}var sg=4,om=1,am=2,yv=3,Fie=2147483648,Gie=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=Hie()}resize(i,e){let t=i*e*sg;t!==this.cells.length&&(this.cells=new Uint32Array(t),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},Kie=`#version 300 es
173
+ }`}var Qo=11,Zl=Qo*Float32Array.BYTES_PER_ELEMENT,Ose=2,Mt=0,_t,Zv=0,ru=0,_se=class extends Cr{constructor(i,e,t,s){super(),this._terminal=i,this._gl=e,this._dimensions=t,this._optionsService=s,this._activeBuffer=0,this._vertices={count:0,attributes:new Float32Array(0),attributesBuffers:[new Float32Array(0),new Float32Array(0)]};let r=this._gl;Po.maxAtlasPages===void 0&&(Po.maxAtlasPages=Math.min(32,Wt(r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS))),Po.maxTextureSize=Wt(r.getParameter(r.MAX_TEXTURE_SIZE))),this._program=Wt(YD(r,mse,gse(Po.maxAtlasPages))),this._register(ji(()=>r.deleteProgram(this._program))),this._projectionLocation=Wt(r.getUniformLocation(this._program,"u_projection")),this._resolutionLocation=Wt(r.getUniformLocation(this._program,"u_resolution")),this._textureLocation=Wt(r.getUniformLocation(this._program,"u_texture")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(ji(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let l=new Uint8Array([0,1,2,3]),c=r.createBuffer();this._register(ji(()=>r.deleteBuffer(c))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,c),r.bufferData(r.ELEMENT_ARRAY_BUFFER,l,r.STATIC_DRAW),this._attributesBuffer=Wt(r.createBuffer()),this._register(ji(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,2,r.FLOAT,!1,Zl,0),r.vertexAttribDivisor(2,1),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,r.FLOAT,!1,Zl,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(3,1),r.enableVertexAttribArray(4),r.vertexAttribPointer(4,1,r.FLOAT,!1,Zl,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(4,1),r.enableVertexAttribArray(5),r.vertexAttribPointer(5,2,r.FLOAT,!1,Zl,5*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(5,1),r.enableVertexAttribArray(6),r.vertexAttribPointer(6,2,r.FLOAT,!1,Zl,7*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(6,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,Zl,9*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.useProgram(this._program);let u=new Int32Array(Po.maxAtlasPages);for(let d=0;d<Po.maxAtlasPages;d++)u[d]=d;r.uniform1iv(this._textureLocation,u),r.uniformMatrix4fv(this._projectionLocation,!1,UD),this._atlasTextures=[];for(let d=0;d<Po.maxAtlasPages;d++){let m=new pse(Wt(r.createTexture()));this._register(ji(()=>r.deleteTexture(m.texture))),r.activeTexture(r.TEXTURE0+d),r.bindTexture(r.TEXTURE_2D,m.texture),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[d]=m}r.enable(r.BLEND),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return this._atlas?this._atlas.beginFrame():!0}updateCell(i,e,t,s,r,n,o,l,c){this._updateCell(this._vertices.attributes,i,e,t,s,r,n,o,l,c)}_updateCell(i,e,t,s,r,n,o,l,c,u){if(Mt=(t*this._terminal.cols+e)*Qo,s===0||s===void 0){i.fill(0,Mt,Mt+Qo-1-Ose);return}this._atlas&&(l&&l.length>1?_t=this._atlas.getRasterizedGlyphCombinedChar(l,r,n,o,!1,this._terminal.element):_t=this._atlas.getRasterizedGlyph(s,r,n,o,!1,this._terminal.element),Zv=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),r!==u&&_t.offset.x>Zv?(ru=_t.offset.x-Zv,i[Mt]=-(_t.offset.x-ru)+this._dimensions.device.char.left,i[Mt+1]=-_t.offset.y+this._dimensions.device.char.top,i[Mt+2]=(_t.size.x-ru)/this._dimensions.device.canvas.width,i[Mt+3]=_t.size.y/this._dimensions.device.canvas.height,i[Mt+4]=_t.texturePage,i[Mt+5]=_t.texturePositionClipSpace.x+ru/this._atlas.pages[_t.texturePage].canvas.width,i[Mt+6]=_t.texturePositionClipSpace.y,i[Mt+7]=_t.sizeClipSpace.x-ru/this._atlas.pages[_t.texturePage].canvas.width,i[Mt+8]=_t.sizeClipSpace.y):(i[Mt]=-_t.offset.x+this._dimensions.device.char.left,i[Mt+1]=-_t.offset.y+this._dimensions.device.char.top,i[Mt+2]=_t.size.x/this._dimensions.device.canvas.width,i[Mt+3]=_t.size.y/this._dimensions.device.canvas.height,i[Mt+4]=_t.texturePage,i[Mt+5]=_t.texturePositionClipSpace.x,i[Mt+6]=_t.texturePositionClipSpace.y,i[Mt+7]=_t.sizeClipSpace.x,i[Mt+8]=_t.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Lie(s,c,_t.size.x,this._dimensions.device.cell.width)&&(i[Mt+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let i=this._terminal,e=i.cols*i.rows*Qo;this._vertices.count!==e?this._vertices.attributes=new Float32Array(e):this._vertices.attributes.fill(0);let t=0;for(;t<this._vertices.attributesBuffers.length;t++)this._vertices.count!==e?this._vertices.attributesBuffers[t]=new Float32Array(e):this._vertices.attributesBuffers[t].fill(0);this._vertices.count=e,t=0;for(let s=0;s<i.rows;s++)for(let r=0;r<i.cols;r++)this._vertices.attributes[t+9]=r/i.cols,this._vertices.attributes[t+10]=s/i.rows,t+=Qo}handleResize(){let i=this._gl;i.useProgram(this._program),i.viewport(0,0,i.canvas.width,i.canvas.height),i.uniform2f(this._resolutionLocation,i.canvas.width,i.canvas.height),this.clear()}render(i){if(!this._atlas)return;let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),this._activeBuffer=(this._activeBuffer+1)%2;let t=this._vertices.attributesBuffers[this._activeBuffer],s=0;for(let r=0;r<i.lineLengths.length;r++){let n=r*this._terminal.cols*Qo,o=this._vertices.attributes.subarray(n,n+i.lineLengths[r]*Qo);t.set(o,s),s+=o.length}e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,t.subarray(0,s),e.STREAM_DRAW);for(let r=0;r<this._atlas.pages.length;r++)this._atlas.pages[r].version!==this._atlasTextures[r].version&&this._bindAtlasPageTexture(e,this._atlas,r);e.drawElementsInstanced(e.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,s/Qo)}setAtlas(i){this._atlas=i;for(let e of this._atlasTextures)e.version=-1}_bindAtlasPageTexture(i,e,t){i.activeTexture(i.TEXTURE0+t),i.bindTexture(i.TEXTURE_2D,this._atlasTextures[t].texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e.pages[t].canvas),i.generateMipmap(i.TEXTURE_2D),this._atlasTextures[t].version=e.pages[t].version}setDimensions(i){this._dimensions=i}},vse=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(i,e,t,s=!1){if(this.selectionStart=e,this.selectionEnd=t,!e||!t||e[0]===t[0]&&e[1]===t[1]){this.clear();return}let r=i.buffers.active.ydisp,n=e[1]-r,o=t[1]-r,l=Math.max(n,0),c=Math.min(o,i.rows-1);if(l>=i.rows||c<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=n,this.viewportEndRow=o,this.viewportCappedStartRow=l,this.viewportCappedEndRow=c,this.startCol=e[0],this.endCol=t[0]}isCellSelected(i,e,t){return this.hasSelection?(t-=i.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?e>=this.startCol&&t>=this.viewportCappedStartRow&&e<this.endCol&&t<=this.viewportCappedEndRow:e<this.startCol&&t>=this.viewportCappedStartRow&&e>=this.endCol&&t<=this.viewportCappedEndRow:t>this.viewportStartRow&&t<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&t===this.viewportStartRow&&e>=this.startCol&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&t===this.viewportEndRow&&e<this.endCol||this.viewportStartRow<this.viewportEndRow&&t===this.viewportStartRow&&e>=this.startCol):!1}};function yse(){return new vse}var sg=4,om=1,am=2,jv=3,bse=2147483648,Sse=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=yse()}resize(i,e){let t=i*e*sg;t!==this.cells.length&&(this.cells=new Uint32Array(t),this.lineLengths=new Uint32Array(e))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},xse=`#version 300 es
167
174
  layout (location = 0) in vec2 a_position;
168
175
  layout (location = 1) in vec2 a_size;
169
176
  layout (location = 2) in vec4 a_color;
@@ -177,7 +184,7 @@ void main() {
177
184
  vec2 zeroToOne = a_position + (a_unitquad * a_size);
178
185
  gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0);
179
186
  v_color = a_color;
180
- }`,Jie=`#version 300 es
187
+ }`,wse=`#version 300 es
181
188
  precision lowp float;
182
189
 
183
190
  in vec4 v_color;
@@ -186,7 +193,7 @@ out vec4 outColor;
186
193
 
187
194
  void main() {
188
195
  outColor = v_color;
189
- }`,$n=8,bv=$n*Float32Array.BYTES_PER_ELEMENT,ese=20*$n,bE=class{constructor(){this.attributes=new Float32Array(ese),this.count=0}},Qn=0,SE=0,xE=0,wE=0,CE=0,kE=0,TE=0,tse=class extends Cr{constructor(i,e,t,s){super(),this._terminal=i,this._gl=e,this._dimensions=t,this._themeService=s,this._vertices=new bE,this._verticesCursor=new bE;let r=this._gl;this._program=Wt(ID(r,Kie,Jie)),this._register(ji(()=>r.deleteProgram(this._program))),this._projectionLocation=Wt(r.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(ji(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let l=new Uint8Array([0,1,2,3]),c=r.createBuffer();this._register(ji(()=>r.deleteBuffer(c))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,c),r.bufferData(r.ELEMENT_ARRAY_BUFFER,l,r.STATIC_DRAW),this._attributesBuffer=Wt(r.createBuffer()),this._register(ji(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,r.FLOAT,!1,bv,0),r.vertexAttribDivisor(0,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,bv,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,4,r.FLOAT,!1,bv,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(u=>{this._updateCachedColors(u),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(i){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,jD),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,i.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,i.count)}handleResize(){this._updateViewportRectangle()}setDimensions(i){this._dimensions=i}_updateCachedColors(i){this._bgFloat=this._colorToFloat32Array(i.background),this._cursorFloat=this._colorToFloat32Array(i.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(i){let e=this._terminal,t=this._vertices,s=1,r,n,o,l,c,u,d,m,g,_,y;for(r=0;r<e.rows;r++){for(o=-1,l=0,c=0,u=!1,n=0;n<e.cols;n++)d=(r*e.cols+n)*sg,m=i.cells[d+om],g=i.cells[d+am],_=!!(g&67108864),(m!==l||g!==c&&(u||_))&&((l!==0||u&&c!==0)&&(y=s++*$n,this._updateRectangle(t,y,c,l,o,n,r)),o=n,l=m,c=g,u=_);(l!==0||u&&c!==0)&&(y=s++*$n,this._updateRectangle(t,y,c,l,o,e.cols,r))}t.count=s}updateCursor(i){let e=this._verticesCursor,t=i.cursor;if(!t||t.style==="block"){e.count=0;return}let s,r=0;(t.style==="bar"||t.style==="outline")&&(s=r++*$n,this._addRectangleFloat(e.attributes,s,t.x*this._dimensions.device.cell.width,t.y*this._dimensions.device.cell.height,t.style==="bar"?t.dpr*t.cursorWidth:t.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(t.style==="underline"||t.style==="outline")&&(s=r++*$n,this._addRectangleFloat(e.attributes,s,t.x*this._dimensions.device.cell.width,(t.y+1)*this._dimensions.device.cell.height-t.dpr,t.width*this._dimensions.device.cell.width,t.dpr,this._cursorFloat)),t.style==="outline"&&(s=r++*$n,this._addRectangleFloat(e.attributes,s,t.x*this._dimensions.device.cell.width,t.y*this._dimensions.device.cell.height,t.width*this._dimensions.device.cell.width,t.dpr,this._cursorFloat),s=r++*$n,this._addRectangleFloat(e.attributes,s,(t.x+t.width)*this._dimensions.device.cell.width-t.dpr,t.y*this._dimensions.device.cell.height,t.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=r}_updateRectangle(i,e,t,s,r,n,o){if(t&67108864)switch(t&50331648){case 16777216:case 33554432:Qn=this._themeService.colors.ansi[t&255].rgba;break;case 50331648:Qn=(t&16777215)<<8;break;case 0:default:Qn=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:Qn=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:Qn=(s&16777215)<<8;break;case 0:default:Qn=this._themeService.colors.background.rgba}i.attributes.length<e+4&&(i.attributes=Zie(i.attributes,this._terminal.rows*this._terminal.cols*$n)),SE=r*this._dimensions.device.cell.width,xE=o*this._dimensions.device.cell.height,wE=(Qn>>24&255)/255,CE=(Qn>>16&255)/255,kE=(Qn>>8&255)/255,TE=1,this._addRectangle(i.attributes,e,SE,xE,(n-r)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,wE,CE,kE,TE)}_addRectangle(i,e,t,s,r,n,o,l,c,u){i[e]=t/this._dimensions.device.canvas.width,i[e+1]=s/this._dimensions.device.canvas.height,i[e+2]=r/this._dimensions.device.canvas.width,i[e+3]=n/this._dimensions.device.canvas.height,i[e+4]=o,i[e+5]=l,i[e+6]=c,i[e+7]=u}_addRectangleFloat(i,e,t,s,r,n,o){i[e]=t/this._dimensions.device.canvas.width,i[e+1]=s/this._dimensions.device.canvas.height,i[e+2]=r/this._dimensions.device.canvas.width,i[e+3]=n/this._dimensions.device.canvas.height,i[e+4]=o[0],i[e+5]=o[1],i[e+6]=o[2],i[e+7]=o[3]}_colorToFloat32Array(i){return new Float32Array([(i.rgba>>24&255)/255,(i.rgba>>16&255)/255,(i.rgba>>8&255)/255,(i.rgba&255)/255])}},ise=class extends Cr{constructor(i,e,t,s,r,n,o,l){super(),this._container=e,this._alpha=r,this._coreBrowserService=n,this._optionsService=o,this._themeService=l,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${t}-layer`),this._canvas.style.zIndex=s.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(c=>{this._refreshCharAtlas(i,c),this.reset(i)})),this._register(ji(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Wt(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(i){}handleFocus(i){}handleCursorMove(i){}handleGridChanged(i,e,t){}handleSelectionChanged(i,e,t,s=!1){}_setTransparency(i,e){if(e===this._alpha)return;let t=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,t),this._refreshCharAtlas(i,this._themeService.colors),this.handleGridChanged(i,0,i.rows-1)}_refreshCharAtlas(i,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=VD(i,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(i,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(i,this._themeService.colors)}_fillBottomLineAtCells(i,e,t=1){this._ctx.fillRect(i*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,t*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(i,e,t,s){this._alpha?this._ctx.clearRect(i*this._deviceCellWidth,e*this._deviceCellHeight,t*this._deviceCellWidth,s*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(i*this._deviceCellWidth,e*this._deviceCellHeight,t*this._deviceCellWidth,s*this._deviceCellHeight))}_fillCharTrueColor(i,e,t,s){this._ctx.font=this._getFont(i,!1,!1),this._ctx.textBaseline=MD,this._clipCell(t,s,e.getWidth()),this._ctx.fillText(e.getChars(),t*this._deviceCellWidth+this._deviceCharLeft,s*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(i,e,t){this._ctx.beginPath(),this._ctx.rect(i*this._deviceCellWidth,e*this._deviceCellHeight,t*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(i,e,t){let s=e?i.options.fontWeightBold:i.options.fontWeight;return`${t?"italic":""} ${s} ${i.options.fontSize*this._coreBrowserService.dpr}px ${i.options.fontFamily}`}},sse=class extends ise{constructor(i,e,t,s,r,n,o){super(t,i,"link",e,!0,r,n,o),this._register(s.onShowLinkUnderline(l=>this._handleShowLinkUnderline(l))),this._register(s.onHideLinkUnderline(l=>this._handleHideLinkUnderline(l)))}resize(i,e){super.resize(i,e),this._state=void 0}reset(i){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let i=this._state.y2-this._state.y1-1;i>0&&this._clearCells(0,this._state.y1+1,this._state.cols,i),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(i){if(i.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:i.fg!==void 0&&Nie(i.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[i.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,i.y1===i.y2)this._fillBottomLineAtCells(i.x1,i.y1,i.x2-i.x1);else{this._fillBottomLineAtCells(i.x1,i.y1,i.cols-i.x1);for(let e=i.y1+1;e<i.y2;e++)this._fillBottomLineAtCells(0,e,i.cols);this._fillBottomLineAtCells(0,i.y2,i.x2)}this._state=i}_handleHideLinkUnderline(i){this._clearCurrentLink()}},Da=typeof window=="object"?window:globalThis,hb=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new yt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new yt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};hb.INSTANCE=new hb;var qD=hb;function rse(i,e,t){typeof e=="string"&&(e=i.matchMedia(e)),e.addEventListener("change",t)}qD.INSTANCE.onDidChangeZoomLevel;qD.INSTANCE.onDidChangeFullscreen;var Nh=typeof navigator=="object"?navigator.userAgent:"";Nh.indexOf("Firefox")>=0;Nh.indexOf("AppleWebKit")>=0;var nse=Nh.indexOf("Chrome")>=0;!nse&&Nh.indexOf("Safari")>=0;Nh.indexOf("Electron/")>=0;Nh.indexOf("Android")>=0;var Sv=!1;if(typeof Da.matchMedia=="function"){let i=Da.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Da.matchMedia("(display-mode: fullscreen)");Sv=i.matches,rse(Da,i,({matches:t})=>{Sv&&e.matches||(Sv=t)})}var rh="en",xv=!1,WD=!1,Lp,lm=rh,AE=rh,ose,Or,Za=globalThis,Li,mP;typeof Za.vscode<"u"&&typeof Za.vscode.process<"u"?Li=Za.vscode.process:typeof process<"u"&&typeof((mP=process==null?void 0:process.versions)==null?void 0:mP.node)=="string"&&(Li=process);var gP,ase=typeof((gP=Li==null?void 0:Li.versions)==null?void 0:gP.electron)=="string",lse=ase&&(Li==null?void 0:Li.type)==="renderer",OP;if(typeof Li=="object"){Li.platform,Li.platform,xv=Li.platform==="linux",xv&&Li.env.SNAP&&Li.env.SNAP_REVISION,Li.env.CI||Li.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Lp=rh,lm=rh;let i=Li.env.VSCODE_NLS_CONFIG;if(i)try{let e=JSON.parse(i);Lp=e.userLocale,AE=e.osLocale,lm=e.resolvedLanguage||rh,ose=(OP=e.languagePack)==null?void 0:OP.translationsConfigFile}catch{}WD=!0}else typeof navigator=="object"&&!lse?(Or=navigator.userAgent,Or.indexOf("Windows")>=0,Or.indexOf("Macintosh")>=0,(Or.indexOf("Macintosh")>=0||Or.indexOf("iPad")>=0||Or.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,xv=Or.indexOf("Linux")>=0,(Or==null?void 0:Or.indexOf("Mobi"))>=0,lm=globalThis._VSCODE_NLS_LANGUAGE||rh,Lp=navigator.language.toLowerCase(),AE=Lp):console.error("Unable to resolve platform.");var ME=WD,rn=Or,To=lm,hse;(i=>{function e(){return To}i.value=e;function t(){return To.length===2?To==="en":To.length>=3?To[0]==="e"&&To[1]==="n"&&To[2]==="-":!1}i.isDefaultVariant=t;function s(){return To==="en"}i.isDefault=s})(hse||(hse={}));var cse=typeof Za.postMessage=="function"&&!Za.importScripts;(()=>{if(cse){let i=[];Za.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let s=0,r=i.length;s<r;s++){let n=i[s];if(n.id===t.data.vscodeScheduleAsyncWork){i.splice(s,1),n.callback();return}}});let e=0;return t=>{let s=++e;i.push({id:s,callback:t}),Za.postMessage({vscodeScheduleAsyncWork:s},"*")}}return i=>setTimeout(i)})();var use=!!(rn&&rn.indexOf("Chrome")>=0);rn&&rn.indexOf("Firefox")>=0;!use&&rn&&rn.indexOf("Safari")>=0;rn&&rn.indexOf("Edg/")>=0;rn&&rn.indexOf("Android")>=0;var Zl=typeof navigator=="object"?navigator:{};ME||document.queryCommandSupported&&document.queryCommandSupported("copy")||Zl&&Zl.clipboard&&Zl.clipboard.writeText,ME||Zl&&Zl.clipboard&&Zl.clipboard.readText;var ix=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(i,e){this._keyCodeToStr[i]=e,this._strToKeyCode[e.toLowerCase()]=i}keyCodeToStr(i){return this._keyCodeToStr[i]}strToKeyCode(i){return this._strToKeyCode[i.toLowerCase()]||0}},wv=new ix,EE=new ix,PE=new ix;new Array(230);var fse;(i=>{function e(l){return wv.keyCodeToStr(l)}i.toString=e;function t(l){return wv.strToKeyCode(l)}i.fromString=t;function s(l){return EE.keyCodeToStr(l)}i.toUserSettingsUS=s;function r(l){return PE.keyCodeToStr(l)}i.toUserSettingsGeneral=r;function n(l){return EE.strToKeyCode(l)||PE.strToKeyCode(l)}i.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return wv.keyCodeToStr(l)}i.toElectronAccelerator=o})(fse||(fse={}));var UD=Object.freeze(function(i,e){let t=setTimeout(i.bind(e),0);return{dispose(){clearTimeout(t)}}}),dse;(i=>{function e(t){return t===i.None||t===i.Cancelled||t instanceof pse?!0:!t||typeof t!="object"?!1:typeof t.isCancellationRequested=="boolean"&&typeof t.onCancellationRequested=="function"}i.isCancellationToken=e,i.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Nn.None}),i.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:UD})})(dse||(dse={}));var pse=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?UD:(this._emitter||(this._emitter=new yt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},mse;(i=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}i.settled=e;function t(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}i.withAsyncBody=t})(mse||(mse={}));var QE=class Ks{static fromArray(e){return new Ks(t=>{t.emitMany(e)})}static fromPromise(e){return new Ks(async t=>{t.emitMany(await e)})}static fromPromises(e){return new Ks(async t=>{await Promise.all(e.map(async s=>t.emitOne(await s)))})}static merge(e){return new Ks(async t=>{await Promise.all(e.map(async s=>{for await(let r of s)t.emitOne(r)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new yt,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Nn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var t;return(t=this._onReturn)==null||t.call(this),{done:!0,value:void 0}}}}static map(e,t){return new Ks(async s=>{for await(let r of e)s.emitOne(t(r))})}map(e){return Ks.map(this,e)}static filter(e,t){return new Ks(async s=>{for await(let r of e)t(r)&&s.emitOne(r)})}filter(e){return Ks.filter(this,e)}static coalesce(e){return Ks.filter(e,t=>!!t)}coalesce(){return Ks.coalesce(this)}static async toPromise(e){let t=[];for await(let s of e)t.push(s);return t}toPromise(){return Ks.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};QE.EMPTY=QE.fromArray([]);var{getWindow:gse}=(function(){let i=new Map,e={window:Da,disposables:new ph};i.set(Da.vscodeWindowId,e);let t=new yt,s=new yt,r=new yt;function n(o,l){return(typeof o=="number"?i.get(o):void 0)??(l?e:void 0)}return{onDidRegisterWindow:t.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(i.has(o.vscodeWindowId))return Cr.None;let l=new ph,c={window:o,disposables:l.add(new ph)};return i.set(o.vscodeWindowId,c),l.add(ji(()=>{i.delete(o.vscodeWindowId),s.fire(o)})),l.add(cb(o,_se.BEFORE_UNLOAD,()=>{r.fire(o)})),t.fire(c),l},getWindows(){return i.values()},getWindowsCount(){return i.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return i.has(o)},getWindowById:n,getWindow(o){var u;let l=o;if((u=l==null?void 0:l.ownerDocument)!=null&&u.defaultView)return l.ownerDocument.defaultView.window;let c=o;return c!=null&&c.view?c.view.window:Da},getDocument(o){return gse(o).document}}})(),Ose=class{constructor(i,e,t,s){this._node=i,this._type=e,this._handler=t,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function cb(i,e,t,s){return new Ose(i,e,t,s)}var _se={BEFORE_UNLOAD:"beforeunload"},vse=class extends Cr{constructor(i,e,t,s,r,n,o,l,c){super(),this._terminal=i,this._characterJoinerService=e,this._charSizeService=t,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._optionsService=o,this._themeService=l,this._cursorBlinkStateManager=new eu,this._charAtlasDisposable=this._register(new eu),this._observerDisposable=this._register(new eu),this._model=new Gie,this._workCell=new vE,this._workCell2=new vE,this._rectangleRenderer=this._register(new eu),this._glyphRenderer=this._register(new eu),this._onChangeTextureAtlas=this._register(new yt),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yt),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yt),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new yt),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new yt),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let u={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext("webgl2",u),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new fie(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new sse(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=cie(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(cb(this._canvas,"webglcontextlost",d=>{console.log("webglcontextlost event received"),d.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(d)},3e3)})),this._register(cb(this._canvas,"webglcontextrestored",d=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,OE(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=_E(this._canvas,this._coreBrowserService.window,(d,m)=>this._setCanvasDevicePixelDimensions(d,m)),this._register(this._coreBrowserService.onWindowChange(d=>{this._observerDisposable.value=_E(this._canvas,d,(m,g)=>this._setCanvasDevicePixelDimensions(m,g))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(ji(()=>{var d;for(let m of this._renderLayers)m.dispose();(d=this._canvas.parentElement)==null||d.removeChild(this._canvas),OE(this._terminal)}))}get textureAtlas(){var i;return(i=this._charAtlas)==null?void 0:i.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(i,e){var t,s,r,n;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let o of this._renderLayers)o.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(t=this._rectangleRenderer.value)==null||t.setDimensions(this.dimensions),(s=this._rectangleRenderer.value)==null||s.handleResize(),(r=this._glyphRenderer.value)==null||r.setDimensions(this.dimensions),(n=this._glyphRenderer.value)==null||n.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var i;for(let e of this._renderLayers)e.handleBlur(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.pause(),this._requestRedrawViewport()}handleFocus(){var i;for(let e of this._renderLayers)e.handleFocus(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.resume(),this._requestRedrawViewport()}handleSelectionChanged(i,e,t){for(let s of this._renderLayers)s.handleSelectionChanged(this._terminal,i,e,t);this._model.selection.update(this._core,i,e,t),this._requestRedrawViewport()}handleCursorMove(){var i;for(let e of this._renderLayers)e.handleCursorMove(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new tse(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Uie(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let i=VD(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==i&&(this._onChangeTextureAtlas.fire(i.pages[0].canvas),this._charAtlasDisposable.value=wD(Nn.forward(i.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Nn.forward(i.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=i,this._charAtlas.warmUp(),(e=this._glyphRenderer.value)==null||e.setAtlas(this._charAtlas)}_clearModel(i){var e;this._model.clear(),i&&((e=this._glyphRenderer.value)==null||e.clear())}clearTextureAtlas(){var i;(i=this._charAtlas)==null||i.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var i;this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(i,e){var t;if(!this._isAttached)if((t=this._core.screenElement)!=null&&t.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let s of this._renderLayers)s.handleGridChanged(this._terminal,i,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(i,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new Xie(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(i,e){let t=this._core,s=this._workCell,r,n,o,l,c,u,d=0,m=!0,g,_,y,b,x,w,k,C,A;i=RE(i,t.rows-1,0),e=RE(e,t.rows-1,0);let P=this._coreService.decPrivateModes.cursorStyle??t.options.cursorStyle??"block",E=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,$=E-t.buffer.ydisp,z=Math.min(this._terminal.buffer.active.cursorX,t.cols-1),I=-1,se=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let F=!1;for(n=i;n<=e;n++)for(o=n+t.buffer.ydisp,l=t.buffer.lines.get(o),this._model.lineLengths[n]=0,y=E===o,d=0,c=this._characterJoinerService.getJoinedCharacters(o),C=0;C<t.cols;C++){if(r=this._cellColorResolver.result.bg,l.loadCell(C,s),C===0&&(r=this._cellColorResolver.result.bg),u=!1,m=C>=d,g=C,c.length>0&&C===c[0][0]&&m){_=c.shift();let R=this._model.selection.isCellSelected(this._terminal,_[0],o);for(k=_[0]+1;k<_[1];k++)m&&(m=R===this._model.selection.isCellSelected(this._terminal,k,o));m&&(m=!y||z<_[0]||z>=_[1]),m?(u=!0,s=new yse(s,l.translateToString(!0,_[0],_[1]),_[1]-_[0]),g=_[1]-1):d=_[1]}if(b=s.getChars(),x=s.getCode(),k=(n*t.cols+C)*sg,this._cellColorResolver.resolve(s,C,o,this.dimensions.device.cell.width),se&&o===E&&(C===z&&(this._model.cursor={x:z,y:$,width:s.getWidth(),style:this._coreBrowserService.isFocused?P:t.options.cursorInactiveStyle,cursorWidth:t.options.cursorWidth,dpr:this._devicePixelRatio},I=z+s.getWidth()-1),C>=z&&C<=I&&(this._coreBrowserService.isFocused&&P==="block"||this._coreBrowserService.isFocused===!1&&t.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),x!==0&&(this._model.lineLengths[n]=C+1),!(this._model.cells[k]===x&&this._model.cells[k+om]===this._cellColorResolver.result.bg&&this._model.cells[k+am]===this._cellColorResolver.result.fg&&this._model.cells[k+yv]===this._cellColorResolver.result.ext)&&(F=!0,b.length>1&&(x|=Fie),this._model.cells[k]=x,this._model.cells[k+om]=this._cellColorResolver.result.bg,this._model.cells[k+am]=this._cellColorResolver.result.fg,this._model.cells[k+yv]=this._cellColorResolver.result.ext,w=s.getWidth(),this._glyphRenderer.value.updateCell(C,n,x,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,b,w,r),u)){for(s=this._workCell,C++;C<=g;C++)A=(n*t.cols+C)*sg,this._glyphRenderer.value.updateCell(C,n,0,0,0,0,sie,0,0),this._model.cells[A]=0,this._model.cells[A+om]=this._cellColorResolver.result.bg,this._model.cells[A+am]=this._cellColorResolver.result.fg,this._model.cells[A+yv]=this._cellColorResolver.result.ext;C--}}F&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(i,e){this._canvas.width===i&&this._canvas.height===e||(this._canvas.width=i,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let i=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:i,end:i})}},yse=class extends sh{constructor(i,e,t){super(),this.content=0,this.combinedData="",this.fg=i.fg,this.bg=i.bg,this.combinedData=e,this._width=t}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(i){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function RE(i,e,t=0){return Math.max(Math.min(i,e),t)}var LE="di$target",$E="di$dependencies",Cv=new Map;function an(i){if(Cv.has(i))return Cv.get(i);let e=function(t,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");bse(e,t,r)};return e._id=i,Cv.set(i,e),e}function bse(i,e,t){e[LE]===e?e[$E].push({id:i,index:t}):(e[$E]=[{id:i,index:t}],e[LE]=e)}an("BufferService");an("CoreMouseService");an("CoreService");an("CharsetService");an("InstantiationService");an("LogService");var Sse=an("OptionsService");an("OscLinkService");an("UnicodeService");an("DecorationService");var xse={trace:0,debug:1,info:2,warn:3,error:4,off:5},wse="xterm.js: ",BE=class extends Cr{constructor(i){super(),this._optionsService=i,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=xse[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let e=0;e<i.length;e++)typeof i[e]=="function"&&(i[e]=i[e]())}_log(i,e,t){this._evalLazyOptionalParams(t),i.call(console,(this._optionsService.options.logger?"":wse)+e,...t)}trace(i,...e){var t;this._logLevel<=0&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.trace.bind(this._optionsService.options.logger))??console.log,i,e)}debug(i,...e){var t;this._logLevel<=1&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.debug.bind(this._optionsService.options.logger))??console.log,i,e)}info(i,...e){var t;this._logLevel<=2&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.info.bind(this._optionsService.options.logger))??console.info,i,e)}warn(i,...e){var t;this._logLevel<=3&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.warn.bind(this._optionsService.options.logger))??console.warn,i,e)}error(i,...e){var t;this._logLevel<=4&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.error.bind(this._optionsService.options.logger))??console.error,i,e)}};BE=qte([Wte(0,Sse)],BE);var Cse=class extends Cr{constructor(i){if(TD&&iie()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=i,this._onChangeTextureAtlas=this._register(new yt),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yt),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yt),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new yt),this.onContextLoss=this._onContextLoss.event}activate(i){let e=i._core;if(!i.element){this._register(e.onWillOpen(()=>this.activate(i)));return}this._terminal=i;let t=e.coreService,s=e.optionsService,r=e,n=r._renderService,o=r._characterJoinerService,l=r._charSizeService,c=r._coreBrowserService,u=r._decorationService;r._logService;let d=r._themeService;this._renderer=this._register(new vse(i,o,l,c,t,u,s,d,this._preserveDrawingBuffer)),this._register(Nn.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Nn.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Nn.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Nn.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(ji(()=>{if(this._terminal._core._store._isDisposed)return;let m=this._terminal._core._renderService;m.setRenderer(this._terminal._core._createRenderer()),m.handleResize(i.cols,i.rows)}))}get textureAtlas(){var i;return(i=this._renderer)==null?void 0:i.textureAtlas}clearTextureAtlas(){var i;(i=this._renderer)==null||i.clearTextureAtlas()}};/**
196
+ }`,$n=8,Iv=$n*Float32Array.BYTES_PER_ELEMENT,Cse=20*$n,HE=class{constructor(){this.attributes=new Float32Array(Cse),this.count=0}},Qn=0,FE=0,GE=0,KE=0,JE=0,eP=0,tP=0,kse=class extends Cr{constructor(i,e,t,s){super(),this._terminal=i,this._gl=e,this._dimensions=t,this._themeService=s,this._vertices=new HE,this._verticesCursor=new HE;let r=this._gl;this._program=Wt(YD(r,xse,wse)),this._register(ji(()=>r.deleteProgram(this._program))),this._projectionLocation=Wt(r.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=r.createVertexArray(),r.bindVertexArray(this._vertexArrayObject);let n=new Float32Array([0,0,1,0,0,1,1,1]),o=r.createBuffer();this._register(ji(()=>r.deleteBuffer(o))),r.bindBuffer(r.ARRAY_BUFFER,o),r.bufferData(r.ARRAY_BUFFER,n,r.STATIC_DRAW),r.enableVertexAttribArray(3),r.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let l=new Uint8Array([0,1,2,3]),c=r.createBuffer();this._register(ji(()=>r.deleteBuffer(c))),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,c),r.bufferData(r.ELEMENT_ARRAY_BUFFER,l,r.STATIC_DRAW),this._attributesBuffer=Wt(r.createBuffer()),this._register(ji(()=>r.deleteBuffer(this._attributesBuffer))),r.bindBuffer(r.ARRAY_BUFFER,this._attributesBuffer),r.enableVertexAttribArray(0),r.vertexAttribPointer(0,2,r.FLOAT,!1,Iv,0),r.vertexAttribDivisor(0,1),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,2,r.FLOAT,!1,Iv,2*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(1,1),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,4,r.FLOAT,!1,Iv,4*Float32Array.BYTES_PER_ELEMENT),r.vertexAttribDivisor(2,1),this._updateCachedColors(s.colors),this._register(this._themeService.onChangeColors(u=>{this._updateCachedColors(u),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(i){let e=this._gl;e.useProgram(this._program),e.bindVertexArray(this._vertexArrayObject),e.uniformMatrix4fv(this._projectionLocation,!1,UD),e.bindBuffer(e.ARRAY_BUFFER,this._attributesBuffer),e.bufferData(e.ARRAY_BUFFER,i.attributes,e.DYNAMIC_DRAW),e.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,e.UNSIGNED_BYTE,0,i.count)}handleResize(){this._updateViewportRectangle()}setDimensions(i){this._dimensions=i}_updateCachedColors(i){this._bgFloat=this._colorToFloat32Array(i.background),this._cursorFloat=this._colorToFloat32Array(i.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(i){let e=this._terminal,t=this._vertices,s=1,r,n,o,l,c,u,d,m,g,_,y;for(r=0;r<e.rows;r++){for(o=-1,l=0,c=0,u=!1,n=0;n<e.cols;n++)d=(r*e.cols+n)*sg,m=i.cells[d+om],g=i.cells[d+am],_=!!(g&67108864),(m!==l||g!==c&&(u||_))&&((l!==0||u&&c!==0)&&(y=s++*$n,this._updateRectangle(t,y,c,l,o,n,r)),o=n,l=m,c=g,u=_);(l!==0||u&&c!==0)&&(y=s++*$n,this._updateRectangle(t,y,c,l,o,e.cols,r))}t.count=s}updateCursor(i){let e=this._verticesCursor,t=i.cursor;if(!t||t.style==="block"){e.count=0;return}let s,r=0;(t.style==="bar"||t.style==="outline")&&(s=r++*$n,this._addRectangleFloat(e.attributes,s,t.x*this._dimensions.device.cell.width,t.y*this._dimensions.device.cell.height,t.style==="bar"?t.dpr*t.cursorWidth:t.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(t.style==="underline"||t.style==="outline")&&(s=r++*$n,this._addRectangleFloat(e.attributes,s,t.x*this._dimensions.device.cell.width,(t.y+1)*this._dimensions.device.cell.height-t.dpr,t.width*this._dimensions.device.cell.width,t.dpr,this._cursorFloat)),t.style==="outline"&&(s=r++*$n,this._addRectangleFloat(e.attributes,s,t.x*this._dimensions.device.cell.width,t.y*this._dimensions.device.cell.height,t.width*this._dimensions.device.cell.width,t.dpr,this._cursorFloat),s=r++*$n,this._addRectangleFloat(e.attributes,s,(t.x+t.width)*this._dimensions.device.cell.width-t.dpr,t.y*this._dimensions.device.cell.height,t.dpr,this._dimensions.device.cell.height,this._cursorFloat)),e.count=r}_updateRectangle(i,e,t,s,r,n,o){if(t&67108864)switch(t&50331648){case 16777216:case 33554432:Qn=this._themeService.colors.ansi[t&255].rgba;break;case 50331648:Qn=(t&16777215)<<8;break;case 0:default:Qn=this._themeService.colors.foreground.rgba}else switch(s&50331648){case 16777216:case 33554432:Qn=this._themeService.colors.ansi[s&255].rgba;break;case 50331648:Qn=(s&16777215)<<8;break;case 0:default:Qn=this._themeService.colors.background.rgba}i.attributes.length<e+4&&(i.attributes=dse(i.attributes,this._terminal.rows*this._terminal.cols*$n)),FE=r*this._dimensions.device.cell.width,GE=o*this._dimensions.device.cell.height,KE=(Qn>>24&255)/255,JE=(Qn>>16&255)/255,eP=(Qn>>8&255)/255,tP=1,this._addRectangle(i.attributes,e,FE,GE,(n-r)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,KE,JE,eP,tP)}_addRectangle(i,e,t,s,r,n,o,l,c,u){i[e]=t/this._dimensions.device.canvas.width,i[e+1]=s/this._dimensions.device.canvas.height,i[e+2]=r/this._dimensions.device.canvas.width,i[e+3]=n/this._dimensions.device.canvas.height,i[e+4]=o,i[e+5]=l,i[e+6]=c,i[e+7]=u}_addRectangleFloat(i,e,t,s,r,n,o){i[e]=t/this._dimensions.device.canvas.width,i[e+1]=s/this._dimensions.device.canvas.height,i[e+2]=r/this._dimensions.device.canvas.width,i[e+3]=n/this._dimensions.device.canvas.height,i[e+4]=o[0],i[e+5]=o[1],i[e+6]=o[2],i[e+7]=o[3]}_colorToFloat32Array(i){return new Float32Array([(i.rgba>>24&255)/255,(i.rgba>>16&255)/255,(i.rgba>>8&255)/255,(i.rgba&255)/255])}},Tse=class extends Cr{constructor(i,e,t,s,r,n,o,l){super(),this._container=e,this._alpha=r,this._coreBrowserService=n,this._optionsService=o,this._themeService=l,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${t}-layer`),this._canvas.style.zIndex=s.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(c=>{this._refreshCharAtlas(i,c),this.reset(i)})),this._register(ji(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Wt(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(i){}handleFocus(i){}handleCursorMove(i){}handleGridChanged(i,e,t){}handleSelectionChanged(i,e,t,s=!1){}_setTransparency(i,e){if(e===this._alpha)return;let t=this._canvas;this._alpha=e,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,t),this._refreshCharAtlas(i,this._themeService.colors),this.handleGridChanged(i,0,i.rows-1)}_refreshCharAtlas(i,e){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=qD(i,this._optionsService.rawOptions,e,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(i,e){this._deviceCellWidth=e.device.cell.width,this._deviceCellHeight=e.device.cell.height,this._deviceCharWidth=e.device.char.width,this._deviceCharHeight=e.device.char.height,this._deviceCharLeft=e.device.char.left,this._deviceCharTop=e.device.char.top,this._canvas.width=e.device.canvas.width,this._canvas.height=e.device.canvas.height,this._canvas.style.width=`${e.css.canvas.width}px`,this._canvas.style.height=`${e.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(i,this._themeService.colors)}_fillBottomLineAtCells(i,e,t=1){this._ctx.fillRect(i*this._deviceCellWidth,(e+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,t*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(i,e,t,s){this._alpha?this._ctx.clearRect(i*this._deviceCellWidth,e*this._deviceCellHeight,t*this._deviceCellWidth,s*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(i*this._deviceCellWidth,e*this._deviceCellHeight,t*this._deviceCellWidth,s*this._deviceCellHeight))}_fillCharTrueColor(i,e,t,s){this._ctx.font=this._getFont(i,!1,!1),this._ctx.textBaseline=RD,this._clipCell(t,s,e.getWidth()),this._ctx.fillText(e.getChars(),t*this._deviceCellWidth+this._deviceCharLeft,s*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(i,e,t){this._ctx.beginPath(),this._ctx.rect(i*this._deviceCellWidth,e*this._deviceCellHeight,t*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(i,e,t){let s=e?i.options.fontWeightBold:i.options.fontWeight;return`${t?"italic":""} ${s} ${i.options.fontSize*this._coreBrowserService.dpr}px ${i.options.fontFamily}`}},Ase=class extends Tse{constructor(i,e,t,s,r,n,o){super(t,i,"link",e,!0,r,n,o),this._register(s.onShowLinkUnderline(l=>this._handleShowLinkUnderline(l))),this._register(s.onHideLinkUnderline(l=>this._handleHideLinkUnderline(l)))}resize(i,e){super.resize(i,e),this._state=void 0}reset(i){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let i=this._state.y2-this._state.y1-1;i>0&&this._clearCells(0,this._state.y1+1,this._state.cols,i),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(i){if(i.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:i.fg!==void 0&&cse(i.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[i.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,i.y1===i.y2)this._fillBottomLineAtCells(i.x1,i.y1,i.x2-i.x1);else{this._fillBottomLineAtCells(i.x1,i.y1,i.cols-i.x1);for(let e=i.y1+1;e<i.y2;e++)this._fillBottomLineAtCells(0,e,i.cols);this._fillBottomLineAtCells(0,i.y2,i.x2)}this._state=i}_handleHideLinkUnderline(i){this._clearCurrentLink()}},Da=typeof window=="object"?window:globalThis,hb=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new yt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new yt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let s=this.getWindowId(t);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};hb.INSTANCE=new hb;var HD=hb;function Mse(i,e,t){typeof e=="string"&&(e=i.matchMedia(e)),e.addEventListener("change",t)}HD.INSTANCE.onDidChangeZoomLevel;HD.INSTANCE.onDidChangeFullscreen;var Nh=typeof navigator=="object"?navigator.userAgent:"";Nh.indexOf("Firefox")>=0;Nh.indexOf("AppleWebKit")>=0;var Ese=Nh.indexOf("Chrome")>=0;!Ese&&Nh.indexOf("Safari")>=0;Nh.indexOf("Electron/")>=0;Nh.indexOf("Android")>=0;var qv=!1;if(typeof Da.matchMedia=="function"){let i=Da.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),e=Da.matchMedia("(display-mode: fullscreen)");qv=i.matches,Mse(Da,i,({matches:t})=>{qv&&e.matches||(qv=t)})}var rh="en",Wv=!1,FD=!1,$p,lm=rh,iP=rh,Pse,Or,Za=globalThis,Li,mP;typeof Za.vscode<"u"&&typeof Za.vscode.process<"u"?Li=Za.vscode.process:typeof process<"u"&&typeof((mP=process==null?void 0:process.versions)==null?void 0:mP.node)=="string"&&(Li=process);var gP,Qse=typeof((gP=Li==null?void 0:Li.versions)==null?void 0:gP.electron)=="string",Rse=Qse&&(Li==null?void 0:Li.type)==="renderer",OP;if(typeof Li=="object"){Li.platform,Li.platform,Wv=Li.platform==="linux",Wv&&Li.env.SNAP&&Li.env.SNAP_REVISION,Li.env.CI||Li.env.BUILD_ARTIFACTSTAGINGDIRECTORY,$p=rh,lm=rh;let i=Li.env.VSCODE_NLS_CONFIG;if(i)try{let e=JSON.parse(i);$p=e.userLocale,iP=e.osLocale,lm=e.resolvedLanguage||rh,Pse=(OP=e.languagePack)==null?void 0:OP.translationsConfigFile}catch{}FD=!0}else typeof navigator=="object"&&!Rse?(Or=navigator.userAgent,Or.indexOf("Windows")>=0,Or.indexOf("Macintosh")>=0,(Or.indexOf("Macintosh")>=0||Or.indexOf("iPad")>=0||Or.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Wv=Or.indexOf("Linux")>=0,(Or==null?void 0:Or.indexOf("Mobi"))>=0,lm=globalThis._VSCODE_NLS_LANGUAGE||rh,$p=navigator.language.toLowerCase(),iP=$p):console.error("Unable to resolve platform.");var sP=FD,rn=Or,Ao=lm,Lse;(i=>{function e(){return Ao}i.value=e;function t(){return Ao.length===2?Ao==="en":Ao.length>=3?Ao[0]==="e"&&Ao[1]==="n"&&Ao[2]==="-":!1}i.isDefaultVariant=t;function s(){return Ao==="en"}i.isDefault=s})(Lse||(Lse={}));var $se=typeof Za.postMessage=="function"&&!Za.importScripts;(()=>{if($se){let i=[];Za.addEventListener("message",t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let s=0,r=i.length;s<r;s++){let n=i[s];if(n.id===t.data.vscodeScheduleAsyncWork){i.splice(s,1),n.callback();return}}});let e=0;return t=>{let s=++e;i.push({id:s,callback:t}),Za.postMessage({vscodeScheduleAsyncWork:s},"*")}}return i=>setTimeout(i)})();var Bse=!!(rn&&rn.indexOf("Chrome")>=0);rn&&rn.indexOf("Firefox")>=0;!Bse&&rn&&rn.indexOf("Safari")>=0;rn&&rn.indexOf("Edg/")>=0;rn&&rn.indexOf("Android")>=0;var jl=typeof navigator=="object"?navigator:{};sP||document.queryCommandSupported&&document.queryCommandSupported("copy")||jl&&jl.clipboard&&jl.clipboard.writeText,sP||jl&&jl.clipboard&&jl.clipboard.readText;var sx=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(i,e){this._keyCodeToStr[i]=e,this._strToKeyCode[e.toLowerCase()]=i}keyCodeToStr(i){return this._keyCodeToStr[i]}strToKeyCode(i){return this._strToKeyCode[i.toLowerCase()]||0}},Uv=new sx,rP=new sx,nP=new sx;new Array(230);var Dse;(i=>{function e(l){return Uv.keyCodeToStr(l)}i.toString=e;function t(l){return Uv.strToKeyCode(l)}i.fromString=t;function s(l){return rP.keyCodeToStr(l)}i.toUserSettingsUS=s;function r(l){return nP.keyCodeToStr(l)}i.toUserSettingsGeneral=r;function n(l){return rP.strToKeyCode(l)||nP.strToKeyCode(l)}i.fromUserSettings=n;function o(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Uv.keyCodeToStr(l)}i.toElectronAccelerator=o})(Dse||(Dse={}));var GD=Object.freeze(function(i,e){let t=setTimeout(i.bind(e),0);return{dispose(){clearTimeout(t)}}}),zse;(i=>{function e(t){return t===i.None||t===i.Cancelled||t instanceof Nse?!0:!t||typeof t!="object"?!1:typeof t.isCancellationRequested=="boolean"&&typeof t.onCancellationRequested=="function"}i.isCancellationToken=e,i.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Nn.None}),i.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:GD})})(zse||(zse={}));var Nse=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?GD:(this._emitter||(this._emitter=new yt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Xse;(i=>{async function e(s){let r,n=await Promise.all(s.map(o=>o.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}i.settled=e;function t(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}i.withAsyncBody=t})(Xse||(Xse={}));var oP=class Ks{static fromArray(e){return new Ks(t=>{t.emitMany(e)})}static fromPromise(e){return new Ks(async t=>{t.emitMany(await e)})}static fromPromises(e){return new Ks(async t=>{await Promise.all(e.map(async s=>t.emitOne(await s)))})}static merge(e){return new Ks(async t=>{await Promise.all(e.map(async s=>{for await(let r of s)t.emitOne(r)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new yt,queueMicrotask(async()=>{let s={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(e(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Nn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var t;return(t=this._onReturn)==null||t.call(this),{done:!0,value:void 0}}}}static map(e,t){return new Ks(async s=>{for await(let r of e)s.emitOne(t(r))})}map(e){return Ks.map(this,e)}static filter(e,t){return new Ks(async s=>{for await(let r of e)t(r)&&s.emitOne(r)})}filter(e){return Ks.filter(this,e)}static coalesce(e){return Ks.filter(e,t=>!!t)}coalesce(){return Ks.coalesce(this)}static async toPromise(e){let t=[];for await(let s of e)t.push(s);return t}toPromise(){return Ks.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};oP.EMPTY=oP.fromArray([]);var{getWindow:Vse}=(function(){let i=new Map,e={window:Da,disposables:new ph};i.set(Da.vscodeWindowId,e);let t=new yt,s=new yt,r=new yt;function n(o,l){return(typeof o=="number"?i.get(o):void 0)??(l?e:void 0)}return{onDidRegisterWindow:t.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:s.event,registerWindow(o){if(i.has(o.vscodeWindowId))return Cr.None;let l=new ph,c={window:o,disposables:l.add(new ph)};return i.set(o.vscodeWindowId,c),l.add(ji(()=>{i.delete(o.vscodeWindowId),s.fire(o)})),l.add(cb(o,jse.BEFORE_UNLOAD,()=>{r.fire(o)})),t.fire(c),l},getWindows(){return i.values()},getWindowsCount(){return i.size},getWindowId(o){return o.vscodeWindowId},hasWindow(o){return i.has(o)},getWindowById:n,getWindow(o){var u;let l=o;if((u=l==null?void 0:l.ownerDocument)!=null&&u.defaultView)return l.ownerDocument.defaultView.window;let c=o;return c!=null&&c.view?c.view.window:Da},getDocument(o){return Vse(o).document}}})(),Zse=class{constructor(i,e,t,s){this._node=i,this._type=e,this._handler=t,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function cb(i,e,t,s){return new Zse(i,e,t,s)}var jse={BEFORE_UNLOAD:"beforeunload"},Ise=class extends Cr{constructor(i,e,t,s,r,n,o,l,c){super(),this._terminal=i,this._characterJoinerService=e,this._charSizeService=t,this._coreBrowserService=s,this._coreService=r,this._decorationService=n,this._optionsService=o,this._themeService=l,this._cursorBlinkStateManager=new tu,this._charAtlasDisposable=this._register(new tu),this._observerDisposable=this._register(new tu),this._model=new Sse,this._workCell=new UE,this._workCell2=new UE,this._rectangleRenderer=this._register(new tu),this._glyphRenderer=this._register(new tu),this._onChangeTextureAtlas=this._register(new yt),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yt),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yt),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new yt),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new yt),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");let u={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext("webgl2",u),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Die(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Ase(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=$ie(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(cb(this._canvas,"webglcontextlost",d=>{console.log("webglcontextlost event received"),d.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(d)},3e3)})),this._register(cb(this._canvas,"webglcontextrestored",d=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,qE(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=WE(this._canvas,this._coreBrowserService.window,(d,m)=>this._setCanvasDevicePixelDimensions(d,m)),this._register(this._coreBrowserService.onWindowChange(d=>{this._observerDisposable.value=WE(this._canvas,d,(m,g)=>this._setCanvasDevicePixelDimensions(m,g))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(ji(()=>{var d;for(let m of this._renderLayers)m.dispose();(d=this._canvas.parentElement)==null||d.removeChild(this._canvas),qE(this._terminal)}))}get textureAtlas(){var i;return(i=this._charAtlas)==null?void 0:i.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(i,e){var t,s,r,n;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let o of this._renderLayers)o.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(t=this._rectangleRenderer.value)==null||t.setDimensions(this.dimensions),(s=this._rectangleRenderer.value)==null||s.handleResize(),(r=this._glyphRenderer.value)==null||r.setDimensions(this.dimensions),(n=this._glyphRenderer.value)==null||n.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var i;for(let e of this._renderLayers)e.handleBlur(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.pause(),this._requestRedrawViewport()}handleFocus(){var i;for(let e of this._renderLayers)e.handleFocus(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.resume(),this._requestRedrawViewport()}handleSelectionChanged(i,e,t){for(let s of this._renderLayers)s.handleSelectionChanged(this._terminal,i,e,t);this._model.selection.update(this._core,i,e,t),this._requestRedrawViewport()}handleCursorMove(){var i;for(let e of this._renderLayers)e.handleCursorMove(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new kse(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new _se(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var e;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let i=qD(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==i&&(this._onChangeTextureAtlas.fire(i.pages[0].canvas),this._charAtlasDisposable.value=AD(Nn.forward(i.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Nn.forward(i.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=i,this._charAtlas.warmUp(),(e=this._glyphRenderer.value)==null||e.setAtlas(this._charAtlas)}_clearModel(i){var e;this._model.clear(),i&&((e=this._glyphRenderer.value)==null||e.clear())}clearTextureAtlas(){var i;(i=this._charAtlas)==null||i.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var i;this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);(i=this._cursorBlinkStateManager.value)==null||i.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(i,e){var t;if(!this._isAttached)if((t=this._core.screenElement)!=null&&t.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let s of this._renderLayers)s.handleGridChanged(this._terminal,i,e);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(i,e),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new use(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(i,e){let t=this._core,s=this._workCell,r,n,o,l,c,u,d=0,m=!0,g,_,y,b,x,w,k,C,A;i=aP(i,t.rows-1,0),e=aP(e,t.rows-1,0);let P=this._coreService.decPrivateModes.cursorStyle??t.options.cursorStyle??"block",E=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,$=E-t.buffer.ydisp,z=Math.min(this._terminal.buffer.active.cursorX,t.cols-1),I=-1,se=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let F=!1;for(n=i;n<=e;n++)for(o=n+t.buffer.ydisp,l=t.buffer.lines.get(o),this._model.lineLengths[n]=0,y=E===o,d=0,c=this._characterJoinerService.getJoinedCharacters(o),C=0;C<t.cols;C++){if(r=this._cellColorResolver.result.bg,l.loadCell(C,s),C===0&&(r=this._cellColorResolver.result.bg),u=!1,m=C>=d,g=C,c.length>0&&C===c[0][0]&&m){_=c.shift();let R=this._model.selection.isCellSelected(this._terminal,_[0],o);for(k=_[0]+1;k<_[1];k++)m&&(m=R===this._model.selection.isCellSelected(this._terminal,k,o));m&&(m=!y||z<_[0]||z>=_[1]),m?(u=!0,s=new qse(s,l.translateToString(!0,_[0],_[1]),_[1]-_[0]),g=_[1]-1):d=_[1]}if(b=s.getChars(),x=s.getCode(),k=(n*t.cols+C)*sg,this._cellColorResolver.resolve(s,C,o,this.dimensions.device.cell.width),se&&o===E&&(C===z&&(this._model.cursor={x:z,y:$,width:s.getWidth(),style:this._coreBrowserService.isFocused?P:t.options.cursorInactiveStyle,cursorWidth:t.options.cursorWidth,dpr:this._devicePixelRatio},I=z+s.getWidth()-1),C>=z&&C<=I&&(this._coreBrowserService.isFocused&&P==="block"||this._coreBrowserService.isFocused===!1&&t.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),x!==0&&(this._model.lineLengths[n]=C+1),!(this._model.cells[k]===x&&this._model.cells[k+om]===this._cellColorResolver.result.bg&&this._model.cells[k+am]===this._cellColorResolver.result.fg&&this._model.cells[k+jv]===this._cellColorResolver.result.ext)&&(F=!0,b.length>1&&(x|=bse),this._model.cells[k]=x,this._model.cells[k+om]=this._cellColorResolver.result.bg,this._model.cells[k+am]=this._cellColorResolver.result.fg,this._model.cells[k+jv]=this._cellColorResolver.result.ext,w=s.getWidth(),this._glyphRenderer.value.updateCell(C,n,x,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,b,w,r),u)){for(s=this._workCell,C++;C<=g;C++)A=(n*t.cols+C)*sg,this._glyphRenderer.value.updateCell(C,n,0,0,0,0,Aie,0,0),this._model.cells[A]=0,this._model.cells[A+om]=this._cellColorResolver.result.bg,this._model.cells[A+am]=this._cellColorResolver.result.fg,this._model.cells[A+jv]=this._cellColorResolver.result.ext;C--}}F&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(i,e){this._canvas.width===i&&this._canvas.height===e||(this._canvas.width=i,this._canvas.height=e,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let i=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:i,end:i})}},qse=class extends sh{constructor(i,e,t){super(),this.content=0,this.combinedData="",this.fg=i.fg,this.bg=i.bg,this.combinedData=e,this._width=t}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(i){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function aP(i,e,t=0){return Math.max(Math.min(i,e),t)}var lP="di$target",hP="di$dependencies",Yv=new Map;function an(i){if(Yv.has(i))return Yv.get(i);let e=function(t,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Wse(e,t,r)};return e._id=i,Yv.set(i,e),e}function Wse(i,e,t){e[lP]===e?e[hP].push({id:i,index:t}):(e[hP]=[{id:i,index:t}],e[lP]=e)}an("BufferService");an("CoreMouseService");an("CoreService");an("CharsetService");an("InstantiationService");an("LogService");var Use=an("OptionsService");an("OscLinkService");an("UnicodeService");an("DecorationService");var Yse={trace:0,debug:1,info:2,warn:3,error:4,off:5},Hse="xterm.js: ",cP=class extends Cr{constructor(i){super(),this._optionsService=i,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Yse[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(i){for(let e=0;e<i.length;e++)typeof i[e]=="function"&&(i[e]=i[e]())}_log(i,e,t){this._evalLazyOptionalParams(t),i.call(console,(this._optionsService.options.logger?"":Hse)+e,...t)}trace(i,...e){var t;this._logLevel<=0&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.trace.bind(this._optionsService.options.logger))??console.log,i,e)}debug(i,...e){var t;this._logLevel<=1&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.debug.bind(this._optionsService.options.logger))??console.log,i,e)}info(i,...e){var t;this._logLevel<=2&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.info.bind(this._optionsService.options.logger))??console.info,i,e)}warn(i,...e){var t;this._logLevel<=3&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.warn.bind(this._optionsService.options.logger))??console.warn,i,e)}error(i,...e){var t;this._logLevel<=4&&this._log(((t=this._optionsService.options.logger)==null?void 0:t.error.bind(this._optionsService.options.logger))??console.error,i,e)}};cP=gie([Oie(0,Use)],cP);var Fse=class extends Cr{constructor(i){if(PD&&Tie()<16){let e={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",e))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=i,this._onChangeTextureAtlas=this._register(new yt),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new yt),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new yt),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new yt),this.onContextLoss=this._onContextLoss.event}activate(i){let e=i._core;if(!i.element){this._register(e.onWillOpen(()=>this.activate(i)));return}this._terminal=i;let t=e.coreService,s=e.optionsService,r=e,n=r._renderService,o=r._characterJoinerService,l=r._charSizeService,c=r._coreBrowserService,u=r._decorationService;r._logService;let d=r._themeService;this._renderer=this._register(new Ise(i,o,l,c,t,u,s,d,this._preserveDrawingBuffer)),this._register(Nn.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Nn.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Nn.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Nn.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),n.setRenderer(this._renderer),this._register(ji(()=>{if(this._terminal._core._store._isDisposed)return;let m=this._terminal._core._renderService;m.setRenderer(this._terminal._core._createRenderer()),m.handleResize(i.cols,i.rows)}))}get textureAtlas(){var i;return(i=this._renderer)==null?void 0:i.textureAtlas}clearTextureAtlas(){var i;(i=this._renderer)==null||i.clearTextureAtlas()}};/**
190
197
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
191
198
  * @license MIT
192
199
  *
@@ -197,13 +204,6 @@ void main() {
197
204
  * Fabrice Bellard's javascript vt100 for jslinux:
198
205
  * http://bellard.org/jslinux/
199
206
  * Copyright (c) 2011 Fabrice Bellard
200
- */var Oi=0,_i=0,vi=0,Rt=0,Zi;(i=>{function e(r,n,o,l){return l!==void 0?`#${Sa(r)}${Sa(n)}${Sa(o)}${Sa(l)}`:`#${Sa(r)}${Sa(n)}${Sa(o)}`}i.toCss=e;function t(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}i.toRgba=t;function s(r,n,o,l){return{css:i.toCss(r,n,o,l),rgba:i.toRgba(r,n,o,l)}}i.toColor=s})(Zi||(Zi={}));var kse;(i=>{function e(c,u){if(Rt=(u.rgba&255)/255,Rt===1)return{css:u.css,rgba:u.rgba};let d=u.rgba>>24&255,m=u.rgba>>16&255,g=u.rgba>>8&255,_=c.rgba>>24&255,y=c.rgba>>16&255,b=c.rgba>>8&255;Oi=_+Math.round((d-_)*Rt),_i=y+Math.round((m-y)*Rt),vi=b+Math.round((g-b)*Rt);let x=Zi.toCss(Oi,_i,vi),w=Zi.toRgba(Oi,_i,vi);return{css:x,rgba:w}}i.blend=e;function t(c){return(c.rgba&255)===255}i.isOpaque=t;function s(c,u,d){let m=hm.ensureContrastRatio(c.rgba,u.rgba,d);if(m)return Zi.toColor(m>>24&255,m>>16&255,m>>8&255)}i.ensureContrastRatio=s;function r(c){let u=(c.rgba|255)>>>0;return[Oi,_i,vi]=hm.toChannels(u),{css:Zi.toCss(Oi,_i,vi),rgba:u}}i.opaque=r;function n(c,u){return Rt=Math.round(u*255),[Oi,_i,vi]=hm.toChannels(c.rgba),{css:Zi.toCss(Oi,_i,vi,Rt),rgba:Zi.toRgba(Oi,_i,vi,Rt)}}i.opacity=n;function o(c,u){return Rt=c.rgba&255,n(c,Rt*u/255)}i.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}i.toColorRGB=l})(kse||(kse={}));var Ei;(i=>{let e,t;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",t=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Oi=parseInt(r.slice(1,2).repeat(2),16),_i=parseInt(r.slice(2,3).repeat(2),16),vi=parseInt(r.slice(3,4).repeat(2),16),Zi.toColor(Oi,_i,vi);case 5:return Oi=parseInt(r.slice(1,2).repeat(2),16),_i=parseInt(r.slice(2,3).repeat(2),16),vi=parseInt(r.slice(3,4).repeat(2),16),Rt=parseInt(r.slice(4,5).repeat(2),16),Zi.toColor(Oi,_i,vi,Rt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Oi=parseInt(n[1]),_i=parseInt(n[2]),vi=parseInt(n[3]),Rt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Zi.toColor(Oi,_i,vi,Rt);if(!e||!t)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=t,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Oi,_i,vi,Rt]=e.getImageData(0,0,1,1).data,Rt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Zi.toRgba(Oi,_i,vi,Rt),css:r}}i.toColor=s})(Ei||(Ei={}));var Fi;(i=>{function e(s){return t(s>>16&255,s>>8&255,s&255)}i.relativeLuminance=e;function t(s,r,n){let o=s/255,l=r/255,c=n/255,u=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+d*.7152+m*.0722}i.relativeLuminance2=t})(Fi||(Fi={}));var hm;(i=>{function e(o,l){if(Rt=(l&255)/255,Rt===1)return l;let c=l>>24&255,u=l>>16&255,d=l>>8&255,m=o>>24&255,g=o>>16&255,_=o>>8&255;return Oi=m+Math.round((c-m)*Rt),_i=g+Math.round((u-g)*Rt),vi=_+Math.round((d-_)*Rt),Zi.toRgba(Oi,_i,vi)}i.blend=e;function t(o,l,c){let u=Fi.relativeLuminance(o>>8),d=Fi.relativeLuminance(l>>8);if(Rn(u,d)<c){if(d<u){let _=s(o,l,c),y=Rn(u,Fi.relativeLuminance(_>>8));if(y<c){let b=r(o,l,c),x=Rn(u,Fi.relativeLuminance(b>>8));return y>x?_:b}return _}let m=r(o,l,c),g=Rn(u,Fi.relativeLuminance(m>>8));if(g<c){let _=s(o,l,c),y=Rn(u,Fi.relativeLuminance(_>>8));return g>y?m:_}return m}}i.ensureContrastRatio=t;function s(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));for(;b<c&&(g>0||_>0||y>0);)g-=Math.max(0,Math.ceil(g*.1)),_-=Math.max(0,Math.ceil(_*.1)),y-=Math.max(0,Math.ceil(y*.1)),b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.reduceLuminance=s;function r(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));for(;b<c&&(g<255||_<255||y<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}i.toChannels=n})(hm||(hm={}));function Sa(i){let e=i.toString(16);return e.length<2?"0"+e:e}function Rn(i,e){return i<e?(e+.05)/(i+.05):(i+.05)/(e+.05)}var Tse=Object.freeze((()=>{let i=[Ei.toColor("#2e3436"),Ei.toColor("#cc0000"),Ei.toColor("#4e9a06"),Ei.toColor("#c4a000"),Ei.toColor("#3465a4"),Ei.toColor("#75507b"),Ei.toColor("#06989a"),Ei.toColor("#d3d7cf"),Ei.toColor("#555753"),Ei.toColor("#ef2929"),Ei.toColor("#8ae234"),Ei.toColor("#fce94f"),Ei.toColor("#729fcf"),Ei.toColor("#ad7fa8"),Ei.toColor("#34e2e2"),Ei.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let t=0;t<216;t++){let s=e[t/36%6|0],r=e[t/6%6|0],n=e[t%6];i.push({css:Zi.toCss(s,r,n),rgba:Zi.toRgba(s,r,n)})}for(let t=0;t<24;t++){let s=8+t*10;i.push({css:Zi.toCss(s,s,s),rgba:Zi.toRgba(s,s,s)})}return i})());function DE(i,e,t){return Math.max(e,Math.min(i,t))}function Ase(i){switch(i){case"&":return"&amp;";case"<":return"&lt;"}return i}var YD=class{constructor(i){this._buffer=i}serialize(i,e){let t=this._buffer.getNullCell(),s=this._buffer.getNullCell(),r=t,n=i.start.y,o=i.end.y,l=i.start.x,c=i.end.x;this._beforeSerialize(o-n,n,o);for(let u=n;u<=o;u++){let d=this._buffer.getLine(u);if(d){let m=u===i.start.y?l:0,g=u===i.end.y?c:d.length;for(let _=m;_<g;_++){let y=d.getCell(_,r===t?s:t);if(!y){console.warn(`Can't get cell at row=${u}, col=${_}`);continue}this._nextCell(y,r,u,_),r=y}}this._rowEnd(u,u===o)}return this._afterSerialize(),this._serializeString(e)}_nextCell(i,e,t,s){}_rowEnd(i,e){}_beforeSerialize(i,e,t){}_afterSerialize(){}_serializeString(i){return""}};function HD(i,e){return i.getFgColorMode()===e.getFgColorMode()&&i.getFgColor()===e.getFgColor()}function Ln(i,e){return i.getBgColorMode()===e.getBgColorMode()&&i.getBgColor()===e.getBgColor()}function FD(i,e){return i.isInverse()===e.isInverse()&&i.isBold()===e.isBold()&&i.isUnderline()===e.isUnderline()&&i.isOverline()===e.isOverline()&&i.isBlink()===e.isBlink()&&i.isInvisible()===e.isInvisible()&&i.isItalic()===e.isItalic()&&i.isDim()===e.isDim()&&i.isStrikethrough()===e.isStrikethrough()}var Mse=class extends YD{constructor(i,e){super(i),this._terminal=e,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(i,e,t){this._allRows=new Array(i),this._lastContentCursorRow=e,this._lastCursorRow=e,this._firstRow=e}_rowEnd(i,e){var s;this._nullCellCount>0&&!Ln(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let t="";if(!e){i-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let r=this._buffer.getLine(i),n=this._buffer.getLine(i+1);if(!n.isWrapped)t=`\r
201
- `,this._lastCursorRow=i+1,this._lastCursorCol=0;else{t="";let o=r.getCell(r.length-1,this._thisRowLastChar),l=r.getCell(r.length-2,this._thisRowLastSecondChar),c=n.getCell(0,this._nextRowFirstChar),u=c.getWidth()>1,d=!1;(c.getChars()&&u?this._nullCellCount<=1:this._nullCellCount<=0)&&((o.getChars()||o.getWidth()===0)&&Ln(o,c)&&(d=!0),u&&(l.getChars()||l.getWidth()===0)&&Ln(o,c)&&Ln(l,c)&&(d=!0)),d||(t="-".repeat(this._nullCellCount+1),t+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(t+="\x1B[A",t+=`\x1B[${r.length-this._nullCellCount}C`,t+=`\x1B[${this._nullCellCount}X`,t+=`\x1B[${r.length-this._nullCellCount}D`,t+="\x1B[B"),this._lastContentCursorRow=i+1,this._lastContentCursorCol=0,this._lastCursorRow=i+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=t,this._currentRow="",this._nullCellCount=0}_diffStyle(i,e){let t=[],s=!HD(i,e),r=!Ln(i,e),n=!FD(i,e);if(s||r||n)if(i.isAttributeDefault())e.isAttributeDefault()||t.push(0);else{if(s){let o=i.getFgColor();i.isFgRGB()?t.push(38,2,o>>>16&255,o>>>8&255,o&255):i.isFgPalette()?o>=16?t.push(38,5,o):t.push(o&8?90+(o&7):30+(o&7)):t.push(39)}if(r){let o=i.getBgColor();i.isBgRGB()?t.push(48,2,o>>>16&255,o>>>8&255,o&255):i.isBgPalette()?o>=16?t.push(48,5,o):t.push(o&8?100+(o&7):40+(o&7)):t.push(49)}n&&(i.isInverse()!==e.isInverse()&&t.push(i.isInverse()?7:27),i.isBold()!==e.isBold()&&t.push(i.isBold()?1:22),i.isUnderline()!==e.isUnderline()&&t.push(i.isUnderline()?4:24),i.isOverline()!==e.isOverline()&&t.push(i.isOverline()?53:55),i.isBlink()!==e.isBlink()&&t.push(i.isBlink()?5:25),i.isInvisible()!==e.isInvisible()&&t.push(i.isInvisible()?8:28),i.isItalic()!==e.isItalic()&&t.push(i.isItalic()?3:23),i.isDim()!==e.isDim()&&t.push(i.isDim()?2:22),i.isStrikethrough()!==e.isStrikethrough()&&t.push(i.isStrikethrough()?9:29))}return t}_nextCell(i,e,t,s){if(i.getWidth()===0)return;let r=i.getChars()==="",n=this._diffStyle(i,this._cursorStyle);if(r?!Ln(this._cursorStyle,i):n.length>0){this._nullCellCount>0&&(Ln(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=t,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${n.join(";")}m`;let o=this._buffer.getLine(t);o!==void 0&&(o.getCell(s,this._cursorStyle),this._cursorStyleRow=t,this._cursorStyleCol=s)}r?this._nullCellCount+=i.getWidth():(this._nullCellCount>0&&(Ln(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=i.getChars(),this._lastContentCursorRow=this._lastCursorRow=t,this._lastContentCursorCol=this._lastCursorCol=s+i.getWidth())}_serializeString(i){let e=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(e=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let t="";for(let n=0;n<e;n++)t+=this._allRows[n],n+1<e&&(t+=this._allRowSeparators[n]);if(!i){let n=this._buffer.baseY+this._buffer.cursorY,o=this._buffer.cursorX,l=n!==this._lastCursorRow||o!==this._lastCursorCol,c=u=>{u>0?t+=`\x1B[${u}C`:u<0&&(t+=`\x1B[${-u}D`)};l&&((u=>{u>0?t+=`\x1B[${u}B`:u<0&&(t+=`\x1B[${-u}A`)})(n-this._lastCursorRow),c(o-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,r=this._diffStyle(s,this._cursorStyle);return r.length>0&&(t+=`\x1B[${r.join(";")}m`),t}},Ese=class{activate(i){this._terminal=i}_serializeBufferByScrollback(i,e,t){let s=e.length,r=t===void 0?s:DE(t+i.rows,0,s);return this._serializeBufferByRange(i,e,{start:s-r,end:s-1},!1)}_serializeBufferByRange(i,e,t,s){return new Mse(e,i).serialize({start:{x:0,y:typeof t.start=="number"?t.start:t.start.line},end:{x:i.cols,y:typeof t.end=="number"?t.end:t.end.line}},s)}_serializeBufferAsHTML(i,e){var l;let t=i.buffer.active,s=new Pse(t,i,e),r=e.onlySelection??!1,n=e.range;if(n)return s.serialize({start:{x:n.startCol,y:(n.startLine,n.startLine)},end:{x:i.cols,y:(n.endLine,n.endLine)}});if(!r){let c=t.length,u=e.scrollback,d=u===void 0?c:DE(u+i.rows,0,c);return s.serialize({start:{x:0,y:c-d},end:{x:i.cols,y:c-1}})}let o=(l=this._terminal)==null?void 0:l.getSelectionPosition();return o!==void 0?s.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}}):""}_serializeModes(i){let e="",t=i.modes;if(t.applicationCursorKeysMode&&(e+="\x1B[?1h"),t.applicationKeypadMode&&(e+="\x1B[?66h"),t.bracketedPasteMode&&(e+="\x1B[?2004h"),t.insertMode&&(e+="\x1B[4h"),t.originMode&&(e+="\x1B[?6h"),t.reverseWraparoundMode&&(e+="\x1B[?45h"),t.sendFocusMode&&(e+="\x1B[?1004h"),t.wraparoundMode===!1&&(e+="\x1B[?7l"),t.mouseTrackingMode!=="none")switch(t.mouseTrackingMode){case"x10":e+="\x1B[?9h";break;case"vt200":e+="\x1B[?1000h";break;case"drag":e+="\x1B[?1002h";break;case"any":e+="\x1B[?1003h";break}return e}serialize(i){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let e=i!=null&&i.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,i.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,i==null?void 0:i.scrollback);if(!(i!=null&&i.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let t=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);e+=`\x1B[?1049h\x1B[H${t}`}return i!=null&&i.excludeModes||(e+=this._serializeModes(this._terminal)),e}serializeAsHTML(i){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,i||{})}dispose(){}},Pse=class extends YD{constructor(i,e,t){super(i),this._terminal=e,this._options=t,this._currentRow="",this._htmlContent="",e._core._themeService?this._ansiColors=e._core._themeService.colors.ansi:this._ansiColors=Tse}_padStart(i,e,t){return e=e>>0,t=t??" ",i.length>e?i:(e-=i.length,e>t.length&&(t+=t.repeat(e/t.length)),t.slice(0,e)+i)}_beforeSerialize(i,e,t){var o,l;this._htmlContent+="<html><body><!--StartFragment--><pre>";let s="#000000",r="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((o=this._terminal.options.theme)==null?void 0:o.foreground)??"#ffffff",r=((l=this._terminal.options.theme)==null?void 0:l.background)??"#000000");let n=[];n.push("color: "+s+";"),n.push("background-color: "+r+";"),n.push("font-family: "+this._terminal.options.fontFamily+";"),n.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+n.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(i,e){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(i,e){let t=e?i.getFgColor():i.getBgColor();if(e?i.isFgRGB():i.isBgRGB())return"#"+[t>>16&255,t>>8&255,t&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(e?i.isFgPalette():i.isBgPalette())return this._ansiColors[t].css}_diffStyle(i,e){let t=[],s=!HD(i,e),r=!Ln(i,e),n=!FD(i,e);if(s||r||n){let o=this._getHexColor(i,!0);o&&t.push("color: "+o+";");let l=this._getHexColor(i,!1);return l&&t.push("background-color: "+l+";"),i.isInverse()&&t.push("color: #000000; background-color: #BFBFBF;"),i.isBold()&&t.push("font-weight: bold;"),i.isUnderline()&&i.isOverline()?t.push("text-decoration: overline underline;"):i.isUnderline()?t.push("text-decoration: underline;"):i.isOverline()&&t.push("text-decoration: overline;"),i.isBlink()&&t.push("text-decoration: blink;"),i.isInvisible()&&t.push("visibility: hidden;"),i.isItalic()&&t.push("font-style: italic;"),i.isDim()&&t.push("opacity: 0.5;"),i.isStrikethrough()&&t.push("text-decoration: line-through;"),t}}_nextCell(i,e,t,s){if(i.getWidth()===0)return;let r=i.getChars()==="",n=this._diffStyle(i,e);n&&(this._currentRow+=n.length===0?"</span><span>":"</span><span style='"+n.join(" ")+"'>"),r?this._currentRow+=" ":this._currentRow+=Ase(i.getChars())}_serializeString(){return this._htmlContent}};const Qse=10,Rse=2e3;function Lse(i={}){const{autoSpawn:e=!1,skipPermissions:t=!1}=i,[s,r]=Y.useState(!1),[n,o]=Y.useState(!1),[l,c]=Y.useState(null),[u,d]=Y.useState(null),m=Y.useRef(null),g=Y.useRef(0),_=Y.useRef(null),y=Y.useRef(!0),b=Y.useRef(null),x=Y.useRef(null),w=Y.useRef(e),k=Y.useRef(t);w.current=e,k.current=t;const C=Y.useCallback(z=>{const I=m.current;I&&I.readyState===WebSocket.OPEN&&I.send(JSON.stringify(z))},[]),A=Y.useCallback(z=>{C({type:"spawn",skipPermissions:z})},[C]),P=Y.useCallback(()=>{C({type:"kill"})},[C]),E=Y.useCallback((z,I)=>{C({type:"resize",cols:z,rows:I})},[C]),$=Y.useCallback(z=>{C({type:"input",data:z})},[C]);return Y.useEffect(()=>{y.current=!0;function z(){if(!y.current)return;const se=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`,F=new WebSocket(se);m.current=F,F.onopen=()=>{y.current&&(r(!0),g.current=0,w.current&&F.send(JSON.stringify({type:"spawn",skipPermissions:k.current})))},F.onclose=()=>{y.current&&(r(!1),m.current=null,g.current<Qse&&(g.current++,_.current=setTimeout(z,Rse)))},F.onmessage=R=>{var L,N;if(y.current)try{const Z=JSON.parse(R.data);switch(Z.type){case"output":(L=b.current)==null||L.call(b,Z.data);break;case"scrollback":(N=x.current)==null||N.call(x,Z.data);break;case"status":c({pid:Z.pid,uptime:Z.uptime,cwd:Z.cwd,memoryMB:Z.memoryMB,isActive:Z.isActive,skipPermissions:Z.skipPermissions,alive:Z.alive});break;case"exit":d(Z.code??1);break;case"started":d(null);break;case"unavailable":o(!0);break}}catch{}},F.onerror=()=>{}}return z(),()=>{y.current=!1,_.current!==null&&(clearTimeout(_.current),_.current=null),m.current&&(m.current.onclose=null,m.current.close(),m.current=null)}},[]),{connected:s,unavailable:n,status:l,exitCode:u,send:C,spawn:A,kill:P,resize:E,writeInput:$,onOutput:b,onScrollback:x}}function $se(i){const e=Math.floor(i/60),t=i%60;return`${e}m ${t}s`}function Bse(i){const e=i.replace(/\\/g,"/").split("/").filter(Boolean);return e.length<=2?i:".../"+e.slice(-2).join("/")}function Dse({status:i,connected:e,exitCode:t,skipPermissions:s,onToggleSkipPermissions:r,onStop:n,onRestart:o}){const l=e&&(i==null?void 0:i.alive),c=e?l?"bg-green-500":"bg-yellow-500":"bg-red-500",u=e?l?`Running (PID ${(i==null?void 0:i.pid)??"?"})`:"Stopped":"Disconnected";return M.jsxs("div",{className:"flex items-center justify-between border-t border-border bg-card px-3 py-1.5 font-mono text-xs text-muted-foreground",children:[M.jsxs("div",{className:"flex items-center gap-3",children:[M.jsx("span",{className:dt("inline-block h-2 w-2 rounded-full",c),title:u}),M.jsx("span",{children:u}),i&&l&&M.jsxs(M.Fragment,{children:[M.jsx("span",{className:"text-border",children:"|"}),M.jsx("span",{children:$se(i.uptime)}),M.jsx("span",{className:"text-border",children:"|"}),M.jsx("span",{title:i.cwd,children:Bse(i.cwd)}),M.jsx("span",{className:"text-border",children:"|"}),M.jsxs("span",{children:[i.memoryMB," MB"]})]})]}),M.jsxs("div",{className:"flex items-center gap-3",children:[M.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5",children:[M.jsx("input",{type:"checkbox",checked:s,onChange:r,className:"h-3 w-3 accent-accent"}),M.jsx("span",{children:"Skip Perms"})]}),l&&M.jsx("button",{type:"button",onClick:n,className:"rounded-sm px-2 py-0.5 text-red-400 transition-colors hover:bg-red-500/20",children:"Stop"}),M.jsx("button",{type:"button",onClick:o,className:"rounded-sm px-2 py-0.5 transition-colors hover:bg-accent/20",children:"Restart"})]})]})}const zse=[{label:"Progress",command:"/maxsim:progress"},{label:"New Project",command:"/maxsim:new-project"},{label:"Discuss",command:"/maxsim:discuss-phase N"},{label:"Plan",command:"/maxsim:plan-phase N"},{label:"Execute",command:"/maxsim:execute-phase N"},{label:"Roadmap",command:"/maxsim:roadmap"},{label:"Verify",command:"/maxsim:verify-work"},{label:"Resume",command:"/maxsim:resume-work"}],GD="maxsim-quick-commands",Nse=3e4;function Xse(){try{const i=localStorage.getItem(GD);if(i)return JSON.parse(i)}catch{}return zse}function Vse(i){localStorage.setItem(GD,JSON.stringify(i))}function Zse({onSendCommand:i,isActive:e,isAlive:t,unavailable:s=!1}){const[r,n]=Y.useState(!1),[o,l]=Y.useState(Xse),[c,u]=Y.useState(!1),[d,m]=Y.useState(null),g=Y.useRef(null),_=Y.useCallback(async E=>{if(!E.includes(" N"))return E;const $=g.current;if($&&Date.now()-$.ts<Nse)return E.replace(" N",` ${$.value}`);try{const z=await fetch("/api/state");if(z.ok){const I=await z.json(),se=String(I.currentPhase??"1");return g.current={value:se,ts:Date.now()},E.replace(" N",` ${se}`)}}catch{}return E},[]),y=s||!t,b=Y.useCallback(async E=>{if(y)return;const $=await _(E.command);m({label:E.label,resolved:$})},[y,_]),x=Y.useCallback(()=>{d&&(i(d.resolved+`\r
202
- `),m(null))},[d,i]),w=Y.useCallback(()=>{m(null)},[]);Y.useEffect(()=>{if(!d)return;const E=$=>{$.key==="Enter"?($.preventDefault(),x()):$.key==="Escape"&&w()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[d,x,w]);const[k,C]=Y.useState([]),A=Y.useCallback(()=>{C([...o]),u(!0)},[o]),P=Y.useCallback(()=>{const E=k.filter($=>$.label.trim()&&$.command.trim());l(E),Vse(E),u(!1)},[k]);return r?M.jsx("div",{className:"absolute bottom-2 right-2 z-20",children:M.jsx("button",{type:"button",onClick:()=>n(!1),className:"rounded-md bg-card/80 p-1.5 text-xs text-muted-foreground shadow-lg backdrop-blur-sm border border-border hover:text-foreground transition-colors",title:"Show quick actions",children:M.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M18 15l-6-6-6 6"})})})}):M.jsxs("div",{className:"absolute bottom-2 right-2 z-20 flex flex-col items-end gap-1",children:[d&&M.jsxs("div",{className:"rounded-lg bg-card border border-border shadow-lg p-2 text-xs mb-1 backdrop-blur-sm",children:[M.jsxs("p",{className:"text-muted-foreground mb-1.5",children:["Send"," ",M.jsx("span",{className:"font-mono text-foreground",children:d.resolved}),"?"]}),M.jsxs("div",{className:"flex gap-1.5",children:[M.jsx("button",{type:"button",onClick:x,className:"rounded-sm bg-accent px-2 py-0.5 text-foreground hover:bg-accent-glow transition-colors",children:"Confirm"}),M.jsx("button",{type:"button",onClick:w,className:"rounded-sm bg-muted px-2 py-0.5 text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]})]}),c&&M.jsxs("div",{className:"rounded-lg bg-card border border-border shadow-lg p-3 text-xs mb-1 backdrop-blur-sm w-72 max-h-64 overflow-y-auto",children:[M.jsx("p",{className:"text-muted-foreground font-medium mb-2",children:"Quick Commands"}),k.map((E,$)=>M.jsxs("div",{className:"flex gap-1 mb-1",children:[M.jsx("input",{className:"flex-[1] rounded-sm border border-border bg-muted px-1.5 py-0.5 text-xs text-foreground",value:E.label,onChange:z=>{const I=[...k];I[$]={...I[$],label:z.target.value},C(I)},placeholder:"Label"}),M.jsx("input",{className:"flex-[2] rounded-sm border border-border bg-muted px-1.5 py-0.5 text-xs font-mono text-foreground",value:E.command,onChange:z=>{const I=[...k];I[$]={...I[$],command:z.target.value},C(I)},placeholder:"Command"}),M.jsx("button",{type:"button",onClick:()=>C(k.filter((z,I)=>I!==$)),className:"text-muted-foreground hover:text-destructive transition-colors px-0.5",title:"Remove",children:"x"})]},$)),M.jsxs("div",{className:"flex justify-between mt-2",children:[M.jsx("button",{type:"button",onClick:()=>C([...k,{label:"",command:""}]),className:"text-muted-foreground hover:text-foreground transition-colors",children:"+ Add"}),M.jsxs("div",{className:"flex gap-1.5",children:[M.jsx("button",{type:"button",onClick:()=>u(!1),className:"rounded-sm bg-muted px-2 py-0.5 text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),M.jsx("button",{type:"button",onClick:P,className:"rounded-sm bg-accent px-2 py-0.5 text-foreground hover:bg-accent-glow transition-colors",children:"Save"})]})]})]}),M.jsxs("div",{className:"flex items-center gap-1 rounded-lg bg-card/80 border border-border shadow-lg p-1.5 backdrop-blur-sm",children:[o.map(E=>M.jsx("button",{type:"button",onClick:()=>b(E),disabled:y,className:"rounded-md px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40 disabled:cursor-not-allowed",title:s?"Terminal unavailable — node-pty not installed":E.command,children:E.label},E.label)),M.jsx("button",{type:"button",onClick:A,className:"rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:text-foreground transition-colors ml-0.5",title:"Settings",children:M.jsxs("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("circle",{cx:"12",cy:"12",r:"3"}),M.jsx("path",{d:"M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 012.83-2.83l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 2.83l-.06.06A1.65 1.65 0 0019.32 9a1.65 1.65 0 001.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"})]})}),M.jsx("button",{type:"button",onClick:()=>n(!0),className:"rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:text-foreground transition-colors",title:"Minimize",children:M.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M6 9l6 6 6-6"})})})]})]})}function jse({onReady:i}){const e=Y.useRef(null),t=Y.useRef(null),s=Y.useRef(null),r=Y.useRef(null),n=Y.useRef(null),[o,l]=Y.useState(!0),{connected:c,unavailable:u,status:d,exitCode:m,writeInput:g,resize:_,spawn:y,kill:b,onOutput:x,onScrollback:w}=Lse({autoSpawn:!0,skipPermissions:o}),k=Y.useCallback($=>{var z;(z=t.current)==null||z.write($)},[]),C=Y.useCallback($=>{var z;(z=t.current)==null||z.write($)},[]);Y.useEffect(()=>(x.current=k,w.current=C,()=>{x.current=null,w.current=null}),[k,C,x,w]),Y.useEffect(()=>{if(!e.current)return;const $=new Vte({cursorBlink:!0,fontSize:14,lineHeight:1.2,theme:{background:"#0a0a0a",foreground:"#e0e0e0",cursor:"#e0e0e0"}}),z=new Ite,I=new Ese;$.loadAddon(z),$.loadAddon(I);try{$.loadAddon(new Cse)}catch{}$.open(e.current),z.fit(),t.current=$,s.current=z;const se=$.onData(R=>{g(R)}),F=new ResizeObserver(()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{s.current&&t.current&&(s.current.fit(),_(t.current.cols,t.current.rows))},100)});return F.observe(e.current),r.current=F,i==null||i($),()=>{se.dispose(),F.disconnect(),n.current&&clearTimeout(n.current),$.dispose(),t.current=null,s.current=null,r.current=null}},[]);const A=Y.useCallback(()=>{y(o),setTimeout(()=>{var $;return($=t.current)==null?void 0:$.focus()},100)},[y,o]),P=Y.useCallback(()=>{b()},[b]),E=Y.useCallback(()=>{l($=>!$)},[]);return M.jsxs("div",{className:"flex h-full w-full flex-col",onWheel:$=>$.stopPropagation(),children:[M.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:[M.jsx("div",{ref:e,className:"h-full w-full"}),M.jsx(Zse,{onSendCommand:g,isActive:(d==null?void 0:d.isActive)??!1,isAlive:(d==null?void 0:d.alive)??!1,unavailable:u}),u&&M.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-card",children:M.jsxs("div",{className:"max-w-sm text-center",children:[M.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Terminal unavailable"}),M.jsxs("p",{className:"text-sm text-muted-foreground",children:["node-pty is not installed. Run ",M.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs",children:"npm install node-pty"})," in the dashboard directory."]})]})}),!c&&m===null&&M.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/60",children:M.jsxs("div",{className:"flex items-center gap-3 font-mono text-sm text-muted-foreground",children:[M.jsxs("svg",{className:"h-5 w-5 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[M.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),M.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Reconnecting..."]})}),m!==null&&M.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-10 flex items-center justify-between bg-card/90 px-4 py-2 font-mono text-sm backdrop-blur-sm",children:[M.jsxs("span",{className:"text-muted-foreground",children:["Process exited (code ",m,")"]}),M.jsx("button",{type:"button",onClick:A,className:"rounded-sm bg-accent px-3 py-1 text-xs text-foreground transition-colors hover:bg-accent-glow",children:"Restart"})]})]}),M.jsx(Dse,{status:d,connected:c,exitCode:m,skipPermissions:o,onToggleSkipPermissions:E,onStop:P,onRestart:A})]})}function Ise(){const[i,e]=Y.useState(!1),t=Y.useCallback(()=>e(s=>!s),[]);return{splitMode:i,toggleSplit:t}}function qse({splitMode:i,onToggle:e}){return M.jsx("button",{type:"button",onClick:e,title:i?"Full-height mode":"Split-panel mode",className:"absolute right-3 top-2 z-20 flex h-7 w-7 items-center justify-center rounded-sm border border-border bg-card text-muted-foreground transition-colors hover:bg-card-hover hover:text-foreground",children:i?M.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:M.jsx("rect",{x:"1",y:"1",width:"12",height:"12",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})}):M.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[M.jsx("rect",{x:"1",y:"1",width:"12",height:"12",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),M.jsx("line",{x1:"1",y1:"7",x2:"13",y2:"7",stroke:"currentColor",strokeWidth:"1.5"})]})})}var jl={},kv,zE;function Wse(){return zE||(zE=1,kv=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),kv}var Tv={},Ao={},NE;function Ka(){if(NE)return Ao;NE=1;let i;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Ao.getSymbolSize=function(s){if(!s)throw new Error('"version" cannot be null or undefined');if(s<1||s>40)throw new Error('"version" should be in range from 1 to 40');return s*4+17},Ao.getSymbolTotalCodewords=function(s){return e[s]},Ao.getBCHDigit=function(t){let s=0;for(;t!==0;)s++,t>>>=1;return s},Ao.setToSJISFunction=function(s){if(typeof s!="function")throw new Error('"toSJISFunc" is not a valid function.');i=s},Ao.isKanjiModeEnabled=function(){return typeof i<"u"},Ao.toSJIS=function(s){return i(s)},Ao}var Av={},XE;function sx(){return XE||(XE=1,(function(i){i.L={bit:1},i.M={bit:0},i.Q={bit:3},i.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return i.L;case"m":case"medium":return i.M;case"q":case"quartile":return i.Q;case"h":case"high":return i.H;default:throw new Error("Unknown EC Level: "+t)}}i.isValid=function(s){return s&&typeof s.bit<"u"&&s.bit>=0&&s.bit<4},i.from=function(s,r){if(i.isValid(s))return s;try{return e(s)}catch{return r}}})(Av)),Av}var Mv,VE;function Use(){if(VE)return Mv;VE=1;function i(){this.buffer=[],this.length=0}return i.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let s=0;s<t;s++)this.putBit((e>>>t-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},Mv=i,Mv}var Ev,ZE;function Yse(){if(ZE)return Ev;ZE=1;function i(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return i.prototype.set=function(e,t,s,r){const n=e*this.size+t;this.data[n]=s,r&&(this.reservedBit[n]=!0)},i.prototype.get=function(e,t){return this.data[e*this.size+t]},i.prototype.xor=function(e,t,s){this.data[e*this.size+t]^=s},i.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},Ev=i,Ev}var Pv={},jE;function Hse(){return jE||(jE=1,(function(i){const e=Ka().getSymbolSize;i.getRowColCoords=function(s){if(s===1)return[];const r=Math.floor(s/7)+2,n=e(s),o=n===145?26:Math.ceil((n-13)/(2*r-2))*2,l=[n-7];for(let c=1;c<r-1;c++)l[c]=l[c-1]-o;return l.push(6),l.reverse()},i.getPositions=function(s){const r=[],n=i.getRowColCoords(s),o=n.length;for(let l=0;l<o;l++)for(let c=0;c<o;c++)l===0&&c===0||l===0&&c===o-1||l===o-1&&c===0||r.push([n[l],n[c]]);return r}})(Pv)),Pv}var Qv={},IE;function Fse(){if(IE)return Qv;IE=1;const i=Ka().getSymbolSize,e=7;return Qv.getPositions=function(s){const r=i(s);return[[0,0],[r-e,0],[0,r-e]]},Qv}var Rv={},qE;function Gse(){return qE||(qE=1,(function(i){i.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};i.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},i.from=function(r){return i.isValid(r)?parseInt(r,10):void 0},i.getPenaltyN1=function(r){const n=r.size;let o=0,l=0,c=0,u=null,d=null;for(let m=0;m<n;m++){l=c=0,u=d=null;for(let g=0;g<n;g++){let _=r.get(m,g);_===u?l++:(l>=5&&(o+=e.N1+(l-5)),u=_,l=1),_=r.get(g,m),_===d?c++:(c>=5&&(o+=e.N1+(c-5)),d=_,c=1)}l>=5&&(o+=e.N1+(l-5)),c>=5&&(o+=e.N1+(c-5))}return o},i.getPenaltyN2=function(r){const n=r.size;let o=0;for(let l=0;l<n-1;l++)for(let c=0;c<n-1;c++){const u=r.get(l,c)+r.get(l,c+1)+r.get(l+1,c)+r.get(l+1,c+1);(u===4||u===0)&&o++}return o*e.N2},i.getPenaltyN3=function(r){const n=r.size;let o=0,l=0,c=0;for(let u=0;u<n;u++){l=c=0;for(let d=0;d<n;d++)l=l<<1&2047|r.get(u,d),d>=10&&(l===1488||l===93)&&o++,c=c<<1&2047|r.get(d,u),d>=10&&(c===1488||c===93)&&o++}return o*e.N3},i.getPenaltyN4=function(r){let n=0;const o=r.data.length;for(let c=0;c<o;c++)n+=r.data[c];return Math.abs(Math.ceil(n*100/o/5)-10)*e.N4};function t(s,r,n){switch(s){case i.Patterns.PATTERN000:return(r+n)%2===0;case i.Patterns.PATTERN001:return r%2===0;case i.Patterns.PATTERN010:return n%3===0;case i.Patterns.PATTERN011:return(r+n)%3===0;case i.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case i.Patterns.PATTERN101:return r*n%2+r*n%3===0;case i.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case i.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+s)}}i.applyMask=function(r,n){const o=n.size;for(let l=0;l<o;l++)for(let c=0;c<o;c++)n.isReserved(c,l)||n.xor(c,l,t(r,c,l))},i.getBestMask=function(r,n){const o=Object.keys(i.Patterns).length;let l=0,c=1/0;for(let u=0;u<o;u++){n(u),i.applyMask(u,r);const d=i.getPenaltyN1(r)+i.getPenaltyN2(r)+i.getPenaltyN3(r)+i.getPenaltyN4(r);i.applyMask(u,r),d<c&&(c=d,l=u)}return l}})(Rv)),Rv}var $p={},WE;function KD(){if(WE)return $p;WE=1;const i=sx(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],t=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $p.getBlocksCount=function(r,n){switch(n){case i.L:return e[(r-1)*4+0];case i.M:return e[(r-1)*4+1];case i.Q:return e[(r-1)*4+2];case i.H:return e[(r-1)*4+3];default:return}},$p.getTotalCodewordsCount=function(r,n){switch(n){case i.L:return t[(r-1)*4+0];case i.M:return t[(r-1)*4+1];case i.Q:return t[(r-1)*4+2];case i.H:return t[(r-1)*4+3];default:return}},$p}var Lv={},ru={},UE;function Kse(){if(UE)return ru;UE=1;const i=new Uint8Array(512),e=new Uint8Array(256);return(function(){let s=1;for(let r=0;r<255;r++)i[r]=s,e[s]=r,s<<=1,s&256&&(s^=285);for(let r=255;r<512;r++)i[r]=i[r-255]})(),ru.log=function(s){if(s<1)throw new Error("log("+s+")");return e[s]},ru.exp=function(s){return i[s]},ru.mul=function(s,r){return s===0||r===0?0:i[e[s]+e[r]]},ru}var YE;function Jse(){return YE||(YE=1,(function(i){const e=Kse();i.mul=function(s,r){const n=new Uint8Array(s.length+r.length-1);for(let o=0;o<s.length;o++)for(let l=0;l<r.length;l++)n[o+l]^=e.mul(s[o],r[l]);return n},i.mod=function(s,r){let n=new Uint8Array(s);for(;n.length-r.length>=0;){const o=n[0];for(let c=0;c<r.length;c++)n[c]^=e.mul(r[c],o);let l=0;for(;l<n.length&&n[l]===0;)l++;n=n.slice(l)}return n},i.generateECPolynomial=function(s){let r=new Uint8Array([1]);for(let n=0;n<s;n++)r=i.mul(r,new Uint8Array([1,e.exp(n)]));return r}})(Lv)),Lv}var $v,HE;function ere(){if(HE)return $v;HE=1;const i=Jse();function e(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(s){this.degree=s,this.genPoly=i.generateECPolynomial(this.degree)},e.prototype.encode=function(s){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(s.length+this.degree);r.set(s);const n=i.mod(r,this.genPoly),o=this.degree-n.length;if(o>0){const l=new Uint8Array(this.degree);return l.set(n,o),l}return n},$v=e,$v}var Bv={},Dv={},zv={},FE;function JD(){return FE||(FE=1,zv.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),zv}var Nr={},GE;function e4(){if(GE)return Nr;GE=1;const i="[0-9]+",e="[A-Z $%*+\\-./:]+";let t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";t=t.replace(/u/g,"\\u");const s="(?:(?![A-Z0-9 $%*+\\-./:]|"+t+`)(?:.|[\r
203
- ]))+`;Nr.KANJI=new RegExp(t,"g"),Nr.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Nr.BYTE=new RegExp(s,"g"),Nr.NUMERIC=new RegExp(i,"g"),Nr.ALPHANUMERIC=new RegExp(e,"g");const r=new RegExp("^"+t+"$"),n=new RegExp("^"+i+"$"),o=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Nr.testKanji=function(c){return r.test(c)},Nr.testNumeric=function(c){return n.test(c)},Nr.testAlphanumeric=function(c){return o.test(c)},Nr}var KE;function Ja(){return KE||(KE=1,(function(i){const e=JD(),t=e4();i.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},i.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},i.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},i.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},i.MIXED={bit:-1},i.getCharCountIndicator=function(n,o){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?n.ccBits[0]:o<27?n.ccBits[1]:n.ccBits[2]},i.getBestModeForData=function(n){return t.testNumeric(n)?i.NUMERIC:t.testAlphanumeric(n)?i.ALPHANUMERIC:t.testKanji(n)?i.KANJI:i.BYTE},i.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},i.isValid=function(n){return n&&n.bit&&n.ccBits};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return i.NUMERIC;case"alphanumeric":return i.ALPHANUMERIC;case"kanji":return i.KANJI;case"byte":return i.BYTE;default:throw new Error("Unknown mode: "+r)}}i.from=function(n,o){if(i.isValid(n))return n;try{return s(n)}catch{return o}}})(Dv)),Dv}var JE;function tre(){return JE||(JE=1,(function(i){const e=Ka(),t=KD(),s=sx(),r=Ja(),n=JD(),o=7973,l=e.getBCHDigit(o);function c(g,_,y){for(let b=1;b<=40;b++)if(_<=i.getCapacity(b,y,g))return b}function u(g,_){return r.getCharCountIndicator(g,_)+4}function d(g,_){let y=0;return g.forEach(function(b){const x=u(b.mode,_);y+=x+b.getBitsLength()}),y}function m(g,_){for(let y=1;y<=40;y++)if(d(g,y)<=i.getCapacity(y,_,r.MIXED))return y}i.from=function(_,y){return n.isValid(_)?parseInt(_,10):y},i.getCapacity=function(_,y,b){if(!n.isValid(_))throw new Error("Invalid QR Code version");typeof b>"u"&&(b=r.BYTE);const x=e.getSymbolTotalCodewords(_),w=t.getTotalCodewordsCount(_,y),k=(x-w)*8;if(b===r.MIXED)return k;const C=k-u(b,_);switch(b){case r.NUMERIC:return Math.floor(C/10*3);case r.ALPHANUMERIC:return Math.floor(C/11*2);case r.KANJI:return Math.floor(C/13);case r.BYTE:default:return Math.floor(C/8)}},i.getBestVersionForData=function(_,y){let b;const x=s.from(y,s.M);if(Array.isArray(_)){if(_.length>1)return m(_,x);if(_.length===0)return 1;b=_[0]}else b=_;return c(b.mode,b.getLength(),x)},i.getEncodedBits=function(_){if(!n.isValid(_)||_<7)throw new Error("Invalid QR Code version");let y=_<<12;for(;e.getBCHDigit(y)-l>=0;)y^=o<<e.getBCHDigit(y)-l;return _<<12|y}})(Bv)),Bv}var Nv={},eP;function ire(){if(eP)return Nv;eP=1;const i=Ka(),e=1335,t=21522,s=i.getBCHDigit(e);return Nv.getEncodedBits=function(n,o){const l=n.bit<<3|o;let c=l<<10;for(;i.getBCHDigit(c)-s>=0;)c^=e<<i.getBCHDigit(c)-s;return(l<<10|c)^t},Nv}var Xv={},Vv,tP;function sre(){if(tP)return Vv;tP=1;const i=Ja();function e(t){this.mode=i.NUMERIC,this.data=t.toString()}return e.getBitsLength=function(s){return 10*Math.floor(s/3)+(s%3?s%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(s){let r,n,o;for(r=0;r+3<=this.data.length;r+=3)n=this.data.substr(r,3),o=parseInt(n,10),s.put(o,10);const l=this.data.length-r;l>0&&(n=this.data.substr(r),o=parseInt(n,10),s.put(o,l*3+1))},Vv=e,Vv}var Zv,iP;function rre(){if(iP)return Zv;iP=1;const i=Ja(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function t(s){this.mode=i.ALPHANUMERIC,this.data=s}return t.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){let n;for(n=0;n+2<=this.data.length;n+=2){let o=e.indexOf(this.data[n])*45;o+=e.indexOf(this.data[n+1]),r.put(o,11)}this.data.length%2&&r.put(e.indexOf(this.data[n]),6)},Zv=t,Zv}var jv,sP;function nre(){if(sP)return jv;sP=1;const i=Ja();function e(t){this.mode=i.BYTE,typeof t=="string"?this.data=new TextEncoder().encode(t):this.data=new Uint8Array(t)}return e.getBitsLength=function(s){return s*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(t){for(let s=0,r=this.data.length;s<r;s++)t.put(this.data[s],8)},jv=e,jv}var Iv,rP;function ore(){if(rP)return Iv;rP=1;const i=Ja(),e=Ka();function t(s){this.mode=i.KANJI,this.data=s}return t.getBitsLength=function(r){return r*13},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(s){let r;for(r=0;r<this.data.length;r++){let n=e.toSJIS(this.data[r]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
204
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),s.put(n,13)}},Iv=t,Iv}var qv={exports:{}},nP;function are(){return nP||(nP=1,(function(i){var e={single_source_shortest_paths:function(t,s,r){var n={},o={};o[s]=0;var l=e.PriorityQueue.make();l.push(s,0);for(var c,u,d,m,g,_,y,b,x;!l.empty();){c=l.pop(),u=c.value,m=c.cost,g=t[u]||{};for(d in g)g.hasOwnProperty(d)&&(_=g[d],y=m+_,b=o[d],x=typeof o[d]>"u",(x||b>y)&&(o[d]=y,l.push(d,y),n[d]=u))}if(typeof r<"u"&&typeof o[r]>"u"){var w=["Could not find a path from ",s," to ",r,"."].join("");throw new Error(w)}return n},extract_shortest_path_from_predecessor_list:function(t,s){for(var r=[],n=s;n;)r.push(n),t[n],n=t[n];return r.reverse(),r},find_path:function(t,s,r){var n=e.single_source_shortest_paths(t,s,r);return e.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(t){var s=e.PriorityQueue,r={},n;t=t||{};for(n in s)s.hasOwnProperty(n)&&(r[n]=s[n]);return r.queue=[],r.sorter=t.sorter||s.default_sorter,r},default_sorter:function(t,s){return t.cost-s.cost},push:function(t,s){var r={value:t,cost:s};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};i.exports=e})(qv)),qv.exports}var oP;function lre(){return oP||(oP=1,(function(i){const e=Ja(),t=sre(),s=rre(),r=nre(),n=ore(),o=e4(),l=Ka(),c=are();function u(w){return unescape(encodeURIComponent(w)).length}function d(w,k,C){const A=[];let P;for(;(P=w.exec(C))!==null;)A.push({data:P[0],index:P.index,mode:k,length:P[0].length});return A}function m(w){const k=d(o.NUMERIC,e.NUMERIC,w),C=d(o.ALPHANUMERIC,e.ALPHANUMERIC,w);let A,P;return l.isKanjiModeEnabled()?(A=d(o.BYTE,e.BYTE,w),P=d(o.KANJI,e.KANJI,w)):(A=d(o.BYTE_KANJI,e.BYTE,w),P=[]),k.concat(C,A,P).sort(function($,z){return $.index-z.index}).map(function($){return{data:$.data,mode:$.mode,length:$.length}})}function g(w,k){switch(k){case e.NUMERIC:return t.getBitsLength(w);case e.ALPHANUMERIC:return s.getBitsLength(w);case e.KANJI:return n.getBitsLength(w);case e.BYTE:return r.getBitsLength(w)}}function _(w){return w.reduce(function(k,C){const A=k.length-1>=0?k[k.length-1]:null;return A&&A.mode===C.mode?(k[k.length-1].data+=C.data,k):(k.push(C),k)},[])}function y(w){const k=[];for(let C=0;C<w.length;C++){const A=w[C];switch(A.mode){case e.NUMERIC:k.push([A,{data:A.data,mode:e.ALPHANUMERIC,length:A.length},{data:A.data,mode:e.BYTE,length:A.length}]);break;case e.ALPHANUMERIC:k.push([A,{data:A.data,mode:e.BYTE,length:A.length}]);break;case e.KANJI:k.push([A,{data:A.data,mode:e.BYTE,length:u(A.data)}]);break;case e.BYTE:k.push([{data:A.data,mode:e.BYTE,length:u(A.data)}])}}return k}function b(w,k){const C={},A={start:{}};let P=["start"];for(let E=0;E<w.length;E++){const $=w[E],z=[];for(let I=0;I<$.length;I++){const se=$[I],F=""+E+I;z.push(F),C[F]={node:se,lastCount:0},A[F]={};for(let R=0;R<P.length;R++){const L=P[R];C[L]&&C[L].node.mode===se.mode?(A[L][F]=g(C[L].lastCount+se.length,se.mode)-g(C[L].lastCount,se.mode),C[L].lastCount+=se.length):(C[L]&&(C[L].lastCount=se.length),A[L][F]=g(se.length,se.mode)+4+e.getCharCountIndicator(se.mode,k))}}P=z}for(let E=0;E<P.length;E++)A[P[E]].end=0;return{map:A,table:C}}function x(w,k){let C;const A=e.getBestModeForData(w);if(C=e.from(k,A),C!==e.BYTE&&C.bit<A.bit)throw new Error('"'+w+'" cannot be encoded with mode '+e.toString(C)+`.
205
- Suggested mode is: `+e.toString(A));switch(C===e.KANJI&&!l.isKanjiModeEnabled()&&(C=e.BYTE),C){case e.NUMERIC:return new t(w);case e.ALPHANUMERIC:return new s(w);case e.KANJI:return new n(w);case e.BYTE:return new r(w)}}i.fromArray=function(k){return k.reduce(function(C,A){return typeof A=="string"?C.push(x(A,null)):A.data&&C.push(x(A.data,A.mode)),C},[])},i.fromString=function(k,C){const A=m(k,l.isKanjiModeEnabled()),P=y(A),E=b(P,C),$=c.find_path(E.map,"start","end"),z=[];for(let I=1;I<$.length-1;I++)z.push(E.table[$[I]].node);return i.fromArray(_(z))},i.rawSplit=function(k){return i.fromArray(m(k,l.isKanjiModeEnabled()))}})(Xv)),Xv}var aP;function hre(){if(aP)return Tv;aP=1;const i=Ka(),e=sx(),t=Use(),s=Yse(),r=Hse(),n=Fse(),o=Gse(),l=KD(),c=ere(),u=tre(),d=ire(),m=Ja(),g=lre();function _(E,$){const z=E.size,I=n.getPositions($);for(let se=0;se<I.length;se++){const F=I[se][0],R=I[se][1];for(let L=-1;L<=7;L++)if(!(F+L<=-1||z<=F+L))for(let N=-1;N<=7;N++)R+N<=-1||z<=R+N||(L>=0&&L<=6&&(N===0||N===6)||N>=0&&N<=6&&(L===0||L===6)||L>=2&&L<=4&&N>=2&&N<=4?E.set(F+L,R+N,!0,!0):E.set(F+L,R+N,!1,!0))}}function y(E){const $=E.size;for(let z=8;z<$-8;z++){const I=z%2===0;E.set(z,6,I,!0),E.set(6,z,I,!0)}}function b(E,$){const z=r.getPositions($);for(let I=0;I<z.length;I++){const se=z[I][0],F=z[I][1];for(let R=-2;R<=2;R++)for(let L=-2;L<=2;L++)R===-2||R===2||L===-2||L===2||R===0&&L===0?E.set(se+R,F+L,!0,!0):E.set(se+R,F+L,!1,!0)}}function x(E,$){const z=E.size,I=u.getEncodedBits($);let se,F,R;for(let L=0;L<18;L++)se=Math.floor(L/3),F=L%3+z-8-3,R=(I>>L&1)===1,E.set(se,F,R,!0),E.set(F,se,R,!0)}function w(E,$,z){const I=E.size,se=d.getEncodedBits($,z);let F,R;for(F=0;F<15;F++)R=(se>>F&1)===1,F<6?E.set(F,8,R,!0):F<8?E.set(F+1,8,R,!0):E.set(I-15+F,8,R,!0),F<8?E.set(8,I-F-1,R,!0):F<9?E.set(8,15-F-1+1,R,!0):E.set(8,15-F-1,R,!0);E.set(I-8,8,1,!0)}function k(E,$){const z=E.size;let I=-1,se=z-1,F=7,R=0;for(let L=z-1;L>0;L-=2)for(L===6&&L--;;){for(let N=0;N<2;N++)if(!E.isReserved(se,L-N)){let Z=!1;R<$.length&&(Z=($[R]>>>F&1)===1),E.set(se,L-N,Z),F--,F===-1&&(R++,F=7)}if(se+=I,se<0||z<=se){se-=I,I=-I;break}}}function C(E,$,z){const I=new t;z.forEach(function(N){I.put(N.mode.bit,4),I.put(N.getLength(),m.getCharCountIndicator(N.mode,E)),N.write(I)});const se=i.getSymbolTotalCodewords(E),F=l.getTotalCodewordsCount(E,$),R=(se-F)*8;for(I.getLengthInBits()+4<=R&&I.put(0,4);I.getLengthInBits()%8!==0;)I.putBit(0);const L=(R-I.getLengthInBits())/8;for(let N=0;N<L;N++)I.put(N%2?17:236,8);return A(I,E,$)}function A(E,$,z){const I=i.getSymbolTotalCodewords($),se=l.getTotalCodewordsCount($,z),F=I-se,R=l.getBlocksCount($,z),L=I%R,N=R-L,Z=Math.floor(I/R),Q=Math.floor(F/R),X=Q+1,W=Z-Q,U=new c(W);let q=0;const D=new Array(R),G=new Array(R);let ie=0;const ce=new Uint8Array(E.buffer);for(let ye=0;ye<R;ye++){const mt=ye<N?Q:X;D[ye]=ce.slice(q,q+mt),G[ye]=U.encode(D[ye]),q+=mt,ie=Math.max(ie,mt)}const he=new Uint8Array(I);let de=0,ge,Ae;for(ge=0;ge<ie;ge++)for(Ae=0;Ae<R;Ae++)ge<D[Ae].length&&(he[de++]=D[Ae][ge]);for(ge=0;ge<W;ge++)for(Ae=0;Ae<R;Ae++)he[de++]=G[Ae][ge];return he}function P(E,$,z,I){let se;if(Array.isArray(E))se=g.fromArray(E);else if(typeof E=="string"){let Z=$;if(!Z){const Q=g.rawSplit(E);Z=u.getBestVersionForData(Q,z)}se=g.fromString(E,Z||40)}else throw new Error("Invalid data");const F=u.getBestVersionForData(se,z);if(!F)throw new Error("The amount of data is too big to be stored in a QR Code");if(!$)$=F;else if($<F)throw new Error(`
206
- The chosen QR Code version cannot contain this amount of data.
207
- Minimum version required to store current data is: `+F+`.
208
- `);const R=C($,z,se),L=i.getSymbolSize($),N=new s(L);return _(N,$),y(N),b(N,$),w(N,z,0),$>=7&&x(N,$),k(N,R),isNaN(I)&&(I=o.getBestMask(N,w.bind(null,N,z))),o.applyMask(I,N),w(N,z,I),{modules:N,version:$,errorCorrectionLevel:z,maskPattern:I,segments:se}}return Tv.create=function($,z){if(typeof $>"u"||$==="")throw new Error("No input text");let I=e.M,se,F;return typeof z<"u"&&(I=e.from(z.errorCorrectionLevel,e.M),se=u.from(z.version),F=o.from(z.maskPattern),z.toSJISFunc&&i.setToSJISFunction(z.toSJISFunc)),P($,se,I,F)},Tv}var Wv={},Uv={},lP;function t4(){return lP||(lP=1,(function(i){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");let s=t.slice().replace("#","").split("");if(s.length<3||s.length===5||s.length>8)throw new Error("Invalid hex color: "+t);(s.length===3||s.length===4)&&(s=Array.prototype.concat.apply([],s.map(function(n){return[n,n]}))),s.length===6&&s.push("F","F");const r=parseInt(s.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+s.slice(0,6).join("")}}i.getOptions=function(s){s||(s={}),s.color||(s.color={});const r=typeof s.margin>"u"||s.margin===null||s.margin<0?4:s.margin,n=s.width&&s.width>=21?s.width:void 0,o=s.scale||4;return{width:n,scale:n?4:o,margin:r,color:{dark:e(s.color.dark||"#000000ff"),light:e(s.color.light||"#ffffffff")},type:s.type,rendererOpts:s.rendererOpts||{}}},i.getScale=function(s,r){return r.width&&r.width>=s+r.margin*2?r.width/(s+r.margin*2):r.scale},i.getImageWidth=function(s,r){const n=i.getScale(s,r);return Math.floor((s+r.margin*2)*n)},i.qrToImageData=function(s,r,n){const o=r.modules.size,l=r.modules.data,c=i.getScale(o,n),u=Math.floor((o+n.margin*2)*c),d=n.margin*c,m=[n.color.light,n.color.dark];for(let g=0;g<u;g++)for(let _=0;_<u;_++){let y=(g*u+_)*4,b=n.color.light;if(g>=d&&_>=d&&g<u-d&&_<u-d){const x=Math.floor((g-d)/c),w=Math.floor((_-d)/c);b=m[l[x*o+w]?1:0]}s[y++]=b.r,s[y++]=b.g,s[y++]=b.b,s[y]=b.a}}})(Uv)),Uv}var hP;function cre(){return hP||(hP=1,(function(i){const e=t4();function t(r,n,o){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=o,n.width=o,n.style.height=o+"px",n.style.width=o+"px"}function s(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}i.render=function(n,o,l){let c=l,u=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(u=s()),c=e.getOptions(c);const d=e.getImageWidth(n.modules.size,c),m=u.getContext("2d"),g=m.createImageData(d,d);return e.qrToImageData(g.data,n,c),t(m,u,d),m.putImageData(g,0,0),u},i.renderToDataURL=function(n,o,l){let c=l;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const u=i.render(n,o,c),d=c.type||"image/png",m=c.rendererOpts||{};return u.toDataURL(d,m.quality)}})(Wv)),Wv}var Yv={},cP;function ure(){if(cP)return Yv;cP=1;const i=t4();function e(r,n){const o=r.a/255,l=n+'="'+r.hex+'"';return o<1?l+" "+n+'-opacity="'+o.toFixed(2).slice(1)+'"':l}function t(r,n,o){let l=r+n;return typeof o<"u"&&(l+=" "+o),l}function s(r,n,o){let l="",c=0,u=!1,d=0;for(let m=0;m<r.length;m++){const g=Math.floor(m%n),_=Math.floor(m/n);!g&&!u&&(u=!0),r[m]?(d++,m>0&&g>0&&r[m-1]||(l+=u?t("M",g+o,.5+_+o):t("m",c,0),c=0,u=!1),g+1<n&&r[m+1]||(l+=t("h",d),d=0)):c++}return l}return Yv.render=function(n,o,l){const c=i.getOptions(o),u=n.modules.size,d=n.modules.data,m=u+c.margin*2,g=c.color.light.a?"<path "+e(c.color.light,"fill")+' d="M0 0h'+m+"v"+m+'H0z"/>':"",_="<path "+e(c.color.dark,"stroke")+' d="'+s(d,u,c.margin)+'"/>',y='viewBox="0 0 '+m+" "+m+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+y+' shape-rendering="crispEdges">'+g+_+`</svg>
209
- `;return typeof l=="function"&&l(null,x),x},Yv}var uP;function fre(){if(uP)return jl;uP=1;const i=Wse(),e=hre(),t=cre(),s=ure();function r(n,o,l,c,u){const d=[].slice.call(arguments,1),m=d.length,g=typeof d[m-1]=="function";if(!g&&!i())throw new Error("Callback required as last argument");if(g){if(m<2)throw new Error("Too few arguments provided");m===2?(u=l,l=o,o=c=void 0):m===3&&(o.getContext&&typeof u>"u"?(u=c,c=void 0):(u=c,c=l,l=o,o=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(l=o,o=c=void 0):m===2&&!o.getContext&&(c=l,l=o,o=void 0),new Promise(function(_,y){try{const b=e.create(l,c);_(n(b,o,c))}catch(b){y(b)}})}try{const _=e.create(l,c);u(null,n(_,o,c))}catch(_){u(_)}}return jl.create=e.create,jl.toCanvas=r.bind(null,t.render),jl.toDataURL=r.bind(null,t.renderToDataURL),jl.toString=r.bind(null,function(n,o,l){return s.render(n,l)}),jl}var dre=fre();const pre=Cz(dre);function mre(){const[i,e]=Y.useState(null),[t,s]=Y.useState(!1),[r,n]=Y.useState(null);return Y.useEffect(()=>{fetch("/api/server-info").then(o=>o.json()).then(o=>e(o)).catch(()=>{})},[]),Y.useEffect(()=>{i!=null&&i.networkUrl&&pre.toDataURL(i.networkUrl,{width:200,margin:2}).then(n).catch(()=>{})},[i==null?void 0:i.networkUrl]),!(i!=null&&i.networkEnabled)||!i.networkUrl?null:M.jsxs("div",{className:"fixed bottom-4 right-4 z-50",children:[t&&M.jsxs("div",{className:"mb-2 rounded-lg border border-border bg-background p-4 shadow-xl",children:[M.jsx("p",{className:"mb-1 font-mono text-[10px] text-muted-foreground",children:"Local Network"}),M.jsx("p",{className:"mb-3 font-mono text-xs text-foreground",children:i.networkUrl}),r&&M.jsx("img",{src:r,alt:"QR code for local network access",width:200,height:200,className:"rounded-sm"})]}),M.jsxs("button",{type:"button",onClick:()=>s(o=>!o),title:t?"Close QR code":"Open on another device",className:"flex items-center gap-1.5 rounded-lg border border-border bg-background px-3 py-2 font-mono text-xs text-foreground shadow-md transition-colors hover:bg-muted",children:[M.jsx(gre,{}),"Share"]})]})}function gre(){return M.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[M.jsx("rect",{x:"3",y:"3",width:"7",height:"7"}),M.jsx("rect",{x:"14",y:"3",width:"7",height:"7"}),M.jsx("rect",{x:"3",y:"14",width:"7",height:"7"}),M.jsx("rect",{x:"14",y:"14",width:"3",height:"3"}),M.jsx("line",{x1:"14",y1:"20",x2:"20",y2:"20"}),M.jsx("line",{x1:"20",y1:"14",x2:"20",y2:"17"})]})}function Ore(){return M.jsxs("div",{className:"flex flex-col gap-6",children:[M.jsxs("div",{className:"flex flex-col gap-4 border-b border-border pb-5",children:[M.jsx("div",{className:"h-3 w-40 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-2 w-full animate-pulse rounded-sm bg-muted"}),M.jsxs("div",{className:"flex gap-8",children:[M.jsx("div",{className:"h-8 w-20 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-8 w-32 animate-pulse rounded-sm bg-muted"}),M.jsxs("div",{className:"ml-auto flex gap-6",children:[M.jsx("div",{className:"h-6 w-24 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-6 w-20 animate-pulse rounded-sm bg-muted"})]})]})]}),M.jsxs("div",{className:"flex flex-col gap-3",children:[M.jsxs("div",{className:"flex justify-between px-4",children:[M.jsx("div",{className:"h-3 w-16 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-3 w-6 animate-pulse rounded-sm bg-muted"})]}),Array.from({length:6}).map((i,e)=>M.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3",children:[M.jsxs("div",{className:"flex gap-3",children:[M.jsx("div",{className:"h-4 w-4 animate-pulse rounded-full bg-muted"}),M.jsx("div",{className:"h-4 w-8 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-4 w-40 animate-pulse rounded-sm bg-muted"})]}),M.jsx("div",{className:"h-1.5 w-full animate-pulse rounded-sm bg-muted"})]},e))]})]})}function _re({message:i,onRetry:e}){return M.jsxs("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-4",children:[M.jsx("p",{className:"font-mono text-sm text-danger",children:i}),M.jsx("button",{type:"button",onClick:e,className:"rounded-sm bg-accent px-4 py-2 font-mono text-xs text-foreground transition-colors hover:bg-accent-glow",children:"Retry"})]})}function vre(){const{roadmap:i,state:e,todos:t,loading:s,error:r}=fb(),[n,o]=Y.useState("overview"),[l,c]=Y.useState(null),{splitMode:u,toggleSplit:d}=Ise(),m=Y.useRef({view:"overview",phaseId:null}),g=Y.useCallback((A,P)=>{A!=="terminal"&&(m.current={view:A,phaseId:A==="phase"&&P?P:null}),o(A),A==="phase"&&P&&c(P)},[]),_=Y.useCallback(A=>{o("phase"),c(A)},[]),y=Y.useCallback(()=>{o("overview"),c(null)},[]),b=Y.useCallback(async(A,P)=>{try{const E=await fetch("/api/roadmap",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({phaseNumber:A,checked:P})});E.ok||console.error("[toggle-phase]",await E.text())}catch(E){console.error("[toggle-phase]",E)}},[]),x=((i==null?void 0:i.phases)??[]).map(A=>({number:A.number,name:A.name,goal:A.goal??"",dependsOn:A.depends_on?[A.depends_on]:[],planCount:A.plan_count,summaryCount:A.summary_count,diskStatus:A.disk_status,roadmapComplete:A.roadmap_complete,hasContext:A.has_context,hasResearch:A.has_research})),w=(i==null?void 0:i.current_phase)??null;function k(){if(s)return M.jsx(Ore,{});if(r)return M.jsx(_re,{message:r,onRetry:()=>window.location.reload()});switch(n){case"overview":return M.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-6",children:[M.jsx(EV,{roadmap:i,state:e,todos:t}),M.jsx(LV,{phases:x,currentPhase:w,onPhaseClick:_,onToggleComplete:b})]});case"phase":return l?M.jsx("div",{className:"mx-auto max-w-4xl",children:M.jsx(CK,{phaseId:l,onBack:y})}):null;case"todos":return M.jsx("div",{className:"mx-auto max-w-3xl",children:M.jsx(kK,{})});case"blockers":return M.jsx("div",{className:"mx-auto max-w-3xl",children:M.jsx(MK,{})});case"terminal":return null;default:return null}}const C=n==="terminal";return M.jsxs(EK,{sidebar:M.jsx(QK,{activeView:n,activePhaseId:l,onNavigate:g}),children:[M.jsx("div",{style:{display:C&&!u?"none":"block"},className:C&&u?"h-1/2 min-h-0 overflow-auto border-b border-border p-6":"flex-1 overflow-y-auto p-6",children:k()}),M.jsxs("div",{style:{display:C?"flex":"none"},className:`relative min-h-0 flex-col overflow-hidden ${C&&u?"h-1/2":"flex-1"}`,children:[M.jsx(qse,{splitMode:u,onToggle:d}),M.jsx(jse,{})]}),M.jsx(mre,{})]})}function yre(){return M.jsx(zz,{children:M.jsx(vre,{})})}const i4=document.getElementById("root");if(!i4)throw new Error("Root element not found");$z.createRoot(i4).render(M.jsx(Y.StrictMode,{children:M.jsx(yre,{})}));
207
+ */var Oi=0,_i=0,vi=0,Rt=0,Zi;(i=>{function e(r,n,o,l){return l!==void 0?`#${Sa(r)}${Sa(n)}${Sa(o)}${Sa(l)}`:`#${Sa(r)}${Sa(n)}${Sa(o)}`}i.toCss=e;function t(r,n,o,l=255){return(r<<24|n<<16|o<<8|l)>>>0}i.toRgba=t;function s(r,n,o,l){return{css:i.toCss(r,n,o,l),rgba:i.toRgba(r,n,o,l)}}i.toColor=s})(Zi||(Zi={}));var Gse;(i=>{function e(c,u){if(Rt=(u.rgba&255)/255,Rt===1)return{css:u.css,rgba:u.rgba};let d=u.rgba>>24&255,m=u.rgba>>16&255,g=u.rgba>>8&255,_=c.rgba>>24&255,y=c.rgba>>16&255,b=c.rgba>>8&255;Oi=_+Math.round((d-_)*Rt),_i=y+Math.round((m-y)*Rt),vi=b+Math.round((g-b)*Rt);let x=Zi.toCss(Oi,_i,vi),w=Zi.toRgba(Oi,_i,vi);return{css:x,rgba:w}}i.blend=e;function t(c){return(c.rgba&255)===255}i.isOpaque=t;function s(c,u,d){let m=hm.ensureContrastRatio(c.rgba,u.rgba,d);if(m)return Zi.toColor(m>>24&255,m>>16&255,m>>8&255)}i.ensureContrastRatio=s;function r(c){let u=(c.rgba|255)>>>0;return[Oi,_i,vi]=hm.toChannels(u),{css:Zi.toCss(Oi,_i,vi),rgba:u}}i.opaque=r;function n(c,u){return Rt=Math.round(u*255),[Oi,_i,vi]=hm.toChannels(c.rgba),{css:Zi.toCss(Oi,_i,vi,Rt),rgba:Zi.toRgba(Oi,_i,vi,Rt)}}i.opacity=n;function o(c,u){return Rt=c.rgba&255,n(c,Rt*u/255)}i.multiplyOpacity=o;function l(c){return[c.rgba>>24&255,c.rgba>>16&255,c.rgba>>8&255]}i.toColorRGB=l})(Gse||(Gse={}));var Ei;(i=>{let e,t;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(e=n,e.globalCompositeOperation="copy",t=e.createLinearGradient(0,0,1,1))}catch{}function s(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Oi=parseInt(r.slice(1,2).repeat(2),16),_i=parseInt(r.slice(2,3).repeat(2),16),vi=parseInt(r.slice(3,4).repeat(2),16),Zi.toColor(Oi,_i,vi);case 5:return Oi=parseInt(r.slice(1,2).repeat(2),16),_i=parseInt(r.slice(2,3).repeat(2),16),vi=parseInt(r.slice(3,4).repeat(2),16),Rt=parseInt(r.slice(4,5).repeat(2),16),Zi.toColor(Oi,_i,vi,Rt);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Oi=parseInt(n[1]),_i=parseInt(n[2]),vi=parseInt(n[3]),Rt=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Zi.toColor(Oi,_i,vi,Rt);if(!e||!t)throw new Error("css.toColor: Unsupported css format");if(e.fillStyle=t,e.fillStyle=r,typeof e.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(e.fillRect(0,0,1,1),[Oi,_i,vi,Rt]=e.getImageData(0,0,1,1).data,Rt!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Zi.toRgba(Oi,_i,vi,Rt),css:r}}i.toColor=s})(Ei||(Ei={}));var Fi;(i=>{function e(s){return t(s>>16&255,s>>8&255,s&255)}i.relativeLuminance=e;function t(s,r,n){let o=s/255,l=r/255,c=n/255,u=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),m=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4);return u*.2126+d*.7152+m*.0722}i.relativeLuminance2=t})(Fi||(Fi={}));var hm;(i=>{function e(o,l){if(Rt=(l&255)/255,Rt===1)return l;let c=l>>24&255,u=l>>16&255,d=l>>8&255,m=o>>24&255,g=o>>16&255,_=o>>8&255;return Oi=m+Math.round((c-m)*Rt),_i=g+Math.round((u-g)*Rt),vi=_+Math.round((d-_)*Rt),Zi.toRgba(Oi,_i,vi)}i.blend=e;function t(o,l,c){let u=Fi.relativeLuminance(o>>8),d=Fi.relativeLuminance(l>>8);if(Rn(u,d)<c){if(d<u){let _=s(o,l,c),y=Rn(u,Fi.relativeLuminance(_>>8));if(y<c){let b=r(o,l,c),x=Rn(u,Fi.relativeLuminance(b>>8));return y>x?_:b}return _}let m=r(o,l,c),g=Rn(u,Fi.relativeLuminance(m>>8));if(g<c){let _=s(o,l,c),y=Rn(u,Fi.relativeLuminance(_>>8));return g>y?m:_}return m}}i.ensureContrastRatio=t;function s(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));for(;b<c&&(g>0||_>0||y>0);)g-=Math.max(0,Math.ceil(g*.1)),_-=Math.max(0,Math.ceil(_*.1)),y-=Math.max(0,Math.ceil(y*.1)),b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.reduceLuminance=s;function r(o,l,c){let u=o>>24&255,d=o>>16&255,m=o>>8&255,g=l>>24&255,_=l>>16&255,y=l>>8&255,b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));for(;b<c&&(g<255||_<255||y<255);)g=Math.min(255,g+Math.ceil((255-g)*.1)),_=Math.min(255,_+Math.ceil((255-_)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),b=Rn(Fi.relativeLuminance2(g,_,y),Fi.relativeLuminance2(u,d,m));return(g<<24|_<<16|y<<8|255)>>>0}i.increaseLuminance=r;function n(o){return[o>>24&255,o>>16&255,o>>8&255,o&255]}i.toChannels=n})(hm||(hm={}));function Sa(i){let e=i.toString(16);return e.length<2?"0"+e:e}function Rn(i,e){return i<e?(e+.05)/(i+.05):(i+.05)/(e+.05)}var Kse=Object.freeze((()=>{let i=[Ei.toColor("#2e3436"),Ei.toColor("#cc0000"),Ei.toColor("#4e9a06"),Ei.toColor("#c4a000"),Ei.toColor("#3465a4"),Ei.toColor("#75507b"),Ei.toColor("#06989a"),Ei.toColor("#d3d7cf"),Ei.toColor("#555753"),Ei.toColor("#ef2929"),Ei.toColor("#8ae234"),Ei.toColor("#fce94f"),Ei.toColor("#729fcf"),Ei.toColor("#ad7fa8"),Ei.toColor("#34e2e2"),Ei.toColor("#eeeeec")],e=[0,95,135,175,215,255];for(let t=0;t<216;t++){let s=e[t/36%6|0],r=e[t/6%6|0],n=e[t%6];i.push({css:Zi.toCss(s,r,n),rgba:Zi.toRgba(s,r,n)})}for(let t=0;t<24;t++){let s=8+t*10;i.push({css:Zi.toCss(s,s,s),rgba:Zi.toRgba(s,s,s)})}return i})());function uP(i,e,t){return Math.max(e,Math.min(i,t))}function Jse(i){switch(i){case"&":return"&amp;";case"<":return"&lt;"}return i}var KD=class{constructor(i){this._buffer=i}serialize(i,e){let t=this._buffer.getNullCell(),s=this._buffer.getNullCell(),r=t,n=i.start.y,o=i.end.y,l=i.start.x,c=i.end.x;this._beforeSerialize(o-n,n,o);for(let u=n;u<=o;u++){let d=this._buffer.getLine(u);if(d){let m=u===i.start.y?l:0,g=u===i.end.y?c:d.length;for(let _=m;_<g;_++){let y=d.getCell(_,r===t?s:t);if(!y){console.warn(`Can't get cell at row=${u}, col=${_}`);continue}this._nextCell(y,r,u,_),r=y}}this._rowEnd(u,u===o)}return this._afterSerialize(),this._serializeString(e)}_nextCell(i,e,t,s){}_rowEnd(i,e){}_beforeSerialize(i,e,t){}_afterSerialize(){}_serializeString(i){return""}};function JD(i,e){return i.getFgColorMode()===e.getFgColorMode()&&i.getFgColor()===e.getFgColor()}function Ln(i,e){return i.getBgColorMode()===e.getBgColorMode()&&i.getBgColor()===e.getBgColor()}function e4(i,e){return i.isInverse()===e.isInverse()&&i.isBold()===e.isBold()&&i.isUnderline()===e.isUnderline()&&i.isOverline()===e.isOverline()&&i.isBlink()===e.isBlink()&&i.isInvisible()===e.isInvisible()&&i.isItalic()===e.isItalic()&&i.isDim()===e.isDim()&&i.isStrikethrough()===e.isStrikethrough()}var ere=class extends KD{constructor(i,e){super(i),this._terminal=e,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(i,e,t){this._allRows=new Array(i),this._lastContentCursorRow=e,this._lastCursorRow=e,this._firstRow=e}_rowEnd(i,e){var s;this._nullCellCount>0&&!Ln(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let t="";if(!e){i-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let r=this._buffer.getLine(i),n=this._buffer.getLine(i+1);if(!n.isWrapped)t=`\r
208
+ `,this._lastCursorRow=i+1,this._lastCursorCol=0;else{t="";let o=r.getCell(r.length-1,this._thisRowLastChar),l=r.getCell(r.length-2,this._thisRowLastSecondChar),c=n.getCell(0,this._nextRowFirstChar),u=c.getWidth()>1,d=!1;(c.getChars()&&u?this._nullCellCount<=1:this._nullCellCount<=0)&&((o.getChars()||o.getWidth()===0)&&Ln(o,c)&&(d=!0),u&&(l.getChars()||l.getWidth()===0)&&Ln(o,c)&&Ln(l,c)&&(d=!0)),d||(t="-".repeat(this._nullCellCount+1),t+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(t+="\x1B[A",t+=`\x1B[${r.length-this._nullCellCount}C`,t+=`\x1B[${this._nullCellCount}X`,t+=`\x1B[${r.length-this._nullCellCount}D`,t+="\x1B[B"),this._lastContentCursorRow=i+1,this._lastContentCursorCol=0,this._lastCursorRow=i+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=t,this._currentRow="",this._nullCellCount=0}_diffStyle(i,e){let t=[],s=!JD(i,e),r=!Ln(i,e),n=!e4(i,e);if(s||r||n)if(i.isAttributeDefault())e.isAttributeDefault()||t.push(0);else{if(s){let o=i.getFgColor();i.isFgRGB()?t.push(38,2,o>>>16&255,o>>>8&255,o&255):i.isFgPalette()?o>=16?t.push(38,5,o):t.push(o&8?90+(o&7):30+(o&7)):t.push(39)}if(r){let o=i.getBgColor();i.isBgRGB()?t.push(48,2,o>>>16&255,o>>>8&255,o&255):i.isBgPalette()?o>=16?t.push(48,5,o):t.push(o&8?100+(o&7):40+(o&7)):t.push(49)}n&&(i.isInverse()!==e.isInverse()&&t.push(i.isInverse()?7:27),i.isBold()!==e.isBold()&&t.push(i.isBold()?1:22),i.isUnderline()!==e.isUnderline()&&t.push(i.isUnderline()?4:24),i.isOverline()!==e.isOverline()&&t.push(i.isOverline()?53:55),i.isBlink()!==e.isBlink()&&t.push(i.isBlink()?5:25),i.isInvisible()!==e.isInvisible()&&t.push(i.isInvisible()?8:28),i.isItalic()!==e.isItalic()&&t.push(i.isItalic()?3:23),i.isDim()!==e.isDim()&&t.push(i.isDim()?2:22),i.isStrikethrough()!==e.isStrikethrough()&&t.push(i.isStrikethrough()?9:29))}return t}_nextCell(i,e,t,s){if(i.getWidth()===0)return;let r=i.getChars()==="",n=this._diffStyle(i,this._cursorStyle);if(r?!Ln(this._cursorStyle,i):n.length>0){this._nullCellCount>0&&(Ln(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=t,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${n.join(";")}m`;let o=this._buffer.getLine(t);o!==void 0&&(o.getCell(s,this._cursorStyle),this._cursorStyleRow=t,this._cursorStyleCol=s)}r?this._nullCellCount+=i.getWidth():(this._nullCellCount>0&&(Ln(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=i.getChars(),this._lastContentCursorRow=this._lastCursorRow=t,this._lastContentCursorCol=this._lastCursorCol=s+i.getWidth())}_serializeString(i){let e=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(e=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let t="";for(let n=0;n<e;n++)t+=this._allRows[n],n+1<e&&(t+=this._allRowSeparators[n]);if(!i){let n=this._buffer.baseY+this._buffer.cursorY,o=this._buffer.cursorX,l=n!==this._lastCursorRow||o!==this._lastCursorCol,c=u=>{u>0?t+=`\x1B[${u}C`:u<0&&(t+=`\x1B[${-u}D`)};l&&((u=>{u>0?t+=`\x1B[${u}B`:u<0&&(t+=`\x1B[${-u}A`)})(n-this._lastCursorRow),c(o-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,r=this._diffStyle(s,this._cursorStyle);return r.length>0&&(t+=`\x1B[${r.join(";")}m`),t}},tre=class{activate(i){this._terminal=i}_serializeBufferByScrollback(i,e,t){let s=e.length,r=t===void 0?s:uP(t+i.rows,0,s);return this._serializeBufferByRange(i,e,{start:s-r,end:s-1},!1)}_serializeBufferByRange(i,e,t,s){return new ere(e,i).serialize({start:{x:0,y:typeof t.start=="number"?t.start:t.start.line},end:{x:i.cols,y:typeof t.end=="number"?t.end:t.end.line}},s)}_serializeBufferAsHTML(i,e){var l;let t=i.buffer.active,s=new ire(t,i,e),r=e.onlySelection??!1,n=e.range;if(n)return s.serialize({start:{x:n.startCol,y:(n.startLine,n.startLine)},end:{x:i.cols,y:(n.endLine,n.endLine)}});if(!r){let c=t.length,u=e.scrollback,d=u===void 0?c:uP(u+i.rows,0,c);return s.serialize({start:{x:0,y:c-d},end:{x:i.cols,y:c-1}})}let o=(l=this._terminal)==null?void 0:l.getSelectionPosition();return o!==void 0?s.serialize({start:{x:o.start.x,y:o.start.y},end:{x:o.end.x,y:o.end.y}}):""}_serializeModes(i){let e="",t=i.modes;if(t.applicationCursorKeysMode&&(e+="\x1B[?1h"),t.applicationKeypadMode&&(e+="\x1B[?66h"),t.bracketedPasteMode&&(e+="\x1B[?2004h"),t.insertMode&&(e+="\x1B[4h"),t.originMode&&(e+="\x1B[?6h"),t.reverseWraparoundMode&&(e+="\x1B[?45h"),t.sendFocusMode&&(e+="\x1B[?1004h"),t.wraparoundMode===!1&&(e+="\x1B[?7l"),t.mouseTrackingMode!=="none")switch(t.mouseTrackingMode){case"x10":e+="\x1B[?9h";break;case"vt200":e+="\x1B[?1000h";break;case"drag":e+="\x1B[?1002h";break;case"any":e+="\x1B[?1003h";break}return e}serialize(i){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let e=i!=null&&i.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,i.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,i==null?void 0:i.scrollback);if(!(i!=null&&i.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let t=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);e+=`\x1B[?1049h\x1B[H${t}`}return i!=null&&i.excludeModes||(e+=this._serializeModes(this._terminal)),e}serializeAsHTML(i){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,i||{})}dispose(){}},ire=class extends KD{constructor(i,e,t){super(i),this._terminal=e,this._options=t,this._currentRow="",this._htmlContent="",e._core._themeService?this._ansiColors=e._core._themeService.colors.ansi:this._ansiColors=Kse}_padStart(i,e,t){return e=e>>0,t=t??" ",i.length>e?i:(e-=i.length,e>t.length&&(t+=t.repeat(e/t.length)),t.slice(0,e)+i)}_beforeSerialize(i,e,t){var o,l;this._htmlContent+="<html><body><!--StartFragment--><pre>";let s="#000000",r="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((o=this._terminal.options.theme)==null?void 0:o.foreground)??"#ffffff",r=((l=this._terminal.options.theme)==null?void 0:l.background)??"#000000");let n=[];n.push("color: "+s+";"),n.push("background-color: "+r+";"),n.push("font-family: "+this._terminal.options.fontFamily+";"),n.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+n.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(i,e){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(i,e){let t=e?i.getFgColor():i.getBgColor();if(e?i.isFgRGB():i.isBgRGB())return"#"+[t>>16&255,t>>8&255,t&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(e?i.isFgPalette():i.isBgPalette())return this._ansiColors[t].css}_diffStyle(i,e){let t=[],s=!JD(i,e),r=!Ln(i,e),n=!e4(i,e);if(s||r||n){let o=this._getHexColor(i,!0);o&&t.push("color: "+o+";");let l=this._getHexColor(i,!1);return l&&t.push("background-color: "+l+";"),i.isInverse()&&t.push("color: #000000; background-color: #BFBFBF;"),i.isBold()&&t.push("font-weight: bold;"),i.isUnderline()&&i.isOverline()?t.push("text-decoration: overline underline;"):i.isUnderline()?t.push("text-decoration: underline;"):i.isOverline()&&t.push("text-decoration: overline;"),i.isBlink()&&t.push("text-decoration: blink;"),i.isInvisible()&&t.push("visibility: hidden;"),i.isItalic()&&t.push("font-style: italic;"),i.isDim()&&t.push("opacity: 0.5;"),i.isStrikethrough()&&t.push("text-decoration: line-through;"),t}}_nextCell(i,e,t,s){if(i.getWidth()===0)return;let r=i.getChars()==="",n=this._diffStyle(i,e);n&&(this._currentRow+=n.length===0?"</span><span>":"</span><span style='"+n.join(" ")+"'>"),r?this._currentRow+=" ":this._currentRow+=Jse(i.getChars())}_serializeString(){return this._htmlContent}};const sre=10,rre=2e3;function nre(i={}){const{autoSpawn:e=!1,skipPermissions:t=!1}=i,[s,r]=Y.useState(!1),[n,o]=Y.useState(!1),[l,c]=Y.useState(null),[u,d]=Y.useState(null),m=Y.useRef(null),g=Y.useRef(0),_=Y.useRef(null),y=Y.useRef(!0),b=Y.useRef(null),x=Y.useRef(null),w=Y.useRef(e),k=Y.useRef(t);w.current=e,k.current=t;const C=Y.useCallback(z=>{const I=m.current;I&&I.readyState===WebSocket.OPEN&&I.send(JSON.stringify(z))},[]),A=Y.useCallback(z=>{C({type:"spawn",skipPermissions:z})},[C]),P=Y.useCallback(()=>{C({type:"kill"})},[C]),E=Y.useCallback((z,I)=>{C({type:"resize",cols:z,rows:I})},[C]),$=Y.useCallback(z=>{C({type:"input",data:z})},[C]);return Y.useEffect(()=>{y.current=!0;function z(){if(!y.current)return;const se=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal`,F=new WebSocket(se);m.current=F,F.onopen=()=>{y.current&&(r(!0),g.current=0,w.current&&F.send(JSON.stringify({type:"spawn",skipPermissions:k.current})))},F.onclose=()=>{y.current&&(r(!1),m.current=null,g.current<sre&&(g.current++,_.current=setTimeout(z,rre)))},F.onmessage=R=>{var L,N;if(y.current)try{const Z=JSON.parse(R.data);switch(Z.type){case"output":(L=b.current)==null||L.call(b,Z.data);break;case"scrollback":(N=x.current)==null||N.call(x,Z.data);break;case"status":c({pid:Z.pid,uptime:Z.uptime,cwd:Z.cwd,memoryMB:Z.memoryMB,isActive:Z.isActive,skipPermissions:Z.skipPermissions,alive:Z.alive});break;case"exit":d(Z.code??1);break;case"started":d(null);break;case"unavailable":o(!0);break}}catch{}},F.onerror=()=>{}}return z(),()=>{y.current=!1,_.current!==null&&(clearTimeout(_.current),_.current=null),m.current&&(m.current.onclose=null,m.current.close(),m.current=null)}},[]),{connected:s,unavailable:n,status:l,exitCode:u,send:C,spawn:A,kill:P,resize:E,writeInput:$,onOutput:b,onScrollback:x}}function ore(i){const e=Math.floor(i/60),t=i%60;return`${e}m ${t}s`}function are(i){const e=i.replace(/\\/g,"/").split("/").filter(Boolean);return e.length<=2?i:".../"+e.slice(-2).join("/")}function lre({status:i,connected:e,exitCode:t,skipPermissions:s,onToggleSkipPermissions:r,onStop:n,onRestart:o}){const l=e&&(i==null?void 0:i.alive),c=e?l?"bg-green-500":"bg-yellow-500":"bg-red-500",u=e?l?`Running (PID ${(i==null?void 0:i.pid)??"?"})`:"Stopped":"Disconnected";return M.jsxs("div",{className:"flex items-center justify-between border-t border-border bg-card px-3 py-1.5 font-mono text-xs text-muted-foreground",children:[M.jsxs("div",{className:"flex items-center gap-3",children:[M.jsx("span",{className:dt("inline-block h-2 w-2 rounded-full",c),title:u}),M.jsx("span",{children:u}),i&&l&&M.jsxs(M.Fragment,{children:[M.jsx("span",{className:"text-border",children:"|"}),M.jsx("span",{children:ore(i.uptime)}),M.jsx("span",{className:"text-border",children:"|"}),M.jsx("span",{title:i.cwd,children:are(i.cwd)}),M.jsx("span",{className:"text-border",children:"|"}),M.jsxs("span",{children:[i.memoryMB," MB"]})]})]}),M.jsxs("div",{className:"flex items-center gap-3",children:[M.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5",children:[M.jsx("input",{type:"checkbox",checked:s,onChange:r,className:"h-3 w-3 accent-accent"}),M.jsx("span",{children:"Skip Perms"})]}),l&&M.jsx("button",{type:"button",onClick:n,className:"rounded-sm px-2 py-0.5 text-red-400 transition-colors hover:bg-red-500/20",children:"Stop"}),M.jsx("button",{type:"button",onClick:o,className:"rounded-sm px-2 py-0.5 transition-colors hover:bg-accent/20",children:"Restart"})]})]})}const hre=[{label:"Progress",command:"/maxsim:progress"},{label:"New Project",command:"/maxsim:new-project"},{label:"Discuss",command:"/maxsim:discuss-phase N"},{label:"Plan",command:"/maxsim:plan-phase N"},{label:"Execute",command:"/maxsim:execute-phase N"},{label:"Roadmap",command:"/maxsim:roadmap"},{label:"Verify",command:"/maxsim:verify-work"},{label:"Resume",command:"/maxsim:resume-work"}],t4="maxsim-quick-commands",cre=3e4;function ure(){try{const i=localStorage.getItem(t4);if(i)return JSON.parse(i)}catch{}return hre}function fre(i){localStorage.setItem(t4,JSON.stringify(i))}function dre({onSendCommand:i,isActive:e,isAlive:t,unavailable:s=!1}){const[r,n]=Y.useState(!1),[o,l]=Y.useState(ure),[c,u]=Y.useState(!1),[d,m]=Y.useState(null),g=Y.useRef(null),_=Y.useCallback(async E=>{if(!E.includes(" N"))return E;const $=g.current;if($&&Date.now()-$.ts<cre)return E.replace(" N",` ${$.value}`);try{const z=await fetch("/api/state");if(z.ok){const I=await z.json(),se=String(I.currentPhase??"1");return g.current={value:se,ts:Date.now()},E.replace(" N",` ${se}`)}}catch{}return E},[]),y=s||!t,b=Y.useCallback(async E=>{if(y)return;const $=await _(E.command);m({label:E.label,resolved:$})},[y,_]),x=Y.useCallback(()=>{d&&(i(d.resolved+`\r
209
+ `),m(null))},[d,i]),w=Y.useCallback(()=>{m(null)},[]);Y.useEffect(()=>{if(!d)return;const E=$=>{$.key==="Enter"?($.preventDefault(),x()):$.key==="Escape"&&w()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[d,x,w]);const[k,C]=Y.useState([]),A=Y.useCallback(()=>{C([...o]),u(!0)},[o]),P=Y.useCallback(()=>{const E=k.filter($=>$.label.trim()&&$.command.trim());l(E),fre(E),u(!1)},[k]);return r?M.jsx("div",{className:"absolute bottom-2 right-2 z-20",children:M.jsx("button",{type:"button",onClick:()=>n(!1),className:"rounded-md bg-card/80 p-1.5 text-xs text-muted-foreground shadow-lg backdrop-blur-sm border border-border hover:text-foreground transition-colors",title:"Show quick actions",children:M.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M18 15l-6-6-6 6"})})})}):M.jsxs("div",{className:"absolute bottom-2 right-2 z-20 flex flex-col items-end gap-1",children:[d&&M.jsxs("div",{className:"rounded-lg bg-card border border-border shadow-lg p-2 text-xs mb-1 backdrop-blur-sm",children:[M.jsxs("p",{className:"text-muted-foreground mb-1.5",children:["Send"," ",M.jsx("span",{className:"font-mono text-foreground",children:d.resolved}),"?"]}),M.jsxs("div",{className:"flex gap-1.5",children:[M.jsx("button",{type:"button",onClick:x,className:"rounded-sm bg-accent px-2 py-0.5 text-foreground hover:bg-accent-glow transition-colors",children:"Confirm"}),M.jsx("button",{type:"button",onClick:w,className:"rounded-sm bg-muted px-2 py-0.5 text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]})]}),c&&M.jsxs("div",{className:"rounded-lg bg-card border border-border shadow-lg p-3 text-xs mb-1 backdrop-blur-sm w-72 max-h-64 overflow-y-auto",children:[M.jsx("p",{className:"text-muted-foreground font-medium mb-2",children:"Quick Commands"}),k.map((E,$)=>M.jsxs("div",{className:"flex gap-1 mb-1",children:[M.jsx("input",{className:"flex-[1] rounded-sm border border-border bg-muted px-1.5 py-0.5 text-xs text-foreground",value:E.label,onChange:z=>{const I=[...k];I[$]={...I[$],label:z.target.value},C(I)},placeholder:"Label"}),M.jsx("input",{className:"flex-[2] rounded-sm border border-border bg-muted px-1.5 py-0.5 text-xs font-mono text-foreground",value:E.command,onChange:z=>{const I=[...k];I[$]={...I[$],command:z.target.value},C(I)},placeholder:"Command"}),M.jsx("button",{type:"button",onClick:()=>C(k.filter((z,I)=>I!==$)),className:"text-muted-foreground hover:text-destructive transition-colors px-0.5",title:"Remove",children:"x"})]},$)),M.jsxs("div",{className:"flex justify-between mt-2",children:[M.jsx("button",{type:"button",onClick:()=>C([...k,{label:"",command:""}]),className:"text-muted-foreground hover:text-foreground transition-colors",children:"+ Add"}),M.jsxs("div",{className:"flex gap-1.5",children:[M.jsx("button",{type:"button",onClick:()=>u(!1),className:"rounded-sm bg-muted px-2 py-0.5 text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),M.jsx("button",{type:"button",onClick:P,className:"rounded-sm bg-accent px-2 py-0.5 text-foreground hover:bg-accent-glow transition-colors",children:"Save"})]})]})]}),M.jsxs("div",{className:"flex items-center gap-1 rounded-lg bg-card/80 border border-border shadow-lg p-1.5 backdrop-blur-sm",children:[o.map(E=>M.jsx("button",{type:"button",onClick:()=>b(E),disabled:y,className:"rounded-md px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-40 disabled:cursor-not-allowed",title:s?"Terminal unavailable — node-pty not installed":E.command,children:E.label},E.label)),M.jsx("button",{type:"button",onClick:A,className:"rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:text-foreground transition-colors ml-0.5",title:"Settings",children:M.jsxs("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("circle",{cx:"12",cy:"12",r:"3"}),M.jsx("path",{d:"M19.4 15a1.65 1.65 0 00.33 1.82l.06.06a2 2 0 010 2.83 2 2 0 01-2.83 0l-.06-.06a1.65 1.65 0 00-1.82-.33 1.65 1.65 0 00-1 1.51V21a2 2 0 01-4 0v-.09A1.65 1.65 0 009 19.4a1.65 1.65 0 00-1.82.33l-.06.06a2 2 0 01-2.83-2.83l.06-.06A1.65 1.65 0 004.68 15a1.65 1.65 0 00-1.51-1H3a2 2 0 010-4h.09A1.65 1.65 0 004.6 9a1.65 1.65 0 00-.33-1.82l-.06-.06a2 2 0 012.83-2.83l.06.06A1.65 1.65 0 009 4.68a1.65 1.65 0 001-1.51V3a2 2 0 014 0v.09a1.65 1.65 0 001 1.51 1.65 1.65 0 001.82-.33l.06-.06a2 2 0 012.83 2.83l-.06.06A1.65 1.65 0 0019.32 9a1.65 1.65 0 001.51 1H21a2 2 0 010 4h-.09a1.65 1.65 0 00-1.51 1z"})]})}),M.jsx("button",{type:"button",onClick:()=>n(!0),className:"rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:text-foreground transition-colors",title:"Minimize",children:M.jsx("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:M.jsx("path",{d:"M6 9l6 6 6-6"})})})]})]})}function pre({onReady:i}){const e=Y.useRef(null),t=Y.useRef(null),s=Y.useRef(null),r=Y.useRef(null),n=Y.useRef(null),[o,l]=Y.useState(!0),{connected:c,unavailable:u,status:d,exitCode:m,writeInput:g,resize:_,spawn:y,kill:b,onOutput:x,onScrollback:w}=nre({autoSpawn:!0,skipPermissions:o}),k=Y.useCallback($=>{var z;(z=t.current)==null||z.write($)},[]),C=Y.useCallback($=>{var z;(z=t.current)==null||z.write($)},[]);Y.useEffect(()=>(x.current=k,w.current=C,()=>{x.current=null,w.current=null}),[k,C,x,w]),Y.useEffect(()=>{if(!e.current)return;const $=new fie({cursorBlink:!0,fontSize:14,lineHeight:1.2,theme:{background:"#0a0a0a",foreground:"#e0e0e0",cursor:"#e0e0e0"}}),z=new mie,I=new tre;$.loadAddon(z),$.loadAddon(I);try{$.loadAddon(new Fse)}catch{}$.open(e.current),z.fit(),t.current=$,s.current=z;const se=$.onData(R=>{g(R)}),F=new ResizeObserver(()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{s.current&&t.current&&(s.current.fit(),_(t.current.cols,t.current.rows))},100)});return F.observe(e.current),r.current=F,i==null||i($),()=>{se.dispose(),F.disconnect(),n.current&&clearTimeout(n.current),$.dispose(),t.current=null,s.current=null,r.current=null}},[]);const A=Y.useCallback(()=>{y(o),setTimeout(()=>{var $;return($=t.current)==null?void 0:$.focus()},100)},[y,o]),P=Y.useCallback(()=>{b()},[b]),E=Y.useCallback(()=>{l($=>!$)},[]);return M.jsxs("div",{className:"flex h-full w-full flex-col",onWheel:$=>$.stopPropagation(),children:[M.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:[M.jsx("div",{ref:e,className:"h-full w-full"}),M.jsx(dre,{onSendCommand:g,isActive:(d==null?void 0:d.isActive)??!1,isAlive:(d==null?void 0:d.alive)??!1,unavailable:u}),u&&M.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center bg-card",children:M.jsxs("div",{className:"max-w-sm text-center",children:[M.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"Terminal unavailable"}),M.jsxs("p",{className:"text-sm text-muted-foreground",children:["node-pty is not installed. Run ",M.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs",children:"npm install node-pty"})," in the dashboard directory."]})]})}),!c&&m===null&&M.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/60",children:M.jsxs("div",{className:"flex items-center gap-3 font-mono text-sm text-muted-foreground",children:[M.jsxs("svg",{className:"h-5 w-5 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[M.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),M.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Reconnecting..."]})}),m!==null&&M.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-10 flex items-center justify-between bg-card/90 px-4 py-2 font-mono text-sm backdrop-blur-sm",children:[M.jsxs("span",{className:"text-muted-foreground",children:["Process exited (code ",m,")"]}),M.jsx("button",{type:"button",onClick:A,className:"rounded-sm bg-accent px-3 py-1 text-xs text-foreground transition-colors hover:bg-accent-glow",children:"Restart"})]})]}),M.jsx(lre,{status:d,connected:c,exitCode:m,skipPermissions:o,onToggleSkipPermissions:E,onStop:P,onRestart:A})]})}function mre(){const[i,e]=Y.useState(!1),t=Y.useCallback(()=>e(s=>!s),[]);return{splitMode:i,toggleSplit:t}}function gre({splitMode:i,onToggle:e}){return M.jsx("button",{type:"button",onClick:e,title:i?"Full-height mode":"Split-panel mode",className:"absolute right-3 top-2 z-20 flex h-7 w-7 items-center justify-center rounded-sm border border-border bg-card text-muted-foreground transition-colors hover:bg-card-hover hover:text-foreground",children:i?M.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:M.jsx("rect",{x:"1",y:"1",width:"12",height:"12",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})}):M.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[M.jsx("rect",{x:"1",y:"1",width:"12",height:"12",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),M.jsx("line",{x1:"1",y1:"7",x2:"13",y2:"7",stroke:"currentColor",strokeWidth:"1.5"})]})})}function Ore(){return M.jsxs("div",{className:"flex flex-col gap-6",children:[M.jsxs("div",{className:"flex flex-col gap-4 border-b border-border pb-5",children:[M.jsx("div",{className:"h-3 w-40 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-2 w-full animate-pulse rounded-sm bg-muted"}),M.jsxs("div",{className:"flex gap-8",children:[M.jsx("div",{className:"h-8 w-20 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-8 w-32 animate-pulse rounded-sm bg-muted"}),M.jsxs("div",{className:"ml-auto flex gap-6",children:[M.jsx("div",{className:"h-6 w-24 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-6 w-20 animate-pulse rounded-sm bg-muted"})]})]})]}),M.jsxs("div",{className:"flex flex-col gap-3",children:[M.jsxs("div",{className:"flex justify-between px-4",children:[M.jsx("div",{className:"h-3 w-16 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-3 w-6 animate-pulse rounded-sm bg-muted"})]}),Array.from({length:6}).map((i,e)=>M.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3",children:[M.jsxs("div",{className:"flex gap-3",children:[M.jsx("div",{className:"h-4 w-4 animate-pulse rounded-full bg-muted"}),M.jsx("div",{className:"h-4 w-8 animate-pulse rounded-sm bg-muted"}),M.jsx("div",{className:"h-4 w-40 animate-pulse rounded-sm bg-muted"})]}),M.jsx("div",{className:"h-1.5 w-full animate-pulse rounded-sm bg-muted"})]},e))]})]})}function _re({message:i,onRetry:e}){return M.jsxs("div",{className:"flex min-h-[50vh] flex-col items-center justify-center gap-4",children:[M.jsx("p",{className:"font-mono text-sm text-danger",children:i}),M.jsx("button",{type:"button",onClick:e,className:"rounded-sm bg-accent px-4 py-2 font-mono text-xs text-foreground transition-colors hover:bg-accent-glow",children:"Retry"})]})}function vre(){const{roadmap:i,state:e,todos:t,loading:s,error:r}=fb(),[n,o]=Y.useState("overview"),[l,c]=Y.useState(null),{splitMode:u,toggleSplit:d}=mre(),m=Y.useRef({view:"overview",phaseId:null}),g=Y.useCallback((A,P)=>{A!=="terminal"&&(m.current={view:A,phaseId:A==="phase"&&P?P:null}),o(A),A==="phase"&&P&&c(P)},[]),_=Y.useCallback(A=>{o("phase"),c(A)},[]),y=Y.useCallback(()=>{o("overview"),c(null)},[]),b=Y.useCallback(async(A,P)=>{try{const E=await fetch("/api/roadmap",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({phaseNumber:A,checked:P})});E.ok||console.error("[toggle-phase]",await E.text())}catch(E){console.error("[toggle-phase]",E)}},[]),x=((i==null?void 0:i.phases)??[]).map(A=>({number:A.number,name:A.name,goal:A.goal??"",dependsOn:A.depends_on?[A.depends_on]:[],planCount:A.plan_count,summaryCount:A.summary_count,diskStatus:A.disk_status,roadmapComplete:A.roadmap_complete,hasContext:A.has_context,hasResearch:A.has_research})),w=(i==null?void 0:i.current_phase)??null;function k(){if(s)return M.jsx(Ore,{});if(r)return M.jsx(_re,{message:r,onRetry:()=>window.location.reload()});switch(n){case"overview":return M.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-6",children:[M.jsx(EV,{roadmap:i,state:e,todos:t}),M.jsx(LV,{phases:x,currentPhase:w,onPhaseClick:_,onToggleComplete:b})]});case"phase":return l?M.jsx("div",{className:"mx-auto max-w-4xl",children:M.jsx(CK,{phaseId:l,onBack:y})}):null;case"todos":return M.jsx("div",{className:"mx-auto max-w-3xl",children:M.jsx(kK,{})});case"blockers":return M.jsx("div",{className:"mx-auto max-w-3xl",children:M.jsx(MK,{})});case"terminal":return null;default:return null}}const C=n==="terminal";return M.jsxs(EK,{sidebar:M.jsx(sJ,{activeView:n,activePhaseId:l,onNavigate:g}),children:[M.jsx("div",{style:{display:C&&!u?"none":"block"},className:C&&u?"h-1/2 min-h-0 overflow-auto border-b border-border p-6":"flex-1 overflow-y-auto p-6",children:k()}),M.jsxs("div",{style:{display:C?"flex":"none"},className:`relative min-h-0 flex-col overflow-hidden ${C&&u?"h-1/2":"flex-1"}`,children:[M.jsx(gre,{splitMode:u,onToggle:d}),M.jsx(pre,{})]})]})}function yre(){return M.jsx(zz,{children:M.jsx(vre,{})})}const i4=document.getElementById("root");if(!i4)throw new Error("Root element not found");$z.createRoot(i4).render(M.jsx(Y.StrictMode,{children:M.jsx(yre,{})}));